Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2007-01-17 21:24:09 +0000
committerMichael Valenta2007-01-17 21:24:09 +0000
commit40516a82661ac57832e2bf7e7304c31f4a7ee24f (patch)
treec4d8cfc1c2bd2f80de115dc3b1e6d07860306248
parentd0ff7cdb08b6dcf66248ae4ae158289a153de0df (diff)
downloadeclipse.platform.team-40516a82661ac57832e2bf7e7304c31f4a7ee24f.tar.gz
eclipse.platform.team-40516a82661ac57832e2bf7e7304c31f4a7ee24f.tar.xz
eclipse.platform.team-40516a82661ac57832e2bf7e7304c31f4a7ee24f.zip
Bug 169387 [Viewers] Automatic split bar movement when one side is empty
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java21
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java21
2 files changed, 36 insertions, 6 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
index 5307c95cf..f3ed7e7e2 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
@@ -92,7 +92,7 @@ public abstract class ContentMergeViewer extends ContentViewer
Rectangle r= composite.getClientArea();
int centerWidth= getCenterWidth();
- int width1= (int)((r.width-centerWidth)*fHSplit);
+ int width1= (int)((r.width-centerWidth)*getHorizontalSplitRatio());
int width2= r.width-width1-centerWidth;
int height1= 0;
@@ -138,6 +138,21 @@ public abstract class ContentMergeViewer extends ContentViewer
handleResizeLeftRight(0, y, width1, centerWidth, width2, height2);
}
+
+ private double getHorizontalSplitRatio() {
+ if (fHSplit < 0) {
+ Object input = getInput();
+ if (input instanceof ICompareInput) {
+ ICompareInput ci = (ICompareInput) input;
+ if (ci.getLeft() == null)
+ return 0.1;
+ if (ci.getRight() == null)
+ return 0.9;
+ }
+ return HSPLIT;
+ }
+ return fHSplit;
+ }
}
class Resizer extends MouseAdapter implements MouseMoveListener {
@@ -168,7 +183,7 @@ public abstract class ContentMergeViewer extends ContentViewer
public void mouseDoubleClick(MouseEvent e) {
if ((fDirection & HORIZONTAL) != 0)
- fHSplit= HSPLIT;
+ fHSplit= -1;
if ((fDirection & VERTICAL) != 0)
fVSplit= VSPLIT;
fComposite.layout(true);
@@ -236,7 +251,7 @@ public abstract class ContentMergeViewer extends ContentViewer
private ListenerList fListenerList;
boolean fConfirmSave= true;
- private double fHSplit= HSPLIT; // width ratio of left and right panes
+ private double fHSplit= -1; // width ratio of left and right panes
private double fVSplit= VSPLIT; // height ratio of ancestor and bottom panes
private boolean fIsThreeWay; // whether their is an ancestor
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
index 5307c95cf..f3ed7e7e2 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
@@ -92,7 +92,7 @@ public abstract class ContentMergeViewer extends ContentViewer
Rectangle r= composite.getClientArea();
int centerWidth= getCenterWidth();
- int width1= (int)((r.width-centerWidth)*fHSplit);
+ int width1= (int)((r.width-centerWidth)*getHorizontalSplitRatio());
int width2= r.width-width1-centerWidth;
int height1= 0;
@@ -138,6 +138,21 @@ public abstract class ContentMergeViewer extends ContentViewer
handleResizeLeftRight(0, y, width1, centerWidth, width2, height2);
}
+
+ private double getHorizontalSplitRatio() {
+ if (fHSplit < 0) {
+ Object input = getInput();
+ if (input instanceof ICompareInput) {
+ ICompareInput ci = (ICompareInput) input;
+ if (ci.getLeft() == null)
+ return 0.1;
+ if (ci.getRight() == null)
+ return 0.9;
+ }
+ return HSPLIT;
+ }
+ return fHSplit;
+ }
}
class Resizer extends MouseAdapter implements MouseMoveListener {
@@ -168,7 +183,7 @@ public abstract class ContentMergeViewer extends ContentViewer
public void mouseDoubleClick(MouseEvent e) {
if ((fDirection & HORIZONTAL) != 0)
- fHSplit= HSPLIT;
+ fHSplit= -1;
if ((fDirection & VERTICAL) != 0)
fVSplit= VSPLIT;
fComposite.layout(true);
@@ -236,7 +251,7 @@ public abstract class ContentMergeViewer extends ContentViewer
private ListenerList fListenerList;
boolean fConfirmSave= true;
- private double fHSplit= HSPLIT; // width ratio of left and right panes
+ private double fHSplit= -1; // width ratio of left and right panes
private double fVSplit= VSPLIT; // height ratio of ancestor and bottom panes
private boolean fIsThreeWay; // whether their is an ancestor

Back to the top