Package com.nomagic.magicdraw.properties
Class TypeProperty
java.lang.Object
com.nomagic.magicdraw.properties.Property
com.nomagic.magicdraw.properties.TypeProperty
- All Implemented Interfaces:
PropertyVisitorAcceptor
,Cloneable
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;
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 inherited from class com.nomagic.magicdraw.properties.Property
DEFAULT_PROPERTY_RESOURCE_PROVIDER, EDITABLE, NULL, NULL_ID_PROPERTY_RESOURCE_PROVIDER, TO, UNDEFINED, VALUE, VALUE_ANNOTATIONS
-
Constructor Summary
ConstructorDescriptionDefault constructor.TypeProperty
(String id, Object type) The property constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Accepts the given visitor.clone()
Clones the property.Returns property class type.Returns not selectable elements class types.getValue()
Returns properties value.Returns value's string representation.boolean
returns true when property allows to enter name of not existing element.boolean
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
(Collection notSelectableTypes, boolean useReverseOnNotSelectable, boolean useUnspecified, boolean allowToEnterNewName) Sets data for property members.void
Sets new property value.boolean
Returns reverse flag for not selectable types.boolean
Returns 'use unspecified' flag for this property.Methods inherited from class com.nomagic.magicdraw.properties.Property
_getValue, _isFrozen, _setFrozen, _setValue, addAnnotation, addPropertyChangeListener, addSource, addSources, areEqualByValue, areValuesEqual, checkFrozen, checkFrozen, createCellEditor, createTableCellRenderer, equals, firePropertyChange, generateDefaultDescriptionID, getAdditionalProperties, getAdditionalProperty, getAnnotation, getAnnotations, getDescription, getDescriptionID, getFirstElementFromSources, getGroup, getID, getIntroductoryVersion, getName, getNonEditableReason, getProjectFromSourcesOrActive, getPureDescription, getResourceProvider, getResourceProviderID, getSortableValueStringRepresentation, getSourceAsElement, getSources, getSourcesAsStream, getUndefinedString, getUndefinedString, hashCode, isEditable, isUndefinedState, isValueCompatible, removeAnnotation, removePropertyChangeListener, setAdditionalProperties, setAdditionalProperty, setAnnotations, setDescription, setDescriptionID, setEditable, setGroup, setID, setIntroductoryVersion, setNonEditableReason, setResourceProvider, setResourceProviderID, setSources, setUndefinedState, toString
-
Constructor Details
-
TypeProperty
public TypeProperty()Default constructor. Value of the property will be null. ID will be empty string. Property is editable. -
TypeProperty
The property constructor.- Parameters:
id
- the ID of property.type
- some type - ModelElement or String.
-
-
Method Details
-
accept
Accepts the given visitor.- Specified by:
accept
in interfacePropertyVisitorAcceptor
- Overrides:
accept
in classProperty
- Parameters:
v
- the PropertyVisitor.- Throws:
Exception
-
clone
Clones the property. -
getClassType
Returns property class type.- Specified by:
getClassType
in interfacePropertyVisitorAcceptor
- Overrides:
getClassType
in classProperty
- Returns:
- PropertyID.STRING_PROPERTY
- See Also:
-
setPropertyData
public void setPropertyData(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:
-
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
Returns not selectable elements class types.- Returns:
- not selectable types.
- See Also:
-
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:
-
useUnspecified
public boolean useUnspecified()Returns 'use unspecified' flag for this property.- Returns:
- 'use unspecified' flag for this property.
- See Also:
-
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
Returns properties value. -
setValue
Sets new property value. Will fire aPropertyChangeEvent
with propertyName - property ID, newValue and oldValue. -
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.
-