Package com.nomagic.magicdraw.properties
Class PropertyManager
java.lang.Object
com.nomagic.magicdraw.properties.PropertyManager
- All Implemented Interfaces:
PropertyVisitorAcceptor,PropertyChangeListener,Cloneable,EventListener
- Direct Known Subclasses:
ExtendablePropertyManager
@OpenApiAll
public class PropertyManager
extends Object
implements Cloneable, PropertyChangeListener, PropertyVisitorAcceptor
This class is used for managing of the set of the properties. The manager has name. Also manager can
return some property with given property ID.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringIdentifies the property as "unique".static final StringIdentifies type ofPropertyChangeEvent.static final StringIdentifies type ofPropertyChangeEvent. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs new property managerPropertyManager(PropertyManager parentPropertyManager, String name, List<? extends Property> properties) Constructs new property manager.PropertyManager(String name, List<? extends Property> properties) Constructs new property manager. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(PropertyVisitor visitor) Accepts the given visitor.voidaddProperties(Collection<Property> properties) Adds the properties to the property manager.voidaddProperty(Property prop) Adds the property to the property manager.voidAddsPropertyChangeListenerto the listeners list.voidappend(PropertyManager manager) Adds not existing properties from given manager to itself.voidappend(PropertyManager manager, boolean makeUndefined, boolean mergeSources) Adds not existing properties from given manager to itself.voidAdds not existing properties from given list to itself.voidAdds not existing properties from given list to itself.voidapply(PropertyManager manager) Applies properties from given manager.voidapply(Collection<Property> properties) Applies properties from given list.voidapplyValues(Collection<Property> col) Applies properties values only from given list.clone()Clones the manager.cloneProperties(List<Property> properties) voiddistinct(PropertyManager man) Sets to itself properties those are not equal to the given properties.Returns properties those are not equal to the given properties.booleanequalsTo(PropertyManager given) booleanequalsWithValues(PropertyManager pm, Set<String> ids) Check it equals with given property value.static voidstatic voidgenerateNullDescriptionID(PropertyManager manager) Returns property class type.getID()Get IDgetName()Returns name of the property manager.Returns list of properties.Returns the list of the properties.Returns the list of the properties.getProperty(String id) Returns the property from the properties list with given id.getPropertyByName(String name) Returns property from the properties list with given name.getStyle()Get property style.voidhideParentProperty(String propertyID) Hides given property with id from parent property manager.booleanisFrozen()booleanisHiddenParentProperty(String propertyID) Check if property with a given ID is hidden parent propertybooleanisTheSame(PropertyManager manager) Check if given property manager is the same as current.static booleanisUndefinedStateOrValuesDiffer(Property first, Property second) voidleaveTheSame(PropertyManager manager) Removes from this manager all properties those does not exist in the given manager.voidleaveTheSame(PropertyManager manager, boolean makeUndefined, boolean mergeSources) Removes from this manager all properties those does not exist in the given manager.makeCopy()Make copy of property.voidmakeOwnProperty(Property prop) Makes given property as own property even if property with such id is in parent (makes property not shared)protected voidmergeBooleanProperty(BooleanProperty currentProp, BooleanProperty otherProp) protected voidmergeChoiceProperty(ChoiceProperty currentProperty, ChoiceProperty otherProperty) protected voidmergeElementProperty(ElementProperty currentProp, ElementProperty otherProp) protected voidmergeProperties(Property currentManagerProperty, Property property, boolean makeUndefined, boolean mergeSources) protected voidmergePropertyByType(Property currentProperty, Property otherProperty) voidListens toPropertyChangeEvents.voidremoveProperty(Property prop) Removes the property from the property manager.voidremoveProperty(String id) Removes the property with given ID from the property manager.voidremoveProperty(Collection<String> propertyIDs) Removes all properties with given ids.voidRemovesPropertyChangeListenerfrom the listeners list.voidretainProperties(Collection<String> ids) Removes all properties except the the ones with given ids.voidsetFrozen(boolean mFrozen) voidSets id for this property manager.voidSets name of the manager.voidsetParentPropertyManager(PropertyManager parentPropertyManager) Set parent Property Manager.voidsetParentPropertyManagerOnly(PropertyManager parentPropertyManager) Set parent Property Manager.voidsetProperties(List<Property> prop) Sets the list of the properties.voidsetPropertyEnableMap(String propertyId, Object[][] map) Set Property Enable MapvoidSet style.sGetID()Property manager simple ID getter (does not generate ID if it is not present).voidshareProperty(Property prop) Makes given property shared form parent PropertyManager.voidshowParentProperty(String propertyID) Show parent property.toString()Returns info used for debug.
-
Field Details
-
OWN_PROPERTY_ADDED
Identifies type ofPropertyChangeEvent. This type of even is fired when particular property is added toPropertyManagerown properties collection. It may be triggered byaddProperty(Property)ormakeOwnProperty(Property)method call.- See Also:
-
OWN_PROPERTY_REMOVED
Identifies type ofPropertyChangeEvent. This type of even is fired when particular property is removed fromPropertyManagerown properties collection. It may be triggered byremoveProperty(Property)orshareProperty(Property)method call.- See Also:
-
IS_UNIQUE
Identifies the property as "unique". Is set viaProperty.setAdditionalProperty(String, Object):property.setAdditionalProperty(PropertyManager.IS_UNIQUE, true);
Unique property will always be removed when callingleaveTheSame(PropertyManager, boolean, boolean)method.- See Also:
-
-
Constructor Details
-
PropertyManager
public PropertyManager()Constructs new property manager -
PropertyManager
public PropertyManager(@CheckForNull String name, @CheckForNull List<? extends Property> properties) Constructs new property manager.- Parameters:
name- the name of the manager.properties- the list of properties.
-
PropertyManager
public PropertyManager(@CheckForNull PropertyManager parentPropertyManager, @CheckForNull String name, @CheckForNull List<? extends Property> properties) Constructs new property manager.- Parameters:
name- the name of the manager.properties- the list of properties.parentPropertyManager- parent property manager which can provides properties can be shared in this manager.
-
-
Method Details
-
getHiddenProperties
-
getID
Get ID- Returns:
- ID of property.
-
sGetID
Property manager simple ID getter (does not generate ID if it is not present).- Returns:
- property manager ID or
null
-
getParentPropertyManager
-
setParentPropertyManager
Set parent Property Manager.- Parameters:
parentPropertyManager- parent manager
-
setParentPropertyManagerOnly
Set parent Property Manager.- Parameters:
parentPropertyManager- parent manager
-
getProperty
Returns the property from the properties list with given id.- Parameters:
id- the ID of property.- Returns:
- property with given ID. Null if such property is not added into the manager.
-
getPropertyByName
Returns property from the properties list with given name.- Parameters:
name- name of the property- Returns:
- property with given name. Null if such property is not added into the manager.
-
addProperty
Adds the property to the property manager. If property with such ID was already added, the old property is removed. Checking if property with same id already exists in parent property manager, and they value is the same do nothing- Parameters:
prop- the new property.
-
addProperties
Adds the properties to the property manager. If property with such ID was already added, the old property is removed. Checking if property with same id already exists in parent property manager, and they value is the same do nothing- Parameters:
properties- the new properties.
-
removeProperty
Removes the property from the property manager.- Parameters:
prop- the property.
-
removeProperty
Removes the property with given ID from the property manager.- Parameters:
id- the property's ID.
-
getProperties
Returns the list of the properties.- Returns:
- all properties from this manager and parent managers.
-
getOwnProperties
Returns the list of the properties.- Returns:
- all properties only from this manager. List is unmodifiable.
-
setProperties
Sets the list of the properties.- Parameters:
prop- the list of new properties for this manager.
-
getOrderedProperties
Returns list of properties. Properties are stored in list no sorting needed- Returns:
- list of properties
-
clone
Clones the manager. Does deep clone - all properties will be cloned too. -
cloneProperties
-
makeCopy
Make copy of property.- Returns:
- Property Manager.
-
apply
Applies properties from given manager. Property from given manager will be replaced with property from this manager if this manager: 1.has property with such ID. 2.state of this property is not UNDEFINED.- Parameters:
manager- manager which properties will be applied to this.- See Also:
-
apply
Applies properties from given list. Property from given list will be replaced with property from this manager if this manager: 1.has property with such ID. 2.state of this property is not UNDEFINED.- Parameters:
properties- collection of properties to be applied to this.
-
applyValues
Applies properties values only from given list.- Parameters:
col- collection of properties to be applied to this.
-
leaveTheSame
Removes from this manager all properties those does not exist in the given manager. Property will be removed if given manager does not have property with the same ID. Existing property in this manager will be set to undefined state if property in the given manager has different value.- Parameters:
manager- the given manager.
-
leaveTheSame
Removes from this manager all properties those does not exist in the given manager. Property will be removed if given manager does not have property with the same ID and the same value.- Parameters:
manager- the given manager.makeUndefined- existing property in this manager will be set to undefined state if property in given manager has different value.mergeSources- if true, properties sources will be merged
-
mergeProperties
-
mergePropertyByType
-
mergeBooleanProperty
-
mergeElementProperty
-
mergeChoiceProperty
-
setName
Sets name of the manager.- Parameters:
name- the new name.
-
getName
Returns name of the property manager.- Returns:
- the name of the property manager.
-
distinct
Returns properties those are not equal to the given properties.- Parameters:
properties- the given properties.- Returns:
- not equal properties to the given properties or empty list.
-
isUndefinedStateOrValuesDiffer
-
distinct
Sets to itself properties those are not equal to the given properties.- Parameters:
man- the manager with given properties.
-
propertyChange
Listens toPropertyChangeEvents. Takes new value from the event(new value must be a list of properties) and sets these properties to itself.- Specified by:
propertyChangein interfacePropertyChangeListener- Parameters:
e- the property change event.
-
accept
Accepts the given visitor.- Specified by:
acceptin interfacePropertyVisitorAcceptor- Parameters:
visitor- the PropertyVisitor.- Throws:
Exception
-
getClassType
Returns property class type.- Specified by:
getClassTypein interfacePropertyVisitorAcceptor- Returns:
- PropertyID.PROPERTY_MANAGER
- See Also:
-
append
Adds not existing properties from given manager to itself. The properties existence is checked by property ID.- Parameters:
manager- the manager with properties.
-
append
Adds not existing properties from given manager to itself. The properties existence is checked by property ID.- Parameters:
manager- the manager with properties.makeUndefined- existing property in this manager will be set to undefined state if property in given manager has different value.mergeSources- if true, properties sources will be merged
-
append
Adds not existing properties from given list to itself. The properties existence is checked by property ID.- Parameters:
properties- the list of given properties.
-
append
Adds not existing properties from given list to itself. The properties existence is checked by property ID.- Parameters:
properties- the list of given properties.makeUndefined- existing property in this manager will be set to undefined state if property in given manager has different value.mergeSources- if true, properties sources will be merged
-
toString
Returns info used for debug. -
makeOwnProperty
Makes given property as own property even if property with such id is in parent (makes property not shared)- Parameters:
prop- property
-
hideParentProperty
Hides given property with id from parent property manager. Not that if property with this id is in this property manager nothing will be changed.- Parameters:
propertyID- property ID to hide from parent manager;
-
isHiddenParentProperty
Check if property with a given ID is hidden parent property- Parameters:
propertyID- property ID
-
showParentProperty
Show parent property.- Parameters:
propertyID- property ID
-
setID
Sets id for this property manager.- Parameters:
id- new id of this property manager.
-
getStyle
Get property style.- Returns:
- Returns the style.
-
setStyle
Set style.- Parameters:
style- The style to set.
-
setPropertyEnableMap
Set Property Enable Map- Parameters:
propertyId- Property id.map- map
-
addPropertyChangeListener
AddsPropertyChangeListenerto the listeners list. Each listeners receivesOWN_PROPERTY_ADDEDandOWN_PROPERTY_REMOVEDevent types.- Parameters:
listener- thePropertyChangeListenerto be added- See Also:
-
removePropertyChangeListener
RemovesPropertyChangeListenerfrom the listeners list. Each listeners receivesOWN_PROPERTY_ADDEDandOWN_PROPERTY_REMOVEDevent types.- Parameters:
listener- the PropertyChangeListener to be removed- See Also:
-
equalsTo
-
generateDefaultDescriptionID
-
generateNullDescriptionID
-
equalsWithValues
Check it equals with given property value.- Parameters:
pm- The given property value.ids- properties IDs to check (may be null - to check all properties)- Returns:
- boolean
-
removeProperty
Removes all properties with given ids.- Parameters:
propertyIDs- ids of the properties to remove from the manager.
-
retainProperties
Removes all properties except the the ones with given ids.- Parameters:
ids- ids of the properties to leave in the manager.
-
isTheSame
Check if given property manager is the same as current. Managers are the same if names are equal and parent managers are equal- Parameters:
manager- manager- Returns:
- true if the same
-
isFrozen
public boolean isFrozen() -
setFrozen
public void setFrozen(boolean mFrozen)
-