Class TypeProperty

java.lang.Object
com.nomagic.magicdraw.properties.Property
com.nomagic.magicdraw.properties.TypeProperty
All Implemented Interfaces:
PropertyVisitorAcceptor, 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;
  • Constructor Details

    • TypeProperty

      public TypeProperty()
      Default constructor. Value of the property will be null. ID will be empty string. Property is editable.
    • TypeProperty

      public TypeProperty(String id, @CheckForNull Object type)
      The property constructor.
      Parameters:
      id - the ID of property.
      type - some type - ModelElement or String.
  • Method Details

    • accept

      public void accept(PropertyVisitor v) throws Exception
      Accepts the given visitor.
      Specified by:
      accept in interface PropertyVisitorAcceptor
      Overrides:
      accept in class Property
      Parameters:
      v - the PropertyVisitor.
      Throws:
      Exception
    • clone

      public TypeProperty clone()
      Clones the property.
      Overrides:
      clone in class Property
      Returns:
      the clone of this property.
    • getClassType

      public String getClassType()
      Returns property class type.
      Specified by:
      getClassType in interface PropertyVisitorAcceptor
      Overrides:
      getClassType in class Property
      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 - if true, project model will be added into the property editor.
    • getNotSelectableTypes

      public Collection 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

      @CheckForNull public Object getValue()
      Returns properties value.
      Overrides:
      getValue in class Property
      Returns:
      value of the property.
    • setValue

      public void setValue(@CheckForNull Object value)
      Sets new property value. Will fire a PropertyChangeEvent with propertyName - property ID, newValue and oldValue.
      Overrides:
      setValue in class Property
      Parameters:
      value - a new property value.
    • getValueStringRepresentation

      public String getValueStringRepresentation()
      Description copied from class: Property
      Returns value's string representation.
      Overrides:
      getValueStringRepresentation in class Property
      Returns:
      string "null" if property does not have value; value. toString() if property has value.