Class 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 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
        Can be 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

      • clone

        public TypeProperty clone()
        Clones the property.
        Overrides:
        clone in class Property
        Returns:
        the clone of this 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 - if true, project model will be added into the property editor.
      • 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)
      • 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.
        Overrides:
        getValue in class Property
        Returns:
        value of the property.
      • setValue

        public void setValue​(@CheckForNull
                             java.lang.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.
      • 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 class Property
        Returns:
        string "null" if property does not have value; value. toString() if property has value.