public abstract class DefaultMultiLinkCommand extends Object implements IMultiLinkCommand
acceptFirstElement
method is called to know if
the element flown over by the mouse is valid to be the first element of the interaction. If it is not valid as first
element, then the acceptLastElement
method is
called to know if the element flown over by the mouse is valid as last element of the interaction (in which case the
interaction is done with a single click, as is the case for IBoxCommand for example). acceptAdditionalElement
method is
called to know if the element flown over by the mouse can be added to the current interaction. If it is not valid to
be added to the current interaction, then the acceptLastElement
method is called to know if the element flown over by the mouse is valid as last element of the
interaction.acceptAdditionalElement
method doesn't
accept the element to be added to the interaction but the
acceptLastElement
method accepts the element
as last element of the interaction, the
actionPerformed
method is
called. actionPerformed
method
is in charge of creating the elements in the model and of unmasking them in the diagram.
This interface is intended to be implemented by MDA Components in order to add commands in a diagram palette.Constructor and Description |
---|
DefaultMultiLinkCommand(String name,
org.eclipse.jface.resource.ImageDescriptor bitmap,
String tooltip)
Construct a DefaultMultiLinkCommand and initialize it by passing the
name , the
bitmap path and the tooltip of the command. |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
acceptAdditionalElement(IDiagramHandle diagramHandle,
List<IDiagramGraphic> previousNodes,
IDiagramGraphic targetNode)
This method accept or refuse the interaction with the diagram for an additional element of the interaction.
|
abstract boolean |
acceptFirstElement(IDiagramHandle diagramHandle,
IDiagramGraphic targetNode)
This method accept or refuse the interaction in the diagram for the first element.
|
abstract boolean |
acceptLastElement(IDiagramHandle diagramHandle,
List<IDiagramGraphic> otherNodes,
IDiagramGraphic targetNode)
This method accept or refuse the interaction with the diagram for the "last" element of the interaction.
|
abstract void |
actionPerformed(IDiagramHandle diagramHandle,
IDiagramGraphic lastNode,
List<IDiagramGraphic> otherNodes,
List<IDiagramLink.LinkRouterKind> routerKinds,
List<ILinkPath> paths,
Rectangle rectangle)
This method is invoked when the command is launched.
|
org.eclipse.jface.resource.ImageDescriptor |
getBitmap()
Get the command's bitmap.
|
String |
getLabel()
Get the name of the command.
|
String |
getTooltip()
Gets the tooltip of this command.
|
void |
setBitmap(org.eclipse.jface.resource.ImageDescriptor image)
Set the command's bitmap.
|
void |
setLabel(String label)
Set the name of the command.
|
void |
setTooltip(String tooltip)
Set the tooltip of this command.
|
public DefaultMultiLinkCommand(String name, org.eclipse.jface.resource.ImageDescriptor bitmap, String tooltip)
name
, the
bitmap path
and the tooltip
of the command.name
- the name of the command.bitmap
- the absolute path of the command bitmap.tooltip
- the tooltip text of the command.public abstract boolean acceptFirstElement(IDiagramHandle diagramHandle, IDiagramGraphic targetNode)
This method is called until the user clicks on an element.
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 acceptLastElement method is called with the same arguments, to check if the pointed element
could be the last of the interaction.
acceptFirstElement
in interface IMultiLinkCommand
diagramHandle
- the representation of the diagram in which the interaction occurs.targetNode
- the graphic that is below the mouse pointer.public abstract boolean acceptAdditionalElement(IDiagramHandle diagramHandle, List<IDiagramGraphic> previousNodes, IDiagramGraphic targetNode)
new InteractionStatus(true, "");
new InteractionStatus(false, "Tooltip message");
. In this case the acceptLastElement method is called with the same arguments, to check if the pointed element
could be the last of the interaction.acceptAdditionalElement
in interface IMultiLinkCommand
diagramHandle
- the representation of the diagram in which the interaction occurs.previousNodes
- the graphics accepted until now (might be empty).targetNode
- the graphic that is below the mouse pointer.public abstract boolean acceptLastElement(IDiagramHandle diagramHandle, List<IDiagramGraphic> otherNodes, IDiagramGraphic targetNode)
new InteractionStatus(true, "");
new InteractionStatus(false, "Tooltip message");
. In this case the mouse pointer is changed to a "forbidden" icon and the tooltip message is displayed in a
tooltip near the mouse pointeracceptLastElement
in interface IMultiLinkCommand
diagramHandle
- the representation of the diagram in which the interaction occurs.otherNodes
- the graphics accepted until now (might be empty).targetNode
- the graphic that is below the mouse pointer.public abstract void actionPerformed(IDiagramHandle diagramHandle, IDiagramGraphic lastNode, List<IDiagramGraphic> otherNodes, List<IDiagramLink.LinkRouterKind> routerKinds, List<ILinkPath> paths, Rectangle rectangle)
lastNode
is the graphic accepted by the acceptLastElement method.
otherNodes
are all the graphics accepted by calls to acceptFirstNode and acceptAdditionalNode.actionPerformed
in interface IMultiLinkCommand
diagramHandle
- the representation of the diagram where the command has been triggered.lastNode
- the last graphic accepted.otherNodes
- all previous accepted graphics.routerKinds
- the router types that are currently defined to compute the path of the links from the previously
accepted graphics to the element to create.paths
- the link paths deduced from the user interactions.rectangle
- the rectangle of the object to create.IDiagramHandle.unmask(IElement, int, int)
public String getTooltip()
IDiagramCommand
getTooltip
in interface IDiagramCommand
public org.eclipse.jface.resource.ImageDescriptor getBitmap()
IDiagramCommand
getBitmap
in interface IDiagramCommand
public String getLabel()
IDiagramCommand
getLabel
in interface IDiagramCommand
public void setLabel(String label)
setLabel
in interface IDiagramCommand
label
- the name of the command.public void setBitmap(org.eclipse.jface.resource.ImageDescriptor image)
setBitmap
in interface IDiagramCommand
image
- the bitmap ImageDescriptor.public void setTooltip(String tooltip)
setTooltip
in interface IDiagramCommand
tooltip
- the text that will be displayed in the command's tooltip.