pl.edu.agh.cast.schema.model.presentation
Class SchemaNode

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<IElement>
              extended by pl.edu.agh.cast.schema.model.presentation.SchemaNode
All Implemented Interfaces:
Serializable, Observer, IDisposable, IReplicable, IValidatable, Identifiable, IElement, IPresentationElement<IElement>, IPropertyChangeProvider, IPropertyContainer, ISchemaElement<IElement>, ISchemaNode

public class SchemaNode
extends PresentationElement<IElement>
implements ISchemaNode

Default implementation of ISchemaNode.

Author:
AGH CAST Team
See Also:
ISchemaNode, 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.schema.model.presentation.ISchemaNode
CONNECTION_EVENT, TYPE
 
Fields inherited from interface pl.edu.agh.cast.data.model.presentation.IPresentationElement
ATTRIBUTE_CHANGE_EVENT
 
Constructor Summary
protected SchemaNode()
          Default constructor.
  SchemaNode(ISchemaDataSet dataSet, IReference<IElement> originalElement)
          The constructor for schema nodes created manually.
  SchemaNode(ISchemaDataSet dataSet, IReferenceList<IElement> originalElements)
          The constructor for schema nodes created manually.
  SchemaNode(ISchemaDataSet dataSet, Type derivedType, String label)
          The constructor for presentation elements created manually.
protected SchemaNode(Type type)
           
 
Method Summary
 void addAllConnections(Collection<? extends ISchemaConnection> connectionsToAdd)
          Adds connections from collection to this node.
 void addConnection(ISchemaConnection connection)
          Adds connection to this node.
protected  IVisualSchemaNode createVisualElement()
          Creates a new visual element to be associated with this presentation element.
 void dispose()
          Remove all connections from the data set during dispose.
 List<? extends ISchemaConnection> getConnections()
          Gets all connections associated with this node.
protected  String getDescString()
          Returns a string with short description of element.
 boolean removeAllConnections(Collection<? extends ISchemaConnection> connectionsToRemove)
          Removes connections from collection to this node.
 boolean removeConnection(ISchemaConnection connection)
          Removes specified connection from this node.
 SchemaNode replicate()
          Returns a replicated instance of this instance.
 SchemaNode replicateTo(Object replica)
          Replicates this instance state to given replica object.
 
Methods inherited from class pl.edu.agh.cast.data.model.presentation.PresentationElement
addPropertyChangeListener, checkIfValid, firePropertyChange, getDerivedType, getLabel, getOriginalElements, getVisualElement, hasAssociatedVisualElement, removePropertyChangeListener, setDerivedType, setLabel, setOriginalElements, setSuppressAllEvents, setVisualElement
 
Methods inherited from class pl.edu.agh.cast.data.model.AbstractElement
afterSetMetaPropertyManager, canReplicateTo, equals, getDataSet, getId, getType, hashCode, isValid, setDataSet, setId, setType, toString
 
Methods inherited from class pl.edu.agh.cast.data.model.property.PropertyContainer
addProperty, createProperty, 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.presentation.IPresentationElement
getDerivedType, getLabel, getOriginalElements, getVisualElement, hasAssociatedVisualElement, setDerivedType, setLabel, setOriginalElements, setSuppressAllEvents, setVisualElement
 
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.data.model.property.IPropertyChangeProvider
addPropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

SchemaNode

protected SchemaNode()
Default constructor.

Usage of this constructor is discouraged, since it does not provide any integrity control. If, however, this constructor is used, the AbstractElement.isValid() method should be called in order to check the integrity.


SchemaNode

protected SchemaNode(Type type)

SchemaNode

public SchemaNode(ISchemaDataSet dataSet,
                  IReference<IElement> originalElement)
The constructor for schema nodes created manually. The schema node belongs to the schema data set given in the constructor. The given list of original elements is used. The ID is randomly generated.

Parameters:
dataSet - the data set this node belongs to
originalElement - a reference to represented domain model element - if null, then empty IReferenceList instance is acquired from ReferenceUtil

SchemaNode

public SchemaNode(ISchemaDataSet dataSet,
                  IReferenceList<IElement> originalElements)
The constructor for schema nodes created manually. The schema node belongs to the schema data set given in the constructor. The given list of original elements is used. The ID is randomly generated.

Parameters:
dataSet - the data set this node belongs to
originalElements - a reference list to represented domain model elements - if null, then empty IReferenceList instance is acquired from ReferenceUtil

SchemaNode

public SchemaNode(ISchemaDataSet dataSet,
                  Type derivedType,
                  String label)
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 this node belongs to
derivedType - derived type
label - node label; if null then default label is set
Method Detail

getConnections

public List<? extends ISchemaConnection> getConnections()
Gets all connections associated with this node.

Specified by:
getConnections in interface ISchemaNode
Returns:
collection of schema connection objects

addAllConnections

public void addAllConnections(Collection<? extends ISchemaConnection> connectionsToAdd)
Adds connections from collection to this node.

Specified by:
addAllConnections in interface ISchemaNode
Parameters:
connectionsToAdd - collection of connections
See Also:
addAllConnections(pl.edu.agh.cast.data.model.IReferenceList)

addConnection

public void addConnection(ISchemaConnection connection)
Adds connection to this node.

Specified by:
addConnection in interface ISchemaNode
Parameters:
connection - connection to add
See Also:
addConnection(pl.edu.agh.cast.schema.model.presentation.ISchemaConnection)

removeAllConnections

public boolean removeAllConnections(Collection<? extends ISchemaConnection> connectionsToRemove)
Removes connections from collection to this node.

Specified by:
removeAllConnections in interface ISchemaNode
Parameters:
connectionsToRemove - collection of connections
Returns:
true if any of the specified connections has been removed
See Also:
ISchemaNode.removeAllConnections(java.util.Collection)

removeConnection

public boolean removeConnection(ISchemaConnection connection)
Removes specified connection from this node. Warning:

Specified by:
removeConnection in interface ISchemaNode
Parameters:
connection - connection to remove
Returns:
true if node was associated with the connection; false otherwise

getDescString

protected String getDescString()
Returns a string with short description of element. This method is used by AbstractElement.toString() and may be overridden in order to customize its results.

Overrides:
getDescString in class AbstractElement
Returns:
a description string
See Also:
AbstractElement.getDescString()

dispose

public void dispose()
Remove all connections from the data set during dispose.

Specified by:
dispose in interface IDisposable
Overrides:
dispose in class PropertyContainer
See Also:
PropertyContainer.dispose()

createVisualElement

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

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

Specified by:
createVisualElement in class PresentationElement<IElement>
Returns:
a new instance of visual element to be associated with this instance
See Also:
PresentationElement.createVisualElement()

replicateTo

public SchemaNode 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.

The lists of connections is empty.

Specified by:
replicateTo in interface IReplicable
Overrides:
replicateTo in class PresentationElement<IElement>
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:
PresentationElement.replicateTo(java.lang.Object)

replicate

public SchemaNode replicate()
                     throws ReplicationException
Returns a replicated instance of this instance.

Specified by:
replicate in interface IReplicable
Overrides:
replicate in class AbstractElement
Returns:
replicated instance
Throws:
ReplicationException - if replication fails
See Also:
IReplicable.replicate()


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