public class TempFile extends SimpleWidget
Modifier and Type | Field and Description |
---|---|
static javax.swing.Icon |
WIDGET_ICON
The icon for the widget
|
name
Constructor and Description |
---|
TempFile(java.lang.String name)
Creates a new instance of a text widget
(this specific constructor is used by the PCD editor ONLY!).
|
TempFile(java.lang.String name,
PCDIO canvas,
boolean input,
boolean output,
boolean save,
boolean overwrite,
java.lang.String format,
boolean forceall)
Creates a new instance of temporary file widgets.
|
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 |
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.
|
editImage, recursiveDraw
public TempFile(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 TempFile(java.lang.String name, PCDIO canvas, boolean input, boolean output, boolean save, boolean overwrite, java.lang.String format, boolean forceall)
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.canvas
- the canvas object to interact withinput
- whether the file should be used as input for a command.
If true, content from the canvas is written to the file
when getValue() is called.output
- whether the file should be used as output for a
command. If true, when the close() method is called,
the contents of the file will be written to the canvas.save
- whether to delete file whenoverwrite
- whether to overwrite the selected sequences in the
canvas. If true any sequences selected will be
overwritten when the close() function is called.format
- the format to use for file I/Oforceall
- if true, use the entire contents of the canvas instead
of limiting file output to only the data selected by
the userpublic 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 filename where the TempFile will write the content to be read by the command. If the file does not exist, then this function creates a file to use for IO. This function also writes the initial contents to the file, if the input flag is set.
public void display(java.awt.Container dest, CloseableWindow window)
Displays the current widget within the container 'dest'.
NOTE: in the case of the temporary file widget, this method does nothing!
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 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
public java.awt.Component displayEdit(javax.swing.JFrame mainFrame)
displayEdit
in interface Widget
displayEdit
in class SimpleWidget
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 TempFile widgets do NOT use static values (the value returned by a TempValue's getInstance method is a filename, which is generated on the fly), this method is left blank.
newValue
- the new value for the widget.Copyright © 2008-2022 University of Manitoba.