*** empty log message ***
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 ca38f69..a21112b 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
@@ -96,7 +96,32 @@
protected ToggleHyperlink toggle;
protected Control textLabel;
private class ExpandableLayout extends Layout implements ILayoutExtension {
+
+ private SizeCache toggleCache = new SizeCache();
+ private SizeCache textClientCache = new SizeCache();
+ private SizeCache textLabelCache = new SizeCache();
+ private SizeCache descriptionCache = new SizeCache();
+ private SizeCache clientCache = new SizeCache();
+
+ private void initCache(boolean shouldFlush) {
+ toggleCache.setControl(toggle);
+ textClientCache.setControl(textClient);
+ textLabelCache.setControl(textLabel);
+ descriptionCache.setControl(getDescriptionControl());
+ clientCache.setControl(client);
+
+ if (shouldFlush) {
+ toggleCache.flush();
+ textClientCache.flush();
+ textLabelCache.flush();
+ descriptionCache.flush();
+ clientCache.flush();
+ }
+ }
+
protected void layout(Composite parent, boolean changed) {
+ initCache(changed);
+
Rectangle clientArea = parent.getClientArea();
int thmargin = 0;
int tvmargin = 0;
@@ -110,20 +135,19 @@
Point tsize = null;
Point tcsize = null;
if (toggle != null)
- tsize = toggle.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
+ tsize = toggleCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
int twidth = clientArea.width - marginWidth - marginWidth - thmargin - thmargin;
if (tsize != null)
twidth -= tsize.x + GAP;
if (textClient !=null)
- tcsize = textClient.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
+ tcsize = textClientCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
if (tcsize!=null)
twidth -= tcsize.x + GAP;
Point size = null;
if (textLabel!=null)
- size = textLabel.computeSize(twidth, SWT.DEFAULT, changed);
+ size = textLabelCache.computeSize(twidth, SWT.DEFAULT);
if (textLabel instanceof Label) {
- Point defSize = textLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT,
- changed);
+ Point defSize = textLabelCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
if (defSize.y == size.y) {
// One line - pick the smaller of the two widths
size.x = Math.min(defSize.x, size.x);
@@ -143,10 +167,10 @@
x += tsize.x + GAP;
}
if (textLabel!=null)
- textLabel.setBounds(x, y, size.x, size.y);
+ textLabelCache.setBounds(x, y, size.x, size.y);
if (textClient!=null) {
int tcx = clientArea.width - tcsize.x-thmargin;
- textClient.setBounds(tcx, y, tcsize.x, tcsize.y);
+ textClientCache.setBounds(tcx, y, tcsize.x, tcsize.y);
}
if (size!=null)
y += size.y;
@@ -172,9 +196,8 @@
Point dsize = null;
Control desc = getDescriptionControl();
if (desc != null) {
- dsize = desc.computeSize(areaWidth, SWT.DEFAULT,
- changed);
- desc.setBounds(cx, y, dsize.x, dsize.y);
+ dsize = descriptionCache.computeSize(areaWidth, SWT.DEFAULT);
+ descriptionCache.setBounds(cx, y, dsize.x, dsize.y);
y += dsize.y + clientVerticalSpacing;
}
else
@@ -184,17 +207,20 @@
int cwidth = areaWidth;
int cheight = clientArea.height - marginHeight
- marginHeight - y;
- client.setBounds(cx, y, cwidth, cheight);
+ clientCache.setBounds(cx, y, cwidth, cheight);
}
}
}
protected Point computeSize(Composite parent, int wHint, int hHint,
boolean changed) {
+
+ initCache(changed);
+
int width = 0, height = 0;
Point tsize = null;
int twidth = 0;
if (toggle != null) {
- tsize = toggle.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
+ tsize = toggleCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
twidth = tsize.x + GAP;
}
int thmargin = 0;
@@ -212,17 +238,16 @@
Point tcsize = null;
if (textClient!=null) {
- tcsize = textClient.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
+ tcsize = textClientCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
if (innertHint!=SWT.DEFAULT)
innertHint -= GAP + tcsize.x;
}
Point size = null;
if (textLabel!=null)
- size = textLabel.computeSize(innertHint, SWT.DEFAULT, changed);
+ size = textLabelCache.computeSize(innertHint, SWT.DEFAULT);
if (textLabel instanceof Label) {
- Point defSize = textLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT,
- changed);
+ Point defSize = textLabelCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
if (defSize.y == size.y) {
// One line - pick the smaller of the two widths
size.x = Math.min(defSize.x, size.x);
@@ -247,8 +272,8 @@
if ((expansionStyle & CLIENT_INDENT) != 0)
cwHint = innerwHint;
Point dsize = null;
- Point csize = client.computeSize(FormUtil.getWidthHint(cwHint,
- client), SWT.DEFAULT, changed);
+ Point csize = clientCache.computeSize(FormUtil.getWidthHint(cwHint,
+ client), SWT.DEFAULT);
if (getDescriptionControl() != null) {
int dwHint = cwHint;
if (dwHint == SWT.DEFAULT) {
@@ -256,8 +281,7 @@
if ((expansionStyle & CLIENT_INDENT) != 0)
dwHint -= twidth;
}
- dsize = getDescriptionControl().computeSize(dwHint,
- SWT.DEFAULT, changed);
+ dsize = descriptionCache.computeSize(dwHint, SWT.DEFAULT);
}
if (dsize != null) {
if ((expansionStyle & CLIENT_INDENT) != 0)
@@ -282,13 +306,16 @@
+ marginHeight + marginHeight+tvmargin+tvmargin);
}
public int computeMinimumWidth(Composite parent, boolean changed) {
+
+ initCache(changed);
+
int width = 0;
Point size = null;
if (textLabel!=null)
- size = textLabel.computeSize(5, SWT.DEFAULT, changed);
+ size = textLabelCache.computeSize(5, SWT.DEFAULT);
Point tcsize=null;
if (textClient!=null) {
- tcsize = textClient.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
+ tcsize = textClientCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
}
int thmargin = 0;
int tvmargin = 0;
@@ -305,16 +332,14 @@
if ((expanded || (expansionStyle & COMPACT) == 0) && client != null) {
Point dsize = null;
if (getDescriptionControl() != null) {
- dsize = getDescriptionControl().computeSize(5, SWT.DEFAULT,
- changed);
+ dsize = descriptionCache.computeSize(5, SWT.DEFAULT);
width = Math.max(width, dsize.x);
}
int cwidth = FormUtil.computeMinimumWidth(client, changed);
width = Math.max(width, cwidth);
}
if (toggle != null) {
- Point tsize = toggle.computeSize(SWT.DEFAULT, SWT.DEFAULT,
- changed);
+ Point tsize = toggleCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
width += tsize.x + GAP;
}
return width + marginWidth + marginWidth+thmargin+thmargin;
@@ -326,11 +351,13 @@
* boolean)
*/
public int computeMaximumWidth(Composite parent, boolean changed) {
+
+ initCache(changed);
+
int width = 0;
Point size = null;
if (textLabel!=null)
- textLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT,
- changed);
+ textLabelCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Point tcsize=null;
int thmargin = 0;
int tvmargin = 0;
@@ -340,7 +367,7 @@
tvmargin = GAP;
}
if (textClient!=null) {
- tcsize = textClient.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
+ tcsize = textClientCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
}
if (size!=null)
width = size.x;
@@ -349,16 +376,14 @@
if ((expanded || (expansionStyle & COMPACT) == 0) && client != null) {
Point dsize = null;
if (getDescriptionControl() != null) {
- dsize = getDescriptionControl().computeSize(SWT.DEFAULT,
- SWT.DEFAULT, changed);
+ dsize = descriptionCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
width = Math.max(width, dsize.x);
}
int cwidth = FormUtil.computeMaximumWidth(client, changed);
width = Math.max(width, cwidth);
}
if (toggle != null) {
- Point tsize = toggle.computeSize(SWT.DEFAULT, SWT.DEFAULT,
- changed);
+ Point tsize = toggleCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
width += tsize.x + GAP;
}
return width + marginWidth + marginWidth+thmargin+thmargin;
diff --git a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/Form.java b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/Form.java
index 0e5cbd4..5dcae93 100644
--- a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/Form.java
+++ b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/Form.java
@@ -63,6 +63,8 @@
private String text;
private Composite body;
private ToolBarManager toolBarManager;
+ private SizeCache bodyCache = new SizeCache();
+ private SizeCache toolbarCache = new SizeCache();
private class FormLayout extends Layout implements ILayoutExtension {
public int computeMinimumWidth(Composite composite, boolean flushCache) {
@@ -73,6 +75,12 @@
}
public Point computeSize(Composite composite, int wHint, int hHint,
boolean flushCache) {
+ if (flushCache) {
+ bodyCache.flush();
+ toolbarCache.flush();
+ }
+ bodyCache.setControl(body);
+
int width = 0;
int height = 0;
if (text != null) {
@@ -92,8 +100,8 @@
if (toolBarManager != null) {
ToolBar toolBar = toolBarManager.getControl();
if (toolBar != null) {
- Point tbsize = toolBar
- .computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ toolbarCache.setControl(toolBar);
+ Point tbsize = toolbarCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
if (width != 0)
width += TITLE_GAP;
width += tbsize.x;
@@ -107,13 +115,21 @@
int ihHint = hHint;
if (ihHint > 0 && ihHint != SWT.DEFAULT)
ihHint -= height;
- Point bsize = body.computeSize(FormUtil.getWidthHint(wHint, body),
- FormUtil.getHeightHint(ihHint, body), flushCache);
+
+
+ Point bsize = bodyCache.computeSize(FormUtil.getWidthHint(wHint, body),
+ FormUtil.getHeightHint(ihHint, body));
width = Math.max(bsize.x, width);
height += bsize.y;
return new Point(width, height);
}
protected void layout(Composite composite, boolean flushCache) {
+ if (flushCache) {
+ bodyCache.flush();
+ toolbarCache.flush();
+ }
+ bodyCache.setControl(body);
+
Rectangle carea = composite.getClientArea();
int height = 0;
Point tbsize = null;
@@ -121,8 +137,9 @@
if (toolBarManager != null) {
ToolBar toolBar = toolBarManager.getControl();
if (toolBar != null) {
- tbsize = toolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- toolBar.setBounds(carea.width - 1 - TITLE_HMARGIN
+ toolbarCache.setControl(toolBar);
+ tbsize = toolbarCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ toolbarCache.setBounds(carea.width - 1 - TITLE_HMARGIN
- tbsize.x, TITLE_VMARGIN, tbsize.x, tbsize.y);
height = tbsize.y;
}
@@ -140,7 +157,8 @@
}
if (height > 0)
height += TITLE_VMARGIN * 2;
- body.setBounds(0, height, carea.width, carea.height - height);
+
+ bodyCache.setBounds(0, height, carea.width, carea.height - height);
}
}
/**
diff --git a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/FormText.java b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/FormText.java
index 9ba935c..1fe6c5c 100644
--- a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/FormText.java
+++ b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/FormText.java
@@ -452,6 +452,7 @@
model.parseRegularText(text, expandURLs);
loading = false;
layout();
+ redraw();
}
/**
* Sets the contents of the stream. Optionally, URLs in untagged text can
@@ -468,6 +469,7 @@
model.parseInputStream(is, expandURLs);
loading = false;
layout();
+ redraw();
}
/**
* Controls whether whitespace inside paragraph and list
diff --git a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/ScrolledForm.java b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/ScrolledForm.java
index 8e0d0f3..594e577 100644
--- a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/ScrolledForm.java
+++ b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/ScrolledForm.java
@@ -151,8 +151,8 @@
* compute new one.
*/
public void reflow(boolean flushCache) {
- content.getBody().layout();
- content.layout();
+ //content.getBody().layout();
+ //content.layout();
super.reflow(flushCache);
}
/**
diff --git a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SharedScrolledComposite.java b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SharedScrolledComposite.java
index 2bcdc1a..26b5687 100644
--- a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SharedScrolledComposite.java
+++ b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SharedScrolledComposite.java
@@ -11,9 +11,16 @@
package org.eclipse.ui.forms.widgets;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.internal.forms.widgets.*;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.ScrollBar;
+import org.eclipse.ui.internal.forms.widgets.FormUtil;
/**
* This class is used to provide common scrolling services to a number
* of controls in the toolkit. Classes that extend it are not
@@ -24,6 +31,12 @@
public abstract class SharedScrolledComposite extends ScrolledComposite {
private static final int H_SCROLL_INCREMENT = 5;
private static final int V_SCROLL_INCREMENT = 64;
+ private boolean ignoreLayouts = true;
+ private boolean ignoreResizes = false;
+ private boolean expandHorizontal = false;
+ private boolean expandVertical = false;
+ private SizeCache contentCache = new SizeCache();
+
/**
* Creates the new instance.
* @param parent the parent composite
@@ -33,7 +46,9 @@
super(parent, style);
addListener(SWT.Resize, new Listener() {
public void handleEvent(Event e) {
- reflow(true);
+ if (!ignoreResizes) {
+ reflow(false);
+ }
}
});
initializeScrollBars();
@@ -89,6 +104,36 @@
else
return super.setFocus();
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Composite#layout(boolean)
+ */
+ public void layout(boolean changed) {
+ if (ignoreLayouts) {
+ return;
+ }
+
+ ignoreLayouts = true;
+ ignoreResizes = true;
+ super.layout(changed);
+ ignoreResizes = false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.custom.ScrolledComposite#setExpandHorizontal(boolean)
+ */
+ public void setExpandHorizontal(boolean expand) {
+ expandHorizontal = expand;
+ super.setExpandHorizontal(expand);
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.custom.ScrolledComposite#setExpandVertical(boolean)
+ */
+ public void setExpandVertical(boolean expand) {
+ expandVertical = expand;
+ super.setExpandVertical(expand);
+ }
+
/**
* Recomputes the body layout and the scroll bars. The method should be
* used when changes somewhere in the form body invalidate the current
@@ -101,13 +146,30 @@
Rectangle clientArea = getClientArea();
if (c == null)
return;
- c.layout(flushCache);
- Point newSize = c.computeSize(FormUtil
+
+ contentCache.setControl(c);
+ if (flushCache) {
+ contentCache.flush();
+ }
+
+ Point newSize = contentCache.computeSize(FormUtil
.getWidthHint(clientArea.width, c), FormUtil.getHeightHint(
- clientArea.height, c), flushCache);
- c.setSize(newSize);
+ clientArea.height, c));
+
+ Point currentSize = c.getSize();
+
+ if (!(expandHorizontal && expandVertical)) {
+ c.setSize(newSize);
+ }
+
setMinSize(newSize);
FormUtil.updatePageIncrement(this);
+
+ ignoreLayouts = false;
+ layout(flushCache);
+ ignoreLayouts = true;
+
+ contentCache.layoutIfNecessary();
}
private void initializeScrollBars() {
ScrollBar hbar = getHorizontalBar();
diff --git a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/TableWrapLayout.java b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/TableWrapLayout.java
index c5bb69b..cd84cbe 100644
--- a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/TableWrapLayout.java
+++ b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/TableWrapLayout.java
@@ -81,6 +81,8 @@
private int widestColumnWidth;
private int[] growingColumns;
private int[] growingRows;
+ private LayoutCache cache = new LayoutCache();
+
private class RowSpan {
Control child;
int row;
@@ -113,6 +115,14 @@
* @see ILayoutExtension
*/
public int computeMinimumWidth(Composite parent, boolean changed) {
+
+ Control[] children = parent.getChildren();
+ if (changed) {
+ cache.flush();
+ }
+
+ cache.setControls(children);
+
changed = true;
initializeIfNeeded(parent, changed);
if (initialLayout) {
@@ -137,6 +147,13 @@
* @see ILayoutExtension
*/
public int computeMaximumWidth(Composite parent, boolean changed) {
+ Control[] children = parent.getChildren();
+ if (changed) {
+ cache.flush();
+ }
+
+ cache.setControls(children);
+
changed = true;
initializeIfNeeded(parent, changed);
if (initialLayout) {
@@ -159,10 +176,18 @@
* @see Layout#layout(Composite, boolean)
*/
protected void layout(Composite parent, boolean changed) {
+
Rectangle clientArea = parent.getClientArea();
Control[] children = parent.getChildren();
+ if (changed) {
+ cache.flush();
+ }
+
if (children.length == 0)
return;
+
+ cache.setControls(children);
+
int parentWidth = clientArea.width;
changed = true;
initializeIfNeeded(parent, changed);
@@ -257,7 +282,7 @@
if (k < j + span - 1)
cwidth += horizontalSpacing;
}
- Point size = computeSize(child, cwidth, td.indent, changed);
+ Point size = computeSize(td.childIndex, cwidth, td.indent);
td.compWidth = cwidth;
if (td.heightHint != SWT.DEFAULT) {
size = new Point(size.x, td.heightHint);
@@ -329,11 +354,12 @@
}
return widths;
}
- Point computeSize(Control child, int width, int indent, boolean changed) {
+ Point computeSize(int childIndex, int width, int indent) {
int widthArg = width - indent;
- if (!isWrap(child))
+ SizeCache controlCache = cache.getCache(childIndex);
+ if (!isWrap(controlCache.getControl()))
widthArg = SWT.DEFAULT;
- Point size = child.computeSize(widthArg, SWT.DEFAULT, changed);
+ Point size = controlCache.computeSize(widthArg, SWT.DEFAULT);
size.x += indent;
return size;
}
@@ -506,10 +532,17 @@
*/
protected Point computeSize(Composite parent, int wHint, int hHint,
boolean changed) {
+
+
Control[] children = parent.getChildren();
+ if (changed) {
+ cache.flush();
+ }
if (children.length == 0) {
return new Point(0, 0);
}
+ cache.setControls(children);
+
int parentWidth = wHint;
changed = true;
initializeIfNeeded(parent, changed);
@@ -584,7 +617,7 @@
}
int cy = td.heightHint;
if (cy == SWT.DEFAULT) {
- Point size = computeSize(child, cwidth, td.indent, changed);
+ Point size = computeSize(td.childIndex, cwidth, td.indent);
cy = size.y;
}
RowSpan rowspan = (RowSpan) rowspans.get(child);
@@ -678,21 +711,10 @@
if (td.isItemData == false)
continue;
Control child = children[td.childIndex];
- int minWidth = -1;
- if (child instanceof Composite) {
- Composite cc = (Composite) child;
- Layout l = cc.getLayout();
- if (l instanceof ILayoutExtension) {
- minWidth = ((ILayoutExtension) l).computeMinimumWidth(
- cc, changed);
- }
- }
- if (minWidth == -1) {
- int minWHint = isWrap(child) ? 0 : SWT.DEFAULT;
- Point size = child.computeSize(minWHint, SWT.DEFAULT,
- changed);
- minWidth = size.x;
- }
+
+ SizeCache childCache = cache.getCache(td.childIndex);
+ int minWidth = childCache.computeMinimumWidth();
+
minWidth += td.indent;
if (td.colspan == 1)
minColumnWidths[j] = Math.max(minColumnWidths[j], minWidth);
@@ -755,21 +777,10 @@
if (td.isItemData == false)
continue;
Control child = children[td.childIndex];
- int maxWidth = SWT.DEFAULT;
- if (child instanceof Composite) {
- Composite cc = (Composite) child;
- Layout l = cc.getLayout();
- if (l instanceof ILayoutExtension) {
- maxWidth = ((ILayoutExtension) l).computeMaximumWidth(
- cc, changed);
- }
- } else if (td.maxWidth != SWT.DEFAULT)
- maxWidth = td.maxWidth;
- if (maxWidth == SWT.DEFAULT) {
- Point size = child.computeSize(SWT.DEFAULT, SWT.DEFAULT,
- changed);
- maxWidth = size.x;
- }
+
+ SizeCache sc = cache.getCache(td.childIndex);
+ int maxWidth = sc.computeMaximumWidth();
+
maxWidth += td.indent;
if (td.colspan == 1)
maxColumnWidths[j] = Math.max(maxColumnWidths[j], maxWidth);