001package jmri;
002
003import java.awt.event.ActionListener;
004
005import javax.annotation.CheckForNull;
006import javax.annotation.Nonnull;
007import javax.swing.Timer;
008
009import jmri.jmrit.Sound;
010
011/**
012 * The consequent of the antecedent of the conditional proposition. The data for
013 * the action to be taken when a Conditional calculates to True.
014 *
015 * @author Pete Cressman Copyright (C) 2009
016 */
017public interface ConditionalAction {
018
019    /**
020     * Integer data for action.
021     *
022     * @return the data
023     */
024    int getActionData();
025
026    /**
027     * Get an I18N String to represent the Action Data.
028     * @return human readable String of the data.
029     */
030    @Nonnull
031    String getActionDataString();
032
033    /**
034     * String data for action.
035     *
036     * @return the action String
037     */
038    @Nonnull
039    String getActionString();
040
041    /**
042     * Name of the device or element that is effected.
043     *
044     * @return the name
045     */
046    String getDeviceName();
047
048    /**
049     * Options on when action is taken.
050     *
051     * @return the option
052     */
053    int getOption();
054
055    /**
056     * Get the Option String in I18N format.
057     * @param type true if option is a change; false if option is a trigger.
058     * @return String name of the option for this consequent type.
059     */
060    @Nonnull
061    String getOptionString(boolean type);
062
063    /**
064     * The consequent device or element type.
065     *
066     * @return the type
067     */
068    @Nonnull
069    Conditional.Action getType();
070
071    /**
072     * @return String name of this consequent type
073     */
074    @Nonnull
075    String getTypeString();
076
077    /**
078     * Sets action data from I18N name for it.
079     *
080     * @param actionData user name
081     */
082    void setActionData(String actionData);
083
084    void setActionData(int actionData);
085
086    /**
087     * Set the Action String.
088     * Any String float values ( delayed Sensor ) should use a . decimal separator.
089     * @param actionString the action String.
090     */
091    void setActionString(String actionString);
092
093    void setDeviceName(String deviceName);
094
095    /**
096     * Set the Action Option.
097     * @param option the action option number.
098     */
099    void setOption(int option);
100
101    /**
102     * Sets type from user's name for it.
103     *
104     * @param type name of the type
105     */
106    void setType(String type);
107
108    void setType(Conditional.Action type);
109
110    /**
111     * Get an I18N description of the ConditionAction.
112     * @param triggerType true if option is a change; false if option is a trigger.
113     * @return human readable description.
114     */
115    @Nonnull
116    String description(boolean triggerType);
117
118    /*
119     * get timer for delays and other timed events
120     */
121    @CheckForNull
122    Timer getTimer();
123
124    /*
125     * set timer for delays and other timed events
126     */
127    void setTimer(Timer timer);
128
129    boolean isTimerActive();
130
131    void startTimer();
132
133    void stopTimer();
134
135    /*
136     * set listener for delays and other timed events
137     */
138    @CheckForNull
139    ActionListener getListener();
140
141    /*
142     * set listener for delays and other timed events
143     */
144    void setListener(ActionListener listener);
145
146    /**
147     * Get the Sound.
148     *
149     * @return the sound
150     */
151    @CheckForNull
152    Sound getSound();
153
154    @CheckForNull
155    NamedBeanHandle<?> getNamedBean();
156
157    @CheckForNull
158    NamedBean getBean();
159
160    /**
161     * Dispose this ConditionalAction.
162     */
163    void dispose();
164
165}