public abstract class ListWidget extends SimpleWidget
Modifier and Type | Field and Description |
---|---|
static java.lang.String[] |
BLANK_STRING_ARRAY
This array is used for the template toArray method for lists
i.e.
|
protected java.lang.String[] |
cnames
The list of choice names
|
protected int |
index
Stores the current value selected by the chooser.
|
protected java.lang.String |
label
The label to associate with the list widget
|
protected java.lang.String[] |
values
The list of choice values
|
name
Constructor and Description |
---|
ListWidget(java.lang.String name)
Creates a new instance of the abstract class list widget.
|
ListWidget(java.lang.String name,
java.lang.String label,
PCDSQL choicesql,
int index)
Creates a new instance of the abstract class list widget.
|
ListWidget(java.lang.String name,
java.lang.String label,
java.lang.String[] cnames,
java.lang.String[] values,
int index)
Creates a new instance of the abstract class list widget.
|
Modifier and Type | Method and Description |
---|---|
java.awt.event.ActionListener |
editWindow(java.awt.Container dest)
Populates a container with the component objects
necessary for editing the current widget's properties.
|
WidgetInstance |
getInstance()
Creates a new widget instance of the widget
|
void |
pcdOut(int scope,
java.lang.Appendable out,
java.lang.String type)
Writes the BioPCD representation of the menu widget to a writer object
(see BioLegato's BioPCD editor for more details)
|
void |
setValue(java.lang.String newValue)
Changes the current value for the widget.
|
displayEdit, editImage, pcdOut, recursiveDraw
protected int index
protected java.lang.String label
protected java.lang.String[] cnames
protected java.lang.String[] values
public static final java.lang.String[] BLANK_STRING_ARRAY
public ListWidget(java.lang.String name)
name
- the PCD variable name (this name can be referenced
in the command using the % symbol; for example,
if the name value was set to "A", the value of this
widget could be accessed by using %A% (lower or
upper-case) within the PCD menu command string.public ListWidget(java.lang.String name, java.lang.String label, PCDSQL choicesql, int index)
name
- the PCD variable name (this name can be referenced
in the command using the % symbol; for example,
if the name value was set to "A", the value of this
widget could be accessed by using %A% (lower or
upper-case) within the PCD menu command string.label
- the label to display representing the parameter to be
manipulated by the number widget. This is the text the
user will see to the left of the widget in any
BioLegato menu windows.choicesql
- the SQL query to use for obtaining the list widget's
choice values and names.index
- the initial value for the list widget to display
(represents an index within both the 'cnames'
and 'values' arrays)public ListWidget(java.lang.String name, java.lang.String label, java.lang.String[] cnames, java.lang.String[] values, int index)
name
- the PCD variable name (this name can be referenced
in the command using the % symbol; for example,
if the name value was set to "A", the value of this
widget could be accessed by using %A% (lower or
upper-case) within the PCD menu command string.label
- the label to display representing the parameter to be
manipulated by the number widget. This is the text the
user will see to the left of the widget in any
BioLegato menu windows.cnames
- the list of names for each option within the list widget
(related to the 'values' method-parameter)values
- the list of values for each option within the list widget
(related to the 'cnames' method-parameter)index
- the initial value for the list widget to display
(represents an index within both the 'cnames'
and 'values' arrays)public java.awt.event.ActionListener editWindow(java.awt.Container dest)
Populates a container with the component objects necessary for editing the current widget's properties.
This method takes the Container 'dest' and populates it with components which can change the properties of the current widget. In other words, this is the window which pops up when you double click on a widget in the PCD editor. For instance, if you place a text box in a PCD menu, then double click on it, you can set its internal PCD 'name' and default value, among other things.
This method returns an action listener, which is called when the widget should update. The reason for this is class extension. To allow sub-classes to use the same method ('editWindow') with only one button, and without re-writing code, an ActionListener object can be passed downwards to the child class. The child class may add code to call its parent class's ActionListener.
Please note that the ActionListener will likely be used by a calling method to create an "Update" button.
editWindow
in class SimpleWidget
dest
- the destination Container object; this is where the
'editWindow' function will add add all of the Components
necessary for editing the Widget parameters (NOTE: this
class implements the Widget interface).public void pcdOut(int scope, java.lang.Appendable out, java.lang.String type) throws java.io.IOException
scope
- the level of scope to write the menu widget. In the case
of PCD, the scope of each line is indicated by the number
of spaced preceding the line. Every 4 spaces count as
one level of scope (any number not divisible by 4 is
considered an error), thus if a line is preceded by 4
spaces, its scope level is considered to be 1out
- the Appendable object to output the BioPCD code.java.io.IOException
public void setValue(java.lang.String newValue)
Changes the current value for the widget. This is used to ensure that any Components that the widget creates for a PCD menu will update the widget object itself. This is important because the widget is expected to store the last value it was set to after a window was closed.
For example, if you opened a PCD menu and set a NumberWidget to 10, and then closed the window, if you reopen the window the NumberWidget should still be 10 (regardless of any default values).
newValue
- the new value for the widget.public WidgetInstance getInstance()
Creates a new widget instance of the widget
A widget instance is an object that stores the value of a widget past after the widget has been closed. This is useful for concurrency. Because more than one BioLegato PCD command can be run simultaneously, BioLegato needs to store the values used to run each command separately. For instance, if the user runs command A, then changing the value of a widget in A's parameter window should not affect the currently running job (i.e. command A). This is achieved through WidgetInstance objects.
In this case the WidgetInstance contains the value selected in the list box widget.
NOTE: ALL subclasses should call this function AFTER they modify the index and clean up their displayed java components. See ComboBoxWidget, Chooser, or ChoiceList for usage examples.
WHY? because the list widget object will handle SQL based lists intrinsically. This will save you the time and effort writing code to handle BOTH SQL based lists and array based lists.
Copyright © 2008-2022 University of Manitoba.