001package jmri.jmrit.withrottle;
002
003import java.awt.event.ActionEvent;
004import javax.swing.AbstractAction;
005import jmri.util.JmriJFrame;
006import org.slf4j.Logger;
007import org.slf4j.LoggerFactory;
008
009/**
010 * @author Brett Hoffman Copyright (C) 2010
011 */
012public class ControllerFilterAction extends AbstractAction {
013
014    public ControllerFilterAction(String name) {
015        super(name);
016        if ((jmri.InstanceManager.getNullableDefault(jmri.TurnoutManager.class) == null) && (jmri.InstanceManager.getNullableDefault(jmri.RouteManager.class) == null)) {
017            setEnabled(false);
018        }
019    }
020
021    public ControllerFilterAction() {
022        this(Bundle.getMessage("MenuMenuFilter"));
023    }
024
025    public String getName() {
026        return "jmri.jmrit.withrottle.ControllerFilterFrame";
027    }
028
029    @Override
030    public void actionPerformed(ActionEvent ae) {
031        JmriJFrame frame = new ControllerFilterFrame();
032        try {
033            frame.initComponents();
034            frame.setVisible(true);
035        } catch (Exception ex) {
036            log.error("Could not create Route & Turnout Filter frame");
037        }
038
039    }
040
041    private final static Logger log = LoggerFactory.getLogger(ControllerFilterAction.class);
042
043}