public class TextWidget extends SimpleWidget
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
label
the label for the text field
|
protected javax.swing.JTextField |
textfield
The text field for obtaining the data
|
protected java.lang.String |
value
the default value for the text field
|
static javax.swing.Icon |
WIDGET_ICON
The icon for the widget
|
name
Constructor and Description |
---|
TextWidget(java.lang.String name)
Creates a new instance of a text widget
(this specific constructor is used by the PCD editor ONLY!).
|
TextWidget(java.lang.String name,
java.lang.String label,
java.lang.String value)
Creates a new instance of a text widget.
|
Modifier and Type | Method and Description |
---|---|
void |
display(java.awt.Container dest,
CloseableWindow window)
Displays the current widget within the container 'dest'.
|
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)
Writes the BioPCD representation of the menu widget to a writer object
(see BioLegato's BioPCD editor for more details)
|
protected 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, recursiveDraw
protected java.lang.String label
protected java.lang.String value
protected transient javax.swing.JTextField textfield
public static final javax.swing.Icon WIDGET_ICON
public TextWidget(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 TextWidget(java.lang.String name, java.lang.String label, java.lang.String value)
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.value
- the default value for the text widgetpublic void display(java.awt.Container dest, CloseableWindow window)
dest
- the destination Container to display the widget. Note that
this will almost definitely be different from the window
parameter, and in most cases, should be a JPanel object.window
- the parent window to communicate with. The communication
involved is supposed to be limited to just using 'window'
to create modal dialog boxes when necessary (for example,
the AbstractFileChooser's "Browse" file choice dialog box).
Please note that this field may be null!! (e.g. displaying
the current state of the widget in the editor canvas)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.
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) throws java.io.IOException
pcdOut
in interface Widget
pcdOut
in class SimpleWidget
scope
- the level of scope to write the menu widget.out
- the writer object to output the BioPCD code.java.io.IOException
protected 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.out
- the writer 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.Copyright © 2008-2022 University of Manitoba.