### Eclipse Workspace Patch 1.0 #P org.eclipse.help.ui Index: src/org/eclipse/help/ui/internal/views/SearchPart.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchPart.java,v retrieving revision 1.50 diff -u -r1.50 SearchPart.java --- src/org/eclipse/help/ui/internal/views/SearchPart.java 16 Mar 2007 20:18:56 -0000 1.50 +++ src/org/eclipse/help/ui/internal/views/SearchPart.java 9 Jul 2007 19:12:09 -0000 @@ -302,7 +302,7 @@ } private void createScopeSet(Section section, FormToolkit toolkit) { - scopeSetLink = toolkit.createHyperlink(section, null, SWT.NULL); + scopeSetLink = toolkit.createHyperlink(section, null, SWT.WRAP); scopeSetLink.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { #P org.eclipse.ui.forms Index: src/org/eclipse/ui/internal/forms/widgets/FormUtil.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.forms/src/org/eclipse/ui/internal/forms/widgets/FormUtil.java,v retrieving revision 1.26 diff -u -r1.26 FormUtil.java --- src/org/eclipse/ui/internal/forms/widgets/FormUtil.java 16 Mar 2007 20:24:02 -0000 1.26 +++ src/org/eclipse/ui/internal/forms/widgets/FormUtil.java 9 Jul 2007 19:12:09 -0000 @@ -130,7 +130,9 @@ int last = 0; int height = lineHeight; int maxWidth = 0; - + if (text.equals("I'm going to try anotherasdf excessivelyasdf long string now")){ //$NON-NLS-1$ + System.out.println(); + } for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) { String word = text.substring(saved, loc); Point extent = gc.textExtent(word); @@ -138,11 +140,20 @@ // overflow saved = last; height += extent.y; - } else { - maxWidth = Math.max(maxWidth, extent.x); + // switch to current word so maxWidth will accommodate very long single words + word = text.substring(last, loc); + extent = gc.textExtent(word); } + maxWidth = Math.max(maxWidth, extent.x); last = loc; } + /* + * Correct the height attribute in case it was calculated wrong due to wHint being less than maxWidth. + * The recursive call proved to be the only thing that worked in all cases. Some attempts can be made + * to estimate the height, but the algorithm needs to be run again to be sure. + */ + if (maxWidth > wHint) + return computeWrapSize(gc, text, maxWidth); return new Point(maxWidth, height); } @@ -387,7 +398,7 @@ } } - static boolean isWrapControl(Control c) { + public static boolean isWrapControl(Control c) { if ((c.getStyle() & SWT.WRAP) != 0) return true; if (c instanceof Composite) { Index: src/org/eclipse/ui/forms/widgets/ExpandableComposite.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/ExpandableComposite.java,v retrieving revision 1.57 diff -u -r1.57 ExpandableComposite.java --- src/org/eclipse/ui/forms/widgets/ExpandableComposite.java 22 Mar 2007 15:49:00 -0000 1.57 +++ src/org/eclipse/ui/forms/widgets/ExpandableComposite.java 9 Jul 2007 19:12:09 -0000 @@ -260,13 +260,27 @@ - thmargin - thmargin; if (tsize.x > 0) twidth -= tsize.x + IGAP; - if (textClient != null) + if (textClient != null) { tcsize = textClientCache.computeSize(SWT.DEFAULT, SWT.DEFAULT); - if (tcsize.x > 0) - twidth -= tcsize.x + IGAP; + } Point size = NULL_SIZE; - if (textLabel != null) - size = textLabelCache.computeSize(twidth, SWT.DEFAULT); + if (textLabel != null) { + if (tcsize.x > 0 && FormUtil.isWrapControl(textClient)) { + size = textLabelCache.computeSize(SWT.DEFAULT, SWT.DEFAULT); + if (twidth < size.x + IGAP + tcsize.x) { + twidth -= IGAP; + if (textLabel instanceof Label) + size = FormUtil.computeWrapSize(new GC(textLabel), ((Label)textLabel).getText(), Math.round(twidth*(size.x/(float)(size.x+tcsize.x)))); + else + size = textLabelCache.computeSize(Math.round(twidth*(size.x/(float)(size.x+tcsize.x))), SWT.DEFAULT); + tcsize = textClientCache.computeSize(twidth-size.x, SWT.DEFAULT); + } + } + else { + twidth -= tcsize.x + IGAP; + size = textLabelCache.computeSize(twidth, SWT.DEFAULT); + } + } if (textLabel instanceof Label) { Point defSize = textLabelCache.computeSize(SWT.DEFAULT, SWT.DEFAULT); @@ -386,13 +400,26 @@ Point tcsize = NULL_SIZE; if (textClient != null) { tcsize = textClientCache.computeSize(SWT.DEFAULT, SWT.DEFAULT); - if (innertHint != SWT.DEFAULT) - innertHint -= IGAP + tcsize.x; } Point size = NULL_SIZE; - if (textLabel != null) - size = textLabelCache.computeSize(innertHint, SWT.DEFAULT); + if (textLabel != null) { + if (tcsize.x > 0 && FormUtil.isWrapControl(textClient)) { + size = textLabelCache.computeSize(SWT.DEFAULT, SWT.DEFAULT); + if (innertHint != SWT.DEFAULT && innertHint < size.x + IGAP + tcsize.x) { + innertHint -= IGAP; + if (textLabel instanceof Label) + size = FormUtil.computeWrapSize(new GC(textLabel), ((Label)textLabel).getText(), Math.round(innertHint*(size.x/(float)(size.x+tcsize.x)))); + else + size = textLabelCache.computeSize(Math.round(innertHint*(size.x/(float)(size.x+tcsize.x))), SWT.DEFAULT); + tcsize = textClientCache.computeSize(innertHint-size.x, SWT.DEFAULT); + } + } else { + if (innertHint != SWT.DEFAULT) + innertHint -= IGAP + tcsize.x; + size = textLabelCache.computeSize(innertHint, SWT.DEFAULT); + } + } if (textLabel instanceof Label) { Point defSize = textLabelCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);