for (int i = row; i < lastRow; i++) {
for (int i = row; i <= lastRow; i++) {
void adjustGridDimensions(Composite composite, boolean flushCache) {	// Ensure that widgets that span more than one row or column have enough space.	for (int row = 0; row < grid.size(); row++) {		for (int column = 0; column < numColumns; column++) {			GridData spec = ((GridData[]) grid.elementAt(row))[column];			if (spec.isItemData()) {				// Widgets spanning columns.				if (spec.hSpan > 1) {					Control child = composite.getChildren()[spec.childIndex];					Point extent = child.computeSize(spec.widthHint, spec.heightHint, flushCache);					// Calculate the size of the widget's spanned columns.					int lastSpanIndex = column + spec.hSpan;					int spannedSize = 0;					for (int c = column; c < lastSpanIndex; c++) {						spannedSize = spannedSize + pixelColumnWidths[c] + horizontalSpacing;					}					spannedSize = spannedSize - horizontalSpacing;					// If the spanned columns are not large enough to display the widget, adjust the column					// sizes to account for the extra space that is needed.					if (extent.x + spec.horizontalIndent > spannedSize) {						int extraSpaceNeeded = extent.x + spec.horizontalIndent - spannedSize;						int lastColumn = column + spec.hSpan - 1;						int colWidth;						if (makeColumnsEqualWidth) {							// Evenly distribute the extra space amongst all of the columns.							int columnExtra = extraSpaceNeeded / numColumns;							int columnRemainder = extraSpaceNeeded % numColumns;							for (int i = 0; i < pixelColumnWidths.length; i++) {								colWidth = pixelColumnWidths[i] + columnExtra;								pixelColumnWidths[i] = colWidth;							}							colWidth = pixelColumnWidths[lastColumn] + columnRemainder;							pixelColumnWidths[lastColumn] = colWidth;						} else {							Vector localExpandableColumns = new Vector();							for (int i = column; i < lastColumn; i++) {								for (int j = 0; j < expandableColumns.length; j++) {									if (expandableColumns[j] == i) {										localExpandableColumns.addElement(new Integer(i));									}								}							}							if (localExpandableColumns.size() > 0) {								// If any of the widget's columns grab excess space, allocate the space amongst those columns.								int columnExtra = extraSpaceNeeded / localExpandableColumns.size();								int columnRemainder = extraSpaceNeeded % localExpandableColumns.size();								for (int i = 0; i < localExpandableColumns.size(); i++) {									int expandableCol = ((Integer) localExpandableColumns.elementAt(i)).intValue();									colWidth = pixelColumnWidths[expandableCol] + columnExtra;									pixelColumnWidths[expandableCol] = colWidth;								}								colWidth = pixelColumnWidths[lastColumn] + columnRemainder;								pixelColumnWidths[lastColumn] = colWidth;							} else {								// Add the extra space to the widget's last column if none of its columns grab excess space.								colWidth = pixelColumnWidths[lastColumn] + extraSpaceNeeded;								pixelColumnWidths[lastColumn] = colWidth;							}						}					}				}				// Widgets spanning rows.				if (spec.verticalSpan > 1) {					Control child = composite.getChildren()[spec.childIndex];					Point extent = child.computeSize(spec.widthHint, spec.heightHint, flushCache);					// Calculate the size of the widget's spanned rows.					int lastSpanIndex = row + spec.verticalSpan;					int spannedSize = 0;					for (int r = row; r < lastSpanIndex; r++) {						spannedSize = spannedSize + pixelRowHeights[r] + verticalSpacing;					}					spannedSize = spannedSize - verticalSpacing;					// If the spanned rows are not large enough to display the widget, adjust the row					// sizes to account for the extra space that is needed.					if (extent.y > spannedSize) {						int extraSpaceNeeded = extent.y - spannedSize;						int lastRow = row + spec.verticalSpan - 1;						int rowHeight;						Vector localExpandableRows = new Vector();						for (int i = row; i < lastRow; i++) {							for (int j = 0; j < expandableRows.length; j++) {								if (expandableRows[j] == i) {									localExpandableRows.addElement(new Integer(i));								}							}						}						if (localExpandableRows.size() > 0) {							// If any of the widget's rows grab excess space, allocate the space amongst those rows.							int rowExtra = extraSpaceNeeded / localExpandableRows.size();							int rowRemainder = extraSpaceNeeded % localExpandableRows.size();							for (int i = 0; i < localExpandableRows.size(); i++) {								int expandableRow = ((Integer) localExpandableRows.elementAt(i)).intValue();								rowHeight = pixelRowHeights[expandableRow] + rowExtra;								pixelRowHeights[expandableRow] = rowHeight;							}							rowHeight = pixelRowHeights[lastRow] + rowRemainder;							pixelRowHeights[lastRow] = rowHeight;						} else {							// Add the extra space to the widget's last row if no rows grab excess space.							rowHeight = pixelRowHeights[lastRow] + extraSpaceNeeded;							pixelRowHeights[lastRow] = rowHeight;						}					}				}			}		}	}}