dsto.dfc.swt.forms
Class Forms

java.lang.Object
  extended by dsto.dfc.swt.forms.Forms

public final class Forms
extends Object

Utility methods for form creation/management.

Version:
$Revision$
Author:
mpp

Method Summary
static org.eclipse.swt.widgets.Button button(org.eclipse.swt.widgets.Composite parent, String text, int style)
          Creates a Button within the given parent with the given text and style.
static org.eclipse.swt.widgets.Combo combo(org.eclipse.swt.widgets.Composite parent, String labelText, int style)
          Create a label and combo box, and thus takes two cells worth of space.
static org.eclipse.swt.widgets.Combo combo(org.eclipse.swt.widgets.Composite parent, String labelText, int columns, int style)
          Create a label and combo box, and thus takes two cells worth of space.
static org.eclipse.swt.widgets.Label description(org.eclipse.swt.widgets.Composite parent, String text)
          Create a wrapping description label.
static org.eclipse.swt.widgets.Label description(org.eclipse.swt.widgets.Composite parent, String text, int columns)
          Create a wrapping description label.
static org.eclipse.swt.widgets.Label getLabel(org.eclipse.swt.widgets.Control control)
          Get the label associated with a control created by the text(Composite, String) or combo(Composite, String, int) methods.
static org.eclipse.swt.layout.GridLayout gridLayout(org.eclipse.swt.widgets.Composite panel, int columns)
          Creates a GridLayout instance with the given number of columns and margin width and height of 0, a GridLayout.verticalSpacing value of 6, and sets it to be the layout of the given Composite panel.
static org.eclipse.swt.layout.GridLayout gridLayout(org.eclipse.swt.widgets.Composite panel, int columns, int margin)
          Creates a GridLayout instance with the given number of columns and margin width and height of margin, a GridLayout.verticalSpacing value of 6, and sets it to be the layout of the given Composite panel.
static org.eclipse.swt.widgets.Group group(org.eclipse.swt.widgets.Composite parent, String text)
          Creates a Group within the given parent with the given text and the style SWT.SHADOW_ETCHED_IN Sets the layout of the Group to be a GridLayout.
static org.eclipse.swt.widgets.Group group(org.eclipse.swt.widgets.Composite parent, String text, int style)
          Creates a Group within the given parent with the given text and style.
static org.eclipse.swt.widgets.Label label(org.eclipse.swt.widgets.Composite panel, String text)
          Creates a left-aligned Label within the parent Composite panel with the provided text.
static org.eclipse.swt.widgets.Label label(org.eclipse.swt.widgets.Composite panel, String text, int style)
          Creates a Label within the parent Composite panel with the provided text and style.
static org.eclipse.swt.widgets.Label label(org.eclipse.swt.widgets.Composite panel, String text, int columns, int style)
          Creates a Label within the parent Composite panel with the provided text and style.
static org.eclipse.swt.widgets.Text text(org.eclipse.swt.widgets.Composite parent, String labelText)
          Create a text field with a descriptive label to the left, and thus takes two cells worth of space.
static org.eclipse.swt.widgets.Text text(org.eclipse.swt.widgets.Composite parent, String labelText, int columns)
          Create a text field with space for the specified number of columns with a descriptive label to the left, and thus takes two cells worth of space.
static org.eclipse.swt.widgets.Text text(org.eclipse.swt.widgets.Composite parent, String labelText, int columns, int hSpan)
          Create a text field with space for the specified number of columns with a descriptive label to the left, and thus takes an extra cell's worth of space.
static org.eclipse.swt.widgets.Text text(org.eclipse.swt.widgets.Composite parent, String labelText, int columns, int hSpan, int style)
          Create a text field with space for the specified number of columns with a descriptive label to the left, and thus takes an extra cell's worth of space.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

description

public static org.eclipse.swt.widgets.Label description(org.eclipse.swt.widgets.Composite parent,
                                                        String text)
Create a wrapping description label. Assumes that parent layout is a GridLayout using 2 columns.


description

public static org.eclipse.swt.widgets.Label description(org.eclipse.swt.widgets.Composite parent,
                                                        String text,
                                                        int columns)
Create a wrapping description label. Assumes that parent layout is a GridLayout using 2 columns.

Parameters:
parent - The parent component.
text - The text to display.
columns - The suggested number of columns for the text. If 0, the column count is the same as the numer of characters in the text, ensuring the text is on one line.

text

public static org.eclipse.swt.widgets.Text text(org.eclipse.swt.widgets.Composite parent,
                                                String labelText)
Create a text field with a descriptive label to the left, and thus takes two cells worth of space. The label is accessible via Widget.getData(String) with the property "label".

Assumes that the Composite this Control is being added to is using the GridLayout.

Parameters:
parent - The parent component.
labelText - The text of the label.
Returns:
The new text field.
See Also:
text(Composite,String,int), getLabel(Control)

text

public static org.eclipse.swt.widgets.Text text(org.eclipse.swt.widgets.Composite parent,
                                                String labelText,
                                                int columns)
Create a text field with space for the specified number of columns with a descriptive label to the left, and thus takes two cells worth of space. The label is accessible via Widget.getData(String) with the property "label".

Assumes that the Composite this Control is being added to is using the GridLayout.

Parameters:
parent - The parent component.
labelText - The text of the label.
columns - The suggested number of colums of text for the field.
Returns:
The new text field.
See Also:
getLabel(Control)

text

public static org.eclipse.swt.widgets.Text text(org.eclipse.swt.widgets.Composite parent,
                                                String labelText,
                                                int columns,
                                                int hSpan)
Create a text field with space for the specified number of columns with a descriptive label to the left, and thus takes an extra cell's worth of space. The label is accessible via Widget.getData(String) with the property "label". The text field's resizing is governed by the hSpan parameter, which is expected to be a value appropriate for GridData.horizontalSpan.

Assumes that the Composite this Control is being added to is using the GridLayout.

Parameters:
parent - The parent component.
labelText - The text of the label.
columns - The suggested number of colums of text for the field.
hSpan - The horizontal (GridLayout) span of the text.
Returns:
The new text field.
See Also:
getLabel(Control)

text

public static org.eclipse.swt.widgets.Text text(org.eclipse.swt.widgets.Composite parent,
                                                String labelText,
                                                int columns,
                                                int hSpan,
                                                int style)
Create a text field with space for the specified number of columns with a descriptive label to the left, and thus takes an extra cell's worth of space. The label is accessible via Widget.getData(String) with the property "label". The text field's resizing is governed by the hSpan parameter, which is expected to be a value appropriate for GridData.horizontalSpan. The style of the text field is specified by style.

Assumes that the Composite this Control is being added to is using the GridLayout.

Parameters:
parent - The parent component.
labelText - The text of the label.
columns - The suggested number of colums of text for the field.
hSpan - The horizontal (GridLayout) span of the text.
style - The style for the text field.
Returns:
The new text field.
See Also:
getLabel(Control)

combo

public static org.eclipse.swt.widgets.Combo combo(org.eclipse.swt.widgets.Composite parent,
                                                  String labelText,
                                                  int style)
Create a label and combo box, and thus takes two cells worth of space. The label is accessible via Widget.getData(String) with the property "label". The style of the combo is specified by style.

Assumes that the Composite this Control is being added to is using the GridLayout.

Parameters:
parent - The parent control.
labelText - The text for the combo label.
style - The style for the combo.
Returns:
The new combo box with an attached GridData as layout data.
See Also:
combo(Composite, String, int, int), getLabel(Control)

combo

public static org.eclipse.swt.widgets.Combo combo(org.eclipse.swt.widgets.Composite parent,
                                                  String labelText,
                                                  int columns,
                                                  int style)
Create a label and combo box, and thus takes two cells worth of space. The label is accessible via Widget.getData(String) with the property "label". The style of the combo is specified by style. The columns parameter is used to set the width hint for the combo.

Assumes that the Composite this Control is being added to is using the GridLayout.

Parameters:
parent - The parent control.
labelText - The text for the combo label.
columns - The number of columns for the combo. Can be SWT.DEFAULT.
style - The style for the combo.
Returns:
The new combo box with an attached GridData as layout data.
See Also:
getLabel(Control)

getLabel

public static org.eclipse.swt.widgets.Label getLabel(org.eclipse.swt.widgets.Control control)
Get the label associated with a control created by the text(Composite, String) or combo(Composite, String, int) methods.


group

public static org.eclipse.swt.widgets.Group group(org.eclipse.swt.widgets.Composite parent,
                                                  String text)
Creates a Group within the given parent with the given text and the style SWT.SHADOW_ETCHED_IN Sets the layout of the Group to be a GridLayout.

Parameters:
parent - The parent of the Group.
text - The text to show at the top of the Group.
Returns:
A new Group.

group

public static org.eclipse.swt.widgets.Group group(org.eclipse.swt.widgets.Composite parent,
                                                  String text,
                                                  int style)
Creates a Group within the given parent with the given text and style. Sets the layout of the Group to be a GridLayout.

Parameters:
parent - The parent of the Group.
text - The text to show at the top of the Group.
style - The SWT style use use for the Group.
Returns:
A new Group.

button

public static org.eclipse.swt.widgets.Button button(org.eclipse.swt.widgets.Composite parent,
                                                    String text,
                                                    int style)
Creates a Button within the given parent with the given text and style.

Parameters:
parent - The parent Composite for the Button.
text - The text to show on the Button.
style - The SWT style of the Button.
Returns:
A new Button.

gridLayout

public static org.eclipse.swt.layout.GridLayout gridLayout(org.eclipse.swt.widgets.Composite panel,
                                                           int columns)
Creates a GridLayout instance with the given number of columns and margin width and height of 0, a GridLayout.verticalSpacing value of 6, and sets it to be the layout of the given Composite panel.

NB There is no need to invoke panel.setLayout() with the returned GridLayout because it's already been done.

Parameters:
panel - The Composite for which to create and set the layout.
columns - The number of columns the layout will have.
Returns:
The new GridLayout, which has been set on the provided panel.

gridLayout

public static org.eclipse.swt.layout.GridLayout gridLayout(org.eclipse.swt.widgets.Composite panel,
                                                           int columns,
                                                           int margin)
Creates a GridLayout instance with the given number of columns and margin width and height of margin, a GridLayout.verticalSpacing value of 6, and sets it to be the layout of the given Composite panel.

NB There is no need to invoke panel.setLayout() with the returned GridLayout because it's already been done.

Parameters:
panel - The Composite for which to create and set the layout.
columns - The number of columns the layout will have.
margin - The value to use for the layout's margin width and height.
Returns:
The new GridLayout, which has been set on the provided panel.

label

public static org.eclipse.swt.widgets.Label label(org.eclipse.swt.widgets.Composite panel,
                                                  String text)
Creates a left-aligned Label within the parent Composite panel with the provided text.

Parameters:
panel - The parent for the Label.
text - The text for the Label to show.
Returns:
A new Label.

label

public static org.eclipse.swt.widgets.Label label(org.eclipse.swt.widgets.Composite panel,
                                                  String text,
                                                  int style)
Creates a Label within the parent Composite panel with the provided text and style.

Parameters:
panel - The parent for the Label.
text - The text for the Label to show.
Returns:
A new Label.

label

public static org.eclipse.swt.widgets.Label label(org.eclipse.swt.widgets.Composite panel,
                                                  String text,
                                                  int columns,
                                                  int style)
Creates a Label within the parent Composite panel with the provided text and style.

Parameters:
panel - The parent for the Label.
text - The text for the Label to show.
columns - The suggested max number of columns or SWT.DEFAULT. This only makes sense when SWT.WRAP is used.
Returns:
A new Label.


Copyright © 2008 Commonwealth of Australia