public class CreationTool extends TargetingTool
EditParts via a
CreationFactory. If the user simply clicks on the viewer, the default
sized EditPart will be created at that point. If the user clicks and drags,
the created EditPart will be sized based on where the user clicked and
dragged.AbstractTool.Input| Modifier and Type | Field and Description |
|---|---|
static java.lang.Object |
PROPERTY_CREATION_FACTORY
Property to be used in
AbstractTool.setProperties(java.util.Map)
for setFactory(CreationFactory). |
MAX_FLAGMAX_STATE, MOUSE_BUTTON_ANY, MOUSE_BUTTON1, MOUSE_BUTTON2, MOUSE_BUTTON3, PROPERTY_UNLOAD_WHEN_FINISHED, STATE_ACCESSIBLE_DRAG, STATE_ACCESSIBLE_DRAG_IN_PROGRESS, STATE_DRAG, STATE_DRAG_IN_PROGRESS, STATE_INITIAL, STATE_INVALID, STATE_TERMINALREQ_ADD, REQ_ALIGN, REQ_ALIGN_CHILDREN, REQ_CLONE, REQ_CONNECTION_END, REQ_CONNECTION_START, REQ_CREATE, REQ_CREATE_BENDPOINT, REQ_DELETE, REQ_DELETE_DEPENDANT, REQ_DIRECT_EDIT, REQ_MOVE, REQ_MOVE_BENDPOINT, REQ_MOVE_CHILDREN, REQ_OPEN, REQ_ORPHAN, REQ_ORPHAN_CHILDREN, REQ_RECONNECT_SOURCE, REQ_RECONNECT_TARGET, REQ_RESIZE, REQ_RESIZE_CHILDREN, REQ_SELECTION, REQ_SELECTION_HOVER| Constructor and Description |
|---|
CreationTool()
Default constructor.
|
CreationTool(CreationFactory aFactory)
Constructs a new CreationTool with the given factory.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
applyProperty(java.lang.Object key,
java.lang.Object value)
This method is invoked from
AbstractTool.setProperties(Map). |
protected Cursor |
calculateCursor()
Returns the appropriate cursor for the tools current state.
|
protected Request |
createTargetRequest()
Creates a
CreateRequest and sets this tool's factory on the
request. |
void |
deactivate()
Deactivates the tool.
|
protected void |
enforceConstraintsForSizeOnDropCreate(CreateRequest request)
Ensures size constraints (by default minimum and maximum) are respected
by the given request.
|
protected java.lang.String |
getCommandName()
Returns the identifier of the command that is being sought.
|
protected CreateRequest |
getCreateRequest()
Cast the target request to a CreateRequest and returns it.
|
protected java.lang.String |
getDebugName()
Returns the debug name for this tool.
|
protected CreationFactory |
getFactory()
Returns the creation factory used to create the new EditParts.
|
protected Dimension |
getMaximumSizeFor(CreateRequest request)
Determines the maximum size for CreateRequest's size on drop.
|
protected Dimension |
getMinimumSizeFor(CreateRequest request)
Determines the minimum size for CreateRequest's size on drop.
|
protected boolean |
handleButtonDown(int button)
The creation tool only works by clicking mouse button 1 (the left mouse
button in a right-handed world).
|
protected boolean |
handleButtonUp(int button)
If the tool is currently in a drag or drag-in-progress state, it goes
into the terminal state, performs some cleanup (erasing feedback,
unlocking target edit part), and then calls
performCreation(int)
. |
protected boolean |
handleDragInProgress()
Updates the request, sets the current command, and asks to show feedback.
|
protected boolean |
handleDragStarted()
Called only one time during a drag when the drag threshold has been
exceeded.
|
protected boolean |
handleFocusLost()
If the user is in the middle of creating a new edit part, the tool erases
feedback and goes into the invalid state when focus is lost.
|
protected boolean |
handleHover()
Handles high-level processing of a mouse hover event.
|
protected boolean |
handleMove()
Updates the request and mouse target, gets the current command and asks
to show feedback.
|
protected void |
performCreation(int button)
Executes the current command and selects the newly created object.
|
void |
setFactory(CreationFactory factory)
Sets the creation factory used to create the new edit parts.
|
protected void |
updateTargetRequest()
Sets the location (and size if the user is performing size-on-drop) of
the request.
|
doAutoexpose, eraseTargetFeedback, getAutoexposeHelper, getCommand, getExclusionSet, getTargetEditPart, getTargetingConditional, getTargetRequest, handleAutoexpose, handleEnteredEditPart, handleExitingEditPart, handleHoverStop, handleInvalidInput, handleLeavingEditPart, handleViewerExited, isShowingTargetFeedback, isTargetLocked, lockTargetEditPart, resetFlags, resetHover, setAutoexposeHelper, setTargetEditPart, setTargetRequest, showTargetFeedback, unlockTargetEditPart, updateAutoexposeHelper, updateTargetUnderMouseacceptArrowKey, activate, addFeedback, commitDrag, createOperationSet, debug, executeCommand, executeCurrentCommand, focusGained, focusLost, getCurrentCommand, getCurrentInput, getCurrentViewer, getDebugNameForState, getDefaultCursor, getDisabledCursor, getDomain, getDragMoveDelta, getLocation, getOperationSet, getStartLocation, getState, handleCommandStackChanged, handleDoubleClick, handleDrag, handleFinished, handleFocusGained, handleKeyDown, handleKeyTraversed, handleKeyUp, handleNativeDragFinished, handleNativeDragStarted, handleViewerEntered, isActive, isHoverActive, isInState, isViewerImportant, keyDown, keyTraversed, keyUp, mouseDoubleClick, mouseDown, mouseDrag, mouseHover, mouseMove, mouseUp, mouseWheelScrolled, movedPastThreshold, nativeDragFinished, nativeDragStarted, performViewerMouseWheel, placeMouseInViewer, reactivate, refreshCursor, releaseToolCapture, removeFeedback, setCurrentCommand, setCursor, setDefaultCursor, setDisabledCursor, setEditDomain, setHoverActive, setProperties, setStartLocation, setState, setToolCapture, setUnloadWhenFinished, setViewer, stateTransition, unloadWhenFinished, viewerEntered, viewerExitedgetFlag, setFlagpublic static final java.lang.Object PROPERTY_CREATION_FACTORY
AbstractTool.setProperties(java.util.Map)
for setFactory(CreationFactory).public CreationTool()
public CreationTool(CreationFactory aFactory)
aFactory - the creation factoryprotected void applyProperty(java.lang.Object key,
java.lang.Object value)
AbstractToolAbstractTool.setProperties(Map). Sub-classes can
override to add support for more properties. This method should fail
silently in case of any error.
AbstractTool uses introspection to match any keys with properties. For
instance, the key "defaultCursor" would lead to the invocation of
AbstractTool.setDefaultCursor(Cursor) with the provided value.
applyProperty in class AbstractToolkey - the key; may be nullvalue - the new valueAbstractTool.applyProperty(java.lang.Object,
java.lang.Object)protected Cursor calculateCursor()
AbstractToolnull is returned. Otherwise,
either the default or disabled cursor is returned, based on the existence
of a current command, and whether that current command is executable.
Subclasses may override or extend this method to calculate the appropriate cursor based on other conditions.
calculateCursor in class AbstractToolnull or a cursor to be displayed.AbstractTool.calculateCursor()protected Request createTargetRequest()
CreateRequest and sets this tool's factory on the
request.createTargetRequest in class TargetingToolTargetingTool.createTargetRequest()public void deactivate()
AbstractTooldeactivate in interface Tooldeactivate in class TargetingToolTool.deactivate()protected java.lang.String getCommandName()
AbstractToolgetCommandName in class AbstractToolAbstractTool.getCommandName()protected CreateRequest getCreateRequest()
TargetingTool.getTargetRequest()protected java.lang.String getDebugName()
AbstractToolgetDebugName in class AbstractToolAbstractTool.getDebugName()protected CreationFactory getFactory()
protected boolean handleButtonDown(int button)
TargetingTool.lockTargetEditPart(EditPart) with the edit part
that was just clicked on.handleButtonDown in class AbstractToolbutton - which button went downtrue if the buttonDown was handledAbstractTool.handleButtonDown(int)protected boolean handleButtonUp(int button)
performCreation(int)
.handleButtonUp in class AbstractToolbutton - the button being releasedtrue if the button up was handledAbstractTool.handleButtonUp(int)protected boolean handleDragInProgress()
handleDragInProgress in class AbstractTooltrue if the drag was handledAbstractTool.handleDragInProgress()protected boolean handleDragStarted()
AbstractToolfalse is returned.
Subclasses may override to interpret the drag starting. Returning
true indicates that the event was handled.handleDragStarted in class AbstractToolAbstractTool.handleDragStarted()protected boolean handleFocusLost()
handleFocusLost in class AbstractTooltrue if the event was handledAbstractTool.handleFocusLost()protected boolean handleHover()
AbstractToolfalse is returned. Subclasses may override this
method to interpret the hover. Return true to indicate that
the hover was handled.handleHover in class AbstractTooltrue if the hover was handledAbstractTool.handleHover()protected boolean handleMove()
handleMove in class AbstractTooltrue if the mouse move was handledAbstractTool.handleMove()protected void performCreation(int button)
handleButtonDown(int) goes into the invalid state if the button
pressed is not button 1, this will always be button 1.button - the button that was pressedpublic void setFactory(CreationFactory factory)
factory - the factoryprotected void updateTargetRequest()
updateTargetRequest in class TargetingToolTargetingTool.updateTargetRequest()protected void enforceConstraintsForSizeOnDropCreate(CreateRequest request)
protected Dimension getMaximumSizeFor(CreateRequest request)
enforceConstraintsForSizeOnDropCreate(CreateRequest) during
creation. By default, a large Dimension is returned.request - the request.protected Dimension getMinimumSizeFor(CreateRequest request)
enforceConstraintsForSizeOnDropCreate(CreateRequest) during
creation. By default, a small Dimension is returned.request - the request.Copyright (c) IBM Corp. and others 2000, 2011. All Rights Reserved.