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 inherited from class com.nomagic.magicdraw.properties.Property
DEFAULT_PROPERTY_RESOURCE_PROVIDER, EDITABLE, NULL, NULL_ID_PROPERTY_RESOURCE_PROVIDER, UNDEFINED, VALUE, VALUE_ANNOTATIONS 
 - 
 
- 
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 voidaccept(PropertyVisitor v)Accepts the given visitor.TypePropertyclone()Clones the property.java.lang.StringgetClassType()Returns property class type.java.util.CollectiongetNotSelectableTypes()Returns not selectable elements class types.java.lang.ObjectgetValue()Returns properties value.java.lang.StringgetValueStringRepresentation()Returns value's string representation.booleanisAllowToEnterNewValue()returns true when property allows to enter name of not existing element.booleanisElementValue()returns true when property value is instance of ElementvoidsetElementValue(boolean b)Sets if project root model will be added to the property editor.voidsetPropertyData(java.util.Collection notSelectableTypes, boolean useReverseOnNotSelectable, boolean useUnspecified, boolean allowToEnterNewName)Sets data for property members.voidsetValue(java.lang.Object value)Sets new property value.booleanuseReverseOnNotSelectableTypes()Returns reverse flag for not selectable types.booleanuseUnspecified()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 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:
 acceptin interfacePropertyVisitorAcceptor- Overrides:
 acceptin 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:
 getClassTypein interfacePropertyVisitorAcceptor- Overrides:
 getClassTypein 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 aPropertyChangeEventwith propertyName - property ID, newValue and oldValue. 
- 
getValueStringRepresentation
public java.lang.String getValueStringRepresentation()
Description copied from class:PropertyReturns value's string representation.- Overrides:
 getValueStringRepresentationin classProperty- Returns:
 - string "null" if property does not have value; 
value. toString()if property has value. 
 
 - 
 
 -