diff --git a/org.eclipse.wb.rcp/src/org/eclipse/wb/internal/rcp/model/layout/grid/GridData2.java b/org.eclipse.wb.rcp/src/org/eclipse/wb/internal/rcp/model/layout/grid/GridData2.java index e32a739b4..a988afe31 100644 --- a/org.eclipse.wb.rcp/src/org/eclipse/wb/internal/rcp/model/layout/grid/GridData2.java +++ b/org.eclipse.wb.rcp/src/org/eclipse/wb/internal/rcp/model/layout/grid/GridData2.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2026 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -12,8 +12,8 @@ *******************************************************************************/ package org.eclipse.wb.internal.rcp.model.layout.grid; -import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Control; /** @@ -50,400 +50,25 @@ * @coverage rcp.model.layout.GridLayout.copy */ public final class GridData2 { - /** - * verticalAlignment specifies how controls will be positioned vertically within a cell. - * - * The default value is CENTER. - * - * Possible values are: - * - */ - public int verticalAlignment = CENTER; - /** - * horizontalAlignment specifies how controls will be positioned horizontally within a cell. - * - * The default value is BEGINNING. - * - * Possible values are: - * - */ - public int horizontalAlignment = BEGINNING; - /** - * widthHint specifies the preferred width in pixels. This value is the wHint passed into - * Control.computeSize(int, int, boolean) to determine the preferred size of the control. - * - * The default value is SWT.DEFAULT. - * - * @see Control#computeSize(int, int, boolean) - */ - public int widthHint = SWT.DEFAULT; - /** - * heightHint specifies the preferred height in pixels. This value is the hHint passed into - * Control.computeSize(int, int, boolean) to determine the preferred size of the control. - * - * The default value is SWT.DEFAULT. - * - * @see Control#computeSize(int, int, boolean) - */ - public int heightHint = SWT.DEFAULT; - /** - * horizontalIndent specifies the number of pixels of indentation that will be placed along the - * left side of the cell. - * - * The default value is 0. - */ - public int horizontalIndent = 0; - /** - * verticalIndent specifies the number of pixels of indentation that will be placed along the top - * side of the cell. - * - * The default value is 0. - * - * @since 3.1 - */ - public int verticalIndent = 0; - /** - * horizontalSpan specifies the number of column cells that the control will take up. - * - * The default value is 1. - */ - public int horizontalSpan = 1; - /** - * verticalSpan specifies the number of row cells that the control will take up. - * - * The default value is 1. - */ - public int verticalSpan = 1; - /** - *

- * grabExcessHorizontalSpace specifies whether the width of the cell changes depending on the size - * of the parent Composite. If grabExcessHorizontalSpace is true, the following rules - * apply to the width of the cell: - *

- * - * - *

- * The default value is false. - *

- * - * @see GridData2#minimumWidth - * @see GridData2#widthHint - */ - public boolean grabExcessHorizontalSpace = false; - /** - *

- * grabExcessVerticalSpace specifies whether the height of the cell changes depending on the size - * of the parent Composite. If grabExcessVerticalSpace is true, the following rules - * apply to the height of the cell: - *

- * - * - *

- * The default value is false. - *

- * - * @see GridData2#minimumHeight - * @see GridData2#heightHint - */ - public boolean grabExcessVerticalSpace = false; - /** - * minimumWidth specifies the minimum width in pixels. This value applies only if - * grabExcessHorizontalSpace is true. A value of SWT.DEFAULT means that the minimum width will be - * the result of Control.computeSize(int, int, boolean) where wHint is determined by - * GridData.widthHint. - * - * The default value is 0. - * - * @since 3.1 - * @see Control#computeSize(int, int, boolean) - * @see GridData2#widthHint - */ - public int minimumWidth = 0; - /** - * minimumHeight specifies the minimum height in pixels. This value applies only if - * grabExcessVerticalSpace is true. A value of SWT.DEFAULT means that the minimum height will be - * the result of Control.computeSize(int, int, boolean) where hHint is determined by - * GridData.heightHint. - * - * The default value is 0. - * - * @since 3.1 - * @see Control#computeSize(int, int, boolean) - * @see GridData2#heightHint - */ - public int minimumHeight = 0; - /** - * exclude informs the layout to ignore this control when sizing and positioning controls. If this - * value is true, the size and position of the control will not be managed by the - * layout. If this value is false, the size and position of the control will be - * computed and assigned. - * - * The default value is false. - * - * @since 3.1 - */ - public boolean exclude = false; - /** - * Value for horizontalAlignment or verticalAlignment. Position the control at the top or left of - * the cell. Not recommended. Use SWT.BEGINNING, SWT.TOP or SWT.LEFT instead. - */ - public static final int BEGINNING = SWT.BEGINNING; - /** - * Value for horizontalAlignment or verticalAlignment. Position the control in the vertical or - * horizontal center of the cell Not recommended. Use SWT.CENTER instead. - */ - public static final int CENTER = 2; - /** - * Value for horizontalAlignment or verticalAlignment. Position the control at the bottom or right - * of the cell Not recommended. Use SWT.END, SWT.BOTTOM or SWT.RIGHT instead. - */ - public static final int END = 3; - /** - * Value for horizontalAlignment or verticalAlignment. Resize the control to fill the cell - * horizontally or vertically. Not recommended. Use SWT.FILL instead. - */ - public static final int FILL = SWT.FILL; - /** - * Style bit for new GridData(int). Position the control at the top of the cell. Not - * recommended. Use new GridData(int, SWT.BEGINNING, boolean, boolean) instead. - */ - public static final int VERTICAL_ALIGN_BEGINNING = 1 << 1; - /** - * Style bit for new GridData(int) to position the control in the vertical center of - * the cell. Not recommended. Use new GridData(int, SWT.CENTER, boolean, boolean) - * instead. - */ - public static final int VERTICAL_ALIGN_CENTER = 1 << 2; - /** - * Style bit for new GridData(int) to position the control at the bottom of the cell. - * Not recommended. Use new GridData(int, SWT.END, boolean, boolean) instead. - */ - public static final int VERTICAL_ALIGN_END = 1 << 3; - /** - * Style bit for new GridData(int) to resize the control to fill the cell vertically. - * Not recommended. Use new GridData(int, SWT.FILL, boolean, boolean) instead - */ - public static final int VERTICAL_ALIGN_FILL = 1 << 4; - /** - * Style bit for new GridData(int) to position the control at the left of the cell. - * Not recommended. Use new GridData(SWT.BEGINNING, int, boolean, boolean) instead. - */ - public static final int HORIZONTAL_ALIGN_BEGINNING = 1 << 5; - /** - * Style bit for new GridData(int) to position the control in the horizontal center - * of the cell. Not recommended. Use new GridData(SWT.CENTER, int, boolean, boolean) - * instead. - */ - public static final int HORIZONTAL_ALIGN_CENTER = 1 << 6; - /** - * Style bit for new GridData(int) to position the control at the right of the cell. - * Not recommended. Use new GridData(SWT.END, int, boolean, boolean) instead. - */ - public static final int HORIZONTAL_ALIGN_END = 1 << 7; - /** - * Style bit for new GridData(int) to resize the control to fill the cell - * horizontally. Not recommended. Use new GridData(SWT.FILL, int, boolean, boolean) - * instead. - */ - public static final int HORIZONTAL_ALIGN_FILL = 1 << 8; - /** - * Style bit for new GridData(int) to resize the control to fit the remaining - * horizontal space. Not recommended. Use new GridData(int, int, true, boolean) - * instead. - */ - public static final int GRAB_HORIZONTAL = 1 << 9; - /** - * Style bit for new GridData(int) to resize the control to fit the remaining - * vertical space. Not recommended. Use new GridData(int, int, boolean, true) - * instead. - */ - public static final int GRAB_VERTICAL = 1 << 10; - /** - * Style bit for new GridData(int) to resize the control to fill the cell vertically - * and to fit the remaining vertical space. FILL_VERTICAL = VERTICAL_ALIGN_FILL | GRAB_VERTICAL - * Not recommended. Use new GridData(int, SWT.FILL, boolean, true) instead. - */ - public static final int FILL_VERTICAL = VERTICAL_ALIGN_FILL | GRAB_VERTICAL; - /** - * Style bit for new GridData(int) to resize the control to fill the cell - * horizontally and to fit the remaining horizontal space. FILL_HORIZONTAL = HORIZONTAL_ALIGN_FILL - * | GRAB_HORIZONTAL Not recommended. Use new GridData(SWT.FILL, int, true, boolean) - * instead. - */ - public static final int FILL_HORIZONTAL = HORIZONTAL_ALIGN_FILL | GRAB_HORIZONTAL; - /** - * Style bit for new GridData(int) to resize the control to fill the cell - * horizontally and vertically and to fit the remaining horizontal and vertical space. FILL_BOTH = - * FILL_VERTICAL | FILL_HORIZONTAL Not recommended. Use - * new GridData(SWT.FILL, SWT.FILL, true, true) instead. - */ - public static final int FILL_BOTH = FILL_VERTICAL | FILL_HORIZONTAL; + final GridData data; int cacheWidth = -1, cacheHeight = -1; int defaultWhint, defaultHhint, defaultWidth = -1, defaultHeight = -1; int currentWhint, currentHhint, currentWidth = -1, currentHeight = -1; /** - * Constructs a new instance of GridData using default values. - */ - public GridData2() { - super(); - } - - /** - * Constructs a new instance based on the GridData style. This constructor is not recommended. + * Constructs a new instance based on the given GridData. * - * @param style - * the GridData style + * @param data the source GridData */ - public GridData2(int style) { - super(); - if ((style & VERTICAL_ALIGN_BEGINNING) != 0) { - verticalAlignment = BEGINNING; - } - if ((style & VERTICAL_ALIGN_CENTER) != 0) { - verticalAlignment = CENTER; - } - if ((style & VERTICAL_ALIGN_FILL) != 0) { - verticalAlignment = FILL; - } - if ((style & VERTICAL_ALIGN_END) != 0) { - verticalAlignment = END; - } - if ((style & HORIZONTAL_ALIGN_BEGINNING) != 0) { - horizontalAlignment = BEGINNING; - } - if ((style & HORIZONTAL_ALIGN_CENTER) != 0) { - horizontalAlignment = CENTER; - } - if ((style & HORIZONTAL_ALIGN_FILL) != 0) { - horizontalAlignment = FILL; - } - if ((style & HORIZONTAL_ALIGN_END) != 0) { - horizontalAlignment = END; - } - grabExcessHorizontalSpace = (style & GRAB_HORIZONTAL) != 0; - grabExcessVerticalSpace = (style & GRAB_VERTICAL) != 0; - } - - /** - * Constructs a new instance of GridData according to the parameters. - * - * @param horizontalAlignment - * how control will be positioned horizontally within a cell - * @param verticalAlignment - * how control will be positioned vertically within a cell - * @param grabExcessHorizontalSpace - * whether cell will be made wide enough to fit the remaining horizontal space - * @param grabExcessVerticalSpace - * whether cell will be made high enough to fit the remaining vertical space - * - * @since 3.0 - */ - public GridData2(int horizontalAlignment, - int verticalAlignment, - boolean grabExcessHorizontalSpace, - boolean grabExcessVerticalSpace) { - this(horizontalAlignment, - verticalAlignment, - grabExcessHorizontalSpace, - grabExcessVerticalSpace, - 1, - 1); - } - - /** - * Constructs a new instance of GridData according to the parameters. - * - * @param horizontalAlignment - * how control will be positioned horizontally within a cell - * @param verticalAlignment - * how control will be positioned vertically within a cell - * @param grabExcessHorizontalSpace - * whether cell will be made wide enough to fit the remaining horizontal space - * @param grabExcessVerticalSpace - * whether cell will be made high enough to fit the remaining vertical space - * @param horizontalSpan - * the number of column cells that the control will take up - * @param verticalSpan - * the number of row cells that the control will take up - * - * @since 3.0 - */ - public GridData2(int horizontalAlignment, - int verticalAlignment, - boolean grabExcessHorizontalSpace, - boolean grabExcessVerticalSpace, - int horizontalSpan, - int verticalSpan) { - super(); - this.horizontalAlignment = horizontalAlignment; - this.verticalAlignment = verticalAlignment; - this.grabExcessHorizontalSpace = grabExcessHorizontalSpace; - this.grabExcessVerticalSpace = grabExcessVerticalSpace; - this.horizontalSpan = horizontalSpan; - this.verticalSpan = verticalSpan; - } - - /** - * Constructs a new instance of GridData according to the parameters. A value of SWT.DEFAULT - * indicates that no minimum width or no minimum height is specified. - * - * @param width - * a minimum width for the column - * @param height - * a minimum height for the row - * - * @since 3.0 - */ - public GridData2(int width, int height) { - super(); - widthHint = width; - heightHint = height; + public GridData2(GridData data) { + this.data = data; } void computeSize(Control control, int wHint, int hHint, boolean flushCache) { if (cacheWidth != -1 && cacheHeight != -1) { return; } - if (wHint == widthHint && hHint == heightHint) { + if (wHint == data.widthHint && hHint == data.heightHint) { if (defaultWidth == -1 || defaultHeight == -1 || wHint != defaultWhint @@ -491,104 +116,6 @@ String getName() { */ @Override public String toString() { - String hAlign = ""; - switch (horizontalAlignment) { - case SWT.FILL : - hAlign = "SWT.FILL"; - break; - case SWT.BEGINNING : - hAlign = "SWT.BEGINNING"; - break; - case SWT.LEFT : - hAlign = "SWT.LEFT"; - break; - case SWT.END : - hAlign = "SWT.END"; - break; - case END : - hAlign = "GridData.END"; - break; - case SWT.RIGHT : - hAlign = "SWT.RIGHT"; - break; - case SWT.CENTER : - hAlign = "SWT.CENTER"; - break; - case CENTER : - hAlign = "GridData.CENTER"; - break; - default : - hAlign = "Undefined " + horizontalAlignment; - break; - } - String vAlign = ""; - switch (verticalAlignment) { - case SWT.FILL : - vAlign = "SWT.FILL"; - break; - case SWT.BEGINNING : - vAlign = "SWT.BEGINNING"; - break; - case SWT.TOP : - vAlign = "SWT.TOP"; - break; - case SWT.END : - vAlign = "SWT.END"; - break; - case END : - vAlign = "GridData.END"; - break; - case SWT.BOTTOM : - vAlign = "SWT.BOTTOM"; - break; - case SWT.CENTER : - vAlign = "SWT.CENTER"; - break; - case CENTER : - vAlign = "GridData.CENTER"; - break; - default : - vAlign = "Undefined " + verticalAlignment; - break; - } - String string = getName() + " {"; - string += "horizontalAlignment=" + hAlign + " "; - if (horizontalIndent != 0) { - string += "horizontalIndent=" + horizontalIndent + " "; - } - if (horizontalSpan != 1) { - string += "horizontalSpan=" + horizontalSpan + " "; - } - if (grabExcessHorizontalSpace) { - string += "grabExcessHorizontalSpace=" + grabExcessHorizontalSpace + " "; - } - if (widthHint != SWT.DEFAULT) { - string += "widthHint=" + widthHint + " "; - } - if (minimumWidth != 0) { - string += "minimumWidth=" + minimumWidth + " "; - } - string += "verticalAlignment=" + vAlign + " "; - if (verticalIndent != 0) { - string += "verticalIndent=" + verticalIndent + " "; - } - if (verticalSpan != 1) { - string += "verticalSpan=" + verticalSpan + " "; - } - if (grabExcessVerticalSpace) { - string += "grabExcessVerticalSpace=" + grabExcessVerticalSpace + " "; - } - if (heightHint != SWT.DEFAULT) { - string += "heightHint=" + heightHint + " "; - } - if (minimumHeight != 0) { - string += "minimumHeight=" + minimumHeight + " "; - } - if (exclude) { - string += "exclude=" + exclude + " "; - } - string = string.trim(); - string += "}"; - return string; + return data.toString(); } } diff --git a/org.eclipse.wb.rcp/src/org/eclipse/wb/internal/rcp/model/layout/grid/GridLayout2.java b/org.eclipse.wb.rcp/src/org/eclipse/wb/internal/rcp/model/layout/grid/GridLayout2.java index 71b28e2dc..059a03f12 100644 --- a/org.eclipse.wb.rcp/src/org/eclipse/wb/internal/rcp/model/layout/grid/GridLayout2.java +++ b/org.eclipse.wb.rcp/src/org/eclipse/wb/internal/rcp/model/layout/grid/GridLayout2.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2026 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -204,7 +204,8 @@ GridData2 getData(Control[][] grid, boolean first) { Control control = grid[row][column]; if (control != null) { - GridData2 data = getLayoutData2(control); + GridData2 cache = getLayoutData2(control); + GridData data = cache.data; int hSpan = Math.max(1, Math.min(data.horizontalSpan, columnCount)); int vSpan = Math.max(1, data.verticalSpan); int i = first ? row + vSpan - 1 : row - vSpan + 1; @@ -212,7 +213,7 @@ GridData2 getData(Control[][] grid, if (0 <= i && i < rowCount) { if (0 <= j && j < columnCount) { if (control == grid[i][j]) { - return data; + return cache; } } } @@ -247,8 +248,8 @@ Point layout(Composite composite, int count = 0; for (int i = 0; i < children.length; i++) { Control control = children[i]; - GridData2 data = getLayoutData2(control); - if (data == null || !data.exclude) { + GridData2 cache = getLayoutData2(control); + if (cache == null || !cache.data.exclude) { children[count++] = children[i]; } } @@ -266,13 +267,14 @@ Point layout(Composite composite, } for (int i = 0; i < count; i++) { Control child = children[i]; - GridData2 data = getLayoutData2(child); + GridData2 cache = getLayoutData2(child); + GridData data = cache.data; if (flushCache) { - data.flushCache(); + cache.flushCache(); } - data.computeSize(child, data.widthHint, data.heightHint, flushCache); + cache.computeSize(child, data.widthHint, data.heightHint, flushCache); if (data.grabExcessHorizontalSpace && data.minimumWidth > 0) { - if (data.cacheWidth < data.minimumWidth) { + if (cache.cacheWidth < data.minimumWidth) { int trim = 0; //TEMPORARY CODE if (child instanceof Scrollable) { @@ -281,12 +283,12 @@ Point layout(Composite composite, } else { trim = child.getBorderWidth() * 2; } - data.cacheWidth = data.cacheHeight = SWT.DEFAULT; - data.computeSize(child, Math.max(0, data.minimumWidth - trim), data.heightHint, false); + cache.cacheWidth = cache.cacheHeight = SWT.DEFAULT; + cache.computeSize(child, Math.max(0, data.minimumWidth - trim), data.heightHint, false); } } if (data.grabExcessVerticalSpace && data.minimumHeight > 0) { - data.cacheHeight = Math.max(data.cacheHeight, data.minimumHeight); + cache.cacheHeight = Math.max(cache.cacheHeight, data.minimumHeight); } } /* Build the grid */ @@ -294,7 +296,8 @@ Point layout(Composite composite, Control[][] grid = new Control[4][columnCount]; for (int i = 0; i < count; i++) { Control child = children[i]; - GridData2 data = getLayoutData2(child); + GridData2 cache = getLayoutData2(child); + GridData data = cache.data; int hSpan = Math.max(1, Math.min(data.horizontalSpan, columnCount)); int vSpan = Math.max(1, data.verticalSpan); while (true) { @@ -352,11 +355,12 @@ Point layout(Composite composite, boolean[] expandColumn = new boolean[columnCount]; for (int j = 0; j < columnCount; j++) { for (int i = 0; i < rowCount; i++) { - GridData2 data = getData(grid, i, j, rowCount, columnCount, true); - if (data != null) { + GridData2 cache = getData(grid, i, j, rowCount, columnCount, true); + if (cache != null) { + GridData data = cache.data; int hSpan = Math.max(1, Math.min(data.horizontalSpan, columnCount)); if (hSpan == 1) { - int w = data.cacheWidth + data.horizontalIndent; + int w = cache.cacheWidth + data.horizontalIndent; widths[j] = Math.max(widths[j], w); if (data.grabExcessHorizontalSpace) { if (!expandColumn[j]) { @@ -367,7 +371,7 @@ Point layout(Composite composite, if (!data.grabExcessHorizontalSpace || data.minimumWidth != 0) { w = !data.grabExcessHorizontalSpace || data.minimumWidth == SWT.DEFAULT - ? data.cacheWidth + ? cache.cacheWidth : data.minimumWidth; w += data.horizontalIndent; minWidths[j] = Math.max(minWidths[j], w); @@ -376,8 +380,9 @@ Point layout(Composite composite, } } for (int i = 0; i < rowCount; i++) { - GridData2 data = getData(grid, i, j, rowCount, columnCount, false); - if (data != null) { + GridData2 cache = getData(grid, i, j, rowCount, columnCount, false); + if (cache != null) { + GridData data = cache.data; int hSpan = Math.max(1, Math.min(data.horizontalSpan, columnCount)); if (hSpan > 1) { int spanWidth = 0, spanMinWidth = 0, spanExpandCount = 0; @@ -393,7 +398,7 @@ Point layout(Composite composite, expandColumn[j] = true; } int w = - data.cacheWidth + cache.cacheWidth + data.horizontalIndent - spanWidth - (hSpan - 1) @@ -428,7 +433,7 @@ Point layout(Composite composite, if (!data.grabExcessHorizontalSpace || data.minimumWidth != 0) { w = !data.grabExcessHorizontalSpace || data.minimumWidth == SWT.DEFAULT - ? data.cacheWidth + ? cache.cacheWidth : data.minimumWidth; w += data.horizontalIndent - spanMinWidth - (hSpan - 1) * horizontalSpacing; if (w > 0) { @@ -494,8 +499,9 @@ Point layout(Composite composite, } for (int j = 0; j < columnCount; j++) { for (int i = 0; i < rowCount; i++) { - GridData2 data = getData(grid, i, j, rowCount, columnCount, false); - if (data != null) { + GridData2 cache = getData(grid, i, j, rowCount, columnCount, false); + if (cache != null) { + GridData data = cache.data; int hSpan = Math.max(1, Math.min(data.horizontalSpan, columnCount)); if (hSpan > 1) { if (!data.grabExcessHorizontalSpace || data.minimumWidth != 0) { @@ -508,7 +514,7 @@ Point layout(Composite composite, } int w = !data.grabExcessHorizontalSpace || data.minimumWidth == SWT.DEFAULT - ? data.cacheWidth + ? cache.cacheWidth : data.minimumWidth; w += data.horizontalIndent - spanWidth - (hSpan - 1) * horizontalSpacing; if (w > 0) { @@ -551,8 +557,9 @@ Point layout(Composite composite, if (width != SWT.DEFAULT) { for (int j = 0; j < columnCount; j++) { for (int i = 0; i < rowCount; i++) { - GridData2 data = getData(grid, i, j, rowCount, columnCount, false); - if (data != null) { + GridData2 cache = getData(grid, i, j, rowCount, columnCount, false); + if (cache != null) { + GridData data = cache.data; if (data.heightHint == SWT.DEFAULT) { Control child = grid[i][j]; //TEMPORARY CODE @@ -562,9 +569,9 @@ Point layout(Composite composite, currentWidth += widths[j - k]; } currentWidth += (hSpan - 1) * horizontalSpacing - data.horizontalIndent; - if (currentWidth != data.cacheWidth + if (currentWidth != cache.cacheWidth && data.horizontalAlignment == SWT.FILL - || data.cacheWidth > currentWidth) { + || cache.cacheWidth > currentWidth) { int trim = 0; if (child instanceof Scrollable) { Rectangle rect = ((Scrollable) child).computeTrim(0, 0, 0, 0); @@ -572,15 +579,15 @@ Point layout(Composite composite, } else { trim = child.getBorderWidth() * 2; } - data.cacheWidth = data.cacheHeight = SWT.DEFAULT; - data.computeSize(child, Math.max(0, currentWidth - trim), data.heightHint, false); + cache.cacheWidth = cache.cacheHeight = SWT.DEFAULT; + cache.computeSize(child, Math.max(0, currentWidth - trim), data.heightHint, false); if (data.grabExcessVerticalSpace && data.minimumHeight > 0) { - data.cacheHeight = Math.max(data.cacheHeight, data.minimumHeight); + cache.cacheHeight = Math.max(cache.cacheHeight, data.minimumHeight); } if (flush == null) { flush = new GridData2[count]; } - flush[flushLength++] = data; + flush[flushLength++] = cache; } } } @@ -599,11 +606,12 @@ Point layout(Composite composite, boolean[] expandRow = new boolean[rowCount]; for (int i = 0; i < rowCount; i++) { for (int j = 0; j < columnCount; j++) { - GridData2 data = getData(grid, i, j, rowCount, columnCount, true); - if (data != null) { + GridData2 cache = getData(grid, i, j, rowCount, columnCount, true); + if (cache != null) { + GridData data = cache.data; int vSpan = Math.max(1, Math.min(data.verticalSpan, rowCount)); if (vSpan == 1) { - int h = data.cacheHeight + data.verticalIndent; + int h = cache.cacheHeight + data.verticalIndent; heights[i] = Math.max(heights[i], h); if (data.grabExcessVerticalSpace) { if (!expandRow[i]) { @@ -614,7 +622,7 @@ Point layout(Composite composite, if (!data.grabExcessVerticalSpace || data.minimumHeight != 0) { h = !data.grabExcessVerticalSpace || data.minimumHeight == SWT.DEFAULT - ? data.cacheHeight + ? cache.cacheHeight : data.minimumHeight; h += data.verticalIndent; minHeights[i] = Math.max(minHeights[i], h); @@ -623,8 +631,9 @@ Point layout(Composite composite, } } for (int j = 0; j < columnCount; j++) { - GridData2 data = getData(grid, i, j, rowCount, columnCount, false); - if (data != null) { + GridData2 cache = getData(grid, i, j, rowCount, columnCount, false); + if (cache != null) { + GridData data = cache.data; int vSpan = Math.max(1, Math.min(data.verticalSpan, rowCount)); if (vSpan > 1) { int spanHeight = 0, spanMinHeight = 0, spanExpandCount = 0; @@ -640,7 +649,7 @@ Point layout(Composite composite, expandRow[i] = true; } int h = - data.cacheHeight + data.verticalIndent - spanHeight - (vSpan - 1) * verticalSpacing; + cache.cacheHeight + data.verticalIndent - spanHeight - (vSpan - 1) * verticalSpacing; if (h > 0) { if (spanExpandCount == 0) { heights[i] += h; @@ -660,7 +669,7 @@ Point layout(Composite composite, if (!data.grabExcessVerticalSpace || data.minimumHeight != 0) { h = !data.grabExcessVerticalSpace || data.minimumHeight == SWT.DEFAULT - ? data.cacheHeight + ? cache.cacheHeight : data.minimumHeight; h += data.verticalIndent - spanMinHeight - (vSpan - 1) * verticalSpacing; if (h > 0) { @@ -710,8 +719,9 @@ Point layout(Composite composite, } for (int i = 0; i < rowCount; i++) { for (int j = 0; j < columnCount; j++) { - GridData2 data = getData(grid, i, j, rowCount, columnCount, false); - if (data != null) { + GridData2 cache = getData(grid, i, j, rowCount, columnCount, false); + if (cache != null) { + GridData data = cache.data; int vSpan = Math.max(1, Math.min(data.verticalSpan, rowCount)); if (vSpan > 1) { if (!data.grabExcessVerticalSpace || data.minimumHeight != 0) { @@ -724,7 +734,7 @@ Point layout(Composite composite, } int h = !data.grabExcessVerticalSpace || data.minimumHeight == SWT.DEFAULT - ? data.cacheHeight + ? cache.cacheHeight : data.minimumHeight; h += data.verticalIndent - spanHeight - (vSpan - 1) * verticalSpacing; if (h > 0) { @@ -770,8 +780,9 @@ Point layout(Composite composite, for (int j = 0; j < columnCount; j++) { m_columnOrigins[j] = gridX; m_rowOrigins[i] = gridY; - GridData2 data = getData(grid, i, j, rowCount, columnCount, true); - if (data != null) { + GridData2 cache = getData(grid, i, j, rowCount, columnCount, true); + if (cache != null) { + GridData data = cache.data; int hSpan = Math.max(1, Math.min(data.horizontalSpan, columnCount)); int vSpan = Math.max(1, data.verticalSpan); int cellWidth = 0, cellHeight = 0; @@ -783,15 +794,15 @@ Point layout(Composite composite, } cellWidth += horizontalSpacing * (hSpan - 1); int childX = gridX + data.horizontalIndent; - int childWidth = Math.min(data.cacheWidth, cellWidth); + int childWidth = Math.min(cache.cacheWidth, cellWidth); switch (data.horizontalAlignment) { case SWT.CENTER : - case GridData2.CENTER : + case GridData.CENTER: childX += Math.max(0, (cellWidth - data.horizontalIndent - childWidth) / 2); break; case SWT.RIGHT : case SWT.END : - case GridData2.END : + case GridData.END: childX += Math.max(0, cellWidth - data.horizontalIndent - childWidth); break; case SWT.FILL : @@ -800,15 +811,15 @@ Point layout(Composite composite, } cellHeight += verticalSpacing * (vSpan - 1); int childY = gridY + data.verticalIndent; - int childHeight = Math.min(data.cacheHeight, cellHeight); + int childHeight = Math.min(cache.cacheHeight, cellHeight); switch (data.verticalAlignment) { case SWT.CENTER : - case GridData2.CENTER : + case GridData.CENTER: childY += Math.max(0, (cellHeight - data.verticalIndent - childHeight) / 2); break; case SWT.BOTTOM : case SWT.END : - case GridData2.END : + case GridData.END: childY += Math.max(0, cellHeight - data.verticalIndent - childHeight); break; case SWT.FILL : @@ -924,8 +935,7 @@ public static GridData2 getLayoutData2(Control control) { if (layoutData == null) { layoutData = new GridData(); } - newGridData = new GridData2(); - copyFields(layoutData, newGridData); + newGridData = new GridData2(layoutData); control.setData(key, newGridData); } return newGridData;