Package jmri.jmrit.jython
Class RunJythonScript
- java.lang.Object
-
- javax.swing.AbstractAction
-
- jmri.util.swing.JmriAbstractAction
-
- jmri.jmrit.jython.RunJythonScript
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,javax.swing.Action
public class RunJythonScript extends JmriAbstractAction
This Action runs a script using an available script engine.The script engine to use is determined by the script's extension.
There are two constructors. One, without a script file name, will open a FileDialog to prompt for the file to use. The other, with a File object, will directly invoke that file.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.io.File
configuredFile
(package private) static javax.swing.JFileChooser
fci
We always use the same file chooser in this class, so that the user's last-accessed directory remains available.-
Fields inherited from class jmri.util.swing.JmriAbstractAction
context, hint, wi
-
-
Constructor Summary
Constructors Constructor Description RunJythonScript(java.lang.String name)
Constructor that, when action is invoked, opens a JFileChooser to select file to invoke.RunJythonScript(java.lang.String name, java.io.File file)
Constructor that, when action is invoked, directly invokes the provided File.RunJythonScript(java.lang.String s, javax.swing.Icon i, WindowInterface wi)
RunJythonScript(java.lang.String s, WindowInterface wi)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent e)
Invoking this action via an event triggers display of a file dialog.(package private) void
invoke(java.io.File file)
JmriPanel
makePanel()
(package private) java.io.File
selectFile()
-
Methods inherited from class jmri.util.swing.JmriAbstractAction
dispose, setContext, setHint, setName, setParameter, setParameter, setWindowInterface, toString
-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
-
-
-
Field Detail
-
configuredFile
java.io.File configuredFile
-
fci
static javax.swing.JFileChooser fci
We always use the same file chooser in this class, so that the user's last-accessed directory remains available.
-
-
Constructor Detail
-
RunJythonScript
public RunJythonScript(java.lang.String s, WindowInterface wi)
-
RunJythonScript
public RunJythonScript(java.lang.String s, javax.swing.Icon i, WindowInterface wi)
-
RunJythonScript
public RunJythonScript(java.lang.String name)
Constructor that, when action is invoked, opens a JFileChooser to select file to invoke.- Parameters:
name
- Action name
-
RunJythonScript
public RunJythonScript(java.lang.String name, java.io.File file)
Constructor that, when action is invoked, directly invokes the provided File.- Parameters:
name
- Action namefile
- the script file to invoke
-
-
Method Detail
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
Invoking this action via an event triggers display of a file dialog. If a file is selected, it's then invoked as a script.- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
- Overrides:
actionPerformed
in classJmriAbstractAction
-
selectFile
java.io.File selectFile()
-
invoke
void invoke(java.io.File file)
-
makePanel
public JmriPanel makePanel()
- Specified by:
makePanel
in classJmriAbstractAction
-
-