if (gbc.row == -1 || gbc.column == -1) {
gbc.row = 0;
gbc.column = 0;
}
else if (gbc.row < 0 || gbc.column < 0) {
UsageException errorVar = new UsageException("gridx and gridy should be >= 0, not row = " + gbc.row + ", column = " + gbc.column);
ErrorMgr.addError(errorVar);
throw errorVar;
}
else if (gbc.row >= rows || gbc.column >= columns) {
// TF:28/04/2008:if ignoreCollapse is true, we're doing the initial insert. In this case we don't
// have the rows and columns necessarily set, so we need to add the components in by expanding the grid
if (ignoreCollapse) {
// TF:09/05/2008:JIRA JCT-545:Since this is the initial insert, we must obey the
// constraints as posted. This means that we'll get the correct row and column
// even if a row or column appears empty when this element is inserted (because
// another element might be inserted later to make the empty row/column populated)
// if (isCollapsed()) {
// if (gbc.row >= rows) {
// gbc.row = rows;
// }
// if (gbc.column >= columns) {
// gbc.column = columns;
// }
// }
for (int i = rows; i <= gbc.row; i++) {
rowWeights.add(i, new Integer(0));
}
for (int i = columns; i <= gbc.column; i++) {
columnWeights.add(i, new Integer(0));
}
rows = Math.max(rows, gbc.row + 1);
columns = Math.max(columns, gbc.column + 1);
}
else {
// Using the replace policy, we never insert a column outside the grid
// TF:10/08/2008:JCT-582:If the grid field is empty, we allow the replace
if (parent.getComponentCount() == 0) {
fallThroughToExpand = true;
}
else {
return false;
}
}
}
if (!fallThroughToExpand) {
JComponent comp = parent.getChildInCell(gbc.row + 1, gbc.column + 1);
if (comp != null) {
parent.remove(comp);
}
break;
}
case Constants.IP_EXPAND:
// If the row or column is -1, we shuffle everything up and across
if (gbc.row == -1 || gbc.column == -1) {
gbc.row = 0;
gbc.column = 0;
for (Component thisChild : parent.getComponents()) {
if (thisChild != newOne) {
GridCell effective = findConstraints(thisChild);
effective.row++;
effective.column++;
}
}
rows++;
columns++;
rowWeights.add(0, new Integer(0));
columnWeights.add(0, new Integer(0));
}
else if (gbc.column < 0 || gbc.row < 0) {
UsageException errorVar = new UsageException("gridx and gridy should be >= 0, not gridx = " + gbc.column + ", gridy = " + gbc.row);
ErrorMgr.addError(errorVar);
throw errorVar;
}
else if (gbc.column >= columns || gbc.row >= rows) {
// If we need to collapse the columns, update the value passed so that it's the