public class CommandButton extends SimpleWidget
Modifier and Type | Field and Description |
---|---|
protected boolean |
close
Whether the button closes the main window when clicked.
|
protected java.lang.String |
command
The command to run when the button is clicked.
|
protected java.lang.String |
label
the text to display for the button.
|
static javax.swing.Icon |
WIDGET_ICON
The icon for the widget
|
protected java.util.Map<java.lang.String,Widget> |
widgets
The hash map containing all of the widgets to be used
as parameters for the button.
|
name
Constructor and Description |
---|
CommandButton(java.lang.String name)
Creates a new instance of a choice list widget
(this specific constructor is used by the PCD editor ONLY!).
|
CommandButton(java.lang.String name,
java.util.Map<java.lang.String,Widget> widgets,
java.lang.String label,
java.lang.String command,
boolean close)
Creates a new instance of CommandButton
|
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)
|
void |
setValue(java.lang.String newValue)
Changes the current value for the widget.
|
displayEdit, editImage, recursiveDraw
protected java.lang.String label
protected boolean close
protected java.lang.String command
protected java.util.Map<java.lang.String,Widget> widgets
public static final javax.swing.Icon WIDGET_ICON
public CommandButton(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 CommandButton(java.lang.String name, java.util.Map<java.lang.String,Widget> widgets, java.lang.String label, java.lang.String command, boolean close)
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.widgets
- the widgets that are used by the current button
when executing commandscommand
- the command to run when the button is clickedclose
- whether to close the parameter window after
the command is donepublic 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.
In this case CommandButtons do not have any values, and do not have any sub-widgets. Thus, this method just returns null.
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. 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).
NOTE: because this widget does not use values (it is a CommandButton), this method is left empty.
newValue
- the new value for the widget.Copyright © 2008-2022 University of Manitoba.