public interface Widget
extends java.io.Serializable
An interface to relate widget variables and invisible variables (such as temporary files). Relating both invisible and visible PCD variables provides a common interface for BioLegato to interact with various PCD widgets, such as NumberWidgets and ListWidgets. Thus, code which executes commands (for example), such as CommandButton, can be agnostic as to whether the widget is visible or invisible, a numerical widget or list widget, etc.
In the case of invisible widgets, the display function should be left empty.
In the case that a variable does not have any values (i.e. display only), such as TabbedWidget, if the widget does house other widgets (like TabbedWidget), then it should create a map object (by recursively calling each of its child widgets' getInstance functions) containing variable names as keys, and variable values as entries, where each entry corresponds to a child widget. This map object should then be passed to the WidgetInstance constructor, and then returned.
In the case that a variable does not have any values, and has no sub-widgets, then it should just pass an empty string ("") to its WidgetInstance constructor for the getInstance method. Please note that at the time of this writing, getInstance is not expected to return null (this could be a future improvement, depending on whether a need arises).
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.
|
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.
|
WidgetInstance getInstance()
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 the case that a variable does not have any values (i.e. display only), such as TabbedWidget, if the widget does house other widgets (like TabbedWidget), then it should create a map object (by recursively calling each of its child widgets' getInstance functions) containing variable names as keys, and variable values as entries, where each entry corresponds to a child widget. This map object should then be passed to the WidgetInstance constructor, and then returned.
In the case that a variable does not have any values, and has no sub-widgets, then it should just return null (see CommandButton for an example of this.)
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)void pcdOut(int scope, java.lang.Appendable out) 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
java.awt.Component displayEdit(javax.swing.JFrame mainFrame)
mainFrame
- a JFrame object for adding modality to any dialog
boxes, which are created by this function.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.