org.jupe.editors.classdiagram.model.connections
Class ConnectionElement

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.connections.ConnectionElement
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:
CommentConnectionElement, DependencyElement, GeneralizationElement, InterfaceRealizationElement, RelationElement

public abstract class ConnectionElement
extends ModelElement

Base class for model element that represent a connection between two node elements of a class diagram.

Author:
Steffen Klüpfel, 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 ENDPOINT_PROP
          Property ID for the target NodeModelElement of a connection.
static java.lang.String SOURCE_PROP
          Property ID for the source NodeModelElement of a connection.
 
Fields inherited from class org.jupe.editors.classdiagram.model.ModelElement
GENERAL_CHANGE_PROP
 
Constructor Summary
ConnectionElement()
          Default constructor.
ConnectionElement(NodeModelElement sourceElement, NodeModelElement targetElement)
          Constructor for ConnectionElement which creates a connection between two distinct NodeModelElements.
 
Method Summary
 void disconnect()
          Disconnect this connection from the NodeModelElement it is attached to.
 java.util.List getChildren()
          A connection should not have any children
 ClassDiagram getClassDiagram()
           
 NodeModelElement getEndPoint()
          Returns the endPoint endpoint of this connection.
 NodeModelElement getSource()
          Returns the source endpoint of this connection.
 void reconnect()
          Reconnect this connection.
 void reconnect(NodeModelElement newSource, NodeModelElement newEndPoint)
          Reconnect to a different source and/or endPoint NodeModelElement.
 void setSource(NodeModelElement newSource)
          Set the source endpoint of this connection.
 void setTarget(NodeModelElement newEndPoint)
          Set the endPoint endpoint of this connection.
 void setUML2Element(org.eclipse.uml2.uml.Element uml2Element)
          (non-Javadoc)
 
Methods inherited from class org.jupe.editors.classdiagram.model.ModelElement
addPropertyChangeListener, getEditableValue, getPropertyDescriptors, getPropertyValue, getUML2Element, isPropertySet, notifyChanged, removePropertyChangeListener, resetPropertyValue, setPropertyValue
 
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

SOURCE_PROP

public static final java.lang.String SOURCE_PROP
Property ID for the source NodeModelElement of a connection. Should not be displayed.

Value: None. Property cannot be get or set, but is only used for ModelElement.firePropertyChange(String, Object, Object).

See Also:
Constant Field Values

ENDPOINT_PROP

public static final java.lang.String ENDPOINT_PROP
Property ID for the target NodeModelElement of a connection. Should not be displayed.

Value: None. Property cannot be get or set, but is only used for ModelElement.firePropertyChange(String, Object, Object).

See Also:
Constant Field Values
Constructor Detail

ConnectionElement

public ConnectionElement()
Default constructor.


ConnectionElement

public ConnectionElement(NodeModelElement sourceElement,
                         NodeModelElement targetElement)
Constructor for ConnectionElement which creates a connection between two distinct NodeModelElements.

Parameters:
sourceElement - a source endpoint for this connection (non null)
targetElement - a target endpoint for this connection (non null)
Throws:
java.lang.IllegalArgumentException - if any of the parameters are null or source == target
Method Detail

disconnect

public void disconnect()
Disconnect this connection from the NodeModelElement it is attached to.


getSource

public NodeModelElement getSource()
Returns the source endpoint of this connection.

Returns:
a non-null NodeModelElement instance

setSource

public void setSource(NodeModelElement newSource)
Set the source endpoint of this connection.

Parameters:
newSource - the new source point given as NodeModelElement

getEndPoint

public NodeModelElement getEndPoint()
Returns the endPoint endpoint of this connection.

Returns:
a non-null NodeModelElement instance

setTarget

public void setTarget(NodeModelElement newEndPoint)
Set the endPoint endpoint of this connection.

Parameters:
newEndPoint - the new endPoint point given as NodeModelElement

reconnect

public void reconnect()
Reconnect this connection. The connection will reconnect with the NodeModelElement it was previously attached to.


reconnect

public void reconnect(NodeModelElement newSource,
                      NodeModelElement newEndPoint)
Reconnect to a different source and/or endPoint NodeModelElement. The connection will disconnect from its current attachments and reconnect to the new source and endPoint.

Parameters:
newSource - a new source endpoint for this connection (non null)
newEndPoint - a new endPoint endpoint for this connection (non null)
Throws:
java.lang.IllegalArgumentException - if any of the paramers are null or newSource == newTarget

getChildren

public java.util.List getChildren()
A connection should not have any children

Returns:
children (should not exist)

setUML2Element

public void setUML2Element(org.eclipse.uml2.uml.Element uml2Element)
(non-Javadoc)

Overrides:
setUML2Element in class ModelElement
Parameters:
uml2Element - the new uml2 reference for the model element
See Also:
org.jupe.editors.classdiagram.model.ModelElement#setUML2Element(org.eclipse.uml2.Element)

getClassDiagram

public ClassDiagram getClassDiagram()
Specified by:
getClassDiagram in class ModelElement