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
Modifier and TypeFieldDescriptionprotected static final PropertyResourceProvider
Default property resource provider.static final String
"Editable" property namestatic final String
Representation of null value as string.static final PropertyResourceProvider
A resource provider which does not try to translate property ID.static final String
static final String
Property "undefined" state literal.static final String
"Value" property namestatic final String
"valueAnnotations" property name -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final Object
boolean
void
_setFrozen
(boolean frozen) This is an internal api method to mark property as frozen.protected final void
void
Accepts the given visitor.void
addAnnotation
(String key, String value) void
DelegatesaddPropertyChangeListener
to thePropertyChangeSupport
, the member of this class, which adds aPropertyChangeListener
to the listener list.void
Add source object to a project.void
addSources
(Collection<?> sources) Append given sources to already existing ones.boolean
areEqualByValue
(Property other) protected boolean
areValuesEqual
(Object oldValue, Object newValue) Check if values are equal before setting new value.protected void
protected void
checkFrozen
(Supplier<String> detailsSupplier) clone()
Clones the property.createCellEditor
(com.nomagic.magicdraw.properties.ui.jideui.RendererEditorFactory factory) Returns the cell editor which edits this property in swing table.createTableCellRenderer
(com.nomagic.magicdraw.properties.ui.jideui.RendererEditorFactory factory) Returns the cell renderer which renders this property in swing table.boolean
Properties are equal if their id are equals.void
firePropertyChange
(String propertyName, Object oldValue, Object newValue) DelegatesfirePropertyChange
to thePropertyChangeSupport
, the member of this class, which reports a bound property update to any registered listeners.static String
generateDefaultDescriptionID
(Property property) Generates default property description id from property idReturn a map structure of attached tags to this property.<T> T
Return 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 String
Returns representation string for "undefined" property statestatic String
getUndefinedString
(Property property) Returns representation string for "undefined" property state.getValue()
Returns properties value.Returns value's string representation.int
hashCode()
The hash code will be the same as ID's hash code.boolean
Gets mEnabled flag's value.boolean
Returns value undefined state flag.protected boolean
isValueCompatible
(Object value) void
removeAnnotation
(String key) void
DelegatesremovePropertyChangeListener
to thePropertyChangeSupport
, the member of this class, which removes a PropertyChangeListener from the listener list.void
setAdditionalProperties
(Map<String, Object> tags) Replace current tags with a new onesvoid
setAdditionalProperty
(String key, Object value) Attach tag like key-value information to a propertyvoid
setAnnotations
(Map<String, String> annotations) void
setDescription
(String description) Set property descriptionvoid
setDescriptionID
(String descriptionID) Set property description ID.void
setEditable
(boolean editable) Set mEnabled flag's value.void
Sets new group name.final void
Sets property id.void
setIntroductoryVersion
(String introductoryVersion) Set application version property is introduced in.void
setNonEditableReason
(String reason) Sets the property reasonvoid
setResourceProvider
(PropertyResourceProvider provider) Sets PropertyResourceProvider for this property.void
setResourceProviderID
(String resourceProviderID) Set resource provider ID.void
setSources
(Collection<?> sources) Set property's sources.void
setUndefinedState
(boolean value) Sets undefined state for this property.void
Sets 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 fromPropertyResourceProvider
with 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 aPropertyChangeEvent
with 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:
accept
in interfacePropertyVisitorAcceptor
- 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
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:
getClassType
in interfacePropertyVisitorAcceptor
- Returns:
- PropertyID.PROPERTY
- See Also:
-
addPropertyChangeListener
DelegatesaddPropertyChangeListener
to thePropertyChangeSupport
, the member of this class, which adds aPropertyChangeListener
to the listener list.- Parameters:
listener
- thePropertyChangeListener
to be added- See Also:
-
firePropertyChange
public void firePropertyChange(String propertyName, @CheckForNull Object oldValue, @CheckForNull Object newValue) DelegatesfirePropertyChange
to 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
DelegatesremovePropertyChangeListener
to 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
PropertyResourceProvider
or 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 project.- 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
-