001package jmri.jmrit.simpleturnoutctrl;
002
003import java.awt.event.ActionEvent;
004import javax.swing.Icon;
005import jmri.util.swing.JmriAbstractAction;
006import jmri.util.swing.WindowInterface;
007
008/**
009 * Swing action to create and register a SimpleTurnoutCtrlFrame
010 * object.
011 *
012 * @author Bob Jacobsen Copyright (C) 2001
013 */
014public class SimpleTurnoutCtrlAction extends JmriAbstractAction {
015
016    public SimpleTurnoutCtrlAction(String s, WindowInterface wi) {
017        super(s, wi);
018    }
019
020    public SimpleTurnoutCtrlAction(String s, Icon i, WindowInterface wi) {
021        super(s, i, wi);
022    }
023
024    public SimpleTurnoutCtrlAction(String s) {
025        super(s);
026
027        // disable ourself if there is no primary turnout manager available
028        if (jmri.InstanceManager.getNullableDefault(jmri.TurnoutManager.class) == null) {
029            setEnabled(false);
030        }
031    }
032
033    public SimpleTurnoutCtrlAction() {
034        this(Bundle.getMessage("Turnouts"));
035    }
036
037    @Override
038    public void actionPerformed(ActionEvent e) {
039
040        SimpleTurnoutCtrlFrame f = new SimpleTurnoutCtrlFrame();
041        f.setVisible(true);
042    }
043
044    // never invoked, because we overrode actionPerformed above
045    @Override
046    public jmri.util.swing.JmriPanel makePanel() {
047        throw new IllegalArgumentException("Should not be invoked");
048    }
049
050}