public abstract class DefaultBoxCommand extends Object implements IBoxCommand
In a diagram, graphic boxes are graphic objects that display diagram nodes. For example Packages and Classes
are graphic boxes. IBoxCommand
is the interface that drives the interaction of creating a box
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 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 by either clicking or by pressing the left mouse button
doing a drag and drop and releasing the mouse button. Once this is done the
actionPerformed
is called.
The actionPerformed
does nothing in
this default implementation.
Subclass the DefaultBoxCommand to provide a behavior to the
actionPerformed
method.
Constructor and Description |
---|
DefaultBoxCommand(String name,
org.eclipse.jface.resource.ImageDescriptor bitmap,
String tooltip)
Construct a DefaultBoxCommand and initialize it by passing the
name , the bitmap path
and the tooltip of the command. |
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 parent,
Rectangle rect)
This method is called when the interaction is validated by the user.
|
org.eclipse.jface.resource.ImageDescriptor |
getBitmap()
Get the command's bitmap path.
|
String |
getLabel()
Get the label 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 DefaultBoxCommand(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 acceptElement(IDiagramHandle diagramHandle, IDiagramGraphic targetNode)
This method is called until the interaction is validated by the user.
This default implementation always accept the interaction.
acceptElement
in interface IBoxCommand
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 parent, Rectangle rect)
This default implementation does nothing.
If the user click or click and drag in a graphic box the parent argument contains the diagram node container corresponding to graphic box. If the user click or click and drag in the diagram background parent is null.
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 IBoxCommand
diagramHandle
- the representation of the diagram where the command has been triggered.parent
- the graphic parent where the user has clicked.rect
- the rectangle of the object to create.IDiagramHandle.unmask(IElement, int, int)
public org.eclipse.jface.resource.ImageDescriptor getBitmap()
getBitmap
in interface IDiagramCommand
IMdacConfiguration.getModuleResourcesPath()
public String getLabel()
getLabel
in interface IDiagramCommand
public String getTooltip()
getTooltip
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.