pl.edu.agh.cast.model.visual
Class ModelElement

java.lang.Object
  extended by pl.edu.agh.cast.model.visual.ModelElement
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, IPropertyChangeProvider, AttributeValueContainer
Direct Known Subclasses:
ConnectionGroup, Diagram, Legend, Node

public abstract class ModelElement
extends java.lang.Object
implements java.io.Serializable, IPropertyChangeProvider, AttributeValueContainer, java.beans.PropertyChangeListener

An abstract class for a visual model element. Provides implementation for property change support

Author:
anonymous, awos
See Also:
Serialized Form

Field Summary
protected  java.util.SortedMap<Attribute,AttributeValue> _attributeValues
           
static java.lang.String ATTRIBUTE_CHANGE
          Id of an event informing of attribute value changes in model elements.
 
Constructor Summary
protected ModelElement()
           
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Add a property change listener to the object
protected  void bindToAttributeManager()
          Registers this model elements to notifications from its attribute manager about changed properties.
protected  void copyAttributes(AttributeValueContainer target)
          Copies attributes present in current model element to another model element
 void copyAttributeValues(pl.edu.agh.cast.model.mapper.Mappable mappable)
          Copies values of all Attributes of mappable that are registered in this ModelElement's AttributeManager.
protected  void firePropertyChange(java.lang.String property, java.lang.Object oldValue, java.lang.Object newValue)
           
 java.util.List<AttributeValue> getAllValues()
          Returns complete list of attribute values in this container.
abstract  AttributeManager getAttributeManager()
          Returns element's attribute manager
 AttributeValue getAttributeValue(java.lang.String name)
           
 long getMid()
           
 boolean isAttributeEditable(java.lang.String attributeName)
           
 boolean isAttributeSettable(java.lang.String name)
           
 boolean isSaved()
           
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
protected  java.lang.Object readResolve()
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Remove a property change listener to the object
 AttributeValue removePropertyValue(java.lang.String name)
          Removes attribute value from this container.
 void setAttributeValue(java.lang.String name, java.lang.Object newValue)
          Sets a new attribute value, fires change event.
 void setAttributeValue(java.lang.String name, java.lang.Object newValue, AttributeMergePolicy policy)
          Sets a new attribute value according to given AttributeMergePolicy, fires change event.
 void setMid(long mid)
           
 void setSaved(boolean saved)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTRIBUTE_CHANGE

public static final java.lang.String ATTRIBUTE_CHANGE
Id of an event informing of attribute value changes in model elements. In the PropertyChangeEvent, old value is of type AttributeValue, and new value is the AttributeValue.getValue() of the new value.

See Also:
Constant Field Values

_attributeValues

@XStreamConverter(value=AttributeValuesConverter.class)
protected java.util.SortedMap<Attribute,AttributeValue> _attributeValues
Constructor Detail

ModelElement

protected ModelElement()
Method Detail

getAttributeManager

public abstract AttributeManager getAttributeManager()
Returns element's attribute manager

Specified by:
getAttributeManager in interface AttributeValueContainer

getMid

public long getMid()

setMid

public void setMid(long mid)

isSaved

public boolean isSaved()

setSaved

public void setSaved(boolean saved)

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)

getAttributeValue

public AttributeValue getAttributeValue(java.lang.String name)
Specified by:
getAttributeValue in interface AttributeValueContainer

isAttributeSettable

public boolean isAttributeSettable(java.lang.String name)

setAttributeValue

public void setAttributeValue(java.lang.String name,
                              java.lang.Object newValue)
Description copied from interface: AttributeValueContainer
Sets a new attribute value, fires change event.

Specified by:
setAttributeValue in interface AttributeValueContainer
Parameters:
name - name of the attribute to change
newValue - new value of the attribute

setAttributeValue

public void setAttributeValue(java.lang.String name,
                              java.lang.Object newValue,
                              AttributeMergePolicy policy)
Description copied from interface: AttributeValueContainer
Sets a new attribute value according to given AttributeMergePolicy, fires change event. If policy is null then acts the same as AttributeValueContainer.setAttributeValue(String, Object).

Specified by:
setAttributeValue in interface AttributeValueContainer
Parameters:
name - name of the attribute to change
newValue - new value of the attribute
policy - merge policy

isAttributeEditable

public boolean isAttributeEditable(java.lang.String attributeName)
Specified by:
isAttributeEditable in interface AttributeValueContainer

getAllValues

public java.util.List<AttributeValue> getAllValues()
Description copied from interface: AttributeValueContainer
Returns complete list of attribute values in this container. Takes into consideration that registered properties may have changed in the manager, i.e. some values may be obsolete.

Specified by:
getAllValues in interface AttributeValueContainer

removePropertyValue

public AttributeValue removePropertyValue(java.lang.String name)
Description copied from interface: AttributeValueContainer
Removes attribute value from this container.

Specified by:
removePropertyValue in interface AttributeValueContainer
Parameters:
name - name of attribute to remove
Returns:
removed AttributeValue, or null if this attribute's value was not set (see Collection.remove(Object))

copyAttributes

protected void copyAttributes(AttributeValueContainer target)
Copies attributes present in current model element to another model element

Parameters:
target -

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

bindToAttributeManager

protected final void bindToAttributeManager()
Registers this model elements to notifications from its attribute manager about changed properties.


copyAttributeValues

public void copyAttributeValues(pl.edu.agh.cast.model.mapper.Mappable mappable)
Copies values of all Attributes of mappable that are registered in this ModelElement's AttributeManager. If defined, the Attribute.getDefaultMergePolicy() policies are used in order to update particular attribute value.

Parameters:
mappable - Mappable to copy attribute values' from


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