Package com.nomagic.magicdraw.properties
Class TypeProperty
- java.lang.Object
-
- com.nomagic.magicdraw.properties.Property
-
- com.nomagic.magicdraw.properties.TypeProperty
-
- All Implemented Interfaces:
PropertyVisitorAcceptor
,java.lang.Cloneable
@OpenApiAll public class TypeProperty extends Property
Property for selecting ModelElement of given type. Editor of this property allows to choose some specific ModelElement from all existing elements in the current project.
Example for selecting some existing class or interface in the project:
ArrayList sel = new ArrayList();
sel.add(ClassTypes.MODELCLASS);
sel.add(ClassTypes.INTERFACE);
TypeProperty prop = new TypeProperty(id, value);
prop.setPropertyData(sel, true, sel, true, false);
...
Object classifier = prop.getValue;
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
mAllowToEnterNewValue
allows or disables free text entering in editor.private boolean
mElementValue
Indicates if property value is instance of Elementprivate java.util.Collection
mNotSelectableTypes
The collection of not selectable elements class types.private boolean
mUseReverseOnNotSelectable
Reverse flag for not selectable types.private boolean
mUseUnspecified
Canbe selected or not? -
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 TypeProperty()
Default constructor.TypeProperty(java.lang.String id, java.lang.Object type)
The property constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(PropertyVisitor v)
Accepts the given visitor.TypeProperty
clone()
Clones the property.java.lang.String
getClassType()
Returns property class type.java.util.Collection
getNotSelectableTypes()
Returns not selectable elements class types.java.lang.Object
getValue()
Returns properties value.java.lang.String
getValueStringRepresentation()
Returns value's string representation.boolean
isAllowToEnterNewValue()
returns true when property allows to enter name of not existing element.boolean
isElementValue()
returns true when property value is instance of Elementvoid
setElementValue(boolean b)
Sets if project root model will be added to the property editor.void
setPropertyData(java.util.Collection notSelectableTypes, boolean useReverseOnNotSelectable, boolean useUnspecified, boolean allowToEnterNewName)
Sets data for property members.void
setValue(java.lang.Object value)
Sets new property value.private void
setValue(java.lang.Object value, boolean isElement)
boolean
useReverseOnNotSelectableTypes()
Returns reverse flag for not selectable types.boolean
useUnspecified()
Returns 'use unspecified' flag for this property.-
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, hashCode, isEditable, isUndefinedState, isValueCompatible, removePropertyChangeListener, setAdditionalProperties, setAdditionalProperty, setDescription, setDescriptionID, setEditable, setGroup, setID, setIntroductoryVersion, setNonEditableReason, setResourceProvider, setResourceProviderID, setSources, setUndefinedState, toString
-
-
-
-
Field Detail
-
mNotSelectableTypes
private java.util.Collection mNotSelectableTypes
The collection of not selectable elements class types.
-
mUseReverseOnNotSelectable
private boolean mUseReverseOnNotSelectable
Reverse flag for not selectable types. If this flag is true, not selectable types will be treated as selectable.
-
mUseUnspecified
private boolean mUseUnspecified
Canbe selected or not?
-
mAllowToEnterNewValue
private boolean mAllowToEnterNewValue
allows or disables free text entering in editor.
-
mElementValue
private boolean mElementValue
Indicates if property value is instance of Element
-
-
Constructor Detail
-
TypeProperty
public TypeProperty()
Default constructor. Value of the property will be null. ID will be empty string. Property is editable.
-
TypeProperty
public TypeProperty(java.lang.String id, @CheckForNull java.lang.Object type)
The property constructor.- Parameters:
id
- the ID of property.type
- some type - ModelElement or String.
-
-
Method Detail
-
accept
public void accept(PropertyVisitor v) throws java.lang.Exception
Accepts the given visitor.- Specified by:
accept
in interfacePropertyVisitorAcceptor
- Overrides:
accept
in classProperty
- Parameters:
v
- the PropertyVisitor.- Throws:
java.lang.Exception
-
clone
public TypeProperty clone()
Clones the property.
-
getClassType
public java.lang.String getClassType()
Returns property class type.- Specified by:
getClassType
in interfacePropertyVisitorAcceptor
- Overrides:
getClassType
in classProperty
- Returns:
- PropertyID.STRING_PROPERTY
- See Also:
PropertyID.STRING_PROPERTY
-
setPropertyData
public void setPropertyData(java.util.Collection notSelectableTypes, boolean useReverseOnNotSelectable, boolean useUnspecified, boolean allowToEnterNewName)
Sets data for property members. This method takes collections of classtypes. You must add into these collections classtypes from constants class ClassTypes. not displayable types will be treated as displayable.- Parameters:
notSelectableTypes
- the collection of not selectable elements class types.useReverseOnNotSelectable
- reverse flag for not selectable types. If this flag is true, not selectable types will be treated as selectable.useUnspecified
- if true, "Unspecified" item will be added into the editor.allowToEnterNewName
- if true editor allows to enter free text (create new type).- See Also:
ClassTypes
-
setElementValue
public void setElementValue(boolean b)
Sets if project root model will be added to the property editor.- Parameters:
b
- iftrue
, project model will be added into the property editor.
-
getNotSelectableTypes
public java.util.Collection getNotSelectableTypes()
Returns not selectable elements class types.- Returns:
- not selectable types.
- See Also:
setPropertyData(java.util.Collection, boolean, boolean, boolean)
-
useReverseOnNotSelectableTypes
public boolean useReverseOnNotSelectableTypes()
Returns reverse flag for not selectable types. If this flag is true, not selectable types will be treated as selectable.- Returns:
- reverse flag value of not selectable types.
- See Also:
setPropertyData(java.util.Collection, boolean, boolean, boolean)
-
useUnspecified
public boolean useUnspecified()
Returns 'use unspecified' flag for this property.- Returns:
- 'use unspecified' flag for this property.
- See Also:
setPropertyData(java.util.Collection, boolean, boolean, boolean)
-
isAllowToEnterNewValue
public boolean isAllowToEnterNewValue()
returns true when property allows to enter name of not existing element.- Returns:
- boolean true when property allows to enter name of not existing element.
-
isElementValue
public boolean isElementValue()
returns true when property value is instance of Element- Returns:
- boolean true when property value is instance of Element
-
getValue
@CheckForNull public java.lang.Object getValue()
Returns properties value.
-
setValue
public void setValue(@CheckForNull java.lang.Object value)
Sets new property value. Will fire aPropertyChangeEvent
with propertyName - property ID, newValue and oldValue.
-
setValue
private void setValue(@CheckForNull java.lang.Object value, boolean isElement)
-
getValueStringRepresentation
public java.lang.String getValueStringRepresentation()
Description copied from class:Property
Returns value's string representation.- Overrides:
getValueStringRepresentation
in classProperty
- Returns:
- string "null" if property does not have value;
value. toString()
if property has value.
-
-