Runtime

org.eclipse.gmf.runtime.diagram.ui.editpolicies
Class DiagramAssistantEditPolicy

java.lang.Object
  extended byorg.eclipse.gef.editpolicies.AbstractEditPolicy
      extended byorg.eclipse.gef.editpolicies.GraphicalEditPolicy
          extended byorg.eclipse.gmf.runtime.diagram.ui.editpolicies.DiagramAssistantEditPolicy
All Implemented Interfaces:
EditPolicy, MouseMotionListener, RequestConstants
Direct Known Subclasses:
ConnectionHandleEditPolicy, PopupBarEditPolicy

public abstract class DiagramAssistantEditPolicy
extends GraphicalEditPolicy
implements MouseMotionListener

Encapsulates behavior common to editpolicies that popup diagram assistants.


Nested Class Summary
 
Nested classes inherited from class org.eclipse.draw2d.MouseMotionListener
MouseMotionListener.Stub
 
Field Summary
 
Fields inherited from interface org.eclipse.gef.EditPolicy
COMPONENT_ROLE, CONNECTION_BENDPOINTS_ROLE, CONNECTION_ENDPOINTS_ROLE, CONNECTION_ROLE, CONTAINER_ROLE, DIRECT_EDIT_ROLE, GRAPHICAL_NODE_ROLE, LAYOUT_ROLE, NODE_ROLE, PRIMARY_DRAG_ROLE, SELECTION_FEEDBACK_ROLE, TREE_CONTAINER_ROLE
 
Fields inherited from interface org.eclipse.gef.RequestConstants
REQ_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 Summary
DiagramAssistantEditPolicy()
          Creates a new instance.
 
Method Summary
 void activate()
           
 void deactivate()
           
protected  int getAppearanceDelay()
          Gets the amount of time to wait before showing the diagram assistant.
protected  int getDisappearanceDelay()
          Gets the amount of time to wait before hiding the diagram assistant after it has been made visible.
protected  int getDisappearanceDelayUponExit()
          Gets the amount of time to wait before hiding the diagram assistant after the user has moved the mouse outside of the editpart.
protected  Point getMouseLocation()
          Gets the current mouse location.
protected abstract  void hideDiagramAssistant()
          Hides the diagram assistant figure(s).
protected  void hideDiagramAssistantAfterDelay(int delay)
          Hides the diagram assistant after a certain amount of time has passed.
protected abstract  boolean isDiagramAssistant(java.lang.Object object)
          Checks if the object is or is part of the diagram assistant figure.
protected abstract  boolean isDiagramAssistantShowing()
          Returns true if the diagram assistant is currently showing; false otherwise.
protected  boolean isPreferenceOn()
          Returns true if the preference to show this diagram assistant is on or if there is no applicable preference; false otherwise.
 void mouseDragged(MouseEvent me)
           
 void mouseEntered(MouseEvent me)
           
 void mouseExited(MouseEvent me)
           
 void mouseHover(MouseEvent me)
           
 void mouseMoved(MouseEvent me)
           
protected  void setAvoidHidingDiagramAssistant(boolean avoidHidingDiagramAssistant)
          Sets the flag to indicate that the diagram assistant should not be hidden.
protected  void setMouseLocation(Point mouseLocation)
          Sets the current mouse location.
protected  boolean shouldAvoidHidingDiagramAssistant()
          Returns true if the diagram assistant should not be hidden; false otherwise.
protected  boolean shouldShowDiagramAssistant()
          Returns true if the diagram assistant should be shown; false otherwise.
protected abstract  void showDiagramAssistant(Point referencePoint)
          Shows the diagram assistant figure(s).
protected  void showDiagramAssistantAfterDelay(int delay)
          Shows the diagram assistant after a certain amount of time has passed.
 
Methods inherited from class org.eclipse.gef.editpolicies.GraphicalEditPolicy
addFeedback, getFeedbackLayer, getHostFigure, getLayer, removeFeedback
 
Methods inherited from class org.eclipse.gef.editpolicies.AbstractEditPolicy
debugFeedback, eraseSourceFeedback, eraseTargetFeedback, getCommand, getHost, getTargetEditPart, setHost, showSourceFeedback, showTargetFeedback, toString, understandsRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DiagramAssistantEditPolicy

public DiagramAssistantEditPolicy()
Creates a new instance.

Method Detail

isDiagramAssistant

protected abstract boolean isDiagramAssistant(java.lang.Object object)
Checks if the object is or is part of the diagram assistant figure. This is used to determine if the mouse is hovering over the diagram assistant.

Parameters:
object - the object in question
Returns:
True if the object in question is or is part of the diagram assistant figure; false otherwise.

isDiagramAssistantShowing

protected abstract boolean isDiagramAssistantShowing()
Returns true if the diagram assistant is currently showing; false otherwise. This is used to determine if the diagram assistant should be shown or hidden at a given point in time.

Returns:
true if the diagram assistant is showing; false otherwise

showDiagramAssistant

protected abstract void showDiagramAssistant(Point referencePoint)
Shows the diagram assistant figure(s).

Parameters:
referencePoint - The reference point which may be used to determine where the diagram assistant should be located. This is most likely the current mouse location. This could be null, for example, when the host gains focus via the space bar, in which case the diagram assistant should be shown in a default location.

hideDiagramAssistant

protected abstract void hideDiagramAssistant()
Hides the diagram assistant figure(s).


shouldShowDiagramAssistant

protected boolean shouldShowDiagramAssistant()
Returns true if the diagram assistant should be shown; false otherwise. This can be overridden to check any other conditions which must be met prior to showing the diagram assistant.

Returns:
true if the diagram assistant should be shown; false otherwise.

isPreferenceOn

protected boolean isPreferenceOn()
Returns true if the preference to show this diagram assistant is on or if there is no applicable preference; false otherwise.


showDiagramAssistantAfterDelay

protected void showDiagramAssistantAfterDelay(int delay)
Shows the diagram assistant after a certain amount of time has passed.

Parameters:
delay - the delay in milliseconds

hideDiagramAssistantAfterDelay

protected void hideDiagramAssistantAfterDelay(int delay)
Hides the diagram assistant after a certain amount of time has passed.

Parameters:
delay - the delay in milliseconds

activate

public void activate()
Specified by:
activate in interface EditPolicy

deactivate

public void deactivate()
Specified by:
deactivate in interface EditPolicy

mouseEntered

public void mouseEntered(MouseEvent me)
Specified by:
mouseEntered in interface MouseMotionListener

mouseExited

public void mouseExited(MouseEvent me)
Specified by:
mouseExited in interface MouseMotionListener

mouseMoved

public void mouseMoved(MouseEvent me)
Specified by:
mouseMoved in interface MouseMotionListener

mouseHover

public void mouseHover(MouseEvent me)
Specified by:
mouseHover in interface MouseMotionListener

mouseDragged

public void mouseDragged(MouseEvent me)
Specified by:
mouseDragged in interface MouseMotionListener

getAppearanceDelay

protected int getAppearanceDelay()
Gets the amount of time to wait before showing the diagram assistant.

Returns:
the time to wait in milliseconds

getDisappearanceDelay

protected int getDisappearanceDelay()
Gets the amount of time to wait before hiding the diagram assistant after it has been made visible.

Returns:
the time to wait in milliseconds

getDisappearanceDelayUponExit

protected int getDisappearanceDelayUponExit()
Gets the amount of time to wait before hiding the diagram assistant after the user has moved the mouse outside of the editpart.

Returns:
the time to wait in milliseconds

getMouseLocation

protected Point getMouseLocation()
Gets the current mouse location. This will be null if the mouse is outside the host and diagram assistant figure.

Returns:
Returns the current mouse location

setMouseLocation

protected void setMouseLocation(Point mouseLocation)
Sets the current mouse location. If set to null, this implies that the mouse is outside the host and diagram assistant figure.

Parameters:
mouseLocation - the current mouse location

setAvoidHidingDiagramAssistant

protected void setAvoidHidingDiagramAssistant(boolean avoidHidingDiagramAssistant)
Sets the flag to indicate that the diagram assistant should not be hidden.

Parameters:
avoidHidingDiagramAssistant - Flag to indicate that the diagram assistant should not be hidden

shouldAvoidHidingDiagramAssistant

protected boolean shouldAvoidHidingDiagramAssistant()
Returns true if the diagram assistant should not be hidden; false otherwise.

Returns:
true if the diagram assistant should not be hidden; false otherwise.

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.