Package org.eclipse.gef.tools
Class CreationTool
java.lang.Object
org.eclipse.gef.util.FlagSupport
org.eclipse.gef.tools.AbstractTool
org.eclipse.gef.tools.TargetingTool
org.eclipse.gef.tools.CreationTool
- All Implemented Interfaces:
- RequestConstants,- Tool
The CreationTool creates new 
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.- 
Nested Class SummaryNested classes/interfaces inherited from class org.eclipse.gef.tools.AbstractToolAbstractTool.Input
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final ObjectProperty to be used inAbstractTool.setProperties(java.util.Map)forsetFactory(CreationFactory).Fields inherited from class org.eclipse.gef.tools.TargetingToolMAX_FLAGFields inherited from class org.eclipse.gef.tools.AbstractToolMAX_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_TERMINALFields inherited from interface org.eclipse.gef.RequestConstantsREQ_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 SummaryConstructorsConstructorDescriptionDefault constructor.CreationTool(CreationFactory aFactory) Constructs a new CreationTool with the given factory.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidapplyProperty(Object key, Object value) This method is invoked fromAbstractTool.setProperties(Map).protected CursorReturns the appropriate cursor for the tools current state.protected RequestCreates aCreateRequestand sets this tool's factory on the request.voidDeactivates the tool.protected voidEnsures size constraints (by default minimum and maximum) are respected by the given request.protected StringReturns the identifier of the command that is being sought.protected CreateRequestDeprecated, for removal: This API element is subject to removal in a future version.use TargetingTool#getTargetRequest()protected StringReturns the debug name for this tool.protected CreationFactoryReturns the creation factory used to create the new EditParts.protected DimensiongetMaximumSizeFor(CreateRequest request) Determines the maximum size for CreateRequest's size on drop.protected DimensiongetMinimumSizeFor(CreateRequest request) Determines the minimum size for CreateRequest's size on drop.protected CreateRequestLazily creates and returns the request used when communicating with the target editpart.protected booleanhandleButtonDown(int button) The creation tool only works by clicking mouse button 1 (the left mouse button in a right-handed world).protected booleanhandleButtonUp(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 callsperformCreation(int).protected booleanUpdates the request, sets the current command, and asks to show feedback.protected booleanCalled only one time during a drag when the drag threshold has been exceeded.protected booleanIf 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 booleanHandles high-level processing of a mouse hover event.protected booleanUpdates the request and mouse target, gets the current command and asks to show feedback.protected voidperformCreation(int button) Executes the current command and selects the newly created object.voidsetFactory(CreationFactory factory) Sets the creation factory used to create the new edit parts.protected voidSets the location (and size if the user is performing size-on-drop) of the request.Methods inherited from class org.eclipse.gef.tools.TargetingTooldoAutoexpose, eraseTargetFeedback, getAutoexposeHelper, getCommand, getDirection, getExclusionSet, getTargetEditPart, getTargetingConditional, handleAutoexpose, handleEnteredEditPart, handleExitingEditPart, handleHoverStop, handleInvalidInput, handleLeavingEditPart, handleViewerExited, isShowingTargetFeedback, isTargetLocked, lockTargetEditPart, resetFlags, resetHover, setAutoexposeHelper, setRefreshRate, setTargetEditPart, setTargetRequest, showTargetFeedback, unlockTargetEditPart, updateAutoexposeHelper, updateTargetUnderMouseMethods inherited from class org.eclipse.gef.tools.AbstractToolacceptArrowKey, accGetStep, accStepIncrement, accStepReset, 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, viewerExitedMethods inherited from class org.eclipse.gef.util.FlagSupportgetFlag, setFlag
- 
Field Details- 
PROPERTY_CREATION_FACTORYProperty to be used inAbstractTool.setProperties(java.util.Map)forsetFactory(CreationFactory).
 
- 
- 
Constructor Details- 
CreationToolpublic CreationTool()Default constructor. Sets the default and disabled cursors.
- 
CreationToolConstructs a new CreationTool with the given factory.- Parameters:
- aFactory- the creation factory
 
 
- 
- 
Method Details- 
applyPropertyDescription copied from class:AbstractToolThis method is invoked fromAbstractTool.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.- Overrides:
- applyPropertyin class- AbstractTool
- Parameters:
- key- the key; may be- null
- value- the new value
- See Also:
 
- 
calculateCursorDescription copied from class:AbstractToolReturns the appropriate cursor for the tools current state. If the tool is in its terminal state,nullis 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. - Overrides:
- calculateCursorin class- AbstractTool
- Returns:
- nullor a cursor to be displayed.
- See Also:
 
- 
createTargetRequestCreates aCreateRequestand sets this tool's factory on the request.- Overrides:
- createTargetRequestin class- TargetingTool
- Returns:
- the new target request
- See Also:
 
- 
deactivatepublic void deactivate()Description copied from class:AbstractToolDeactivates the tool. This method is called whenever the user switches to another tool. Use this method to do some clean-up when the tool is switched. The abstract tool allows cursors for viewers to be changed. When the tool is deactivated it must revert to normal the cursor of the last tool it changed.- Specified by:
- deactivatein interface- Tool
- Overrides:
- deactivatein class- TargetingTool
- See Also:
 
- 
getCommandNameDescription copied from class:AbstractToolReturns the identifier of the command that is being sought. This name is also the named that will be logged in the debug view.- Specified by:
- getCommandNamein class- AbstractTool
- Returns:
- the identifier for the command
- See Also:
 
- 
getCreateRequestDeprecated, for removal: This API element is subject to removal in a future version.use TargetingTool#getTargetRequest()Cast the target request to a CreateRequest and returns it.- Returns:
- the target request as a CreateRequest
- See Also:
 
- 
getDebugNameDescription copied from class:AbstractToolReturns the debug name for this tool.- Overrides:
- getDebugNamein class- AbstractTool
- Returns:
- the debug name
- See Also:
 
- 
getFactoryReturns the creation factory used to create the new EditParts.- Returns:
- the creation factory
 
- 
handleButtonDownprotected boolean handleButtonDown(int button) The creation tool only works by clicking mouse button 1 (the left mouse button in a right-handed world). If any other button is pressed, the tool goes into an invalid state. Otherwise, it goes into the drag state, updates the request's location and callsTargetingTool.lockTargetEditPart(EditPart)with the edit part that was just clicked on.- Overrides:
- handleButtonDownin class- AbstractTool
- Parameters:
- button- which button went down
- Returns:
- trueif the buttonDown was handled
- See Also:
 
- 
handleButtonUpprotected 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 callsperformCreation(int).- Overrides:
- handleButtonUpin class- AbstractTool
- Parameters:
- button- the button being released
- Returns:
- trueif the button up was handled
- See Also:
 
- 
handleDragInProgressprotected boolean handleDragInProgress()Updates the request, sets the current command, and asks to show feedback.- Overrides:
- handleDragInProgressin class- AbstractTool
- Returns:
- trueif the drag was handled
- See Also:
 
- 
handleDragStartedprotected boolean handleDragStarted()Description copied from class:AbstractToolCalled only one time during a drag when the drag threshold has been exceeded. By default, nothing happens andfalseis returned. Subclasses may override to interpret the drag starting. Returningtrueindicates that the event was handled.- Overrides:
- handleDragStartedin class- AbstractTool
- Returns:
- true if the drag starting was handled
- See Also:
 
- 
handleFocusLostprotected 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.- Overrides:
- handleFocusLostin class- AbstractTool
- Returns:
- trueif the event was handled
- See Also:
 
- 
handleHoverprotected boolean handleHover()Description copied from class:AbstractToolHandles high-level processing of a mouse hover event. By default, nothing happens andfalseis returned. Subclasses may override this method to interpret the hover. Returntrueto indicate that the hover was handled.- Overrides:
- handleHoverin class- AbstractTool
- Returns:
- trueif the hover was handled
- See Also:
 
- 
handleMoveprotected boolean handleMove()Updates the request and mouse target, gets the current command and asks to show feedback.- Overrides:
- handleMovein class- AbstractTool
- Returns:
- trueif the mouse move was handled
- See Also:
 
- 
performCreationprotected void performCreation(int button) Executes the current command and selects the newly created object. The button that was released to cause this creation is passed in, but sincehandleButtonDown(int)goes into the invalid state if the button pressed is not button 1, this will always be button 1.- Parameters:
- button- the button that was pressed
 
- 
setFactorySets the creation factory used to create the new edit parts.- Parameters:
- factory- the factory
 
- 
updateTargetRequestprotected void updateTargetRequest()Sets the location (and size if the user is performing size-on-drop) of the request.- Overrides:
- updateTargetRequestin class- TargetingTool
- See Also:
 
- 
enforceConstraintsForSizeOnDropCreateEnsures size constraints (by default minimum and maximum) are respected by the given request. May be overwritten by clients to enforce additional constraints.- Since:
- 3.7
 
- 
getMaximumSizeForDetermines the maximum size for CreateRequest's size on drop. It is called fromenforceConstraintsForSizeOnDropCreate(CreateRequest)during creation. By default, a largeDimensionis returned.- Parameters:
- request- the request.
- Returns:
- the minimum size
- Since:
- 3.7
 
- 
getMinimumSizeForDetermines the minimum size for CreateRequest's size on drop. It is called fromenforceConstraintsForSizeOnDropCreate(CreateRequest)during creation. By default, a smallDimensionis returned.- Parameters:
- request- the request.
- Returns:
- the minimum size
- Since:
- 3.7
 
- 
getTargetRequestDescription copied from class:TargetingToolLazily creates and returns the request used when communicating with the target editpart.- Overrides:
- getTargetRequestin class- TargetingTool
- Returns:
- the target request
- Since:
- 3.21
 
 
-