|
Eclipse GEF 2.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.gef.util.FlagSupport | +--org.eclipse.gef.tools.AbstractTool
Default implementation support for Tool
s.
Nested Class Summary | |
static class |
AbstractTool.Input
Allows the user to access mouse and keyboard input. |
Field Summary | |
protected static int |
MAX_FLAG
|
protected static int |
MAX_STATE
|
protected static int |
MOUSE_BUTTON_ANY
|
protected static int |
MOUSE_BUTTON1
|
protected static int |
MOUSE_BUTTON2
|
protected static int |
MOUSE_BUTTON3
|
protected static int |
STATE_ACCESSIBLE_DRAG
|
protected static int |
STATE_ACCESSIBLE_DRAG_IN_PROGRESS
|
protected static int |
STATE_DRAG
|
protected static int |
STATE_DRAG_IN_PROGRESS
|
protected static int |
STATE_INITIAL
|
protected static int |
STATE_INVALID
|
protected static int |
STATE_TERMINAL
|
Fields inherited from interface org.eclipse.gef.RequestConstants |
REQ_ADD, REQ_ALIGN, REQ_ALIGN_CHILDREN, 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 Summary | |
AbstractTool()
|
Method Summary | |
void |
activate()
Activates the tool. |
protected void |
addFeedback(org.eclipse.draw2d.IFigure figure)
Adds the given figure to the feedback layer. |
protected Cursor |
calculateCursor()
Determines (and returns) the appropriate cursur. |
void |
commitDrag()
|
protected List |
createOperationSet()
Creates and returns a List of EditPart s that the tool
will be working with. |
void |
deactivate()
Deactivates the tool. |
protected void |
debug(String message)
Prints a string in the GEF Debug console if the Tools debug option is selected. |
protected void |
executeCurrentCommand()
Execute the currently active command. |
void |
focusGained(FocusEvent event,
EditPartViewer viewer)
Called when a viewer that the editor controls gains focus. |
void |
focusLost(FocusEvent event,
EditPartViewer viewer)
Called when a viewer that the editor controls loses focus. |
protected Command |
getCommand()
Re-queries the target viewer object for a command |
protected abstract String |
getCommandName()
Returns the name identifier of the command that the tool is currently looking for. |
protected Command |
getCurrentCommand()
Returns the currently active command. |
protected AbstractTool.Input |
getCurrentInput()
Returns the current mouse and keyboard input. |
protected EditPartViewer |
getCurrentViewer()
Return the viewer that the tool is currently operating on. |
protected abstract String |
getDebugName()
Returns the debug name for this tool. |
protected String |
getDebugNameForState(int state)
Returns a String representation of the given state for debug purposes. |
protected Cursor |
getDefaultCursor()
Returns the default Cursor . |
protected Cursor |
getDisabledCursor()
Returns the disabled Cursor . |
protected EditDomain |
getDomain()
Returns the EditDomain. |
protected org.eclipse.draw2d.geometry.Dimension |
getDragMoveDelta()
Return the number of pixels that the mouse has been moved since that drag was started. |
protected org.eclipse.draw2d.geometry.Point |
getLocation()
Return the current x, y position of the cursor. |
protected List |
getOperationSet()
Returns the collection of editparts that the drag is operating on. |
protected org.eclipse.draw2d.geometry.Point |
getStartLocation()
Returns the starting location for the current tool operation. |
protected int |
getState()
Returns the current state. |
protected boolean |
handleButtonDown(int button)
Called when the mouse button has been pressed. |
protected boolean |
handleButtonUp(int button)
Handles the high-level processing of a mouse release. |
protected boolean |
handleDoubleClick(int button)
Handles high-level processing of a double click. |
protected boolean |
handleDrag()
Handles high-level processing of a mouse drag. |
protected boolean |
handleDragInProgress()
Handles high-level processing of a mouse drag once the threshold has been passed. |
protected boolean |
handleDragStarted()
Called once when the drag threshold has been passed. |
protected void |
handleFinished()
Called when the current tool operation is complete. |
protected boolean |
handleFocusGained()
Handles high-level processing of a focus gained event. |
protected boolean |
handleFocusLost()
Handles high-level processing of a focus lost event. |
protected boolean |
handleHover()
Handles high-level processing of a mouse hover event. |
protected boolean |
handleKeyDown(KeyEvent e)
Handles high-level processing of a key down event. |
protected boolean |
handleKeyUp(KeyEvent e)
Handles high-level processing of a key up event. |
protected boolean |
handleMove()
Handles high-level processing of a mouse move. |
protected boolean |
handleNativeDragFinished(DragSourceEvent event)
|
protected boolean |
handleNativeDragStarted(DragSourceEvent event)
|
protected boolean |
handleViewerEntered()
Called when the mouse enters an EditPartViewer. |
protected boolean |
handleViewerExited()
Called when the mouse exits an EditPartViewer. |
protected boolean |
isActive()
Returns true if the tool is active. |
protected boolean |
isHoverActive()
Returns true if the tool is hovering. |
protected boolean |
isInState(int state)
Returns true if the tool is in the given state. |
void |
keyDown(KeyEvent evt,
EditPartViewer viewer)
Processes a KeyDown event for the given viewer. |
void |
keyUp(KeyEvent evt,
EditPartViewer viewer)
Processes a KeyUp event for the given viewer. |
void |
mouseDoubleClick(MouseEvent me,
EditPartViewer viewer)
Handles mouse double click events within a viewer. |
void |
mouseDown(MouseEvent me,
EditPartViewer viewer)
Handles mouse down events within a viewer. |
void |
mouseDrag(MouseEvent me,
EditPartViewer viewer)
Handles mouse drag events within a viewer. |
void |
mouseHover(MouseEvent me,
EditPartViewer viewer)
Handles mouse hover event. within a viewer. |
void |
mouseMove(MouseEvent me,
EditPartViewer viewer)
Handles mouse moves (if the mouse button is up) within a viewer. |
void |
mouseUp(MouseEvent me,
EditPartViewer viewer)
Handles mouse up within a viewer. |
protected boolean |
movedPastThreshold()
Returns true if the mouse has been dragged past
the drag threshold. |
void |
nativeDragFinished(DragSourceEvent event,
EditPartViewer viewer)
Called when a native drag ends on a Viewer. |
void |
nativeDragStarted(DragSourceEvent event,
EditPartViewer viewer)
Called when a native drag begins on a Viewer. |
protected void |
reactivate()
Deactivates and then activates
this tool. |
protected void |
refreshCursor()
Selects the appropriate cursor. |
protected void |
releaseToolCapture()
Releases capture. |
protected void |
removeFeedback(org.eclipse.draw2d.IFigure figure)
Removes the given figure from the feedback layer. |
protected void |
resetFlags()
Resets the flags. |
protected void |
setCurrentCommand(Command c)
Sets the current command. |
protected void |
setCursor(Cursor cursor)
Set the cursor on the argument to the not cursor Record the fact we have altered the cursor of this viewer so that when we are deactivated we can go back and set it to normal |
void |
setDefaultCursor(Cursor cursor)
Sets the default cursor. |
void |
setDisabledCursor(Cursor cursor)
Sets the disabled cursor. |
void |
setEditDomain(EditDomain domain)
Sets the EditDomain. |
protected void |
setHoverActive(boolean value)
Sets the hover flag to true. |
protected void |
setStartLocation(org.eclipse.draw2d.geometry.Point p)
|
protected void |
setState(int state)
Sets the tool state. |
protected void |
setToolCapture()
By setting capture on mouseDown, a tool can prevent native Drag operations from occuring. |
void |
setUnloadWhenFinished(boolean value)
Setting this to true will cause the tool
to be unloaded after one operation has completed. |
void |
setViewer(EditPartViewer viewer)
Sets the active EditPartViewer. |
protected boolean |
stateTransition(int start,
int end)
This method attempts to transistion the tool from state start to state end and returns
true if successful. |
protected boolean |
unloadWhenFinished()
Returns true if the tool is set to unload when
its current operation is complete. |
void |
viewerEntered(MouseEvent me,
EditPartViewer viewer)
Handles the mouse entering a viewer. |
void |
viewerExited(MouseEvent me,
EditPartViewer viewer)
Handles the mouse exiting a viewer. |
Methods inherited from class org.eclipse.gef.util.FlagSupport |
getFlag, setFlag |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final int STATE_TERMINAL
protected static final int STATE_INITIAL
protected static final int STATE_DRAG
protected static final int STATE_DRAG_IN_PROGRESS
protected static final int STATE_INVALID
protected static final int STATE_ACCESSIBLE_DRAG
protected static final int STATE_ACCESSIBLE_DRAG_IN_PROGRESS
protected static final int MAX_STATE
protected static final int MOUSE_BUTTON1
protected static final int MOUSE_BUTTON2
protected static final int MOUSE_BUTTON3
protected static final int MOUSE_BUTTON_ANY
protected static final int MAX_FLAG
Constructor Detail |
public AbstractTool()
Method Detail |
public void activate()
activate
in interface Tool
deactivate()
protected void addFeedback(org.eclipse.draw2d.IFigure figure)
protected Cursor calculateCursor()
public void commitDrag()
protected List createOperationSet()
EditPart
s that the tool
will be working with.
public void deactivate()
deactivate
in interface Tool
activate()
protected void debug(String message)
public void focusGained(FocusEvent event, EditPartViewer viewer)
focusGained
in interface Tool
event
- The SWT focus eventviewer
- The viewer that the focus event is over.public void focusLost(FocusEvent event, EditPartViewer viewer)
focusLost
in interface Tool
event
- The SWT focus eventviewer
- The viewer that the focus event is over.protected void executeCurrentCommand()
protected Command getCommand()
protected abstract String getCommandName()
protected Command getCurrentCommand()
protected AbstractTool.Input getCurrentInput()
protected EditPartViewer getCurrentViewer()
protected abstract String getDebugName()
protected String getDebugNameForState(int state)
protected Cursor getDefaultCursor()
Cursor
.
protected Cursor getDisabledCursor()
Cursor
.
protected EditDomain getDomain()
protected org.eclipse.draw2d.geometry.Dimension getDragMoveDelta()
protected org.eclipse.draw2d.geometry.Point getLocation()
protected List getOperationSet()
protected org.eclipse.draw2d.geometry.Point getStartLocation()
protected int getState()
protected boolean handleButtonDown(int button)
protected boolean handleButtonUp(int button)
mouseUp(MouseEvent, EditPartViewer)
protected boolean handleDoubleClick(int button)
mouseDoubleClick(MouseEvent, EditPartViewer)
protected boolean handleDrag()
mouseDrag(MouseEvent, EditPartViewer)
protected boolean handleDragInProgress()
movedPastThreshold()
,
mouseDrag(MouseEvent, EditPartViewer)
protected boolean handleDragStarted()
movedPastThreshold()
,
mouseDrag(MouseEvent, EditPartViewer)
protected void handleFinished()
protected boolean handleFocusGained()
focusGained(FocusEvent, EditPartViewer)
protected boolean handleFocusLost()
focusLost(FocusEvent, EditPartViewer)
protected boolean handleHover()
mouseHover(MouseEvent, EditPartViewer)
protected boolean handleKeyDown(KeyEvent e)
keyDown(KeyEvent, EditPartViewer)
protected boolean handleKeyUp(KeyEvent e)
keyUp(KeyEvent, EditPartViewer)
protected boolean handleMove()
mouseMove(MouseEvent, EditPartViewer)
protected boolean handleNativeDragFinished(DragSourceEvent event)
protected boolean handleNativeDragStarted(DragSourceEvent event)
protected boolean handleViewerEntered()
protected boolean handleViewerExited()
protected boolean isActive()
true
if the tool is active.
protected boolean isHoverActive()
true
if the tool is hovering.
protected boolean isInState(int state)
true
if the tool is in the given state.
public void keyDown(KeyEvent evt, EditPartViewer viewer)
handleKeyDown(KeyEvent)
.
keyDown
in interface Tool
evt
- the SWT KeyEventviewer
- the Viewer which received a key presspublic void keyUp(KeyEvent evt, EditPartViewer viewer)
handleKeyUp(KeyEvent)
.
keyUp
in interface Tool
evt
- the SWT KeyEventviewer
- the Viewer which received a key upprotected boolean movedPastThreshold()
true
if the mouse has been dragged past
the drag threshold.
public void nativeDragFinished(DragSourceEvent event, EditPartViewer viewer)
Tool
mouseUp(..)
will not occur
once a native drag has started. The Tool should correct its state to handle this
lost Event.
nativeDragFinished
in interface Tool
event
- the SWT DragSourceEventviewer
- the Viewer on which a native drag startedTool.nativeDragStarted(DragSourceEvent, EditPartViewer)
public void nativeDragStarted(DragSourceEvent event, EditPartViewer viewer)
Tool
mouseUp(..)
will not occur
once a native drag has started. The Tool should correct its state to handle this
lost Event.
nativeDragStarted
in interface Tool
event
- the SWT DragSourceEventviewer
- the Viewer on which a native drag startedTool.nativeDragStarted(DragSourceEvent, EditPartViewer)
public void mouseDoubleClick(MouseEvent me, EditPartViewer viewer)
handleDoubleClick(int)
.
mouseDoubleClick
in interface Tool
me
- the SWT mouse eventviewer
- the Viewer which received a double-clickpublic void mouseDown(MouseEvent me, EditPartViewer viewer)
handleButtonDown(int)
.
mouseDown
in interface Tool
me
- the SWT mouse eventviewer
- the Viewer which received a mouse downpublic void mouseDrag(MouseEvent me, EditPartViewer viewer)
handleDrag()
and/or
handleDragInProgress()
.
mouseDrag
in interface Tool
me
- the SWT mouse eventviewer
- the Viewer which received a dragpublic void mouseHover(MouseEvent me, EditPartViewer viewer)
handleHover()
.
mouseHover
in interface Tool
me
- the SWT mouse eventviewer
- the Viewer which received a mouse downMouseTrackListener.mouseHover(MouseEvent)
public void mouseMove(MouseEvent me, EditPartViewer viewer)
handleMove()
.
mouseMove
in interface Tool
me
- the SWT mouse eventviewer
- the Viewer which received a mouse moveTool.mouseDrag(MouseEvent, EditPartViewer)
public void mouseUp(MouseEvent me, EditPartViewer viewer)
handleButtonUp(int)
.
mouseUp
in interface Tool
me
- the SWT mouse eventviewer
- the Viewer which received a mouse upprotected void reactivate()
Deactivates
and then activates
this tool.
protected void refreshCursor()
calculateCursor()
protected void releaseToolCapture()
setToolCapture()
protected void removeFeedback(org.eclipse.draw2d.IFigure figure)
protected void resetFlags()
protected void setCurrentCommand(Command c)
protected void setCursor(Cursor cursor)
public void setDefaultCursor(Cursor cursor)
public void setDisabledCursor(Cursor cursor)
public void setEditDomain(EditDomain domain)
setEditDomain
in interface Tool
domain
- The EditDomain to which this Tool belongsprotected void setHoverActive(boolean value)
protected void setStartLocation(org.eclipse.draw2d.geometry.Point p)
protected void setState(int state)
protected void setToolCapture()
releaseToolCapture()
must be called when capture is no longer needed.
public void setUnloadWhenFinished(boolean value)
true
will cause the tool
to be unloaded after one operation has completed.
public void setViewer(EditPartViewer viewer)
setViewer
in interface Tool
viewer
- The current Viewerprotected boolean stateTransition(int start, int end)
start
to state end
and returns
true
if successful. If the tool is not in
state start
, the tool remains in its current
state and false
is returned to indicate
the failure.
protected final boolean unloadWhenFinished()
true
if the tool is set to unload when
its current operation is complete.
public void viewerEntered(MouseEvent me, EditPartViewer viewer)
handleViewerEntered()
.
FEATURE in SWT: mouseExit comes after mouseEntered. Therefore, if the current viewer is
not null
, it means the exit has not been sent yet by SWT. To maintain
proper ordering, GEF fakes the exit and calls handleViewerExited()
. The real
exit will then be ignored.
viewerEntered
in interface Tool
me
- the SWT mouse eventviewer
- the Viewer which received a mouse enterpublic void viewerExited(MouseEvent me, EditPartViewer viewer)
handleViewerExited()
.
viewerExited
in interface Tool
me
- the SWT mouse eventviewer
- the Viewer which received a mouse exit
|
Eclipse GEF 2.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |