org.jupe.editors.classdiagram.model.nodes
Class NodeModelElement

java.lang.Object
  extended by org.eclipse.emf.common.notify.impl.AdapterImpl
      extended by org.jupe.editors.classdiagram.model.ModelElement
          extended by org.jupe.editors.classdiagram.model.nodes.NodeModelElement
All Implemented Interfaces:
org.eclipse.emf.common.notify.Adapter, org.eclipse.emf.common.notify.Adapter.Internal, org.eclipse.ui.views.properties.IPropertySource
Direct Known Subclasses:
AbstractClassInterfaceElement, AttributeElement, ClassDiagram, CommentElement, MethodElement, ObjectElement, PackageElement, SlotElement

public abstract class NodeModelElement
extends ModelElement

NodeModelElement is an abstract class for all possible nodes in the model: package, classes etc.

Author:
carlos, Michael Pradel, Emanuel Thomas

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.emf.common.notify.Adapter
org.eclipse.emf.common.notify.Adapter.Internal
 
Field Summary
static java.lang.String CHILD_ADDED_PROP
          PropertyId used to fire an event when a child is added to this diagram.
static java.lang.String CHILD_REMOVED_PROP
          PropertyId used to fire an event when a child is removed from this diagram.
static java.lang.String CONNECTIONS_PROP
          Property ID used to fire an event when either an outgoing or incoming connection is modified.
static java.lang.String LOCATION_PROP
          PropertyId used to fire an event when the location of this node is modified.
static java.lang.String SIZE_PROP
          PropertyId used to fire an event when the size of this node is modified.
static java.lang.String SOURCE_CONNECTIONS_PROP
          Property ID used to fire an event when the list of outgoing connections is modified.
static java.lang.String TARGET_CONNECTIONS_PROP
          Property ID used to fire an event when the list of incoming connections is modified.
 
Fields inherited from class org.jupe.editors.classdiagram.model.ModelElement
GENERAL_CHANGE_PROP
 
Constructor Summary
NodeModelElement()
          Default constructor.
 
Method Summary
 boolean addChild(NodeModelElement child)
          Adds a child to the NodeModelElement.
 void addConnection(ConnectionElement conn)
          Add an incoming or outgoing connection to this shape.
 void addToHash(org.eclipse.uml2.uml.Element uml2Element, NodeModelElement modelElement)
          Add a new element and its corresponding uml2 element to the hash.
 java.util.Set<NodeModelElement> getAllChildren()
          Returns a list with all children including recursively the children of the children etc.
 java.util.List<NodeModelElement> getChildren()
           
 ClassDiagram getClassDiagram()
          Get the class diagram that contains this element.
 org.eclipse.draw2d.geometry.Point getLocation()
          This method should be used to get the location of a NodeModelElement.
 NodeModelElement getParent()
           
 java.lang.Object getPropertyValue(java.lang.Object propertyId)
          Children should override this.
 org.eclipse.draw2d.geometry.Dimension getSize()
           
 java.util.List<ConnectionElement> getSourceConnections()
           
 java.util.List<ConnectionElement> getTargetConnections()
           
 boolean isPropertySet(java.lang.Object propertyId)
          Children should override this.
 void notifyChanged(org.eclipse.emf.common.notify.Notification notification)
          The ModelElement does not handle all types of notifications only ADD and REMOVE.
 boolean removeChild(NodeModelElement child)
          Remove a given child from the NodeModelElement.
 void removeConnection(ConnectionElement connection)
          Remove an incoming or outgoing connection from this shape.
 void removeFromHash(org.eclipse.uml2.uml.Element uml2Element)
          Remove an element from the hash table, that contains all elements and their corresponding uml2 elements.
 boolean removeFromModel()
          Removes this element and all its children from the model.
 void resetPropertyValue(java.lang.Object propertyId)
          Children should override this.
 void setLocation(org.eclipse.draw2d.geometry.Point newLocation)
          Set the location for a NodeModelElement.
 void setPropertyValue(java.lang.Object propertyId, java.lang.Object value)
          Children should override this.
 void setSize(org.eclipse.draw2d.geometry.Dimension newSize)
          Set the size of a NodeModelElement.
 void setSourceConnections(java.util.List<ConnectionElement> newSourceConnections)
          Sets the list of all ConnectionElement which have this NodeModelElements as source.
 void setTargetConnections(java.util.List<ConnectionElement> newTargetConnections)
          Sets the list of all ConnectionElement which have this NodeModelElements as targets.
 
Methods inherited from class org.jupe.editors.classdiagram.model.ModelElement
addPropertyChangeListener, getEditableValue, getPropertyDescriptors, getUML2Element, removePropertyChangeListener, setUML2Element
 
Methods inherited from class org.eclipse.emf.common.notify.impl.AdapterImpl
getTarget, isAdapterForType, setTarget, unsetTarget
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHILD_ADDED_PROP

public static final java.lang.String CHILD_ADDED_PROP
PropertyId used to fire an event when a child is added to this diagram.

See Also:
Constant Field Values

CHILD_REMOVED_PROP

public static final java.lang.String CHILD_REMOVED_PROP
PropertyId used to fire an event when a child is removed from this diagram.

See Also:
Constant Field Values

LOCATION_PROP

public static final java.lang.String LOCATION_PROP
PropertyId used to fire an event when the location of this node is modified.

See Also:
Constant Field Values

SIZE_PROP

public static final java.lang.String SIZE_PROP
PropertyId used to fire an event when the size of this node is modified.

See Also:
Constant Field Values

CONNECTIONS_PROP

public static final java.lang.String CONNECTIONS_PROP
Property ID used to fire an event when either an outgoing or incoming connection is modified.

See Also:
Constant Field Values

SOURCE_CONNECTIONS_PROP

public static final java.lang.String SOURCE_CONNECTIONS_PROP
Property ID used to fire an event when the list of outgoing connections is modified.

See Also:
Constant Field Values

TARGET_CONNECTIONS_PROP

public static final java.lang.String TARGET_CONNECTIONS_PROP
Property ID used to fire an event when the list of incoming connections is modified.

See Also:
Constant Field Values
Constructor Detail

NodeModelElement

public NodeModelElement()
Default constructor.

Method Detail

getLocation

public org.eclipse.draw2d.geometry.Point getLocation()
This method should be used to get the location of a NodeModelElement. Returns a Point indicating the position.

Returns:
location of the NodeModelElement

setLocation

public void setLocation(org.eclipse.draw2d.geometry.Point newLocation)
Set the location for a NodeModelElement.

Parameters:
newLocation - of the NodeModelElement

getSize

public org.eclipse.draw2d.geometry.Dimension getSize()
Returns:
the element's size

setSize

public void setSize(org.eclipse.draw2d.geometry.Dimension newSize)
Set the size of a NodeModelElement.

Parameters:
newSize - of the NodeModelElement

addConnection

public void addConnection(ConnectionElement conn)
Add an incoming or outgoing connection to this shape.

Parameters:
conn - a non-null connection instance
Throws:
java.lang.IllegalArgumentException - if the connection is null or has not distinct endpoints

removeConnection

public void removeConnection(ConnectionElement connection)
Remove an incoming or outgoing connection from this shape.

Parameters:
connection - a non-null connection instance

setSourceConnections

public void setSourceConnections(java.util.List<ConnectionElement> newSourceConnections)
Sets the list of all ConnectionElement which have this NodeModelElements as source.

Parameters:
newSourceConnections - a list of new source connections

setTargetConnections

public void setTargetConnections(java.util.List<ConnectionElement> newTargetConnections)
Sets the list of all ConnectionElement which have this NodeModelElements as targets.

Parameters:
newTargetConnections - a list of new target connections

getSourceConnections

public java.util.List<ConnectionElement> getSourceConnections()
Returns:
a list of all ConnectionElement which have this NodeModelElement as source

getTargetConnections

public java.util.List<ConnectionElement> getTargetConnections()
Returns:
a list of all ConnectionElement which have this NodeModelElement as target

setPropertyValue

public void setPropertyValue(java.lang.Object propertyId,
                             java.lang.Object value)
Description copied from class: ModelElement
Children should override this.

Specified by:
setPropertyValue in interface org.eclipse.ui.views.properties.IPropertySource
Specified by:
setPropertyValue in class ModelElement
See Also:
eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)

resetPropertyValue

public void resetPropertyValue(java.lang.Object propertyId)
Description copied from class: ModelElement
Children should override this.

Specified by:
resetPropertyValue in interface org.eclipse.ui.views.properties.IPropertySource
Specified by:
resetPropertyValue in class ModelElement
See Also:
IPropertySource.resetPropertyValue(java.lang.Object)

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.Object propertyId)
Description copied from class: ModelElement
Children should override this.

Specified by:
getPropertyValue in interface org.eclipse.ui.views.properties.IPropertySource
Specified by:
getPropertyValue in class ModelElement
See Also:
eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)

isPropertySet

public boolean isPropertySet(java.lang.Object propertyId)
Description copied from class: ModelElement
Children should override this.

Specified by:
isPropertySet in interface org.eclipse.ui.views.properties.IPropertySource
Specified by:
isPropertySet in class ModelElement
See Also:
eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)

addChild

public boolean addChild(NodeModelElement child)
Adds a child to the NodeModelElement.

Parameters:
child - to add
Returns:
true if child is added successfully

getChildren

public java.util.List<NodeModelElement> getChildren()
Returns:
reference to the list with all children

getParent

public NodeModelElement getParent()
Returns:
reference to the parent element

getClassDiagram

public ClassDiagram getClassDiagram()
Get the class diagram that contains this element.

Specified by:
getClassDiagram in class ModelElement
Returns:
The containing class diagram, or null if there is none.

removeChild

public boolean removeChild(NodeModelElement child)
Remove a given child from the NodeModelElement.

Parameters:
child - to remove
Returns:
true if removed successfully

removeFromModel

public boolean removeFromModel()
Removes this element and all its children from the model.

Returns:
True if it has been removed successfully, false otherwise.

getAllChildren

public java.util.Set<NodeModelElement> getAllChildren()
Returns a list with all children including recursively the children of the children etc.

Returns:
a list with all children

notifyChanged

public void notifyChanged(org.eclipse.emf.common.notify.Notification notification)
The ModelElement does not handle all types of notifications only ADD and REMOVE. So subclasses should call this method for these cases. Other ones like SET need special treatment for each Element. This implementation will only work with UML2 1.1 due to his implementation. See AddAdapter for details. All implementations in the subclasses should call this super method to handle ADD and REMOVE. It is also necessary to verify that the handleNotifications variable is set to true to avoid notifications for each call of setPropertyValue().

Specified by:
notifyChanged in interface org.eclipse.emf.common.notify.Adapter
Overrides:
notifyChanged in class ModelElement
See Also:
Adapter.notifyChanged(org.eclipse.emf.common.notify.Notification)

addToHash

public void addToHash(org.eclipse.uml2.uml.Element uml2Element,
                      NodeModelElement modelElement)
Add a new element and its corresponding uml2 element to the hash.

Parameters:
uml2Element -
modelElement -

removeFromHash

public void removeFromHash(org.eclipse.uml2.uml.Element uml2Element)
Remove an element from the hash table, that contains all elements and their corresponding uml2 elements.

Parameters:
uml2Element -