Update of /cvsroot/spring-rich-c/spring-richclient/src/org/springframework/richclient/layout
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4506/src/org/springframework/richclient/layout
Modified Files:
GridBagLayoutBuilder.java
Added Files:
LabelOrientation.java
Log Message:
Added appendLabeledField to GridBagLayoutBuilder
Index: GridBagLayoutBuilder.java
===================================================================
RCS file: /cvsroot/spring-rich-c/spring-richclient/src/org/springframework/richclient/layout/GridBagLayoutBuilder.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** GridBagLayoutBuilder.java 15 Oct 2004 22:18:28 -0000 1.3
--- GridBagLayoutBuilder.java 25 Oct 2004 21:51:32 -0000 1.4
***************
*** 16,29 ****
package org.springframework.richclient.layout;
! import java.awt.Component;
! import java.awt.GridBagConstraints;
! import java.awt.GridBagLayout;
! import java.awt.Insets;
import java.util.ArrayList;
import java.util.List;
! import javax.swing.JComponent;
! import javax.swing.JLabel;
! import javax.swing.JPanel;
import org.apache.commons.logging.Log;
--- 16,24 ----
package org.springframework.richclient.layout;
! import java.awt.*;
import java.util.ArrayList;
import java.util.List;
! import javax.swing.*;
import org.apache.commons.logging.Log;
***************
*** 36,59 ****
* This provides an easy way to create panels using a {@link GridBagLayout}.
* <p />
! *
* Usage is:
! *
* <pre>
* GridBagLayoutBuilder builder = new GridBagLayoutBuilder();
! *
* builder.appendRightLabel("label.field1").appendField(field1);
* builder.appendRightLabel("label.field2").appendField(field2);
* builder.nextLine();
! *
* builder.appendRightLabel("label.field3").appendField(field3);
* // because "field3" is the last component on this line, but the panel has
* // 4 columns, "field3" will span 3 columns
* builder.nextLine();
! *
* // once everything's been put into the builder, ask it to build a panel
* // to use in the UI.
* JPanel panel = builder.getPanel();
* </pre>
! *
* @author Jim Moore
* @see #setAutoSpanLastComponent(boolean)
--- 31,54 ----
* This provides an easy way to create panels using a {@link GridBagLayout}.
* <p />
! *
* Usage is:
! *
* <pre>
* GridBagLayoutBuilder builder = new GridBagLayoutBuilder();
! *
* builder.appendRightLabel("label.field1").appendField(field1);
* builder.appendRightLabel("label.field2").appendField(field2);
* builder.nextLine();
! *
* builder.appendRightLabel("label.field3").appendField(field3);
* // because "field3" is the last component on this line, but the panel has
* // 4 columns, "field3" will span 3 columns
* builder.nextLine();
! *
* // once everything's been put into the builder, ask it to build a panel
* // to use in the UI.
* JPanel panel = builder.getPanel();
* </pre>
! *
* @author Jim Moore
* @see #setAutoSpanLastComponent(boolean)
***************
*** 63,67 ****
public class GridBagLayoutBuilder implements LayoutBuilder {
private static final Log LOG = LogFactory
! .getLog(GridBagLayoutBuilder.class);
private Insets defaultInsets = new Insets(0, 0, 4, 4);
--- 58,62 ----
public class GridBagLayoutBuilder implements LayoutBuilder {
private static final Log LOG = LogFactory
! .getLog(GridBagLayoutBuilder.class);
private Insets defaultInsets = new Insets(0, 0, 4, 4);
***************
*** 141,148 ****
* Appends the given component to the end of the current line, using the
* default insets and no expansion
! *
! * @param component
! * the component to add to the current line
! *
* @return "this" to make it easier to string together append calls
*/
--- 136,142 ----
* Appends the given component to the end of the current line, using the
* default insets and no expansion
! *
! * @param component the component to add to the current line
! *
* @return "this" to make it easier to string together append calls
*/
***************
*** 154,169 ****
* Appends the given component to the end of the current line, using the
* default insets and no expansion
! *
! * @param component
! * the component to add to the current line
! * @param colSpan
! * the number of columns to span
! * @param rowSpan
! * the number of rows to span
! *
* @return "this" to make it easier to string together append calls
*/
public GridBagLayoutBuilder append(Component component, int colSpan,
! int rowSpan) {
return append(component, colSpan, rowSpan, 0.0, 0.0);
}
--- 148,160 ----
* Appends the given component to the end of the current line, using the
* default insets and no expansion
! *
! * @param component the component to add to the current line
! * @param colSpan the number of columns to span
! * @param rowSpan the number of rows to span
! *
* @return "this" to make it easier to string together append calls
*/
public GridBagLayoutBuilder append(Component component, int colSpan,
! int rowSpan) {
return append(component, colSpan, rowSpan, 0.0, 0.0);
}
***************
*** 172,215 ****
* Appends the given component to the end of the current line, using the
* default insets
! *
! * @param component
! * the component to add to the current line
! * @param colSpan
! * the number of columns to span
! * @param rowSpan
! * the number of rows to span
! * @param expandX
! * should the component "grow" horrizontally?
! * @param expandY
! * should the component "grow" vertically?
! *
* @return "this" to make it easier to string together append calls
*/
public GridBagLayoutBuilder append(Component component, int colSpan,
! int rowSpan, boolean expandX, boolean expandY) {
return append(component, colSpan, rowSpan, expandX, expandY,
! defaultInsets);
}
/**
* Appends the given component to the end of the current line
! *
! * @param component
! * the component to add to the current line
! * @param colSpan
! * the number of columns to span
! * @param rowSpan
! * the number of rows to span
! * @param expandX
! * should the component "grow" horrizontally?
! * @param expandY
! * should the component "grow" vertically?
! * @param insets
! * the insets to use for this component
! *
* @return "this" to make it easier to string together append calls
*/
public GridBagLayoutBuilder append(Component component, int colSpan,
! int rowSpan, boolean expandX, boolean expandY, Insets insets) {
if (expandX && expandY)
return append(component, colSpan, rowSpan, 1.0, 1.0, insets);
--- 163,197 ----
* Appends the given component to the end of the current line, using the
* default insets
! *
! * @param component the component to add to the current line
! * @param colSpan the number of columns to span
! * @param rowSpan the number of rows to span
! * @param expandX should the component "grow" horrizontally?
! * @param expandY should the component "grow" vertically?
! *
* @return "this" to make it easier to string together append calls
*/
public GridBagLayoutBuilder append(Component component, int colSpan,
! int rowSpan, boolean expandX,
! boolean expandY) {
return append(component, colSpan, rowSpan, expandX, expandY,
! defaultInsets);
}
/**
* Appends the given component to the end of the current line
! *
! * @param component the component to add to the current line
! * @param colSpan the number of columns to span
! * @param rowSpan the number of rows to span
! * @param expandX should the component "grow" horrizontally?
! * @param expandY should the component "grow" vertically?
! * @param insets the insets to use for this component
! *
* @return "this" to make it easier to string together append calls
*/
public GridBagLayoutBuilder append(Component component, int colSpan,
! int rowSpan, boolean expandX,
! boolean expandY, Insets insets) {
if (expandX && expandY)
return append(component, colSpan, rowSpan, 1.0, 1.0, insets);
***************
*** 224,250 ****
/**
* Appends the given component to the end of the current line
! *
! * @param component
! * the component to add to the current line
! * @param x
! * the column to put the component
! * @param y
! * the row to put the component
! * @param colSpan
! * the number of columns to span
! * @param rowSpan
! * the number of rows to span
! * @param expandX
! * should the component "grow" horrizontally?
! * @param expandY
! * should the component "grow" vertically?
! * @param insets
! * the insets to use for this component
! *
* @return "this" to make it easier to string together append calls
*/
public GridBagLayoutBuilder append(Component component, int x, int y,
! int colSpan, int rowSpan, boolean expandX, boolean expandY,
! Insets insets) {
if (expandX && expandY)
return append(component, x, y, colSpan, rowSpan, 1.0, 1.0, insets);
--- 206,224 ----
/**
* Appends the given component to the end of the current line
! *
! * @param component the component to add to the current line
! * @param x the column to put the component
! * @param y the row to put the component
! * @param colSpan the number of columns to span
! * @param rowSpan the number of rows to span
! * @param expandX should the component "grow" horrizontally?
! * @param expandY should the component "grow" vertically?
! * @param insets the insets to use for this component
! *
* @return "this" to make it easier to string together append calls
*/
public GridBagLayoutBuilder append(Component component, int x, int y,
! int colSpan, int rowSpan, boolean expandX, boolean expandY,
! Insets insets) {
if (expandX && expandY)
return append(component, x, y, colSpan, rowSpan, 1.0, 1.0, insets);
***************
*** 260,341 ****
* Appends the given component to the end of the current line, using the
* default insets
! *
! * @param component
! * the component to add to the current line
! * @param colSpan
! * the number of columns to span
! * @param rowSpan
! * the number of rows to span
! * @param xweight
! * the "growth weight" horrizontally
! * @param yweight
! * the "growth weight" horrizontally
! *
* @return "this" to make it easier to string together append calls
! *
* @see GridBagConstraints#weightx
* @see GridBagConstraints#weighty
*/
public GridBagLayoutBuilder append(Component component, int colSpan,
! int rowSpan, double xweight, double yweight) {
return append(component, colSpan, rowSpan, xweight, yweight,
! defaultInsets);
}
/**
* Appends the given component to the end of the current line
! *
! * @param component
! * the component to add to the current line
! * @param colSpan
! * the number of columns to span
! * @param rowSpan
! * the number of rows to span
! * @param xweight
! * the "growth weight" horrizontally
! * @param yweight
! * the "growth weight" horrizontally
! * @param insets
! * the insets to use for this component
! *
* @return "this" to make it easier to string together append calls
! *
* @see GridBagConstraints#weightx
* @see GridBagConstraints#weighty
*/
public GridBagLayoutBuilder append(Component component, int colSpan,
! int rowSpan, double xweight, double yweight, Insets insets) {
return append(component, getCurrentCol(), getCurrentRow(), colSpan,
! rowSpan, xweight, yweight, insets);
}
/**
* Appends the given component to the end of the current line
! *
! * @param component
! * the component to add to the current line
! * @param x
! * the column to put the component
! * @param y
! * the row to put the component
! * @param colSpan
! * the number of columns to span
! * @param rowSpan
! * the number of rows to span
! * @param xweight
! * the "growth weight" horrizontally
! * @param yweight
! * the "growth weight" horrizontally
! * @param insets
! * the insets to use for this component
! *
* @return "this" to make it easier to string together append calls
! *
* @see GridBagConstraints#weightx
* @see GridBagConstraints#weighty
*/
public GridBagLayoutBuilder append(Component component, int x, int y,
! int colSpan, int rowSpan, double xweight, double yweight,
! Insets insets) {
final List rowList = getRow(y);
ensureCapacity(rowList, Math.max(x, maxCol) + 1);
--- 234,413 ----
* Appends the given component to the end of the current line, using the
* default insets
! *
! * @param component the component to add to the current line
! * @param colSpan the number of columns to span
! * @param rowSpan the number of rows to span
! * @param xweight the "growth weight" horrizontally
! * @param yweight the "growth weight" horrizontally
! *
* @return "this" to make it easier to string together append calls
! *
* @see GridBagConstraints#weightx
* @see GridBagConstraints#weighty
*/
public GridBagLayoutBuilder append(Component component, int colSpan,
! int rowSpan, double xweight,
! double yweight) {
return append(component, colSpan, rowSpan, xweight, yweight,
! defaultInsets);
}
/**
* Appends the given component to the end of the current line
! *
! * @param component the component to add to the current line
! * @param colSpan the number of columns to span
! * @param rowSpan the number of rows to span
! * @param xweight the "growth weight" horrizontally
! * @param yweight the "growth weight" horrizontally
! * @param insets the insets to use for this component
! *
* @return "this" to make it easier to string together append calls
! *
* @see GridBagConstraints#weightx
* @see GridBagConstraints#weighty
*/
public GridBagLayoutBuilder append(Component component, int colSpan,
! int rowSpan, double xweight,
! double yweight, Insets insets) {
return append(component, getCurrentCol(), getCurrentRow(), colSpan,
! rowSpan, xweight, yweight, insets);
! }
!
! /**
! * Appends a label and field to the end of the current line.
! * <p />
! *
! * The label will be to the left of the field, and be right-justified.
! * <br />
! * The field will "grow" horizontally as space allows.
! * <p />
! *
! * @param propertyName the name of the property to create the controls for
! *
! * @return "this" to make it easier to string together append calls
! */
! public GridBagLayoutBuilder appendLabeledField(String propertyName,
! final JComponent field,
! LabelOrientation labelOrientation) {
! return appendLabeledField(propertyName, field, labelOrientation, 1);
! }
!
! /**
! * Appends a label and field to the end of the current line.
! * <p />
! *
! * The label will be to the left of the field, and be right-justified.
! * <br />
! * The field will "grow" horizontally as space allows.
! * <p />
! *
! * @param propertyName the name of the property to create the controls for
! * @param colSpan the number of columns the field should span
! *
! * @return "this" to make it easier to string together append calls
! */
! public GridBagLayoutBuilder appendLabeledField(String propertyName,
! final JComponent field, LabelOrientation labelOrientation,
! int colSpan) {
! return appendLabeledField(propertyName, field, labelOrientation,
! colSpan, 1, true, false);
! }
!
! /**
! * Appends a label and field to the end of the current line.<p />
! *
! * The label will be to the left of the field, and be right-justified.<br />
! * The field will "grow" horizontally as space allows.<p />
! *
! * @param propertyName the name of the property to create the controls for
! * @param colSpan the number of columns the field should span
! *
! * @return "this" to make it easier to string together append calls
! */
! public GridBagLayoutBuilder appendLabeledField(String propertyName,
! final JComponent field,
! LabelOrientation labelOrientation,
! int colSpan,
! int rowSpan,
! boolean expandX,
! boolean expandY) {
! final JLabel label = getComponentFactory().createLabel(propertyName);
! return appendLabeledField(label, field, labelOrientation,
! colSpan, rowSpan, expandX, expandY);
! }
!
! /**
! * Appends a label and field to the end of the current line.<p />
! *
! * The label will be to the left of the field, and be right-justified.<br />
! * The field will "grow" horizontally as space allows.<p />
! *
! * @param label the label to associate and layout with the field
! * @param colSpan the number of columns the field should span
! *
! * @return "this" to make it easier to string together append calls
! */
! public GridBagLayoutBuilder appendLabeledField(final JLabel label,
! final JComponent field,
! LabelOrientation labelOrientation,
! int colSpan,
! int rowSpan,
! boolean expandX,
! boolean expandY) {
! label.setLabelFor(field);
!
! final int col = getCurrentCol();
! final int row = getCurrentRow();
! final Insets insets = getDefaultInsets();
!
! if (labelOrientation == LabelOrientation.LEFT
! || labelOrientation == null) {
! label.setHorizontalAlignment(JLabel.RIGHT);
! append(label, col, row, 1, 1, false, expandY, insets);
! append(field, col + 1, row, colSpan, rowSpan, expandX, expandY,
! insets);
! }
! else if (labelOrientation == LabelOrientation.RIGHT) {
! label.setHorizontalAlignment(JLabel.LEFT);
! append(field, col, row, colSpan, rowSpan, expandX, expandY, insets);
! append(label, col + colSpan, row, 1, rowSpan, false, expandY, insets);
! }
! else if (labelOrientation == LabelOrientation.TOP) {
! label.setHorizontalAlignment(JLabel.LEFT);
! append(label, col, row, colSpan, 1, false, expandY, insets);
! append(field, col, row + 1, colSpan, rowSpan, expandX,
! expandY, insets);
! }
! else if (labelOrientation == LabelOrientation.BOTTOM) {
! label.setHorizontalAlignment(JLabel.LEFT);
! append(field, col, row, colSpan, rowSpan, expandX, expandY, insets);
! append(label, col, row + rowSpan, colSpan, 1, false, expandY,
! insets);
! }
!
! return this;
}
/**
* Appends the given component to the end of the current line
! *
! * @param component the component to add to the current line
! * @param x the column to put the component
! * @param y the row to put the component
! * @param colSpan the number of columns to span
! * @param rowSpan the number of rows to span
! * @param xweight the "growth weight" horrizontally
! * @param yweight the "growth weight" horrizontally
! * @param insets the insets to use for this component
! *
* @return "this" to make it easier to string together append calls
! *
* @see GridBagConstraints#weightx
* @see GridBagConstraints#weighty
*/
public GridBagLayoutBuilder append(Component component, int x, int y,
! int colSpan, int rowSpan, double xweight, double yweight,
! Insets insets) {
final List rowList = getRow(y);
ensureCapacity(rowList, Math.max(x, maxCol) + 1);
***************
*** 346,357 ****
final GridBagConstraints gbc = createGridBagConstraint(col, y, colSpan,
! rowSpan, xweight, yweight, insets);
rowList.set(col, new Item(component, gbc));
// keep track of the largest column this has seen...
this.maxCol = Math.max(this.maxCol, col);
! currentCol += colSpan;
return this;
--- 418,430 ----
final GridBagConstraints gbc = createGridBagConstraint(col, y, colSpan,
! rowSpan, xweight, yweight, insets);
rowList.set(col, new Item(component, gbc));
+ if (LOG.isDebugEnabled()) LOG.debug(getDebugString(component, gbc));
// keep track of the largest column this has seen...
this.maxCol = Math.max(this.maxCol, col);
! currentCol = col + colSpan;
return this;
***************
*** 359,363 ****
private void insertPlaceholdersIfNeeded(final int rowSpan, final int y,
! final int col, final Component component, final int colSpan) {
if (rowSpan > 1) {
growRowsIfNeeded(rowSpan);
--- 432,438 ----
private void insertPlaceholdersIfNeeded(final int rowSpan, final int y,
! final int col,
! final Component component,
! final int colSpan) {
if (rowSpan > 1) {
growRowsIfNeeded(rowSpan);
***************
*** 367,373 ****
if (row.get(col) != null) {
// sanity check -- shouldn't ever happen
! throw new IllegalStateException(
! "Trying to overwrite another component: "
! + component + ", " + col + " " + y);
}
for (int j = 0; j < colSpan; j++) {
--- 442,447 ----
if (row.get(col) != null) {
// sanity check -- shouldn't ever happen
! throw new IllegalStateException("Trying to overwrite another component: "
! + component + ", " + col + " " + y);
}
for (int j = 0; j < colSpan; j++) {
***************
*** 390,394 ****
private int bypassPlaceholders(final List list, final int col) {
int theCol = col;
! while (theCol < list.size() && list.get(theCol) == NULL_ITEM) {
theCol++;
}
--- 464,468 ----
private int bypassPlaceholders(final List list, final int col) {
int theCol = col;
! while (theCol < list.size() && list.get(theCol) != null) {
theCol++;
}
***************
*** 417,424 ****
* Appends the given label to the end of the current line. The label does
* not "grow."
! *
! * @param label
! * the label to append
! *
* @return "this" to make it easier to string together append calls
*/
--- 491,497 ----
* Appends the given label to the end of the current line. The label does
* not "grow."
! *
! * @param label the label to append
! *
* @return "this" to make it easier to string together append calls
*/
***************
*** 430,439 ****
* Appends the given label to the end of the current line. The label does
* not "grow."
! *
! * @param label
! * the label to append
! * @param colSpan
! * the number of columns to span
! *
* @return "this" to make it easier to string together append calls
*/
--- 503,510 ----
* Appends the given label to the end of the current line. The label does
* not "grow."
! *
! * @param label the label to append
! * @param colSpan the number of columns to span
! *
* @return "this" to make it easier to string together append calls
*/
***************
*** 447,455 ****
* {@link #setComponentFactory(ComponentFactory) ComponentFactory's}message
* bundle for the text to use.
! *
! * @param labelKey
! * the key into the message bundle; if not found the key is used
! * as the text to display
! *
* @return "this" to make it easier to string together append calls
*/
--- 518,525 ----
* {@link #setComponentFactory(ComponentFactory) ComponentFactory's}message
* bundle for the text to use.
! *
! * @param labelKey the key into the message bundle; if not found the key is used
! * as the text to display
! *
* @return "this" to make it easier to string together append calls
*/
***************
*** 463,473 ****
* {@link #setComponentFactory(ComponentFactory) ComponentFactory's}message
* bundle for the text to use.
! *
! * @param labelKey
! * the key into the message bundle; if not found the key is used
! * as the text to display
! * @param colSpan
! * the number of columns to span
! *
* @return "this" to make it easier to string together append calls
*/
--- 533,541 ----
* {@link #setComponentFactory(ComponentFactory) ComponentFactory's}message
* bundle for the text to use.
! *
! * @param labelKey the key into the message bundle; if not found the key is used
! * as the text to display
! * @param colSpan the number of columns to span
! *
* @return "this" to make it easier to string together append calls
*/
***************
*** 483,491 ****
* {@link #setComponentFactory(ComponentFactory) ComponentFactory's}message
* bundle for the text to use.
! *
! * @param labelKey
! * the key into the message bundle; if not found the key is used
! * as the text to display
! *
* @return "this" to make it easier to string together append calls
*/
--- 551,558 ----
* {@link #setComponentFactory(ComponentFactory) ComponentFactory's}message
* bundle for the text to use.
! *
! * @param labelKey the key into the message bundle; if not found the key is used
! * as the text to display
! *
* @return "this" to make it easier to string together append calls
*/
***************
*** 499,509 ****
* {@link #setComponentFactory(ComponentFactory) ComponentFactory's}message
* bundle for the text to use.
! *
! * @param labelKey
! * the key into the message bundle; if not found the key is used
! * as the text to display
! * @param colSpan
! * the number of columns to span
! *
* @return "this" to make it easier to string together append calls
*/
--- 566,574 ----
* {@link #setComponentFactory(ComponentFactory) ComponentFactory's}message
* bundle for the text to use.
! *
! * @param labelKey the key into the message bundle; if not found the key is used
! * as the text to display
! * @param colSpan the number of columns to span
! *
* @return "this" to make it easier to string together append calls
*/
***************
*** 517,524 ****
* Appends the given component to the end of the current line. The component
* will "grow" horizontally as space allows.
! *
! * @param component
! * the item to append
! *
* @return "this" to make it easier to string together append calls
*/
--- 582,588 ----
* Appends the given component to the end of the current line. The component
* will "grow" horizontally as space allows.
! *
! * @param component the item to append
! *
* @return "this" to make it easier to string together append calls
*/
***************
*** 530,539 ****
* Appends the given component to the end of the current line. The component
* will "grow" horizontally as space allows.
! *
! * @param component
! * the item to append
! * @param colSpan
! * the number of columns to span
! *
* @return "this" to make it easier to string together append calls
*/
--- 594,601 ----
* Appends the given component to the end of the current line. The component
* will "grow" horizontally as space allows.
! *
! * @param component the item to append
! * @param colSpan the number of columns to span
! *
* @return "this" to make it easier to string together append calls
*/
***************
*** 545,549 ****
* Appends a seperator (usually a horizonal line). Has an implicit
* {@link #nextLine()}before and after it.
! *
* @return "this" to make it easier to string together append calls
*/
--- 607,611 ----
* Appends a seperator (usually a horizonal line). Has an implicit
* {@link #nextLine()}before and after it.
! *
* @return "this" to make it easier to string together append calls
*/
***************
*** 558,562 ****
* bundle for the text to put along with the seperator. Has an implicit
* {@link #nextLine()}before and after it.
! *
* @return "this" to make it easier to string together append calls
*/
--- 620,624 ----
* bundle for the text to put along with the seperator. Has an implicit
* {@link #nextLine()}before and after it.
! *
* @return "this" to make it easier to string together append calls
*/
***************
*** 565,570 ****
nextLine();
}
! final JComponent separator = getComponentFactory()
! .createLabeledSeparator(labelKey);
return append(separator, 1, 1, true, false).nextLine();
}
--- 627,632 ----
nextLine();
}
! final JComponent separator =
! getComponentFactory().createLabeledSeparator(labelKey);
return append(separator, 1, 1, true, false).nextLine();
}
***************
*** 572,576 ****
/**
* Ends the current line and starts a new one
! *
* @return "this" to make it easier to string together append calls
*/
--- 634,638 ----
/**
* Ends the current line and starts a new one
! *
* @return "this" to make it easier to string together append calls
*/
***************
*** 583,588 ****
private GridBagConstraints createGridBagConstraint(int x, int y,
! int colSpan, int rowSpan, double xweight, double yweight,
! Insets insets) {
final GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = x;
--- 645,650 ----
private GridBagConstraints createGridBagConstraint(int x, int y,
! int colSpan, int rowSpan, double xweight, double yweight,
! Insets insets) {
final GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = x;
***************
*** 610,614 ****
* Creates and returns a JPanel with all the given components in it, using
* the "hints" that were provided to the builder.
! *
* @return a new JPanel with the components laid-out in it
*/
--- 672,676 ----
* Creates and returns a JPanel with all the given components in it, using
* the "hints" that were provided to the builder.
! *
* @return a new JPanel with the components laid-out in it
*/
***************
*** 619,623 ****
final JPanel panel = this.showGuidelines ? new GridBagLayoutDebugPanel()
! : new JPanel(new GridBagLayout());
final int lastRowIndex = this.rows.size() - 1;
--- 681,685 ----
final JPanel panel = this.showGuidelines ? new GridBagLayoutDebugPanel()
! : new JPanel(new GridBagLayout());
final int lastRowIndex = this.rows.size() - 1;
***************
*** 630,634 ****
private void addRow(final List row, final int currentRowIndex,
! final int lastRowIndex, final JPanel panel) {
final int lastColIndex = row.size() - 1;
--- 692,696 ----
private void addRow(final List row, final int currentRowIndex,
! final int lastRowIndex, final JPanel panel) {
final int lastColIndex = row.size() - 1;
***************
*** 649,653 ****
if (LOG.isDebugEnabled()) {
LOG.debug("Adding to panel: "
! + getDebugString(item.component, gbc));
}
panel.add(item.component, gbc);
--- 711,715 ----
if (LOG.isDebugEnabled()) {
LOG.debug("Adding to panel: "
! + getDebugString(item.component, gbc));
}
panel.add(item.component, gbc);
***************
*** 694,698 ****
// remove any insets at the bottom of the GBC
final Insets oldInset = gbc.insets;
! gbc.insets = new Insets(oldInset.top, oldInset.left, 0, oldInset.right);
}
--- 756,761 ----
// remove any insets at the bottom of the GBC
final Insets oldInset = gbc.insets;
! gbc.insets =
! new Insets(oldInset.top, oldInset.left, 0, oldInset.right);
}
***************
*** 701,716 ****
* the end of the panel?
* <p />
! *
* For example, if you have
! *
* <pre>
* append(a).append(b).append(c).nextLine();
* append(d).append(e).nextLine();
* </pre>
! *
* then "e" would automaticly span two columns.
! *
! * @param autoSpanLastComponent
! * default is true
*/
public void setAutoSpanLastComponent(boolean autoSpanLastComponent) {
--- 764,778 ----
* the end of the panel?
* <p />
! *
* For example, if you have
! *
* <pre>
* append(a).append(b).append(c).nextLine();
* append(d).append(e).nextLine();
* </pre>
! *
* then "e" would automaticly span two columns.
! *
! * @param autoSpanLastComponent default is true
*/
public void setAutoSpanLastComponent(boolean autoSpanLastComponent) {
***************
*** 719,726 ****
private void formatLastColumn(final GridBagConstraints gbc,
! final int currentColIndex) {
// remove any insets at the right of the GBC
final Insets oldInset = gbc.insets;
! gbc.insets = new Insets(oldInset.top, oldInset.left, oldInset.bottom, 0);
if (this.autoSpanLastComponent) {
--- 781,789 ----
private void formatLastColumn(final GridBagConstraints gbc,
! final int currentColIndex) {
// remove any insets at the right of the GBC
final Insets oldInset = gbc.insets;
! gbc.insets =
! new Insets(oldInset.top, oldInset.left, oldInset.bottom, 0);
if (this.autoSpanLastComponent) {
***************
*** 730,734 ****
if (LOG.isDebugEnabled()) {
LOG.debug("Increasing gridwidth from " + gbc.gridwidth
! + " to " + colSpan);
}
gbc.gridwidth = colSpan;
--- 793,797 ----
if (LOG.isDebugEnabled()) {
LOG.debug("Increasing gridwidth from " + gbc.gridwidth
! + " to " + colSpan);
}
gbc.gridwidth = colSpan;
***************
*** 754,756 ****
}
! }
\ No newline at end of file
--- 817,819 ----
}
! }
--- NEW FILE: LabelOrientation.java ---
package org.springframework.richclient.layout;
import javax.swing.*;
import org.springframework.enums.ShortCodedEnum;
public final class LabelOrientation extends ShortCodedEnum {
public static final LabelOrientation TOP = new LabelOrientation(
SwingConstants.TOP, "Top");
public static final LabelOrientation BOTTOM = new LabelOrientation(
SwingConstants.BOTTOM, "Bottom");
public static final LabelOrientation LEFT = new LabelOrientation(
SwingConstants.LEFT, "Left");
public static final LabelOrientation RIGHT = new LabelOrientation(
SwingConstants.RIGHT, "Right");
private LabelOrientation(int code, String label) {
super(code, label);
}
}
|