jmri.jmrit.jython
Class RunJythonScript

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by jmri.util.swing.JmriAbstractAction
          extended by jmri.jmrit.jython.RunJythonScript
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action

public class RunJythonScript
extends JmriAbstractAction

This Action runs a script by invoking a Jython interpreter.

A standard JMRI-Jython dialog is defined by invoking the "jython/jmri-defaults.py" file before starting the user code.

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.

Access is via Java reflection so that both users and developers can work without the jython.jar file in the classpath. To make it easier to read the code, the "non-reflection" statements are in the comments.

Author:
Bob Jacobsen Copyright (C) 2004, 2007
See Also:
Serialized Form

Field Summary
 
Fields inherited from class jmri.util.swing.JmriAbstractAction
context, wi
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
RunJythonScript(String name)
          Constructor that, when action is invoked, opens a JFileChooser to select file to invoke.
RunJythonScript(String name, File file)
          Constructor that, when action is invoked, directly invokes the provided File
RunJythonScript(String s, Icon i, WindowInterface wi)
           
RunJythonScript(String s, WindowInterface wi)
           
 
Method Summary
 void actionPerformed(ActionEvent e)
          Invoking this action via an event triggers display of a file dialog.
 JmriPanel makePanel()
           
 
Methods inherited from class jmri.util.swing.JmriAbstractAction
dispose, setContext, setHint, setName, setParameter, setWindowInterface, toString
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RunJythonScript

public RunJythonScript(String s,
                       WindowInterface wi)

RunJythonScript

public RunJythonScript(String s,
                       Icon i,
                       WindowInterface wi)

RunJythonScript

public RunJythonScript(String name)
Constructor that, when action is invoked, opens a JFileChooser to select file to invoke.

Parameters:
name - Action name

RunJythonScript

public RunJythonScript(String name,
                       File file)
Constructor that, when action is invoked, directly invokes the provided File

Parameters:
name - Action name
Method Detail

actionPerformed

public void actionPerformed(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 interface ActionListener
Overrides:
actionPerformed in class JmriAbstractAction
Parameters:
e -

makePanel

public JmriPanel makePanel()
Specified by:
makePanel in class JmriAbstractAction


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads