jmri.jmrit.symbolicprog
Class IndexedEnumVariableValue

java.lang.Object
  extended by jmri.jmrit.symbolicprog.AbstractValue
      extended by jmri.jmrit.symbolicprog.VariableValue
          extended by jmri.jmrit.symbolicprog.IndexedEnumVariableValue
All Implemented Interfaces:
ActionListener, PropertyChangeListener, EventListener

public class IndexedEnumVariableValue
extends VariableValue
implements ActionListener, PropertyChangeListener

Extends VariableValue to represent a enumerated indexed variable.

Author:
Howard G. Penny Copyright (C) 2005

Nested Class Summary
 class IndexedEnumVariableValue.IVarComboBox
           
 
Field Summary
 
Fields inherited from class jmri.jmrit.symbolicprog.VariableValue
_cvVector, _status, _tooltipText
 
Fields inherited from class jmri.jmrit.symbolicprog.AbstractValue
DIFF, EDITED, FROMFILE, READ, SAME, STORED, UNKNOWN
 
Constructor Summary
protected IndexedEnumVariableValue()
          Create a null object.
  IndexedEnumVariableValue(int row, String name, String comment, String cvName, boolean readOnly, boolean infoOnly, boolean writeOnly, boolean opsOnly, int cvNum, String mask, Vector<CvValue> v, JLabel status, String stdname)
           
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 void addItem(String s)
          Create a new item in the enumeration, with an associated value one more than the last item (or zero if this is the first one added)
 void addItem(String s, int value)
          Create a new item in the enumeration, with a specified associated value.
 void confirmAll()
          Confirm the contents of this Variable
 void dispose()
           
 Component getCommonRep()
           
 int getIntValue()
          Get the value as a single number.
 Component getNewRep(String format)
           
 String getTextValue()
           
 Object getValueObject()
           
 String getValueString()
           
 boolean isChanged()
          Determine whether this Variable is "changed", so that "read changes" and "write changes" will act on it.
 boolean isToRead()
          Simple implementation for the case of a single CV.
 boolean isToWrite()
          Simple implementation for the case of a single CV.
 void lastItem()
           
 void nItems(int n)
           
 void propertyChange(PropertyChangeEvent e)
           
 Object rangeVal()
           
 void readAll()
          Always read the contents of this Variable
 void readChanges()
          Read the contents of this Variable if it's in a state that indicates it was "changed"
protected  void selectValue(int value)
          Set to a specific value.
 void setAvailable(boolean a)
           
 void setCvState(int state)
          Notify the connected CVs of a state change from above
 void setIntValue(int i)
          Set the value from a single number.
 void setToolTipText(String t)
          Set tooltip text to be used by both the "value" and representations of this Variable.
 void setToRead(boolean state)
          Simple implementation for the case of a single CV.
 void setToWrite(boolean state)
          Simple implementation for the case of a single CV.
 void setValue(int value)
           
 CvValue[] usesCVs()
          Provide access to CVs referenced by this operation
 void writeAll()
          Always write the contents of this Variable
 void writeChanges()
          Write the contents of this Variable if it's in a state that indicates it was "changed"
 
Methods inherited from class jmri.jmrit.symbolicprog.VariableValue
considerChanged, cvName, getComment, getCvNum, getInfoOnly, getMask, getOpsOnly, getReadOnly, getState, getWriteOnly, isBusy, item, label, maskVal, newValue, offsetVal, setBusy, setState, updateRepresentation
 
Methods inherited from class jmri.jmrit.symbolicprog.AbstractValue
addPropertyChangeListener, getAvailable, removePropertyChangeListener, stateNameFromValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexedEnumVariableValue

public IndexedEnumVariableValue(int row,
                                String name,
                                String comment,
                                String cvName,
                                boolean readOnly,
                                boolean infoOnly,
                                boolean writeOnly,
                                boolean opsOnly,
                                int cvNum,
                                String mask,
                                Vector<CvValue> v,
                                JLabel status,
                                String stdname)

IndexedEnumVariableValue

protected IndexedEnumVariableValue()
Create a null object. Normally only used for tests and to pre-load classes.

Method Detail

usesCVs

public CvValue[] usesCVs()
Description copied from class: VariableValue
Provide access to CVs referenced by this operation

Specified by:
usesCVs in class VariableValue

nItems

public void nItems(int n)

addItem

public void addItem(String s)
Create a new item in the enumeration, with an associated value one more than the last item (or zero if this is the first one added)

Parameters:
s - Name of the enumeration item

addItem

public void addItem(String s,
                    int value)
Create a new item in the enumeration, with a specified associated value.

Parameters:
s - Name of the enumeration item

lastItem

public void lastItem()

setToolTipText

public void setToolTipText(String t)
Description copied from class: VariableValue
Set tooltip text to be used by both the "value" and representations of this Variable.

This is expected to be overridden in subclasses to change their internal info.

Overrides:
setToolTipText in class VariableValue
See Also:
VariableValue.updateRepresentation(javax.swing.JComponent)

rangeVal

public Object rangeVal()
Specified by:
rangeVal in class VariableValue

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener

getValueString

public String getValueString()
Specified by:
getValueString in class VariableValue
Returns:
String that can (usually) be interpreted as an integer

setIntValue

public void setIntValue(int i)
Description copied from class: VariableValue
Set the value from a single number. In some cases, e.g. speed tables, this will result in complex behavior, where setIntValue(getIntValue()) results in something unexpected.

Specified by:
setIntValue in class VariableValue

getTextValue

public String getTextValue()
Overrides:
getTextValue in class VariableValue
Returns:
User-desired value, which may or may not be an integer

selectValue

protected void selectValue(int value)
Set to a specific value. This searches for the displayed value, and sets the enum to that particular one. If the value is larger than any defined, a new one is created.

Parameters:
value -

getIntValue

public int getIntValue()
Description copied from class: VariableValue
Get the value as a single number. In some cases, e.g. speed tables, this will result in complex behavior, where setIntValue(getIntValue()) results in something unexpected.

Specified by:
getIntValue in class VariableValue

getValueObject

public Object getValueObject()
Specified by:
getValueObject in class VariableValue
Returns:
Value as a native-form Object

getCommonRep

public Component getCommonRep()
Specified by:
getCommonRep in class VariableValue

setValue

public void setValue(int value)

getNewRep

public Component getNewRep(String format)
Specified by:
getNewRep in class VariableValue

setAvailable

public void setAvailable(boolean a)
Overrides:
setAvailable in class AbstractValue

setCvState

public void setCvState(int state)
Notify the connected CVs of a state change from above

Specified by:
setCvState in class VariableValue
Parameters:
state -

setToRead

public void setToRead(boolean state)
Description copied from class: VariableValue
Simple implementation for the case of a single CV. Intended to be sufficient for many subclasses.

Overrides:
setToRead in class VariableValue

isToRead

public boolean isToRead()
Description copied from class: VariableValue
Simple implementation for the case of a single CV. Intended to be sufficient for many subclasses.

Overrides:
isToRead in class VariableValue

setToWrite

public void setToWrite(boolean state)
Description copied from class: VariableValue
Simple implementation for the case of a single CV. Intended to be sufficient for many subclasses.

Overrides:
setToWrite in class VariableValue

isToWrite

public boolean isToWrite()
Description copied from class: VariableValue
Simple implementation for the case of a single CV. Intended to be sufficient for many subclasses.

Overrides:
isToWrite in class VariableValue

isChanged

public boolean isChanged()
Description copied from class: VariableValue
Determine whether this Variable is "changed", so that "read changes" and "write changes" will act on it.

Specified by:
isChanged in class VariableValue
See Also:
VariableValue.considerChanged(jmri.jmrit.symbolicprog.CvValue)

readChanges

public void readChanges()
Description copied from class: VariableValue
Read the contents of this Variable if it's in a state that indicates it was "changed"

Specified by:
readChanges in class VariableValue
See Also:
VariableValue.isChanged()

writeChanges

public void writeChanges()
Description copied from class: VariableValue
Write the contents of this Variable if it's in a state that indicates it was "changed"

Specified by:
writeChanges in class VariableValue
See Also:
VariableValue.isChanged()

readAll

public void readAll()
Description copied from class: VariableValue
Always read the contents of this Variable

Specified by:
readAll in class VariableValue

writeAll

public void writeAll()
Description copied from class: VariableValue
Always write the contents of this Variable

Specified by:
writeAll in class VariableValue

confirmAll

public void confirmAll()
Description copied from class: VariableValue
Confirm the contents of this Variable

Overrides:
confirmAll in class VariableValue

propertyChange

public void propertyChange(PropertyChangeEvent e)
Specified by:
propertyChange in interface PropertyChangeListener
Specified by:
propertyChange in class VariableValue

dispose

public void dispose()
Specified by:
dispose in class VariableValue


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads