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

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

public abstract class AttributeManager
extends java.lang.Object
implements java.io.Serializable, IPropertyChangeProvider, java.beans.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:
lab, awos
See Also:
Serialized Form

Field Summary
static java.lang.String ATTRIBUTE_REGISTRATION_STATUS
           
static java.lang.String ATTRIBUTES_PROPERTY_CHANGE
           
 
Constructor Summary
AttributeManager()
           
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Add a property change listener to the object
protected  void firePropertyChange(java.lang.String property, java.lang.Object oldValue, java.lang.Object newValue)
           
 Attribute getAttribute(java.lang.String id)
          Returns attribute with given id (name).
 java.util.Collection<Attribute> getAttributes()
           
 java.util.List<Attribute> getPermanentAttributes()
           
 void init(java.util.List<Attribute> attributes)
          Initialise this manager after deserializing attributes
 boolean isRegisteredId(java.lang.String id)
           
 void propertyChange(java.beans.PropertyChangeEvent evt)
          Forward property change events from single attributes
protected  java.lang.Object readResolve()
           
 void registerAttribute(java.lang.String id, ValueType valueType)
           
protected  void registerPermanentAttribute(java.lang.String id, ValueType type, boolean editable, boolean showAsLabel)
          This register method should be used for predefined attributes, i.e.
protected  void registerPermanentAttribute(java.lang.String id, ValueType type, boolean editable, boolean showAsLabel, java.lang.String ownerTypeId, java.lang.String modelExtensionId)
          This register method should be used for attributes defined in domain models.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Remove a property change listener to the object
 void setAttributeIsLabel(java.lang.String id, boolean showAsLabel)
          Modifies registered attribute's showAsLabel flag.
 void unregisterId(java.lang.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 java.lang.String ATTRIBUTES_PROPERTY_CHANGE
See Also:
Constant Field Values

ATTRIBUTE_REGISTRATION_STATUS

public static final java.lang.String ATTRIBUTE_REGISTRATION_STATUS
See Also:
Constant Field Values
Constructor Detail

AttributeManager

public AttributeManager()
Method Detail

isRegisteredId

public boolean isRegisteredId(java.lang.String id)

getPermanentAttributes

public java.util.List<Attribute> getPermanentAttributes()

registerAttribute

public void registerAttribute(java.lang.String id,
                              ValueType valueType)

setAttributeIsLabel

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

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

registerPermanentAttribute

protected void registerPermanentAttribute(java.lang.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(java.lang.String id,
                                          ValueType type,
                                          boolean editable,
                                          boolean showAsLabel,
                                          java.lang.String ownerTypeId,
                                          java.lang.String modelExtensionId)
This register method should be used for attributes defined in domain models.


getAttributes

public java.util.Collection<Attribute> getAttributes()

unregisterId

public void unregisterId(java.lang.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:
java.lang.IllegalArgumentException - if attribute was not registered in this manager, or attribute is permanent

getAttribute

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

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

init

public void init(java.util.List<Attribute> attributes)
Initialise this manager after deserializing attributes

Parameters:
attributes -

propertyChange

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

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

readResolve

protected java.lang.Object readResolve()

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Description copied from interface: IPropertyChangeProvider
Add a property change listener to the object

Specified by:
addPropertyChangeListener in interface IPropertyChangeProvider

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Description copied from interface: IPropertyChangeProvider
Remove a property change listener to the object

Specified by:
removePropertyChangeListener in interface IPropertyChangeProvider

firePropertyChange

protected void firePropertyChange(java.lang.String property,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)


Copyright © 2007-2008 AGH University of Science and Technology. All Rights Reserved.