Eclipse Draw2d
2.1

org.eclipse.draw2d
Class SWTEventDispatcher

java.lang.Object
  |
  +--org.eclipse.draw2d.EventDispatcher
        |
        +--org.eclipse.draw2d.SWTEventDispatcher

public class SWTEventDispatcher
extends EventDispatcher

The SWTEventDispatcher provides draw2d with the ability to dispatch SWT Events. The LightweightSystem adds SWT event listeners on its Canvas. When the Canvas receives an SWT event, it calls the appropriate dispatcher method in SWTEventDispatcher.


Nested Class Summary
protected  class SWTEventDispatcher.FigureAccessibilityDispatcher
          Implements EventDispatcher.AccessibilityDispatcher but does nothing in the implementation.
 
Nested classes inherited from class org.eclipse.draw2d.EventDispatcher
 
Field Summary
protected static int ANY_BUTTON
          Used to tell if any button is pressed without regard to the specific button.
protected  Control control
          The control this dispatcher is listening to.
 
Constructor Summary
SWTEventDispatcher()
           
 
Method Summary
 void dispatchFocusGained(FocusEvent e)
          Dispatches a focus gained event.
 void dispatchFocusLost(FocusEvent e)
          Dispatches a focus lost event.
 void dispatchKeyPressed(KeyEvent e)
          Dispatches a key pressed event.
 void dispatchKeyReleased(KeyEvent e)
          Dispatches a key released event.
 void dispatchKeyTraversed(TraverseEvent e)
          Dispatches a key traversed event.
 void dispatchMouseDoubleClicked(MouseEvent me)
          Dispatches a mouse double clicked event.
 void dispatchMouseEntered(MouseEvent me)
          Dispatches a mouse entered event.
 void dispatchMouseExited(MouseEvent me)
          Dispatches a mouse exited event.
 void dispatchMouseHover(MouseEvent me)
          Dispatches a mouse hover event.
 void dispatchMouseMoved(MouseEvent me)
          Dispatches a moved event event.
 void dispatchMousePressed(MouseEvent me)
          Dispatches a mouse pressed event.
 void dispatchMouseReleased(MouseEvent me)
          Dispatches a mouse released event.
protected  EventDispatcher.AccessibilityDispatcher getAccessibilityDispatcher()
          Returns the AccessibilityDispatcher.
protected  MouseEvent getCurrentEvent()
          Returns the current mouse event.
protected  IFigure getCursorTarget()
          Returns the figure that the cursor is over.
protected  FocusTraverseManager getFocusTraverseManager()
          Returns the FocusTraverseManager which is used to determine which figure will get focus when a TAB or ALT+TAB key sequence occurs.
protected  IFigure getMouseTarget()
          Returns the figure that is the target of mouse events.
protected  IFigure getRoot()
          Returns the root figure for this dispatcher.
protected  ToolTipHelper getToolTipHelper()
          Returns the ToolTipHelper used to display tooltips on hover events.
 boolean isCaptured()
           
protected  void releaseCapture()
          Releases capture initiated by setCapture(IFigure).
 void requestFocus(IFigure fig)
          Requests focus for the given figure.
 void requestRemoveFocus(IFigure fig)
          Requests focus to be removed from the given figure.
protected  void setCapture(IFigure figure)
          Sets capture to the given figure.
 void setControl(Control c)
          Sets the contol associated with this event dispatcher.
protected  void setCursor(Cursor c)
          Sets the mouse cursor.
 void setEnableKeyTraversal(boolean traverse)
          Enables key traversal via TAB and ALT+TAB if traverse is true.
protected  void setFigureUnderCursor(IFigure f)
          Sets the figure under the mouse cursor.
protected  void setFocus(IFigure fig)
          Sets the focus figure.
protected  void setHoverSource(Figure figure, MouseEvent me)
          Sets the figure that the mouse cursor is hovering over.
protected  void setMouseTarget(IFigure figure)
          Sets the given figure to be the target of future mouse events.
 void setRoot(IFigure figure)
          Sets the root figure for this dispatcher.
protected  void updateCursor()
          Updates the cursor.
protected  void updateFigureUnderCursor(MouseEvent me)
          Updates the figure under the cursor, unless the mouse is captured, in which case all mouse events will be routed to the figure that captured the mouse.
protected  void updateHoverSource(MouseEvent me)
          Updates the figure that will receive hover events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANY_BUTTON

protected static final int ANY_BUTTON
Used to tell if any button is pressed without regard to the specific button.

See Also:
Constant Field Values

control

protected Control control
The control this dispatcher is listening to.

Constructor Detail

SWTEventDispatcher

public SWTEventDispatcher()
Method Detail

dispatchFocusGained

public void dispatchFocusGained(FocusEvent e)
Description copied from class: EventDispatcher
Dispatches a focus gained event.

Specified by:
dispatchFocusGained in class EventDispatcher
Parameters:
e - the event
See Also:
EventDispatcher.dispatchFocusGained(FocusEvent)

dispatchFocusLost

public void dispatchFocusLost(FocusEvent e)
Description copied from class: EventDispatcher
Dispatches a focus lost event.

Specified by:
dispatchFocusLost in class EventDispatcher
Parameters:
e - the event
See Also:
EventDispatcher.dispatchFocusLost(FocusEvent)

dispatchKeyPressed

public void dispatchKeyPressed(KeyEvent e)
Description copied from class: EventDispatcher
Dispatches a key pressed event.

Specified by:
dispatchKeyPressed in class EventDispatcher
Parameters:
e - the event
See Also:
EventDispatcher.dispatchKeyPressed(KeyEvent)

dispatchKeyReleased

public void dispatchKeyReleased(KeyEvent e)
Description copied from class: EventDispatcher
Dispatches a key released event.

Specified by:
dispatchKeyReleased in class EventDispatcher
Parameters:
e - the event
See Also:
EventDispatcher.dispatchKeyReleased(KeyEvent)

dispatchKeyTraversed

public void dispatchKeyTraversed(TraverseEvent e)
Description copied from class: EventDispatcher
Dispatches a key traversed event.

Specified by:
dispatchKeyTraversed in class EventDispatcher
Parameters:
e - the event
See Also:
EventDispatcher.dispatchKeyTraversed(TraverseEvent)

dispatchMouseHover

public void dispatchMouseHover(MouseEvent me)
Description copied from class: EventDispatcher
Dispatches a mouse hover event.

Specified by:
dispatchMouseHover in class EventDispatcher
Parameters:
me - the event
See Also:
EventDispatcher.dispatchMouseHover(MouseEvent)

dispatchMouseDoubleClicked

public void dispatchMouseDoubleClicked(MouseEvent me)
Description copied from class: EventDispatcher
Dispatches a mouse double clicked event.

Specified by:
dispatchMouseDoubleClicked in class EventDispatcher
Parameters:
me - the event
See Also:
EventDispatcher.dispatchMouseDoubleClicked(MouseEvent)

dispatchMouseEntered

public void dispatchMouseEntered(MouseEvent me)
Description copied from class: EventDispatcher
Dispatches a mouse entered event.

Specified by:
dispatchMouseEntered in class EventDispatcher
Parameters:
me - the event
See Also:
EventDispatcher.dispatchMouseEntered(MouseEvent)

dispatchMouseExited

public void dispatchMouseExited(MouseEvent me)
Description copied from class: EventDispatcher
Dispatches a mouse exited event.

Specified by:
dispatchMouseExited in class EventDispatcher
Parameters:
me - the event
See Also:
EventDispatcher.dispatchMouseExited(MouseEvent)

dispatchMousePressed

public void dispatchMousePressed(MouseEvent me)
Description copied from class: EventDispatcher
Dispatches a mouse pressed event.

Specified by:
dispatchMousePressed in class EventDispatcher
Parameters:
me - the event
See Also:
EventDispatcher.dispatchMousePressed(MouseEvent)

dispatchMouseMoved

public void dispatchMouseMoved(MouseEvent me)
Description copied from class: EventDispatcher
Dispatches a moved event event.

Specified by:
dispatchMouseMoved in class EventDispatcher
Parameters:
me - the event
See Also:
EventDispatcher.dispatchMouseMoved(MouseEvent)

dispatchMouseReleased

public void dispatchMouseReleased(MouseEvent me)
Description copied from class: EventDispatcher
Dispatches a mouse released event.

Specified by:
dispatchMouseReleased in class EventDispatcher
Parameters:
me - the event
See Also:
EventDispatcher.dispatchMouseReleased(MouseEvent)

getAccessibilityDispatcher

protected EventDispatcher.AccessibilityDispatcher getAccessibilityDispatcher()
Description copied from class: EventDispatcher
Returns the AccessibilityDispatcher.

Specified by:
getAccessibilityDispatcher in class EventDispatcher
Returns:
the AccessibilityDispatcher
See Also:
EventDispatcher.getAccessibilityDispatcher()

getCurrentEvent

protected MouseEvent getCurrentEvent()
Returns the current mouse event.

Returns:
the current mouse event

getCursorTarget

protected IFigure getCursorTarget()
Returns the figure that the cursor is over.

Returns:
the cursor target

getToolTipHelper

protected ToolTipHelper getToolTipHelper()
Returns the ToolTipHelper used to display tooltips on hover events.

Returns:
the ToolTipHelper

getFocusTraverseManager

protected final FocusTraverseManager getFocusTraverseManager()
Returns the FocusTraverseManager which is used to determine which figure will get focus when a TAB or ALT+TAB key sequence occurs.

Returns:
the FocusTraverseManager

getMouseTarget

protected IFigure getMouseTarget()
Returns the figure that is the target of mouse events. This may not be the figure beneath the cursor because another figure may have captured the mouse and will continue to get mouse events until capture is released.

Returns:
the mouse target

getRoot

protected IFigure getRoot()
Returns the root figure for this dispatcher.

Returns:
the root figure

isCaptured

public boolean isCaptured()
Specified by:
isCaptured in class EventDispatcher
Returns:
whether events are captured by a figure
See Also:
EventDispatcher.isCaptured()

releaseCapture

protected void releaseCapture()
Description copied from class: EventDispatcher
Releases capture initiated by EventDispatcher.setCapture(IFigure).

Specified by:
releaseCapture in class EventDispatcher
See Also:
EventDispatcher.releaseCapture()

requestFocus

public void requestFocus(IFigure fig)
Description copied from class: EventDispatcher
Requests focus for the given figure.

Specified by:
requestFocus in class EventDispatcher
Parameters:
fig - the figure requesting focus
See Also:
EventDispatcher.requestFocus(IFigure)

requestRemoveFocus

public void requestRemoveFocus(IFigure fig)
Description copied from class: EventDispatcher
Requests focus to be removed from the given figure.

Specified by:
requestRemoveFocus in class EventDispatcher
Parameters:
fig - the figure requesting focus be removed
See Also:
EventDispatcher.requestRemoveFocus(IFigure)

setCapture

protected void setCapture(IFigure figure)
Description copied from class: EventDispatcher
Sets capture to the given figure. All subsequent events will be sent to the given figure until EventDispatcher.releaseCapture() is called.

Specified by:
setCapture in class EventDispatcher
Parameters:
figure - the figure capturing the events
See Also:
EventDispatcher.setCapture(IFigure)

setControl

public void setControl(Control c)
Description copied from class: EventDispatcher
Sets the contol associated with this event dispatcher.

Specified by:
setControl in class EventDispatcher
Parameters:
c - the control
See Also:
EventDispatcher.setControl(Control)

setCursor

protected void setCursor(Cursor c)
Sets the mouse cursor.

Parameters:
c - the new cursor

setEnableKeyTraversal

public void setEnableKeyTraversal(boolean traverse)
Enables key traversal via TAB and ALT+TAB if traverse is true. Disables it otherwise.

Parameters:
traverse - whether key traversal should be enabled

setFigureUnderCursor

protected void setFigureUnderCursor(IFigure f)
Sets the figure under the mouse cursor.

Parameters:
f - the new figure under the cursor

setFocus

protected void setFocus(IFigure fig)
Sets the focus figure. If the figure currently with focus is not null, IFigure.handleFocusLost(FocusEvent) is called on the current focused figure. If the new focus figure is not null, this will call IFigure.handleFocusGained(FocusEvent) on the new focused figure.

Parameters:
fig - the new focus figure

setHoverSource

protected void setHoverSource(Figure figure,
                              MouseEvent me)
Sets the figure that the mouse cursor is hovering over.

Parameters:
figure - the new hover source
me - the mouse event

setMouseTarget

protected void setMouseTarget(IFigure figure)
Sets the given figure to be the target of future mouse events.

Parameters:
figure - the new mouse target

setRoot

public void setRoot(IFigure figure)
Description copied from class: EventDispatcher
Sets the root figure for this dispatcher.

Specified by:
setRoot in class EventDispatcher
Parameters:
figure - the root figure
See Also:
EventDispatcher.setRoot(IFigure)

updateCursor

protected void updateCursor()
Description copied from class: EventDispatcher
Updates the cursor.

Specified by:
updateCursor in class EventDispatcher
See Also:
EventDispatcher.updateCursor()

updateFigureUnderCursor

protected void updateFigureUnderCursor(MouseEvent me)
Updates the figure under the cursor, unless the mouse is captured, in which case all mouse events will be routed to the figure that captured the mouse.

Parameters:
me - the mouse event

updateHoverSource

protected void updateHoverSource(MouseEvent me)
Updates the figure that will receive hover events. The hover source must have a tooltip. If the figure under the mouse doesn't have a tooltip set, this method will walk up the ancestor hierarchy until either a figure with a tooltip is found or it gets to the root figure.

Parameters:
me - the mouse event

Eclipse Draw2d
2.1

Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.