pl.edu.agh.cast.data.model.presentation
Class PresentationElement<T extends IElement>

java.lang.Object
  extended by pl.edu.agh.cast.data.model.property.PropertyContainer
      extended by pl.edu.agh.cast.data.model.AbstractElement
          extended by pl.edu.agh.cast.data.model.presentation.PresentationElement<T>
Type Parameters:
T - type of referenced (presented) elements
All Implemented Interfaces:
Serializable, Observer, IDisposable, IReplicable, IValidatable, Identifiable, IElement, IPresentationElement<T>, IPropertyChangeProvider, IPropertyContainer
Direct Known Subclasses:
SchemaConnection, SchemaNode

public abstract class PresentationElement<T extends IElement>
extends AbstractElement
implements IPresentationElement<T>

PresentationElement is a base class for elements of presentation models such as schema nodes or time-lines.

Author:
AGH CAST Team
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface pl.edu.agh.cast.data.model.presentation.IPresentationElement
IPresentationElement.Properties, IPresentationElement.PropertyCategory
 
Field Summary
 
Fields inherited from interface pl.edu.agh.cast.data.model.presentation.IPresentationElement
ATTRIBUTE_CHANGE_EVENT, TYPE
 
Constructor Summary
protected PresentationElement(IPresentationDataSet<? extends IPresentationElement<?>> dataSet, Type type)
          The constructor for presentation elements created manually.
protected PresentationElement(IPresentationDataSet<? extends IPresentationElement<?>> dataSet, Type type, IReferenceList<T> references)
          The constructor for presentation elements created manually.
protected PresentationElement(IPresentationDataSet<? extends IPresentationElement<?>> dataSet, Type type, Type derivedType)
          The constructor for presentation elements created manually.
protected PresentationElement(IPresentationDataSet<? extends IPresentationElement<?>> dataSet, Type type, UUID id)
          The constructor for presentation elements created manually.
protected PresentationElement(IPresentationDataSet<? extends IPresentationElement<?>> dataSet, Type type, UUID id, IReferenceList<T> references)
          The constructor for presentation elements created manually.
protected PresentationElement(Type type)
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add a property change listener to the object.
protected  boolean checkIfValid()
          Checks if the element is valid.
protected abstract  IVisualElement createVisualElement()
          Creates a new visual element to be associated with this presentation element.
protected  void firePropertyChange(String property, Object oldValue, Object newValue)
          Fires the property change event.
 Type getDerivedType()
          The derived type of the element is based on the type of the element(s) from the domain model wrapped by this presentation element.
 String getLabel()
          Label getter.
 List<? extends T> getOriginalElements()
          Returns the original elements which are presented by this presentation element.
<V extends IVisualElement<? extends IPresentationElement<T>>>
V
getVisualElement()
          Returns the visual element associated with this presentation element.
 boolean hasAssociatedVisualElement()
          Checks if any visual element is associated with this presentation element.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Remove a property change listener to the object.
 PresentationElement<T> replicateTo(Object replica)
          Replicates this instance state to given replica object.
 void setDerivedType(Type derivedType)
          The derived type setter may be invoked only if there is no domain model element, given presentation element is based on (i.e.
 void setLabel(String label)
          Label setter.
 void setOriginalElements(List<? extends T> elements)
          Sets the original elements which are presented by this presentation elements.
 void setSuppressAllEvents(boolean flag)
          Sets suppress all events flag.
 void setVisualElement(IVisualElement visualElement)
          Sets the visual element associated with this presentation element.
 
Methods inherited from class pl.edu.agh.cast.data.model.AbstractElement
afterSetMetaPropertyManager, canReplicateTo, equals, getDataSet, getDescString, getId, getType, hashCode, isValid, replicate, setDataSet, setId, setType, toString
 
Methods inherited from class pl.edu.agh.cast.data.model.property.PropertyContainer
addProperty, createProperty, dispose, getCustomProperties, getMetaPropertyManager, getPermanentProperties, getProperties, getProperty, getTransientProperties, initializeProperties, matches, removeProperty, setMetaPropertyManager, setProperty, update
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface pl.edu.agh.cast.data.model.IElement
getDataSet
 
Methods inherited from interface pl.edu.agh.cast.data.model.Identifiable
getId, getType
 
Methods inherited from interface pl.edu.agh.cast.data.model.property.IPropertyContainer
addProperty, getCustomProperties, getMetaPropertyManager, getPermanentProperties, getProperties, getProperty, getTransientProperties, matches, removeProperty, setProperty
 
Methods inherited from interface java.util.Observer
update
 
Methods inherited from interface pl.edu.agh.cast.common.IValidatable
isValid
 
Methods inherited from interface pl.edu.agh.cast.common.IDisposable
dispose
 
Methods inherited from interface pl.edu.agh.cast.common.IReplicable
replicate
 

Constructor Detail

PresentationElement

protected PresentationElement(Type type)

PresentationElement

protected PresentationElement(IPresentationDataSet<? extends IPresentationElement<?>> dataSet,
                              Type type)
The constructor for presentation elements created manually. The presentation element belongs to the presentation data set given in the constructor. The type of the element might be schema node, etc. The ID is randomly generated and the list of referenced elements is empty.

Parameters:
dataSet - the data set given element belongs to
type - the type of the element

PresentationElement

protected PresentationElement(IPresentationDataSet<? extends IPresentationElement<?>> dataSet,
                              Type type,
                              Type derivedType)
The constructor for presentation elements created manually. The presentation element belongs to the presentation data set given in the constructor. The type of the element might be schema node, etc. The ID is randomly generated and the list of referenced elements is empty. The derived type is set as given in the third parameter.

Parameters:
dataSet - the data set given element belongs to
type - the type of the element
derivedType - the type of derived element (for example phone call, bank transfer, etc.); if null than derived type is also set to to null - no exception is thrown

PresentationElement

protected PresentationElement(IPresentationDataSet<? extends IPresentationElement<?>> dataSet,
                              Type type,
                              UUID id)
The constructor for presentation elements created manually. The presentation element belongs to the presentation data set and ID given in the constructor. The type of the element might be schema node, etc. The list of referenced elements is empty.

Parameters:
dataSet - the data set given element belongs to
type - the type of the element
id - the ID of the element

PresentationElement

protected PresentationElement(IPresentationDataSet<? extends IPresentationElement<?>> dataSet,
                              Type type,
                              IReferenceList<T> references)
The constructor for presentation elements created manually. The presentation element belongs to the presentation data set given in the constructor. The type of the element might be schema node, etc. The given list of referenced elements is used. The ID is randomly generated.

Parameters:
dataSet - the data set given element belongs to
type - the type of the element
originalElements - the list of references to represented domain model elements - if null, then empty IReferenceList instance is acquired from ReferenceUtil

PresentationElement

protected PresentationElement(IPresentationDataSet<? extends IPresentationElement<?>> dataSet,
                              Type type,
                              UUID id,
                              IReferenceList<T> references)
The constructor for presentation elements created manually. The presentation element belongs to the presentation data set and ID given in the constructor. The type of the element might be schema node, etc. The given list of referenced elements is used.

Parameters:
dataSet - the data set given element belongs to
type - the type of the element
id - the ID of the element
originalElements - the list of originalElements to represented domain model elements - if null, then empty IReferenceList instance is acquired from ReferenceUtil
Method Detail

checkIfValid

protected boolean checkIfValid()
Checks if the element is valid.

This method is called by the AbstractElement.isValid() method. By default it always returns true, however it can be overridden in order to define new validation rules. In such case the implementation from base class should be called inside the overridden method in order to preserve data consistency.

Overrides:
checkIfValid in class AbstractElement
Returns:
true if the element is valid, false otherwise
See Also:
AbstractElement.checkIfValid()

addPropertyChangeListener

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

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

removePropertyChangeListener

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

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

firePropertyChange

protected final void firePropertyChange(String property,
                                        Object oldValue,
                                        Object newValue)
Fires the property change event.

Parameters:
property - the name of the property
oldValue - the old value of the property
newValue - the new value of the property
See Also:
PropertyChangeProviderHelper.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)

setSuppressAllEvents

public void setSuppressAllEvents(boolean flag)
Sets suppress all events flag. If flag set to true all events will be ignored.

Specified by:
setSuppressAllEvents in interface IPresentationElement<T extends IElement>
Parameters:
flag - suppress all events flag
See Also:
IPresentationDataSet.setSuppressAllEvents(boolean)

getLabel

public String getLabel()
Label getter.

Specified by:
getLabel in interface IPresentationElement<T extends IElement>
Returns:
The label of the element.
See Also:
IPresentationElement.getLabel()

setLabel

public void setLabel(String label)
Label setter.

Specified by:
setLabel in interface IPresentationElement<T extends IElement>
Parameters:
label - The label to set.
See Also:
IPresentationElement.setLabel(java.lang.String)

getDerivedType

public Type getDerivedType()
The derived type of the element is based on the type of the element(s) from the domain model wrapped by this presentation element.

Specified by:
getDerivedType in interface IPresentationElement<T extends IElement>
Returns:
The derived type of the element
See Also:
IPresentationElement.getDerivedType()

setDerivedType

public void setDerivedType(Type derivedType)
The derived type setter may be invoked only if there is no domain model element, given presentation element is based on (i.e. the presentation element was created manually).

Specified by:
setDerivedType in interface IPresentationElement<T extends IElement>
Parameters:
derivedType - The type to set.
See Also:
IPresentationElement.setDerivedType(pl.edu.agh.cast.data.model.Type)

getOriginalElements

public List<? extends T> getOriginalElements()
Returns the original elements which are presented by this presentation element.

Specified by:
getOriginalElements in interface IPresentationElement<T extends IElement>
Returns:
a list of original elements
See Also:
IPresentationElement.getOriginalElements()

setOriginalElements

public void setOriginalElements(List<? extends T> elements)
Sets the original elements which are presented by this presentation elements.

Specified by:
setOriginalElements in interface IPresentationElement<T extends IElement>
Parameters:
elements - a list of original elements presented by this presentation element
See Also:
IPresentationElement.setOriginalElements(java.util.List)

getVisualElement

public <V extends IVisualElement<? extends IPresentationElement<T>>> V getVisualElement()
Returns the visual element associated with this presentation element.

Specified by:
getVisualElement in interface IPresentationElement<T extends IElement>
Type Parameters:
V - the type of expected visual element
Returns:
the associated visual element or null
See Also:
IPresentationElement.getVisualElement()

setVisualElement

public void setVisualElement(IVisualElement visualElement)
Sets the visual element associated with this presentation element.

Specified by:
setVisualElement in interface IPresentationElement<T extends IElement>
Parameters:
visualElement - the associated visual element (null value is allowed)
See Also:
#setVisualElement(pl.edu.agh.cast.data.model.visual.IVisualElement)

createVisualElement

protected abstract IVisualElement createVisualElement()
Creates a new visual element to be associated with this presentation element.

This method should be implemented in each concrete subclass of PresentationElement.

Returns:
a new instance of visual element to be associated with this instance

hasAssociatedVisualElement

public final boolean hasAssociatedVisualElement()
Checks if any visual element is associated with this presentation element.

Specified by:
hasAssociatedVisualElement in interface IPresentationElement<T extends IElement>
Returns:
true if an associated visual element is present
See Also:
IPresentationElement.hasAssociatedVisualElement()

replicateTo

public PresentationElement<T> replicateTo(Object replica)
                                                    throws IllegalArgumentException,
                                                           ReplicationException
Replicates this instance state to given replica object. The replica should be an instance of replicated instance's class (same class or subclass).

Replicates element type and ID.

Replicates element derived type, label and original element list.

Specified by:
replicateTo in interface IReplicable
Overrides:
replicateTo in class AbstractElement
Parameters:
replica - the object to replicate to
Returns:
the replica object (the same instance as given)
Throws:
IllegalArgumentException - if given object is null or of invalid type
ReplicationException - if replication fails
See Also:
AbstractElement.replicateTo(java.lang.Object)


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