Package com.nomagic.magicdraw.properties
Class ChoiceProperty
- java.lang.Object
-
- com.nomagic.magicdraw.properties.Property
-
- com.nomagic.magicdraw.properties.AbstractChoiceProperty
-
- com.nomagic.magicdraw.properties.ChoiceProperty
-
- All Implemented Interfaces:
PropertyVisitorAcceptor
,java.lang.Cloneable
- Direct Known Subclasses:
LocaleProperty
@OpenApiAll public class ChoiceProperty extends AbstractChoiceProperty
The property selecting some value from a list of possible values or entering a new String value.
-
-
Field Summary
-
Fields inherited from class com.nomagic.magicdraw.properties.Property
DEFAULT_PROPERTY_RESOURCE_PROVIDER, EDITABLE, NULL, NULL_ID_PROPERTY_RESOURCE_PROVIDER, UNDEFINED, VALUE
-
-
Constructor Summary
Constructors Constructor Description ChoiceProperty()
Default constructor.ChoiceProperty(java.lang.String id, int index, java.util.List choice)
The constructor.ChoiceProperty(java.lang.String id, int index, java.util.List choice, int max)
The constructor.ChoiceProperty(java.lang.String id, java.lang.Object value, java.util.List choice)
The constructor.ChoiceProperty(java.lang.String id, java.lang.Object value, java.util.List choice, int max)
The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(PropertyVisitor v)
Accepts thePropertyVisitor
.ChoiceProperty
clone()
Clones the property.java.lang.String
getClassType()
Returns property class type.int
getIndex()
Returns the index of value in the choice list.boolean
isAppendValue()
Return append value flag.void
setAppendValue(boolean appendValue)
Sets the append value flag.void
setChoice(java.util.List val)
Sets the list of possible values for selecting.void
setIndex(int val)
Sets index of selected value.void
setValue(java.lang.Object value)
Sets value of the property.java.lang.String
toString()
The string representation of the property.-
Methods inherited from class com.nomagic.magicdraw.properties.AbstractChoiceProperty
getChoice, isEditableValue, isUndefinedStateAvailable, isValuesTranslatable, setEditableValue, setUndefinedStateAvailable, setValuesTranslatable
-
Methods inherited from class com.nomagic.magicdraw.properties.Property
_getValue, _isFrozen, _setFrozen, _setValue, addPropertyChangeListener, addSource, addSources, areValuesEqual, checkFrozen, checkFrozen, createCellEditor, createTableCellRenderer, equals, firePropertyChange, generateDefaultDescriptionID, getAdditionalProperties, getAdditionalProperty, getDescription, getDescriptionID, getFirstElementFromSources, getGroup, getID, getIntroductoryVersion, getName, getNonEditableReason, getProjectFromSourcesOrActive, getPureDescription, getResourceProvider, getResourceProviderID, getSourceAsElement, getSources, getSourcesAsStream, getUndefinedString, getUndefinedString, getValue, getValueStringRepresentation, hashCode, isEditable, isUndefinedState, isValueCompatible, removePropertyChangeListener, setAdditionalProperties, setAdditionalProperty, setDescription, setDescriptionID, setEditable, setGroup, setID, setIntroductoryVersion, setNonEditableReason, setResourceProvider, setResourceProviderID, setSources, setUndefinedState
-
-
-
-
Constructor Detail
-
ChoiceProperty
public ChoiceProperty()
Default constructor. Value of the property will be null. ID will be empty string.
-
ChoiceProperty
public ChoiceProperty(java.lang.String id, @CheckForNull java.lang.Object value, java.util.List choice)
The constructor.- Parameters:
id
- the ID of property.value
- the value of the property.choice
- the list of possible values.
-
ChoiceProperty
public ChoiceProperty(java.lang.String id, @CheckForNull java.lang.Object value, java.util.List choice, int max)
The constructor.- Parameters:
id
- the ID of property.value
- the value of the property.choice
- the list of possible values.max
- the maximum size of possible values list.
-
ChoiceProperty
public ChoiceProperty(java.lang.String id, int index, java.util.List choice, int max)
The constructor.- Parameters:
id
- the ID of property.index
- the index in choice of selected value.choice
- the list of possible values.max
- the maximum size of possible values list.
-
ChoiceProperty
public ChoiceProperty(java.lang.String id, int index, java.util.List choice)
The constructor.- Parameters:
id
- the ID of property.index
- the index in choice of selected value.choice
- the list of possible values.
-
-
Method Detail
-
isAppendValue
public boolean isAppendValue()
Return append value flag.- Returns:
- the appendValue flag.
-
setAppendValue
public void setAppendValue(boolean appendValue)
Sets the append value flag. If property is editable, entered value is appended to the choice.- Parameters:
appendValue
- the append state of the property.
-
accept
public void accept(PropertyVisitor v) throws java.lang.Exception
Accepts thePropertyVisitor
.- Specified by:
accept
in interfacePropertyVisitorAcceptor
- Overrides:
accept
in classProperty
- Parameters:
v
- the given visitor.- Throws:
java.lang.Exception
-
getIndex
public int getIndex()
Returns the index of value in the choice list.- Returns:
- index of value in the choice list; if value is not in the choice list, return -1.
-
setChoice
public void setChoice(java.util.List val)
Sets the list of possible values for selecting. Sets only mMaximum number of values from the List's beginning.- Overrides:
setChoice
in classAbstractChoiceProperty
- Parameters:
val
- a new possible values list.
-
setIndex
public void setIndex(int val)
Sets index of selected value. The index in possible values' list of new property value.- Parameters:
val
- a new index.
-
setValue
public void setValue(@CheckForNull java.lang.Object value)
Sets value of the property.
-
getClassType
public java.lang.String getClassType()
Returns property class type.- Specified by:
getClassType
in interfacePropertyVisitorAcceptor
- Overrides:
getClassType
in classProperty
- Returns:
- PropertyID.CHOICE_PROPERTY.
- See Also:
PropertyID.CHOICE_PROPERTY
-
toString
public java.lang.String toString()
The string representation of the property. Used for debugging purposes only.
-
clone
public ChoiceProperty clone()
Description copied from class:Property
Clones the property. Clone is not deep, the clone will have the same instance of value. The clone will not have registered PropertyChangeListeners.- Overrides:
clone
in classAbstractChoiceProperty
- Returns:
- the cloned property.
-
-