public class PanelWidget extends java.lang.Object implements Widget
Modifier and Type | Field and Description |
---|---|
static javax.swing.Icon |
WIDGET_ICON
The icon for the widget.
|
Constructor and Description |
---|
PanelWidget()
Creates a new empty instance of a panel widget
(this specific constructor is used by the PCD editor ONLY!).
|
PanelWidget(java.util.Map<java.lang.String,Widget> subwidgets)
Creates a new instance of a panel 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.Component |
displayEdit(javax.swing.JFrame mainFrame)
Displays the current widget in an editor panel.
|
java.awt.event.ActionListener |
edit(java.awt.Component parent,
java.awt.Container dest)
Populates a container with the component objects
necessary for editing the current widget
|
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.
|
public PanelWidget()
public PanelWidget(java.util.Map<java.lang.String,Widget> subwidgets)
subwidgets
- the widgets that should be contained within the panelpublic void display(java.awt.Container dest, CloseableWindow window)
display
in interface Widget
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 PanelWidgets do not have any values (i.e. display only); however, PanelWidgets CAN house house other widgets (such as NumberWidgets), which CAN have values. Therefore, the PanelWidget class returns a map object (generated by recursively calling each of its child widgets' getInstance functions) contained inside a WidgetInstace object. The map is comprised of WidgetInstances for each child widget to the panel. The keys of the map are the variable names for the child widgets, and the entries are the actual WidgetInstance objects.
getInstance
in interface Widget
public java.awt.event.ActionListener edit(java.awt.Component parent, java.awt.Container dest)
parent
- the JDialog/JFrame/etc. which contains the edit
information (this parameter should ONLY be used for
creating modal child windows for displaying error
messages and the like!)dest
- the destination to display the widget-editing componentspublic void pcdOut(int scope, java.lang.Appendable out) throws java.io.IOException
pcdOut
in interface Widget
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 java.awt.Component displayEdit(javax.swing.JFrame mainFrame)
displayEdit
in interface Widget
mainFrame
- a JFrame object for adding modality to any dialog
boxes, which are created by this function.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 PanelWidget), this method is left empty.
Copyright © 2008-2022 University of Manitoba.