001package jmri.script.swing;
002
003import java.awt.event.ActionEvent;
004
005import javax.swing.AbstractAction;
006import javax.swing.BoxLayout;
007import javax.swing.JFrame;
008
009import jmri.util.JmriJFrame;
010
011/**
012 * This Action runs creates an InputWindow for sending input to the global
013 * jython interpreter
014 *
015 * @author Bob Jacobsen Copyright (C) 2004
016 */
017public class InputWindowAction extends AbstractAction {
018
019    /**
020     * Constructor just initializes parent class.
021     *
022     * @param name Action name
023     */
024    public InputWindowAction(String name) {
025        super(name);
026    }
027
028    public InputWindowAction() {
029        super("Script Input Window");
030    }
031
032    /**
033     * Invoking this action via an event triggers display of a file dialog. If a
034     * file is selected, it's then invoked as a script.
035     *
036     */
037    @Override
038    public void actionPerformed(ActionEvent e) {
039        f = new JmriJFrame(Bundle.getMessage("TitleInputFrame"));
040        f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), javax.swing.BoxLayout.Y_AXIS));
041        f.getContentPane().add(new InputWindow());
042
043        f.pack();
044        f.setVisible(true);
045    }
046
047    public JFrame getFrame() {
048        return f;
049    }
050
051    JFrame f;
052}