Class Property

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private com.nomagic.utils.ArrayListMap<java.lang.String,​java.lang.Object> additionalProperties
      Additional properties map
      protected static PropertyResourceProvider DEFAULT_PROPERTY_RESOURCE_PROVIDER
      Default property resource provider.
      private java.lang.String description
      Property description
      private java.lang.String descriptionId
      Property description ID.
      private boolean editable
      If the property is not enabled then it's editor should be disabled.
      static java.lang.String EDITABLE
      "Editable" property name
      private boolean frozen
      Value of frozen property can not be changed.
      private java.lang.String groupName
      Property group name
      private java.lang.String id
      Property ID.
      private java.lang.String introductoryVersion  
      private com.nomagic.utils.ExtendedPropertyChangeSupport listeners
      PropertyChangeListeners support.
      private java.lang.String name
      A name of the property
      private java.lang.String nonEditableReason
      Value of reason why property is not editable
      static java.lang.String NULL
      Representation of null value as string.
      static PropertyResourceProvider NULL_ID_PROPERTY_RESOURCE_PROVIDER
      A resource provider which does not try to translate property ID.
      private PropertyResourceProvider resourceProvider
      The resource provider for this property.
      private java.lang.String resourceProviderID
      Id of resource provider, which should be registered to application to be used.
      private java.util.Collection<com.nomagic.magicdraw.uml.ElementReference<java.lang.Object>> sources
      Source of the property.
      static java.lang.String UNDEFINED
      Property "undefined" state literal.
      private boolean undefinedState
      Set undefined state.
      private java.lang.Object value
      The value of the property.
      static java.lang.String VALUE
      "Value" property name
    • Constructor Summary

      Constructors 
      Constructor Description
      Property()
      Constructs new property.
      Property​(java.lang.String id, java.lang.Object value)
      The property constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.Object _getValue()  
      boolean _isFrozen()  
      void _setFrozen​(boolean frozen)
      This is an internal api method to mark property as frozen.
      protected void _setValue​(java.lang.Object value)  
      void accept​(PropertyVisitor v)
      Accepts the given visitor.
      void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)
      Delegates addPropertyChangeListener to the PropertyChangeSupport, the member of this class, which adds a PropertyChangeListener to the listener list.
      void addSource​(java.lang.Object source)
      Add source object to a project.
      void addSources​(java.util.Collection<?> sources)
      Append given sources to already existing ones.
      protected boolean areValuesEqual​(java.lang.Object oldValue, java.lang.Object newValue)
      Check if values are equal before setting new value.
      protected void checkFrozen()  
      protected void checkFrozen​(java.util.function.Supplier<java.lang.String> detailsSupplier)  
      Property clone()
      Clones the property.
      javax.swing.CellEditor createCellEditor​(com.nomagic.magicdraw.properties.ui.jideui.RendererEditorFactory factory)
      Returns the cell editor which edits this property in swing table.
      javax.swing.table.TableCellRenderer createTableCellRenderer​(com.nomagic.magicdraw.properties.ui.jideui.RendererEditorFactory factory)
      Returns the cell renderer which renders this property in swing table.
      boolean equals​(java.lang.Object o)
      Properties are equal if their id are equals.
      void firePropertyChange​(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
      Delegates firePropertyChange to the PropertyChangeSupport, the member of this class, which reports a bound property update to any registered listeners.
      static java.lang.String generateDefaultDescriptionID​(Property property)
      Generates default property description id from property id
      java.util.Map<java.lang.String,​java.lang.Object> getAdditionalProperties()
      Return a map structure of attached tags to this property.
      <T> T getAdditionalProperty​(java.lang.String tag)
      Return attached "tag" like string value
      java.lang.String getClassType()
      Returns property class type.
      java.lang.String getDescription()
      Returns property description from resource provider by property description id.
      java.lang.String getDescriptionID()
      Returns property description ID.
      Element getFirstElementFromSources()
      Looks for a first Element among sources.
      java.lang.String getGroup()
      Returns group name for property.
      java.lang.String getID()
      Returns property id.
      java.lang.String getIntroductoryVersion()
      Get application version the property was introduced in.
      java.lang.String getName()
      Returns name of the property.
      java.lang.String getNonEditableReason()
      Returns the property reason
      Project getProjectFromSourcesOrActive()
      Looks for a project of property's sources
      java.lang.String getPureDescription()
      Returns pure description - does not goes into resource provider.
      PropertyResourceProvider getResourceProvider()
      Returns PropertyResourceProvider.
      java.lang.String getResourceProviderID()
      Returns Resource provider ID.
      Element getSourceAsElement()
      Returns source as Element if property has just one source and that source is an Element
      java.util.Collection<?> getSources()
      Return a collection of property sources.
      java.util.stream.Stream<java.lang.Object> getSourcesAsStream()
      Return a stream of property sources.
      static java.lang.String getUndefinedString()
      Returns representation string for "undefined" property state
      static java.lang.String getUndefinedString​(Property property)
      Returns representation string for "undefined" property state.
      java.lang.Object getValue()
      Returns properties value.
      java.lang.String getValueStringRepresentation()
      Returns value's string representation.
      int hashCode()
      The hash code will be the same as ID's hash code.
      boolean isEditable()
      Gets mEnabled flag's value.
      boolean isUndefinedState()
      Returns value undefined state flag.
      protected boolean isValueCompatible​(java.lang.Object value)  
      void removePropertyChangeListener​(java.beans.PropertyChangeListener listener)
      Delegates removePropertyChangeListener to the PropertyChangeSupport, the member of this class, which removes a PropertyChangeListener from the listener list.
      void setAdditionalProperties​(java.util.Map<java.lang.String,​java.lang.Object> tags)
      Replace current tags with a new ones
      void setAdditionalProperty​(java.lang.String key, java.lang.Object value)
      Attach tag like key-value information to a property
      void setDescription​(java.lang.String description)
      Set property description
      void setDescriptionID​(java.lang.String descriptionID)
      Set property description ID.
      void setEditable​(boolean editable)
      Set mEnabled flag's value.
      void setGroup​(java.lang.String group)
      Sets new group name.
      void setID​(java.lang.String id)
      Sets property id.
      void setIntroductoryVersion​(java.lang.String introductoryVersion)
      Set application version property is introduced in.
      void setNonEditableReason​(java.lang.String reason)
      Sets the property reason
      void setResourceProvider​(PropertyResourceProvider provider)
      Sets PropertyResourceProvider for this property.
      void setResourceProviderID​(java.lang.String resourceProviderID)
      Set resource provider ID.
      void setSources​(java.util.Collection<?> sources)
      Set property's sources.
      void setUndefinedState​(boolean value)
      Sets undefined state for this property.
      void setValue​(java.lang.Object value)
      Sets new property value.
      java.lang.String toString()
      Return string representation of property for debug purposes.
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • name

        @CheckForNull
        private java.lang.String name
        A name of the property
      • VALUE

        public static final java.lang.String VALUE
        "Value" property name
        See Also:
        Constant Field Values
      • EDITABLE

        public static final java.lang.String EDITABLE
        "Editable" property name
        See Also:
        Constant Field Values
      • UNDEFINED

        public static final java.lang.String UNDEFINED
        Property "undefined" state literal. The PropertyChangeEvent.getPropertyName() return this string when state of the property changes it's "undefined" state.
        See Also:
        setUndefinedState(boolean), Constant Field Values
      • NULL

        public static final java.lang.String NULL
        Representation of null value as string.
        See Also:
        Constant Field Values
      • DEFAULT_PROPERTY_RESOURCE_PROVIDER

        protected static final PropertyResourceProvider DEFAULT_PROPERTY_RESOURCE_PROVIDER
        Default property resource provider.
      • frozen

        private boolean frozen
        Value of frozen property can not be changed.
      • nonEditableReason

        private java.lang.String nonEditableReason
        Value of reason why property is not editable
      • NULL_ID_PROPERTY_RESOURCE_PROVIDER

        public static final PropertyResourceProvider NULL_ID_PROPERTY_RESOURCE_PROVIDER
        A resource provider which does not try to translate property ID.
      • listeners

        @CheckForNull
        private com.nomagic.utils.ExtendedPropertyChangeSupport listeners
        PropertyChangeListeners support. Every property fires event on value change.
      • undefinedState

        private boolean undefinedState
        Set undefined state. If two properties with the same id has different values such properties can have undefined state
      • id

        private java.lang.String id
        Property ID. This ID is used as identifier for property.
      • descriptionId

        @CheckForNull
        private java.lang.String descriptionId
        Property description ID.
      • value

        @CheckForNull
        private java.lang.Object value
        The value of the property.
      • groupName

        @CheckForNull
        private java.lang.String groupName
        Property group name
      • editable

        private boolean editable
        If the property is not enabled then it's editor should be disabled.
      • sources

        @CheckForNull
        private java.util.Collection<com.nomagic.magicdraw.uml.ElementReference<java.lang.Object>> sources
        Source of the property. This property is not persistence.
      • additionalProperties

        @CheckForNull
        private com.nomagic.utils.ArrayListMap<java.lang.String,​java.lang.Object> additionalProperties
        Additional properties map
      • description

        @CheckForNull
        private java.lang.String description
        Property description
      • resourceProviderID

        @CheckForNull
        private java.lang.String resourceProviderID
        Id of resource provider, which should be registered to application to be used.
      • introductoryVersion

        @CheckForNull
        private java.lang.String introductoryVersion
    • Constructor Detail

      • Property

        public Property()
        Constructs new property. Property ID will be empty string, property value - null.
      • Property

        public Property​(java.lang.String id,
                        @CheckForNull
                        java.lang.Object value)
        The property constructor.
        Parameters:
        id - the ID of property.
        value - the value of the property.
    • Method Detail

      • getName

        public java.lang.String getName()
        Returns name of the property. Property name is taken from PropertyResourceProvider with key - Property ID.
        Returns:
        name of the property.
      • getID

        public java.lang.String getID()
        Returns property id.
        Returns:
        property ID.
      • setID

        public final void setID​(java.lang.String id)
        Sets property id.
        Parameters:
        id - a new property id.
      • setValue

        public void setValue​(@CheckForNull
                             java.lang.Object value)
        Sets new property value. Will fire a PropertyChangeEvent with propertyName - property ID, newValue and oldValue.
        Parameters:
        value - a new property value.
      • isValueCompatible

        protected boolean isValueCompatible​(java.lang.Object value)
        Returns:
        true if given object can be assigned as value to this property
      • areValuesEqual

        protected boolean areValuesEqual​(java.lang.Object oldValue,
                                         java.lang.Object newValue)
        Check if values are equal before setting new value. If values are equal value is not changed.
        Parameters:
        oldValue - current value.
        newValue - new value.
        Returns:
        true if values are equal.
      • equals

        public boolean equals​(java.lang.Object o)
        Properties are equal if their id are equals.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - some other Property.
      • hashCode

        public int hashCode()
        The hash code will be the same as ID's hash code.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        property hash code.
      • getValue

        public java.lang.Object getValue()
        Returns properties value.
        Returns:
        value of the property.
      • getValueStringRepresentation

        public java.lang.String getValueStringRepresentation()
        Returns value's string representation.
        Returns:
        string "null" if property does not have value; value. toString() if property has value.
      • accept

        public void accept​(PropertyVisitor v)
                    throws java.lang.Exception
        Accepts the given visitor.
        Specified by:
        accept in interface PropertyVisitorAcceptor
        Parameters:
        v - the PropertyVisitor.
        Throws:
        java.lang.Exception
      • createCellEditor

        @CheckForNull
        @NotApi
        public javax.swing.CellEditor createCellEditor​(com.nomagic.magicdraw.properties.ui.jideui.RendererEditorFactory factory)
        Returns the cell editor which edits this property in swing table.
        Parameters:
        factory - factory
        Returns:
        null here.
      • createTableCellRenderer

        @CheckForNull
        @NotApi
        public javax.swing.table.TableCellRenderer createTableCellRenderer​(com.nomagic.magicdraw.properties.ui.jideui.RendererEditorFactory factory)
        Returns the cell renderer which renders this property in swing table.
        Parameters:
        factory - factory
        Returns:
        null here.
      • clone

        public Property clone()
        Clones the property. Clone is not deep, the clone will have the same instance of value. The clone will not have registered PropertyChangeListeners.
        Overrides:
        clone in class java.lang.Object
        Returns:
        the cloned property.
      • setUndefinedState

        public void setUndefinedState​(boolean value)
        Sets undefined state for this property. Notifies property change listeners if property undefined state changes.
        Parameters:
        value - the new value of undefined state flag.
      • isUndefinedState

        public boolean isUndefinedState()
        Returns value undefined state flag.
        Returns:
        value value of undefined state flag.
      • addPropertyChangeListener

        public void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)
        Delegates addPropertyChangeListener to the PropertyChangeSupport, the member of this class, which adds a PropertyChangeListener to the listener list.
        Parameters:
        listener - the PropertyChangeListener to be added
        See Also:
        PropertyChangeSupport
      • firePropertyChange

        public void firePropertyChange​(java.lang.String propertyName,
                                       @CheckForNull
                                       java.lang.Object oldValue,
                                       @CheckForNull
                                       java.lang.Object newValue)
        Delegates firePropertyChange to the PropertyChangeSupport, the member of this class, which reports a bound property update to any registered listeners. No event is fired if old and new are equal and non-null.
        Parameters:
        propertyName - the programmatic name of the property that was changed.
        oldValue - the old value of the property
        newValue - the new value of the property
        See Also:
        PropertyChangeSupport
      • removePropertyChangeListener

        public void removePropertyChangeListener​(java.beans.PropertyChangeListener listener)
        Delegates removePropertyChangeListener to the PropertyChangeSupport, the member of this class, which removes a PropertyChangeListener from the listener list.
        Parameters:
        listener - the PropertyChangeListener to be removed
        See Also:
        PropertyChangeSupport
      • toString

        public java.lang.String toString()
        Return string representation of property for debug purposes.
        Overrides:
        toString in class java.lang.Object
        Returns:
        string representation of the property.
      • getResourceProviderID

        @CheckForNull
        public java.lang.String getResourceProviderID()
        Returns Resource provider ID.
        Returns:
        id of resource provider.
      • setResourceProviderID

        public void setResourceProviderID​(@CheckForNull
                                          java.lang.String resourceProviderID)
        Set resource provider ID.
        Parameters:
        resourceProviderID - resource provider id
      • setResourceProvider

        public void setResourceProvider​(@CheckForNull
                                        PropertyResourceProvider provider)
        Sets PropertyResourceProvider for this property.
        Parameters:
        provider - the given provider.
      • getResourceProvider

        public PropertyResourceProvider getResourceProvider()
        Returns PropertyResourceProvider. If property does not have resource provider returns shared instance of DefaultPropertyResourceProvider.
        Returns:
        set PropertyResourceProvider or default one.
      • getGroup

        @CheckForNull
        public java.lang.String getGroup()
        Returns group name for property. Properties with same group can be grouped in GUI.
        Returns:
        Returns group name for property. Can be null.
      • setGroup

        public void setGroup​(@CheckForNull
                             java.lang.String group)
        Sets new group name.
        Parameters:
        group - group name, can be null.
      • getDescriptionID

        @CheckForNull
        public java.lang.String getDescriptionID()
        Returns property description ID.
        Returns:
        description id.
      • setDescriptionID

        public void setDescriptionID​(@CheckForNull
                                     java.lang.String descriptionID)
        Set property description ID.
        Parameters:
        descriptionID - description id.
      • setDescription

        public void setDescription​(@CheckForNull
                                   java.lang.String description)
        Set property description
        Parameters:
        description - description
      • getDescription

        @CheckForNull
        public java.lang.String getDescription()
        Returns property description from resource provider by property description id. May be null.
        Returns:
        description of the property.
      • getPureDescription

        @CheckForNull
        public java.lang.String getPureDescription()
        Returns pure description - does not goes into resource provider.
        Returns:
        description
      • generateDefaultDescriptionID

        public static java.lang.String generateDefaultDescriptionID​(Property property)
        Generates default property description id from property id
        Parameters:
        property - the given property.
        Returns:
        description id.
      • isEditable

        public boolean isEditable()
        Gets mEnabled flag's value.
        Returns:
        true if editing of the property is enabled, otherwise - false.
      • setEditable

        public void setEditable​(boolean editable)
        Set mEnabled flag's value.
        Parameters:
        editable - new value.
      • getUndefinedString

        public static java.lang.String getUndefinedString()
        Returns representation string for "undefined" property state
        Returns:
        "undefined" representation string
      • getUndefinedString

        public static java.lang.String getUndefinedString​(Property property)
        Returns representation string for "undefined" property state. Property can define its own "undefined" representation string by setting additional property QPropertiesHelper.UNDEFINED_STRING.
        Parameters:
        property - property for which undefined string is get.
        Returns:
        "undefined" representation string
      • setSources

        public void setSources​(java.util.Collection<?> sources)
        Set property's sources.
        Parameters:
        sources - sources
        See Also:
        getSources()
      • addSources

        public void addSources​(java.util.Collection<?> sources)
        Append given sources to already existing ones.
        Parameters:
        sources - sources to append
        See Also:
        getSources()
      • addSource

        public void addSource​(java.lang.Object source)
        Add source object to a project.
        Parameters:
        source - source object
        See Also:
        getSources()
      • getAdditionalProperty

        @CheckForNull
        public <T> T getAdditionalProperty​(java.lang.String tag)
        Return attached "tag" like string value
        Parameters:
        tag - tag key
        Returns:
        value of given key or null
      • setAdditionalProperty

        public void setAdditionalProperty​(java.lang.String key,
                                          @CheckForNull
                                          java.lang.Object value)
        Attach tag like key-value information to a property
        Parameters:
        key - tag key
        value - tag value
      • getAdditionalProperties

        @CheckForNull
        public java.util.Map<java.lang.String,​java.lang.Object> getAdditionalProperties()
        Return a map structure of attached tags to this property.
        Returns:
        tags
        See Also:
        setAdditionalProperty(String, Object)
      • setAdditionalProperties

        public void setAdditionalProperties​(@CheckForNull
                                            java.util.Map<java.lang.String,​java.lang.Object> tags)
        Replace current tags with a new ones
        Parameters:
        tags - new tags
      • _isFrozen

        public boolean _isFrozen()
        Returns:
        true if property is frozen
      • _setFrozen

        public void _setFrozen​(boolean frozen)
        This is an internal api method to mark property as frozen. Value of frozen property can not be changed - runtime exception will be thrown
        Parameters:
        frozen - frozen property state
      • getNonEditableReason

        public java.lang.String getNonEditableReason()
        Returns the property reason
        Returns:
        property reason, if reason is null returns empty string
      • setNonEditableReason

        public void setNonEditableReason​(java.lang.String reason)
        Sets the property reason
        Parameters:
        reason - reason why property is not editable
      • getProjectFromSourcesOrActive

        public Project getProjectFromSourcesOrActive()
        Looks for a project of property's sources
        Returns:
        source's project or active project
      • getFirstElementFromSources

        @CheckForNull
        public Element getFirstElementFromSources()
        Looks for a first Element among sources.
        Returns:
        element
      • getSourceAsElement

        @CheckForNull
        public Element getSourceAsElement()
        Returns source as Element if property has just one source and that source is an Element
        Returns:
        element
      • getIntroductoryVersion

        @CheckForNull
        public java.lang.String getIntroductoryVersion()
        Get application version the property was introduced in.
        Returns:
        application version.
      • setIntroductoryVersion

        public void setIntroductoryVersion​(@CheckForNull
                                           java.lang.String introductoryVersion)
        Set application version property is introduced in.
        Parameters:
        introductoryVersion - current application version or null
      • checkFrozen

        protected void checkFrozen()
      • checkFrozen

        protected void checkFrozen​(@CheckForNull
                                   java.util.function.Supplier<java.lang.String> detailsSupplier)
      • _setValue

        protected final void _setValue​(@CheckForNull
                                       java.lang.Object value)
      • _getValue

        @CheckForNull
        protected final java.lang.Object _getValue()