001package jmri.jmrit.symbolicprog.tabbedframe;
002
003import javax.swing.JComponent;
004import jmri.jmrit.symbolicprog.ArithmeticQualifier;
005import jmri.jmrit.symbolicprog.VariableValue;
006
007/**
008 * Qualify a JComponent on a numerical test by setting the JComponent's
009 * visibility.
010 *
011 * @author Bob Jacobsen Copyright (C) 2010, 2014
012 */
013public class JComponentQualifier extends ArithmeticQualifier {
014
015    JComponent component;
016
017    public JComponentQualifier(JComponent component, VariableValue watchedVal, int value, String relation) {
018        super(watchedVal, value, relation);
019
020        this.component = component;
021
022        setWatchedAvailable(currentDesiredState());
023    }
024
025    @Override
026    public void setWatchedAvailable(boolean enable) {
027        component.setVisible(enable);
028    }
029
030    @Override
031    protected boolean currentAvailableState() {
032        return component.isVisible();
033    }
034
035}