public abstract class DefaultAttachedBoxTool extends DefaultDiagramTool implements IAttachedBoxTool
In a diagram, graphic boxes attached are graphic objects that display diagram nodes linked to another diagram
element. For example Notes and Constraints are graphic attached boxes.
IAttachedBoxCommand
is the interface that drives the interaction of creating a box attached to another
diagram element
The interaction is started when the user clicks on the button in the diagram palette. Once the interaction is started
the user can use the mouse to create a new graphic attached box in the diagram. The
acceptElement
method is called to know if the element
flown over by the mouse is valid for the command. If it is not valid the user cannot finish the interaction. If the
element is valid the user can terminates the interaction.
If the user click in the diagram background
actionPerformedInDiagram
is called.
If the user click on the element to attach then in the diagram background
actionPerformed
is called.
The
actionPerformed
and actionPerformedInDiagram
methods do nothing in this default implementation.
Subclass the DefaultAttachedBoxTool to provide a behavior to the
actionPerformed
and actionPerformedInDiagram
methods.
Constructor and Description |
---|
DefaultAttachedBoxTool() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
acceptElement(IDiagramHandle diagramHandle,
IDiagramGraphic targetNode)
This method accept or refuse the interaction in the diagram.
|
abstract void |
actionPerformed(IDiagramHandle diagramHandle,
IDiagramGraphic originNode,
IDiagramLink.LinkRouterKind routerType,
ILinkPath path,
Point point)
This method is called when the user click on an existing diagram element.
|
abstract void |
actionPerformedInDiagram(IDiagramHandle diagramHandle,
Rectangle rect)
This method is called when the user click in the diagram background.
|
decorate, findStereotypeFromSpec, getBitmap, getLabel, getModule, getParameter, getParameters, getSourceScopes, getTargetScopes, getTooltip, initialize
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decorate, getBitmap, getLabel, getModule, getParameters, getSourceScopes, getTargetScopes, getTooltip, initialize
public abstract boolean acceptElement(IDiagramHandle diagramHandle, IDiagramGraphic targetNode)
This method is called until the interaction is validated by the user.
If the interaction is allowed the method return new InteractionStatus(true, "");
If the interaction is not allowed the method return new InteractionStatus(false, "Tooltip message");
. In this case the mouse pointer is changed to a "forbiden" icon and the tooltip message is displayed in a
tooltip near the mouse pointer
acceptElement
in interface IAttachedBoxTool
diagramHandle
- the representation of the diagram in which the interaction occurs.targetNode
- the graphic that is below the mouse pointer.public abstract void actionPerformed(IDiagramHandle diagramHandle, IDiagramGraphic originNode, IDiagramLink.LinkRouterKind routerType, ILinkPath path, Point point)
The method is in charge of creating the model element in the model and of unmasking the element in the diagram.
The originNode argument contains the diagram node container corresponding to the origin graphic box.
The rect argument is the rectangle that result from the user interaction with the diagram. This rect should be used to manage the unmasking of the model element in the diagram.
actionPerformed
in interface IAttachedBoxTool
diagramHandle
- the representation of the diagram where the command has been triggered.originNode
- the graphic parent where the user has clicked.routerType
- the router type that is currently defined to compute the path of the link.path
- the link path deduced from the user interactions.point
- the point of the second user click.IDiagramHandle.unmask(MObject, int, int)
public abstract void actionPerformedInDiagram(IDiagramHandle diagramHandle, Rectangle rect)
The method is in charge of creating the model element in the model and of unmasking the element in the diagram.
The rect argument is the rectangle that result from the user interaction with the diagram background. This rect should be used to manage the unmasking of the model element in the diagram.
actionPerformedInDiagram
in interface IAttachedBoxTool
diagramHandle
- the representation of the diagram where the command has been triggered.rect
- the rectangle of the object to create.IDiagramHandle.unmask(MObject,int, int)