001package jmri.jmrit.symbolicprog.tabbedframe;
002
003import javax.swing.JTabbedPane;
004import jmri.jmrit.symbolicprog.ArithmeticQualifier;
005import jmri.jmrit.symbolicprog.VariableValue;
006import org.slf4j.Logger;
007import org.slf4j.LoggerFactory;
008
009/**
010 * Qualify a JMRI DecoderPro pane on a numerical relation by enabling/disabling
011 * the tab.
012 *
013 * @author Bob Jacobsen Copyright (C) 2010, 2014
014 */
015public class PaneQualifier extends ArithmeticQualifier {
016
017    PaneProgPane pane;
018    JTabbedPane tabs;
019    int index;
020
021    public PaneQualifier(PaneProgPane qualifiedPane, VariableValue watchedVal, int value, String relation, JTabbedPane tabPane, int index) {
022        super(watchedVal, value, relation);
023
024        this.pane = qualifiedPane;
025        this.tabs = tabPane;
026        this.index = index;
027
028        setWatchedAvailable(currentDesiredState());
029    }
030
031    @Override
032    public void setWatchedAvailable(boolean enable) {
033        log.debug("setWatchedAvailable with {} on {}", enable, index);
034        tabs.setEnabledAt(index, enable);
035    }
036
037    @Override
038    protected boolean currentAvailableState() {
039        return tabs.isEnabledAt(index);
040    }
041
042    private final static Logger log = LoggerFactory.getLogger(PaneQualifier.class);
043
044}