pl.edu.agh.cast.model.attributes
Class AttributeManager

java.lang.Object
  extended by pl.edu.agh.cast.model.attributes.AttributeManager
All Implemented Interfaces:
PropertyChangeListener, Serializable, EventListener, IPropertyChangeProvider
Direct Known Subclasses:
ConnectionGroupAttributeManager, DiagramAttributeManager, LegendAttributeManager, NodeAttributeManager

public abstract class AttributeManager
extends Object
implements Serializable, IPropertyChangeProvider, PropertyChangeListener

Class responsible for holding available attribute types for different model element types. Available attribute types are specific for model element types, such as Node, ConnectionGroup, Legend etc. For convenience, the manager acts as a forwarder of all events fired by its registered attributes. Events have ID ATTRIBUTES_PROPERTY_CHANGE, and oldValue set to corresponding PropertyChangeEvent object that is being forwarded.

Author:
AGH CAST Team
See Also:
Serialized Form

Field Summary
static String ATTRIBUTE_REGISTRATION_STATUS
          ID of the RegistrationStatus property.
static String ATTRIBUTES_PROPERTY_CHANGE
          ID of the AttributesProperty property.
 
Constructor Summary
AttributeManager()
          Default constructor.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
          Add a property change listener to the object.
protected  void firePropertyChange(String property, Object oldValue, Object newValue)
           
 Attribute getAttribute(String id)
          Returns attribute with given id (name).
 Collection<Attribute> getAttributes()
          Returns a collection of registered attributes.
 List<Attribute> getPermanentAttributes()
          Returns list of permanent attributes.
 void init(List<Attribute> attributes)
          Initialize this manager after deserializing attributes.
 boolean isRegisteredId(String id)
          Checks if an attribute with given ID is registered.
 void propertyChange(PropertyChangeEvent evt)
          Forward property change events from single attributes.
protected  Object readResolve()
           
 void registerAttribute(String id, ValueType valueType)
          Registers new Attribute in this manager.
protected  void registerPermanentAttribute(String id, ValueType type, boolean editable, boolean showAsLabel)
          This register method should be used for predefined attributes, i.e.
protected  void registerPermanentAttribute(String id, ValueType type, boolean editable, boolean showAsLabel, String ownerTypeId, String modelExtensionId)
          This register method should be used for attributes defined in domain models.
 void removePropertyChangeListener(PropertyChangeListener l)
          Remove a property change listener to the object.
 void setAttributeIsLabel(String id, boolean showAsLabel)
          Modifies registered attribute's showAsLabel flag.
 void unregisterId(String id)
          Unregisters an attribute from this manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTRIBUTES_PROPERTY_CHANGE

public static final String ATTRIBUTES_PROPERTY_CHANGE
ID of the AttributesProperty property.

See Also:
Constant Field Values

ATTRIBUTE_REGISTRATION_STATUS

public static final String ATTRIBUTE_REGISTRATION_STATUS
ID of the RegistrationStatus property.

See Also:
Constant Field Values
Constructor Detail

AttributeManager

public AttributeManager()
Default constructor.

Method Detail

isRegisteredId

public boolean isRegisteredId(String id)
Checks if an attribute with given ID is registered.

Parameters:
id - ID to check
Returns:
true if an attribute with given ID is registered

getPermanentAttributes

public List<Attribute> getPermanentAttributes()
Returns list of permanent attributes.

Returns:
list of permanent attributes

registerAttribute

public void registerAttribute(String id,
                              ValueType valueType)
Registers new Attribute in this manager.

Parameters:
id - id of the new attribute
valueType - value type of the new attribute

setAttributeIsLabel

public void setAttributeIsLabel(String id,
                                boolean showAsLabel)
Modifies registered attribute's showAsLabel flag.

Parameters:
id - attribute name
showAsLabel - new value of the showAsLabel flag
Throws:
IllegalArgumentException - if attribute name is not registered in this manager

registerPermanentAttribute

protected void registerPermanentAttribute(String id,
                                          ValueType type,
                                          boolean editable,
                                          boolean showAsLabel)
This register method should be used for predefined attributes, i.e. attributes defined in the Core plug-in.


registerPermanentAttribute

protected void registerPermanentAttribute(String id,
                                          ValueType type,
                                          boolean editable,
                                          boolean showAsLabel,
                                          String ownerTypeId,
                                          String modelExtensionId)
This register method should be used for attributes defined in domain models.


getAttributes

public Collection<Attribute> getAttributes()
Returns a collection of registered attributes.

Returns:
an unmodifiable collection of attributes registered in this manager

unregisterId

public void unregisterId(String id)
Unregisters an attribute from this manager. Fires ATTRIBUTE_REGISTRATION_STATUS event with old value set to the removed attribute object and newValue set to null.

Parameters:
id - name of attribute to remove
Throws:
IllegalArgumentException - if attribute was not registered in this manager, or attribute is permanent

getAttribute

public Attribute getAttribute(String id)
Returns attribute with given id (name).

Parameters:
id - attribute name
Returns:
Attribute object registered in this manager
Throws:
IllegalArgumentException - if attribute id is not registered in this manager

init

public void init(List<Attribute> attributes)
Initialize this manager after deserializing attributes.

Parameters:
attributes - list of attributes to register

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Forward property change events from single attributes.

Specified by:
propertyChange in interface PropertyChangeListener
See Also:
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)

readResolve

protected Object readResolve()

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)
Add a property change listener to the object.

Specified by:
addPropertyChangeListener in interface IPropertyChangeProvider
Parameters:
l - property change listener
See Also:
IPropertyChangeProvider.addPropertyChangeListener(java.beans.PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)
Remove a property change listener to the object.

Specified by:
removePropertyChangeListener in interface IPropertyChangeProvider
Parameters:
l - property change listener
See Also:
#removePropertyChangeListener(java.beans.PropertyChangeListener)

firePropertyChange

protected void firePropertyChange(String property,
                                  Object oldValue,
                                  Object newValue)


Copyright © 2007-2009 IISG AGH-UST Krakow, Poland. All Rights Reserved.