Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Xenos2017-05-05 18:03:04 +0000
committerStefan Xenos2017-05-05 18:10:12 +0000
commit10d206d1b845d370971b710b96a81750f263f778 (patch)
treea1ff4f4db6b79599c1e527d8eb01ccdf73b3b41e
parentaad2395cd78f3e285e3fc02a7c01712301a61222 (diff)
downloadeclipse.platform.ui-10d206d1b845d370971b710b96a81750f263f778.tar.gz
eclipse.platform.ui-10d206d1b845d370971b710b96a81750f263f778.tar.xz
eclipse.platform.ui-10d206d1b845d370971b710b96a81750f263f778.zip
Bug 196692 - Section cannot handle most kinds of wrapping controls
-rw-r--r--bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/ExpandableComposite.java2
-rw-r--r--tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/ExpandableCompositeTest.java19
2 files changed, 18 insertions, 3 deletions
diff --git a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/ExpandableComposite.java b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/ExpandableComposite.java
index 1cd4f385b5d..c139a4655df 100644
--- a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/ExpandableComposite.java
+++ b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/ExpandableComposite.java
@@ -322,7 +322,7 @@ public class ExpandableComposite extends Canvas {
if (toggle != null) {
// if label control is absent we vertically center the toggle,
// because the text client is usually a lot thicker
- int ty = size.x == 0 ? (height - toggleSize.y) / 2 : 0;
+ int ty = (height - toggleSize.y) / 2;
ty = Math.max(ty, 0);
ty += marginHeight + tvmargin;
toggle.setLocation(x, ty);
diff --git a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/ExpandableCompositeTest.java b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/ExpandableCompositeTest.java
index 37ed74327fa..89b5089af84 100644
--- a/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/ExpandableCompositeTest.java
+++ b/tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/ExpandableCompositeTest.java
@@ -16,6 +16,7 @@ import static org.junit.Assert.assertTrue;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.util.Geometry;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
@@ -415,8 +416,7 @@ public class ExpandableCompositeTest {
private void assertTextLines(int lines, Rectangle bounds) {
Point textExtend = getTextExtend(shortText);
// it will be around "lines" lines of text
- assertAround("Expected " + lines + " lines of text", (textExtend.y * lines), bounds.height,
- textExtend.y * 2);
+ assertAround("Expected " + lines + " lines of text", (textExtend.y * lines), bounds.height, textExtend.y * 2);
}
private Label createLabel(Composite comp, String text) {
@@ -531,4 +531,19 @@ public class ExpandableCompositeTest {
assertTextLines(4, bounds);
assertAround("Width", 500, bounds.width, 2);
}
+
+ @Test
+ public void testTwistieIsVerticallyCentered() {
+ createExtendableComposite(shortText,
+ ExpandableComposite.LEFT_TEXT_CLIENT_ALIGNMENT | ExpandableComposite.TWISTIE);
+ width500();
+ update();
+
+ Control[] children = ec.getChildren();
+
+ int textCenter = Geometry.centerPoint(children[1].getBounds()).y;
+ int twistieCenter = Geometry.centerPoint(children[0].getBounds()).y;
+
+ assertEquals(textCenter, twistieCenter);
+ }
}

Back to the top