Appendix A - Widgets in XSWT

Standard SWT widgets

Tip

The SWT controls are documented on the Eclipse web site. See: http://help.eclipse.org/galileo/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/package-summary.html

It is possible to bind template variables to a specific control by using the x:id attribute.

<text x:id="templateVariableName" />

This is the way that template variables are bound to the controls (R=read, W=write):

Button

This SWT class represents buttons, checkboxes and radio buttons, depending on its style attribute (SWT.PUSH, SWT.CHECK, SWT.RADIO).

  • W: the string "true" selects the checkbox/radio button; everything else clears it.
  • R: returns a Boolean.
Combo, CCombo

Represent a combo box and a custom combo box. It can be made read-only (with the SWT.READ_ONLY style). A read-only combo allows list selection but no manual editing. The list items can be specified from XSWT. Variables only work with the textedit part (cannot add/remove list items).

  • W: the string value gets written into the combo. If the combo is read-only and contains no such item, nothing happens.
  • R: returns the currently selected item as string.
DateTime

A widget for editing date/time.

  • W: accepts a string in the following format: "yyyy-mm-dd hh:mm:ss". If the string is not in the right format, an error occurs.
  • R: returns a string in the same format, "yyyy-mm-dd hh:mm:ss".
Label

Label widget (not interactive).

  • W: sets the label to the string.
  • R: returns the label.
List

A listbox widget that allows selection of one or more items, depending on the style attribute (SWT.SINGLE or SWT.MULTI). List items can be specified from XSWT. Template variables only work with the selection (cannot add/remove list items).

  • W: accepts a string with comma-separated items and selects the corresponding item(s) in the listbox. Items that are not among the listbox items are ignored.
  • R: Returns a string array object (String[]) that can be iterated over in the template.
Scale

A graphical widget for selecting a numeric value.

  • W: accepts strings with an integer value. Non-numeric strings will cause an error (a message dialog will be displayed).
  • R: returns an Integer which can be used in arithmetic expressions in the template.
Slider
A scrollbar-like widget for selecting a positive numeric value. Handled in a similar way as Scale.
Spinner
Similar to a textedit, but contains little up and down arrows and can be used to input an integer number. Handled in a similar way as Scale.
StyledText
A textedit widget which allows displaying and editing of styled text. Handled similarly to Text.
Text

A textedit widget. It can be single-line or multi-line, depending on the style attribute (SWT.SINGLE, SWT.MULTI).

  • W: accepts a (potentially multiline) string.
  • R: returns the edited text as a string.

Custom widgets

HttpLink

A control containing a text and a hyperlink between <a></a> tags. An URL can be specified to be opened in an external browser.

  • W: accepts a string with the target URL.
  • R: returns the target URL as string.
  • Other attributes:

    • text : the textual content of the control <a></a> denotes the link inside.
    • URL: the target URL where the control points to.
InfoLink

A control that displays a text with embedded link(s). Clicking on a link will display a hover text in a window. The hover text can be given with the setHoverText method (i.e. the hoverText XSWT attribute), or bound to a template variable (using the x:id XSWT attribute).

  • W: accepts a string with the hover text for the control.
  • R: returns the hover text as string.
  • Other attributes:

    • text: the content of the control.
    • hoverText: the html formatted text displayed in the hover control.
    • hoverMinimumWidth: the minimum width for the hover control.
    • hoverMinimumHeight: the minimum height for the hover control.
    • hoverPreferredWidth: the preferred width for the hover control.
    • hoverPreferredHeight: the preferred height for the hover control.
FileLink

A control for displaying the name of a resource as a link. When clicked, it shows the resource (opens Project Explorer and focuses it to the resource).

  • W: accepts a string with the workspace path of the resource to be shown.
  • R: returns the full workspace path of the resource.
  • Other attributes:

    • resourcePath: the full workspace path of the file.
FileChooser

A control for selecting a file from the workspace. Implemented as a Composite with a single-line Text and a Browse button.

  • W: accepts a string with the workspace file name.
  • R: returns the name of the selected file as a string from the workspace.
  • Other attributes:

    • fileName : the full workspace path of the selected file.
ExternalFileChooser

A control for selecting a file from the filesystem. Implemented as a Composite with a single-line Text and a Browse button.

  • W: accepts a string with the full file name.
  • R: returns the name of the selected file as a string from the filesystem.
  • Other attributes:

    • fileName : the full filesystem path of the selected file.
SaveAsChooser

A control for selecting a name for a new file from the workspace. Implemented as a Composite with a single-line Text and a Browse button.

  • W: accepts a string with the workspace file name.
  • R: returns the name of the selected file as a string from the workspace.
  • Other attributes:

    • fileName : the full workspace path for the new file.
ExternalSaveAsChooser

A control for selecting a name for a new file in the filesystem. Implemented as a Composite with a single-line Text and a Browse button.

  • W: accepts a string with the full file name.
  • R: returns the name (with full filesystem path) of the new file as a string.
  • Other attributes:

    • fileName : the full filesystem path for the new file.
GateChooser

A control for selecting a gate of a NED module type. If the module exists, it lets the user select one of its gates from a combo; if the module does not exist, it lets the user enter a gate name.

  • W: accepts strings with a gate name.
  • R: returns the name of the selected gate as a string.
  • Other attributes:

    • gateName: the name of the selected gate.
    • nedTypeName : the NED type whose gates should be enumerated.
    • gateFilter : type filter for the enumerated gates. Expects a binary OR (|) of the following values: GateChooser.INPUT, GateChooser.OUTPUT, GateChooser.INOUT, GateChooser.VECTOR, GateChooser.SCALAR.

      <gateChooser x:id="gateName"
        nedTypeName="${nodeType}"
        gateFilter="GateChooser.INOUT|GateChooser.VECTOR"/>
NedTypeChooser

A control for selecting a NED module type. An existing type name can be selected or a new one can be entered.

  • W: accepts strings with a NED type name.
  • R: returns the name of the selected NED type as a string.
  • Other attributes:

    • nedName: the NED module type as a string.
    • acceptedTypes : filter for the enumeration of types. Expects a binary OR (|) of the following values: NedTypeChooser.MODULE, NedTypeChooser.SIMPLE_MODULE, NedTypeChooser.COMPOUND_MODULE, NedTypeChooser.MODULEINTERFACE, NedTypeChooser.CHANNEL, NedTypeChooser.CHANNELINTERFACE, NedTypeChooser.NETWORK.

      <nedTypeChooser x:id="channelType"
           acceptedTypes="NedTypeChooser.CHANNEL"/>

Note

Table and tree widgets are currently not supported in a useful way; the main reason being that SWT Tables and Trees are not editable by default.

Some non-interactive widgets which cannot be connected to template variables but are useful in forms as structuring elements:

Composite

Used to group two or more controls into a single one.

<composite>
  <layoutData x:class="GridData" horizontalSpan="2"/>
  <layout x:class="GridLayout"/>
  <x:children>
    <button x:id="dynamic" text="Dynamic" x:style="RADIO"/>
    <button x:id="static" text="Static" x:style="RADIO"/>
  </x:children>
</composite>
Group

Used to group the controls with a visual heading.

<group text="Heading text">
  <x:children>
     <label text="Control 1"/>
     <label text="Control 2"/>
  </x:children>
</group>
TabFolder/TabItem

Can be used to group the controls into separate pages.

<tabFolder>
  <x:children>
    <composite x:id="page1"></composite>
    <composite x:id="page2"></composite>
    <tabItem text="Tab 1" control="page1"/>
    <tabItem text="Tab 2" control="page2"/>
  </x:children>
</tabFolder>