Class Property

java.lang.Object
com.nomagic.magicdraw.properties.Property
All Implemented Interfaces:
PropertyVisitorAcceptor, Cloneable
Direct Known Subclasses:
AbstractChoiceProperty, BooleanProperty, ColorProperty, ElementProperty, FileProperty, FontProperty, ListProperty, NumberProperty, PageFormatProperty, StringProperty, TypeProperty

@OpenApiAll public class Property extends Object implements Cloneable, PropertyVisitorAcceptor
This class represents some property with some value. This is based class, specific type properties must be derived from this class.
  • Field Details

  • Constructor Details

    • Property

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

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

    • getName

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

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

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

      public void setValue(@CheckForNull 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(Object value)
      Returns:
      true if given object can be assigned as value to this property
    • areValuesEqual

      protected boolean areValuesEqual(Object oldValue, 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(Object o)
      Properties are equal if their id are equals.
      Overrides:
      equals in class 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 Object
      Returns:
      property hash code.
    • getValue

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

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

      public String getSortableValueStringRepresentation()
    • accept

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

      @CheckForNull @NotApi public 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 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 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.
    • getClassType

      public String getClassType()
      Returns property class type.
      Specified by:
      getClassType in interface PropertyVisitorAcceptor
      Returns:
      PropertyID.PROPERTY
      See Also:
    • addPropertyChangeListener

      public void addPropertyChangeListener(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:
    • firePropertyChange

      public void firePropertyChange(String propertyName, @CheckForNull Object oldValue, @CheckForNull 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:
    • removePropertyChangeListener

      public void removePropertyChangeListener(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:
    • toString

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

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

      public void setResourceProviderID(@CheckForNull 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 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 String group)
      Sets new group name.
      Parameters:
      group - group name, can be null.
    • getDescriptionID

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

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

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

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

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

      public static 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 String getUndefinedString()
      Returns representation string for "undefined" property state
      Returns:
      "undefined" representation string
    • getUndefinedString

      public static 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
    • getSources

      public Collection<?> getSources()
      Return a collection of property sources. In most cases property represents a value of some object. In these case that object can be added as Property source if traceability is required from property to source object.
      Returns:
      sources
      See Also:
    • getSourcesAsStream

      public Stream<Object> getSourcesAsStream()
      Return a stream of property sources. In most cases property represents a value of some object. In these case that object can be added as Property source if traceability is required from property to source object.
      Returns:
      sources
      See Also:
    • setSources

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

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

      public void addSource(@CheckForNull Object source)
      Add source object to a project.
      Parameters:
      source - source object
      See Also:
    • getAdditionalProperty

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

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

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

      public void setAdditionalProperties(@CheckForNull Map<String,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 String getNonEditableReason()
      Returns the property reason
      Returns:
      property reason, if reason is null returns empty string
    • setNonEditableReason

      public void setNonEditableReason(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
    • areEqualByValue

      public boolean areEqualByValue(Property other)
    • getIntroductoryVersion

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

      public void setIntroductoryVersion(@CheckForNull 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 Supplier<String> detailsSupplier)
    • _setValue

      protected final void _setValue(@CheckForNull Object value)
    • _getValue

      @CheckForNull protected final Object _getValue()
    • getAnnotations

      @CheckForNull public Map<String,String> getAnnotations()
    • addAnnotation

      public void addAnnotation(String key, @CheckForNull String value)
    • removeAnnotation

      public void removeAnnotation(String key)
    • getAnnotation

      @CheckForNull public String getAnnotation(String id)
    • setAnnotations

      public void setAnnotations(@CheckForNull Map<String,String> annotations)