001package jmri.jmrit.throttle;
002
003import java.awt.event.ActionEvent;
004import javax.swing.AbstractAction;
005import jmri.InstanceManager;
006
007/**
008 * Action to open the JMRI throttles UI preferences window
009 * 
010 * <hr>
011 * This file is part of JMRI.
012 * <p>
013 * JMRI is free software; you can redistribute it and/or modify it under the
014 * terms of version 2 of the GNU General Public License as published by the Free
015 * Software Foundation. See the "COPYING" file for a copy of this license.
016 * <p>
017 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY
018 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
019 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
020 *
021 * @author Lionel Jeanson
022 * 
023 */
024
025public class ThrottlesPreferencesAction extends AbstractAction {
026
027    /**
028     * Constructor
029     *
030     * @param s Name for the action.
031     */
032    public ThrottlesPreferencesAction(String s) {
033        super(s);
034        // disable the ourselves if there is no throttle Manager
035        if (jmri.InstanceManager.getNullableDefault(jmri.ThrottleManager.class) == null) {
036            setEnabled(false);
037        }
038    }
039
040    public ThrottlesPreferencesAction() {
041        this("Throttles preferences");
042    }
043
044    @Override
045    public void actionPerformed(ActionEvent e) {
046        InstanceManager.getDefault(ThrottleFrameManager.class).showThrottlesPreferences();
047    }
048}