org.openpermis.editor.policy.gui.forms
Class FormBuilder

java.lang.Object
  extended by org.openpermis.editor.policy.gui.forms.FormBuilder

public class FormBuilder
extends Object

Simple builder for GUI forms that mostly look the same.

Since:
0.9.0

Nested Class Summary
protected static class FormBuilder.AbstractRow
          Abstract base class for rows.
protected static class FormBuilder.ComponentRow
          Abstract row that contains multiple components.
protected static class FormBuilder.GapRow
          Row without components that denotes a section gap.
protected static class FormBuilder.LabelComponentRow
          Row that contains a label and a component (no tool bar).
protected static class FormBuilder.LabelComponentsRow
          Row that contains a label and two components.
protected static class FormBuilder.LabelToolBarRow
          Row that contains a label and a toolbar.
protected static interface FormBuilder.Row
          Describes a single row during construction time of a form builder layout.
protected static class FormBuilder.SingleComponentRow
          Row that fills and grows vertically.
 
Field Summary
protected static String LINE_GAP
          Gap between two related rows.
protected static String SECTION_GAP
          Gap between two unrelated rows.
 
Constructor Summary
FormBuilder(ActionMap actionMap, org.jdesktop.application.ResourceMap resourceMap)
          Creates a new form builder.
 
Method Summary
 FormBuilder addComponentRow(JComponent component, boolean grow)
          Adds a row that contains a single component.
 FormBuilder addGap()
          Adds a section gap which is slightly bigger than the usual row gap.
 FormBuilder addHeaderRow(String header)
          Adds a labeled header row with a separator.
 FormBuilder addLabelComponentButtonRow(String label, JComponent component, String button)
          Adds a row consisting of a label, component and a button.
 FormBuilder addLabelComponentRow(String label, JComponent component)
          Adds a row consisting of a label and a component (no tool bar).
 FormBuilder addLabelComponentRow(String label, JComponent component, String rowSpec)
          Adds a row consisting of a label and a component (no tool bar).
 FormBuilder addLabelComponentToolBarRow(String label, JComponent component, String toolBar)
          Adds a row consisting of a label, component and its tool bar.
 FormBuilder addLabelRow(String label)
          Adds a row that containing a single label.
 FormBuilder addLabelToolBarComponentRows(String label, String toolBar, JComponent scrollComponent)
          Convenience method to add two rows to the form layout.
 FormBuilder addLabelToolBarRow(String label, String toolBar)
          Adds a row consisting of a label and a tool bar.
protected  FormBuilder addRow(FormBuilder.Row row)
          Adds a row to the layout.
 FormBuilder addScrollComponentRow(JComponent component)
          Adds a row that contains a single component that is optionally wrapped in a scroll pane.
protected  FormBuilder addSingleComponentRow(JComponent component, boolean scroll, boolean grow, boolean gap)
          Adds a single component that stretches the whole row.
 JComponent createDialogPane()
          Builds a component that can be used as the content of a dialog, includes dialog borders.
static JComponent createDialogPane(JComponent content)
          Wraps the specified content in a form pane which features dialog borders.
 JComponent createFormPane()
          Builds a component that can be used as the content of a form, includes scroll pane and correct form borders.
static JComponent createFormPane(JComponent content)
          Wraps the specified content in a form pane which features scroll bars and form borders.
static com.jgoodies.forms.layout.FormLayout createLayout(String encodedColumnSpecs, String encodedRowSpecs)
          Creates a new form layout that uses the form builder layout map.
 JPanel createPanel()
          Builds a panel with the components added to this form builder.
static JComponent createToolPane(JComponent content, JToolBar toolBar)
          Wraps the specified content in a form pane which features optional scroll bars and appropriate borders for a tool (including an optional tool bar).
<T extends JComponent>
T
fill(T container)
          Fills the container specified with the components added to the form builder.
protected  String getColumnSpecs()
          Returns the column specifications used by the form builder.
protected  ControlFactory getControlFactory()
          Returns the control factory.
static com.jgoodies.forms.layout.LayoutMap getLayoutMap()
          Returns the layout map of the form layout used by the form builder.
protected  String getRowSpecs()
          Returns the row specifications used by the form builder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LINE_GAP

protected static final String LINE_GAP
Gap between two related rows.

Constant Field Value:
"${nlgap}"
Since:
0.9.0

SECTION_GAP

protected static final String SECTION_GAP
Gap between two unrelated rows.

Constant Field Value:
"${npgap}"
Since:
0.9.0
Constructor Detail

FormBuilder

public FormBuilder(ActionMap actionMap,
                   org.jdesktop.application.ResourceMap resourceMap)
Creates a new form builder.

Parameters:
actionMap - the action map used to create actions.
resourceMap - the resource map used to create components.
Since:
0.9.0
Method Detail

getLayoutMap

public static com.jgoodies.forms.layout.LayoutMap getLayoutMap()
Returns the layout map of the form layout used by the form builder.

This layout map extends the default layout map with the following mappings:

Variable Value
*lcgap gap between a label and its component
*rgap gap between two related components
*ugap gap between two unrelated components
*lgap gap between two lines
*nlgap narrow gap between two lines
*pgap gap between two paragraphs/sections
fpgfill,preferred,grow fill:min(50dlu;pref):grow
lctlabel,control,toolbar pref,${lcgap},${fpg},${rgap},pref
npgapnarrow section gap 3dlu
fgapform gap 3dlu
dgapdialog gap 6dlu

*) Marked variables are part of the default JGoodies LayoutMap.

Returns:
the (shared) layout map requested.
Since:
0.9.0

createLayout

public static com.jgoodies.forms.layout.FormLayout createLayout(String encodedColumnSpecs,
                                                                String encodedRowSpecs)
Creates a new form layout that uses the form builder layout map.

Parameters:
encodedColumnSpecs - comma separated encoded column specifications.
encodedRowSpecs - comma separated encoded row specifications.
Returns:
the form layout requested.
See Also:
getLayoutMap(), FormLayout.FormLayout(String, String)
Since:
0.9.0

createFormPane

public static JComponent createFormPane(JComponent content)
Wraps the specified content in a form pane which features scroll bars and form borders.

Parameters:
content - the content to wrap in a form pane.
Returns:
the form pane that wraps the content.
Since:
0.9.0

createDialogPane

public static JComponent createDialogPane(JComponent content)
Wraps the specified content in a form pane which features dialog borders.

Parameters:
content - the content to wrap in a dialog pane.
Returns:
the dialog pane that wraps the content.
Since:
0.9.0

createToolPane

public static JComponent createToolPane(JComponent content,
                                        JToolBar toolBar)
Wraps the specified content in a form pane which features optional scroll bars and appropriate borders for a tool (including an optional tool bar).

Parameters:
content - the content to wrap in a form.
toolBar - optional tool bar to include, may be null.
Returns:
the tool pane that wraps the content.
Since:
0.9.0

getControlFactory

protected ControlFactory getControlFactory()
Returns the control factory.

Returns:
the control factory.
Since:
0.9.0

addRow

protected FormBuilder addRow(FormBuilder.Row row)
Adds a row to the layout.

Parameters:
row - the row to add.
Returns:
the form builder for fluent use.
Since:
0.9.0

getColumnSpecs

protected String getColumnSpecs()
Returns the column specifications used by the form builder.

Returns:
the column specifications used by the form builder.
Since:
0.9.0

getRowSpecs

protected String getRowSpecs()
Returns the row specifications used by the form builder.

Returns:
the row specifications used by the form builder.
Since:
0.9.0

addGap

public FormBuilder addGap()
Adds a section gap which is slightly bigger than the usual row gap.

Returns:
this form builder for fluent use.
Since:
0.9.0

addLabelComponentButtonRow

public FormBuilder addLabelComponentButtonRow(String label,
                                              JComponent component,
                                              String button)
Adds a row consisting of a label, component and a button.

Parameters:
label - the key of the label to add.
component - the component to add.
button - the key of the button to add.
Returns:
this form builder for fluent use.
Since:
0.9.0

addLabelComponentToolBarRow

public FormBuilder addLabelComponentToolBarRow(String label,
                                               JComponent component,
                                               String toolBar)
Adds a row consisting of a label, component and its tool bar.

Parameters:
label - the key of the label to add.
component - the component to add.
toolBar - the key of the tool bar to add.
Returns:
this form builder for fluent use.
Since:
0.9.0

addLabelComponentRow

public FormBuilder addLabelComponentRow(String label,
                                        JComponent component)
Adds a row consisting of a label and a component (no tool bar).

Parameters:
label - the key of the label to add.
component - the component to add.
Returns:
this form builder for fluent use.
Since:
0.9.0

addLabelRow

public FormBuilder addLabelRow(String label)
Adds a row that containing a single label.

Parameters:
label - the key of the label to add.
Returns:
this form builder for fluent use.
Since:
0.9.0

addHeaderRow

public FormBuilder addHeaderRow(String header)
Adds a labeled header row with a separator.

Parameters:
header - the key of the header to add.
Returns:
this form builder for fluent use.
Since:
0.9.0

addLabelComponentRow

public FormBuilder addLabelComponentRow(String label,
                                        JComponent component,
                                        String rowSpec)
Adds a row consisting of a label and a component (no tool bar).

Parameters:
label - the key of the label to add.
component - the component to add.
rowSpec - the row specification (height format) of the row, may be null for preferred size.
Returns:
this form builder for fluent use.
Since:
0.9.0

addLabelToolBarRow

public FormBuilder addLabelToolBarRow(String label,
                                      String toolBar)
Adds a row consisting of a label and a tool bar.

Parameters:
label - the key of the label to add.
toolBar - the key of the tool bar to add.
Returns:
this form builder for fluent use.
Since:
0.9.0

addComponentRow

public FormBuilder addComponentRow(JComponent component,
                                   boolean grow)
Adds a row that contains a single component.

Parameters:
component - the component to add.
grow - true to make the row fill and grow vertically, false to use the component preferred size.
Returns:
this form builder for fluent use.
Since:
0.9.0

addScrollComponentRow

public FormBuilder addScrollComponentRow(JComponent component)
Adds a row that contains a single component that is optionally wrapped in a scroll pane.

The row of the component will grow and fill available space.

Parameters:
component - the component to add, if it does not denote a JScrollPane it will be wrapped into a JScrollPane before adding.
Returns:
this form builder for fluent use.
Since:
0.9.0

addSingleComponentRow

protected FormBuilder addSingleComponentRow(JComponent component,
                                            boolean scroll,
                                            boolean grow,
                                            boolean gap)
Adds a single component that stretches the whole row.

The component is added with preferred size and can optionally be wrapped in a scroll pane if necessary and fill/grow vertically.

Parameters:
component - the component to add.
scroll - true to optionally wrap the component in a JScrollPane, false to leave the component alone and use it as is.
grow - true to make the row fill and grow vertically, false to use the component preferred size.
gap - true to add a default row gap in front of the component, false to insert the component without any row gap.
Returns:
this form builder for fluent use.
Since:
0.9.0

addLabelToolBarComponentRows

public FormBuilder addLabelToolBarComponentRows(String label,
                                                String toolBar,
                                                JComponent scrollComponent)
Convenience method to add two rows to the form layout.

The first row consists of a label and a toolbar, the second row of a filling and growing scroll component.

If the component passed in is already a scroll pane then it is added directly.

Parameters:
label - the label of the first row.
toolBar - the toolbar of the first row.
scrollComponent - the scroll component in the second row.
Returns:
this form builder for fluent use.
Since:
0.9.0

createPanel

public JPanel createPanel()
Builds a panel with the components added to this form builder.

Returns:
the panel created.
Since:
0.9.0

createFormPane

public JComponent createFormPane()
Builds a component that can be used as the content of a form, includes scroll pane and correct form borders.

Returns:
the form component created.
Since:
0.9.0

createDialogPane

public JComponent createDialogPane()
Builds a component that can be used as the content of a dialog, includes dialog borders.

Returns:
the dialog component created.
Since:
0.9.0

fill

public <T extends JComponent> T fill(T container)
Fills the container specified with the components added to the form builder.

Note: The container must not have any components added to begin with.

Type Parameters:
T - the type of container to fill.
Parameters:
container - the container to fill.
Returns:
the container passed in.
Since:
0.9.0


OpenPermis Role Based Access Control 0.9.0 (Build 16)
2009/08/13 07:17:21
Copyright (c) 2002-2007 Ergon Informatik AG