Package com.nomagic.magicdraw.properties
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
This class represents some property with some value.
 This is based class, specific type properties must be derived from this class.
- 
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final PropertyResourceProviderDefault property resource provider.static final String"Editable" property namestatic final StringRepresentation of null value as string.static final PropertyResourceProviderA resource provider which does not try to translate property ID.static final Stringstatic final StringProperty "undefined" state literal.static final String"Value" property namestatic final String"valueAnnotations" property name - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionprotected final Objectbooleanvoid_setFrozen(boolean frozen) This is an internal api method to mark property as frozen.protected final voidvoidAccepts the given visitor.voidaddAnnotation(String key, String value) voidDelegatesaddPropertyChangeListenerto thePropertyChangeSupport, the member of this class, which adds aPropertyChangeListenerto the listener list.voidAdd source object to a property.voidaddSources(Collection<?> sources) Append given sources to already existing ones.booleanareEqualByValue(Property other) protected booleanareValuesEqual(Object oldValue, Object newValue) Check if values are equal before setting new value.protected voidprotected voidcheckFrozen(Supplier<String> detailsSupplier) clone()Clones the property.booleanProperties are equal if their id are equals.voidfirePropertyChange(String propertyName, Object oldValue, Object newValue) DelegatesfirePropertyChangeto thePropertyChangeSupport, the member of this class, which reports a bound property update to any registered listeners.static StringgenerateDefaultDescriptionID(Property property) Generates default property description id from property idReturn a map structure of attached tags to this property.<T> TReturn attached "tag" like string valuegetAnnotation(String id) Returns property class type.Returns property description from resource provider by property description id.Returns property description ID.Looks for a first Element among sources.getGroup()Returns group name for property.getID()Returns property id.Get application version the property was introduced in.getName()Returns name of the property.Returns the property reasonLooks for a project of property's sourcesReturns pure description - does not goes into resource provider.ReturnsPropertyResourceProvider.Returns Resource provider ID.Returns source as Element if property has just one source and that source is an ElementCollection<?>Return a collection of property sources.Return a stream of property sources.static StringReturns representation string for "undefined" property statestatic StringgetUndefinedString(Property property) Returns representation string for "undefined" property state.getValue()Returns properties value.Returns value's string representation.inthashCode()The hash code will be the same as ID's hash code.booleanGets mEnabled flag's value.booleanReturns value undefined state flag.protected booleanisValueCompatible(Object value) voidremoveAnnotation(String key) voidDelegatesremovePropertyChangeListenerto thePropertyChangeSupport, the member of this class, which removes a PropertyChangeListener from the listener list.voidsetAdditionalProperties(Map<String, Object> tags) Replace current tags with a new onesvoidsetAdditionalProperty(String key, Object value) Attach tag like key-value information to a propertyvoidsetAnnotations(Map<String, String> annotations) voidsetDescription(String description) Set property descriptionvoidsetDescriptionID(String descriptionID) Set property description ID.voidsetEditable(boolean editable) Set mEnabled flag's value.voidSets new group name.final voidSets property id.voidsetIntroductoryVersion(String introductoryVersion) Set application version property is introduced in.voidsetNonEditableReason(String reason) Sets the property reasonvoidsetResourceProvider(PropertyResourceProvider provider) Sets PropertyResourceProvider for this property.voidsetResourceProviderID(String resourceProviderID) Set resource provider ID.voidsetSources(Collection<?> sources) Set property's sources.voidsetUndefinedState(boolean value) Sets undefined state for this property.voidSets new property value.toString()Return string representation of property for debug purposes. 
- 
Field Details
- 
TO
- See Also:
 
 - 
VALUE
"Value" property name- See Also:
 
 - 
VALUE_ANNOTATIONS
"valueAnnotations" property name- See Also:
 
 - 
EDITABLE
"Editable" property name- See Also:
 
 - 
UNDEFINED
Property "undefined" state literal. ThePropertyChangeEvent.getPropertyName()return this string when state of the property changes it's "undefined" state. - 
NULL
Representation of null value as string.- See Also:
 
 - 
DEFAULT_PROPERTY_RESOURCE_PROVIDER
Default property resource provider. - 
NULL_ID_PROPERTY_RESOURCE_PROVIDER
A resource provider which does not try to translate property ID. 
 - 
 - 
Constructor Details
- 
Property
public Property()Constructs new property. Property ID will be empty string, property value - null. - 
Property
The property constructor.- Parameters:
 id- the ID of property.value- the value of the property.
 
 - 
 - 
Method Details
- 
getName
Returns name of the property. Property name is taken fromPropertyResourceProviderwith key - Property ID.- Returns:
 - name of the property.
 
 - 
getID
Returns property id.- Returns:
 - property ID.
 
 - 
setID
Sets property id.- Parameters:
 id- a new property id.
 - 
setValue
Sets new property value. Will fire aPropertyChangeEventwith propertyName - property ID, newValue and oldValue.- Parameters:
 value- a new property value.
 - 
isValueCompatible
- Returns:
 - true if given object can be assigned as value to this property
 
 - 
areValuesEqual
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
Properties are equal if their id are equals. - 
hashCode
public int hashCode()The hash code will be the same as ID's hash code. - 
getValue
Returns properties value.- Returns:
 - value of the property.
 
 - 
getValueStringRepresentation
Returns value's string representation.- Returns:
 - string "null" if property does not have value; 
value. toString()if property has value. 
 - 
getSortableValueStringRepresentation
 - 
accept
Accepts the given visitor.- Specified by:
 acceptin interfacePropertyVisitorAcceptor- Parameters:
 v- the PropertyVisitor.- Throws:
 Exception
 - 
clone
Clones the property. Clone is not deep, the clone will have the same instance of value. The clone will not have registered PropertyChangeListeners. - 
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
Returns property class type.- Specified by:
 getClassTypein interfacePropertyVisitorAcceptor- Returns:
 - PropertyID.PROPERTY
 - See Also:
 
 - 
addPropertyChangeListener
DelegatesaddPropertyChangeListenerto thePropertyChangeSupport, the member of this class, which adds aPropertyChangeListenerto the listener list.- Parameters:
 listener- thePropertyChangeListenerto be added- See Also:
 
 - 
firePropertyChange
public void firePropertyChange(String propertyName, @CheckForNull Object oldValue, @CheckForNull Object newValue) DelegatesfirePropertyChangeto thePropertyChangeSupport, 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 propertynewValue- the new value of the property- See Also:
 
 - 
removePropertyChangeListener
DelegatesremovePropertyChangeListenerto thePropertyChangeSupport, the member of this class, which removes a PropertyChangeListener from the listener list.- Parameters:
 listener- the PropertyChangeListener to be removed- See Also:
 
 - 
toString
Return string representation of property for debug purposes. - 
getResourceProviderID
Returns Resource provider ID.- Returns:
 - id of resource provider.
 
 - 
setResourceProviderID
Set resource provider ID.- Parameters:
 resourceProviderID- resource provider id
 - 
setResourceProvider
Sets PropertyResourceProvider for this property.- Parameters:
 provider- the given provider.
 - 
getResourceProvider
ReturnsPropertyResourceProvider. If property does not have resource provider returns shared instance ofDefaultPropertyResourceProvider.- Returns:
 - set 
PropertyResourceProvideror default one. 
 - 
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
Sets new group name.- Parameters:
 group- group name, can be null.
 - 
getDescriptionID
Returns property description ID.- Returns:
 - description id.
 
 - 
setDescriptionID
Set property description ID.- Parameters:
 descriptionID- description id.
 - 
setDescription
Set property description- Parameters:
 description- description
 - 
getDescription
Returns property description from resource provider by property description id. May be null.- Returns:
 - description of the property.
 
 - 
getPureDescription
Returns pure description - does not goes into resource provider.- Returns:
 - description
 
 - 
generateDefaultDescriptionID
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
Returns representation string for "undefined" property state- Returns:
 - "undefined" representation string
 
 - 
getUndefinedString
Returns representation string for "undefined" property state. Property can define its own "undefined" representation string by setting additional propertyQPropertiesHelper.UNDEFINED_STRING.- Parameters:
 property- property for which undefined string is get.- Returns:
 - "undefined" representation string
 
 - 
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
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
Set property's sources.- Parameters:
 sources- sources- See Also:
 
 - 
addSources
Append given sources to already existing ones.- Parameters:
 sources- sources to append- See Also:
 
 - 
addSource
Add source object to a property.- Parameters:
 source- source object- See Also:
 
 - 
getAdditionalProperty
Return attached "tag" like string value- Parameters:
 tag- tag key- Returns:
 - value of given key or null
 
 - 
setAdditionalProperty
Attach tag like key-value information to a property- Parameters:
 key- tag keyvalue- tag value
 - 
getAdditionalProperties
Return a map structure of attached tags to this property.- Returns:
 - tags
 - See Also:
 
 - 
setAdditionalProperties
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
Returns the property reason- Returns:
 - property reason, if reason is null returns empty string
 
 - 
setNonEditableReason
Sets the property reason- Parameters:
 reason- reason why property is not editable
 - 
getProjectFromSourcesOrActive
Looks for a project of property's sources- Returns:
 - source's project or active project
 
 - 
getFirstElementFromSources
Looks for a first Element among sources.- Returns:
 - element
 
 - 
getSourceAsElement
Returns source as Element if property has just one source and that source is an Element- Returns:
 - element
 
 - 
areEqualByValue
 - 
getIntroductoryVersion
Get application version the property was introduced in.- Returns:
 - application version.
 
 - 
setIntroductoryVersion
Set application version property is introduced in.- Parameters:
 introductoryVersion- current application version ornull
 - 
checkFrozen
protected void checkFrozen() - 
checkFrozen
 - 
_setValue
 - 
_getValue
 - 
getAnnotations
 - 
addAnnotation
 - 
removeAnnotation
 - 
getAnnotation
 - 
setAnnotations
 
 -