org.eclipse.graphiti.tb
Class DefaultToolBehaviorProvider

java.lang.Object
  extended by org.eclipse.graphiti.tb.DefaultToolBehaviorProvider
All Implemented Interfaces:
IToolBehaviorProvider

public class DefaultToolBehaviorProvider
extends Object
implements IToolBehaviorProvider

The Class DefaultToolBehaviorProvider.


Field Summary
protected static int CONTEXT_BUTTON_DELETE
          Identifier for a generic context button, used in setGenericContextButtons(IContextButtonPadData, PictogramElement, int) .
protected static int CONTEXT_BUTTON_REMOVE
          Identifier for a generic context button, used in setGenericContextButtons(IContextButtonPadData, PictogramElement, int) .
protected static int CONTEXT_BUTTON_UPDATE
          Identifier for a generic context button, used in setGenericContextButtons(IContextButtonPadData, PictogramElement, int) .
static int DEFAULT_LINE_SELECTION_WIDTH
          The default selection width (the tolerance area a user can click to still select) a lathy object (e.g.
private static String DIAGRAM_PROPERTY_CONTRIBUTOR_SUFFIX
           
private  IDiagramTypeProvider diagramTypeProvider
           
protected static IContextMenuEntry[] NO_CONTEXT_MENU_ENTRIES
          The Constant NO_CONTEXT_MENU_ENTRIES.
private static IDecorator[] NO_RENDERING_DECORATORS
           
protected  int THRESHOLD_FOR_LONG_RUNNING_OPERATION
           
private static double[] ZOOM_LEVELS
           
 
Constructor Summary
DefaultToolBehaviorProvider(IDiagramTypeProvider diagramTypeProvider)
          Creates a new DefaultToolBehaviorProvider.
 
Method Summary
 void dispose()
          Dispose.
 boolean equalsBusinessObjects(Object o1, Object o2)
          Default Implementation.
protected  ILocation getAbsoluteLocation(GraphicsAlgorithm ga)
          Returns the location of the graphics algorithm in absolute coordinates.
protected  ILocation getAbsoluteLocation(PictogramElement pe)
          Returns the location of the graphics algorithm associated to the pictogram element in absolute coordinates.
 Object getAdapter(Class<?> type)
          Returns the adapter for the specified key.
 GraphicsAlgorithm getChopboxAnchorArea(PictogramElement pe)
          Provides the graphics algorithm that defines the outline for the given pictogram element's chopbox Anchor.
 GraphicsAlgorithm[] getClickArea(PictogramElement pe)
          The returned graphics algorithm's define the area where the user can click to select the shape.
 ICustomFeature getCommandFeature(CustomContext context, String hint)
          Command features can do anything, but they are tied to an external command.
 GraphicsAlgorithm getContentArea(ContainerShape cs)
          The returned graphics algorithm defines the technical container for active children.
 IContextButtonPadData getContextButtonPad(IPictogramElementContext context)
          Returns the context button pad data for the given pictogram element context.
 IContextMenuEntry[] getContextMenu(ICustomContext context)
          Returns the context menu for the current mouse location.
 String getContributorId()
          Returns the contributor ID for the tabbed property sheet page.
 IDecorator[] getDecorators(PictogramElement pe)
          Returns decorators which will be used at rendering time to decorate the graphical representation of the given pictogram element.
Currently only decorators of type IImageDecorator are supported.
 DiagramScrollingBehavior getDiagramScrollingBehavior()
          Deprecated. Scroll bar based infinite canvas is a workaround for Bug 195527 and can be harmed by GEF modifications. It will be removed then
protected  IDiagramTypeProvider getDiagramTypeProvider()
          Gets the diagram type provider.
 ICustomFeature getDoubleClickFeature(IDoubleClickContext context)
          Returns a feature which will be executed at at double click.
protected  IFeatureProvider getFeatureProvider()
          Gets the feature provider.
 int getLineSelectionWidth(Polyline polyline)
          Is asked to return the selection width (the tolerance area a user can click to still select) a lathy object (e.g.
 ILocationInfo getLocationInfo(PictogramElement pe, ILocationInfo locationInfo)
          Returns the location info which will be used for direct editing if the framework cannot decide this.
 IPaletteCompartmentEntry[] getPalette()
          Default implementation: creates a connection and an object compartment.
 PictogramElement getSelection(PictogramElement originalPe, PictogramElement[] oldSelection)
          Override this method if you want to change the default selection on mouse click.
 GraphicsAlgorithm getSelectionBorder(PictogramElement pe)
          The returned graphics algorithm defines the selection border and the rectangle where the context buttons appear at.
 IAnchorSelectionInfo getSelectionInfoForAnchor(Anchor anchor)
          Return the selection info for the given anchor.
 IConnectionSelectionInfo getSelectionInfoForConnection(Connection connection)
          Return the selection info for the given connection.
 IShapeSelectionInfo getSelectionInfoForShape(Shape shape)
          Return the selection info for the given shape.
 ICustomFeature getSingleClickFeature(ISingleClickContext context)
          Returns a feature which will be executed at at a single click on an already selected shape.
 String getTitleToolTip()
          Returns a tooltip for the workbench titlebar.
 Object getToolTip(GraphicsAlgorithm ga)
          Returns the tooltip to be attached to the graphical representation of the given graphics algorithm.
 double[] getZoomLevels()
          Gets the zoom levels.
 boolean isConnectionSelectionEnabled()
          Indicates if the selection of connections is enabled.
 boolean isDefaultBendPointRenderingActive()
           
 boolean isMultiSelectionEnabled()
          Indicates if the selection of multiple elements is enabled.
 boolean isShowFlyoutPalette()
          IToolBehaviorProvider.isShowFlyoutPalette().
 boolean isShowGuides()
          Indicates whether guides will be shown or not.
 boolean isShowMarqueeTool()
          IToolBehaviorProvider.isShowMarqueeTool().
 boolean isShowSelectionTool()
          IToolBehaviorProvider.isShowSelectionTool().
 void postExecute(IExecutionInfo executionInfo)
          Called after execution on stack.
 void preExecute(IExecutionInfo executionInfo)
          Called before execution on stack.
private  void setDiagramTypeProvider(IDiagramTypeProvider diagramTypeProvider)
           
protected  void setGenericContextButtons(IContextButtonPadData data, PictogramElement pe, int identifiers)
          Sets the defined generic context buttons to the given IContextButtonPadData.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_LINE_SELECTION_WIDTH

public static final int DEFAULT_LINE_SELECTION_WIDTH
The default selection width (the tolerance area a user can click to still select) a lathy object (e.g. Polyline or Polygon for Shapes and Connections) in the diagram. Is returned in the default implementation of getLineSelectionWidth(Polyline).

Since:
0.9
See Also:
Constant Field Values

THRESHOLD_FOR_LONG_RUNNING_OPERATION

protected int THRESHOLD_FOR_LONG_RUNNING_OPERATION

NO_RENDERING_DECORATORS

private static final IDecorator[] NO_RENDERING_DECORATORS

ZOOM_LEVELS

private static double[] ZOOM_LEVELS

DIAGRAM_PROPERTY_CONTRIBUTOR_SUFFIX

private static final String DIAGRAM_PROPERTY_CONTRIBUTOR_SUFFIX
See Also:
Constant Field Values

CONTEXT_BUTTON_UPDATE

protected static int CONTEXT_BUTTON_UPDATE
Identifier for a generic context button, used in setGenericContextButtons(IContextButtonPadData, PictogramElement, int) .


CONTEXT_BUTTON_REMOVE

protected static int CONTEXT_BUTTON_REMOVE
Identifier for a generic context button, used in setGenericContextButtons(IContextButtonPadData, PictogramElement, int) .


CONTEXT_BUTTON_DELETE

protected static int CONTEXT_BUTTON_DELETE
Identifier for a generic context button, used in setGenericContextButtons(IContextButtonPadData, PictogramElement, int) .


NO_CONTEXT_MENU_ENTRIES

protected static final IContextMenuEntry[] NO_CONTEXT_MENU_ENTRIES
The Constant NO_CONTEXT_MENU_ENTRIES.


diagramTypeProvider

private IDiagramTypeProvider diagramTypeProvider
Constructor Detail

DefaultToolBehaviorProvider

public DefaultToolBehaviorProvider(IDiagramTypeProvider diagramTypeProvider)
Creates a new DefaultToolBehaviorProvider.

Parameters:
diagramTypeProvider - the diagram type provider
Method Detail

dispose

public void dispose()
Description copied from interface: IToolBehaviorProvider
Dispose.

Specified by:
dispose in interface IToolBehaviorProvider

getAdapter

public Object getAdapter(Class<?> type)
Description copied from interface: IToolBehaviorProvider
Returns the adapter for the specified key. This method will be called in the getAdapter() method of the graphical editor.

Specified by:
getAdapter in interface IToolBehaviorProvider
Parameters:
type - the type
Returns:
the adapter

getSelection

public PictogramElement getSelection(PictogramElement originalPe,
                                     PictogramElement[] oldSelection)
Description copied from interface: IToolBehaviorProvider
Override this method if you want to change the default selection on mouse click.

Specified by:
getSelection in interface IToolBehaviorProvider
Parameters:
originalPe - the original pictogram element
oldSelection - the old selection
Returns:
an active pictogram element to be selected instead; return null if there should not be a special selection behavior; if there should not be a selection simply return the diagram

getSelectionInfoForConnection

public IConnectionSelectionInfo getSelectionInfoForConnection(Connection connection)
Description copied from interface: IToolBehaviorProvider
Return the selection info for the given connection.

Specified by:
getSelectionInfoForConnection in interface IToolBehaviorProvider
Parameters:
connection - the connection
Returns:
the connection selection info
Since:
0.10

getContextButtonPad

public IContextButtonPadData getContextButtonPad(IPictogramElementContext context)
Description copied from interface: IToolBehaviorProvider
Returns the context button pad data for the given pictogram element context. The context button pad data defines, which context buttons to show for a given pictogram element. Can return null, if no there is no context button pad for the given pictogram element.

Specified by:
getContextButtonPad in interface IToolBehaviorProvider
Parameters:
context - The pictogram element context, for which to return the context button pad data.
Returns:
The context button pad data for the given pictogram element context.

setGenericContextButtons

protected void setGenericContextButtons(IContextButtonPadData data,
                                        PictogramElement pe,
                                        int identifiers)
Sets the defined generic context buttons to the given IContextButtonPadData. You should never change the list of generic context buttons directly but always use this method. This ensures, that only the 'generic' context buttons are set and that they have the correct ordering.

Parameters:
data - The IContextButtonPadData to which to set the generic context buttons.
pe - The pictogram element for which to get the underlying features of the context buttons.
identifiers - The context button identifiers (e.g. " CONTEXT_BUTTON_UPDATE & CONTEXT_BUTTON_REMOVE")

getAbsoluteLocation

protected ILocation getAbsoluteLocation(PictogramElement pe)
Returns the location of the graphics algorithm associated to the pictogram element in absolute coordinates. Also see getAbsoluteLocation(GraphicsAlgorithm).

Parameters:
pe - The pictogram element, for which graphics algorithm to return the location.
Returns:
The location of the graphics algorithm associated to the pictogram element in absolute coordinates.

getAbsoluteLocation

protected ILocation getAbsoluteLocation(GraphicsAlgorithm ga)
Returns the location of the graphics algorithm in absolute coordinates.

Parameters:
ga - The graphics algorithm for which to return the location.
Returns:
The location of the graphics algorithm in absolute coordinates.

getContextMenu

public IContextMenuEntry[] getContextMenu(ICustomContext context)
Description copied from interface: IToolBehaviorProvider
Returns the context menu for the current mouse location.

Specified by:
getContextMenu in interface IToolBehaviorProvider
Parameters:
context - the custom context which contains the info about the location where the context menu appears.
Returns:
the context menu

getLocationInfo

public ILocationInfo getLocationInfo(PictogramElement pe,
                                     ILocationInfo locationInfo)
Description copied from interface: IToolBehaviorProvider
Returns the location info which will be used for direct editing if the framework cannot decide this. E.g. a shape is selected and the user presses F2 but the mouse is outside the shape.

Specified by:
getLocationInfo in interface IToolBehaviorProvider
Parameters:
pe - the active and selected pictogram element
locationInfo - the current location info determined by the framework
Returns:
the location info for the given selected pictogram element

getDoubleClickFeature

public ICustomFeature getDoubleClickFeature(IDoubleClickContext context)
Description copied from interface: IToolBehaviorProvider
Returns a feature which will be executed at at double click. For that purpose a custom feature is used, because custom features appear in the context menu and the double click feature should also appear in the context menu (usual UI guideline).

Specified by:
getDoubleClickFeature in interface IToolBehaviorProvider
Parameters:
context - contains information where the double click gesture has happened
Returns:
the feature to execute

getSingleClickFeature

public ICustomFeature getSingleClickFeature(ISingleClickContext context)
Description copied from interface: IToolBehaviorProvider
Returns a feature which will be executed at at a single click on an already selected shape. If the feature provider already returned a direct editing feature for that single click, then this method will not be called.

Specified by:
getSingleClickFeature in interface IToolBehaviorProvider
Parameters:
context - contains information where the single click gesture has happened
Returns:
the feature to execute
Since:
0.10

getCommandFeature

public ICustomFeature getCommandFeature(CustomContext context,
                                        String hint)
Description copied from interface: IToolBehaviorProvider
Command features can do anything, but they are tied to an external command. They can be invoked through a keybinding, a menu action or a toolbar item.

Specified by:
getCommandFeature in interface IToolBehaviorProvider
Parameters:
context - the context
hint - the hint specified in the command binding
Returns:
the feature
Since:
0.10

getPalette

public IPaletteCompartmentEntry[] getPalette()
Default implementation: creates a connection and an object compartment. Adds all connection creation features and creation features.

Specified by:
getPalette in interface IToolBehaviorProvider
Returns:
the palette entries

getDecorators

public IDecorator[] getDecorators(PictogramElement pe)
Description copied from interface: IToolBehaviorProvider
Returns decorators which will be used at rendering time to decorate the graphical representation of the given pictogram element.
Currently only decorators of type IImageDecorator are supported.

Specified by:
getDecorators in interface IToolBehaviorProvider
Parameters:
pe - the pictogram element
Returns:
the decorators

getSelectionInfoForShape

public IShapeSelectionInfo getSelectionInfoForShape(Shape shape)
Description copied from interface: IToolBehaviorProvider
Return the selection info for the given shape.

Specified by:
getSelectionInfoForShape in interface IToolBehaviorProvider
Parameters:
shape - the shape
Returns:
the shape selection info
Since:
0.10

getSelectionInfoForAnchor

public IAnchorSelectionInfo getSelectionInfoForAnchor(Anchor anchor)
Description copied from interface: IToolBehaviorProvider
Return the selection info for the given anchor.

Specified by:
getSelectionInfoForAnchor in interface IToolBehaviorProvider
Parameters:
anchor - the anchor
Returns:
the anchor selection info
Since:
0.10

getZoomLevels

public double[] getZoomLevels()
Description copied from interface: IToolBehaviorProvider
Gets the zoom levels.

Specified by:
getZoomLevels in interface IToolBehaviorProvider
Returns:
the zoom levels

getDiagramScrollingBehavior

@Deprecated
public DiagramScrollingBehavior getDiagramScrollingBehavior()
Deprecated. Scroll bar based infinite canvas is a workaround for Bug 195527 and can be harmed by GEF modifications. It will be removed then

Description copied from interface: IToolBehaviorProvider
Override this method if you want to change the default scrolling behavior of the diagram. The default is DiagramScrollingBehavior.GEF_DEFAULT: the empty diagram comes up without scroll bars. The scroll bars start to appear when objects are moved to the outside of the currently visible area. For permanently visible scroll bars, return the value DiagramScrollingBehavior.SCROLLBARS_PERMANENTLY_VISIBLE.

Specified by:
getDiagramScrollingBehavior in interface IToolBehaviorProvider
Returns:
The DiagramScrollingBehavior
See Also:
getDiagramScrollingBehavior()

setDiagramTypeProvider

private void setDiagramTypeProvider(IDiagramTypeProvider diagramTypeProvider)

getDiagramTypeProvider

protected IDiagramTypeProvider getDiagramTypeProvider()
Gets the diagram type provider.

Returns:
the diagram type provider

getFeatureProvider

protected IFeatureProvider getFeatureProvider()
Gets the feature provider.

Returns:
the feature provider

preExecute

public void preExecute(IExecutionInfo executionInfo)
Description copied from interface: IToolBehaviorProvider
Called before execution on stack. Overriding this method can be necessary if any additional actions have to be processed before the stack will be executed.

Specified by:
preExecute in interface IToolBehaviorProvider
Parameters:
executionInfo - info about content to be executed

postExecute

public void postExecute(IExecutionInfo executionInfo)
Description copied from interface: IToolBehaviorProvider
Called after execution on stack. Overriding this method can be necessary if any additional actions have to be processed after the stack will be executed. As example a tool could process an automatic layout of the diagram after each diagram modification.

Specified by:
postExecute in interface IToolBehaviorProvider
Parameters:
executionInfo - info about content to be executed

getToolTip

public Object getToolTip(GraphicsAlgorithm ga)
Returns the tooltip to be attached to the graphical representation of the given graphics algorithm.

Specified by:
getToolTip in interface IToolBehaviorProvider
Parameters:
graphicsAlgorithm - the graphics algorithm
Returns:
the tooltip
Since:
0.10

getSelectionBorder

public GraphicsAlgorithm getSelectionBorder(PictogramElement pe)
Description copied from interface: IToolBehaviorProvider
The returned graphics algorithm defines the selection border and the rectangle where the context buttons appear at.

Specified by:
getSelectionBorder in interface IToolBehaviorProvider
Parameters:
pe - the pictogram element
Returns:
the graphics algorithm which defines the selection border

getClickArea

public GraphicsAlgorithm[] getClickArea(PictogramElement pe)
Description copied from interface: IToolBehaviorProvider
The returned graphics algorithm's define the area where the user can click to select the shape.

Specified by:
getClickArea in interface IToolBehaviorProvider
Parameters:
pe - the pictogram element
Returns:
the click area

getChopboxAnchorArea

public GraphicsAlgorithm getChopboxAnchorArea(PictogramElement pe)
Description copied from interface: IToolBehaviorProvider
Provides the graphics algorithm that defines the outline for the given pictogram element's chopbox Anchor.

Specified by:
getChopboxAnchorArea in interface IToolBehaviorProvider
Parameters:
pe - the given pictogram element
Returns:
the graphics algorithm that defines the outline for connections from or to the shape's chopbox anchor

getTitleToolTip

public String getTitleToolTip()
Description copied from interface: IToolBehaviorProvider
Returns a tooltip for the workbench titlebar.

Specified by:
getTitleToolTip in interface IToolBehaviorProvider
Returns:
a tooltip or null to indicate that the default from the graphics framework will be used

isShowGuides

public boolean isShowGuides()
Description copied from interface: IToolBehaviorProvider
Indicates whether guides will be shown or not.

Specified by:
isShowGuides in interface IToolBehaviorProvider
Returns:
true, if guides should be shown

getContentArea

public GraphicsAlgorithm getContentArea(ContainerShape cs)
Description copied from interface: IToolBehaviorProvider
The returned graphics algorithm defines the technical container for active children. Currently implementers have to secure to deliver a (Rounded)Rectangle. Does not make sense for other types of graphics algorithm.

Specified by:
getContentArea in interface IToolBehaviorProvider
Parameters:
cs - the container shape
Returns:
the graphics algorithm acting as technical container

getContributorId

public String getContributorId()
Description copied from interface: IToolBehaviorProvider
Returns the contributor ID for the tabbed property sheet page.

Specified by:
getContributorId in interface IToolBehaviorProvider
Returns:
the contributor ID for the tabbed property sheet page.

isDefaultBendPointRenderingActive

public boolean isDefaultBendPointRenderingActive()

isMultiSelectionEnabled

public boolean isMultiSelectionEnabled()
Description copied from interface: IToolBehaviorProvider
Indicates if the selection of multiple elements is enabled. Override this method and return false if an editor with single selection behavior is needed.

Specified by:
isMultiSelectionEnabled in interface IToolBehaviorProvider
Returns:
false, if single selection is enforced

isConnectionSelectionEnabled

public boolean isConnectionSelectionEnabled()
Description copied from interface: IToolBehaviorProvider
Indicates if the selection of connections is enabled.

Specified by:
isConnectionSelectionEnabled in interface IToolBehaviorProvider
Returns:
true, if selection of connections is enabled

equalsBusinessObjects

public boolean equalsBusinessObjects(Object o1,
                                     Object o2)
Default Implementation. Customers requested the possibility to plug in equality decision based on object identity.

Specified by:
equalsBusinessObjects in interface IToolBehaviorProvider
Returns:
true if the business objects are deemed equal, false otherwise.

isShowFlyoutPalette

public boolean isShowFlyoutPalette()
IToolBehaviorProvider.isShowFlyoutPalette(). This default implementation returns true and tells the framework to show the palette.

Specified by:
isShowFlyoutPalette in interface IToolBehaviorProvider
Returns:
true
Since:
0.9

isShowSelectionTool

public boolean isShowSelectionTool()
IToolBehaviorProvider.isShowSelectionTool(). This default implementation returns true and tells the framework to show the selection tool entry in the palette.

Specified by:
isShowSelectionTool in interface IToolBehaviorProvider
Returns:
true
Since:
0.9

isShowMarqueeTool

public boolean isShowMarqueeTool()
IToolBehaviorProvider.isShowMarqueeTool(). This default implementation returns true and tells the framework to show the marquee tool entry in the palette.

Specified by:
isShowMarqueeTool in interface IToolBehaviorProvider
Returns:
true
Since:
0.9

getLineSelectionWidth

public int getLineSelectionWidth(Polyline polyline)
Is asked to return the selection width (the tolerance area a user can click to still select) a lathy object (e.g. Polyline or Polygon for Shapes and Connections) in the diagram. The method is called when a new object is drawn for the first time onto a diagram (on creation of the object or on opening the diagram).
The default implementation returns DEFAULT_LINE_SELECTION_WIDTH with the value 5 for all shapes.

Specified by:
getLineSelectionWidth in interface IToolBehaviorProvider
Parameters:
polyline - the Polyline object to get the selection width for
Returns:
an int representing the allowed tolerance for clicking in pixels
Since:
0.9


Copyright (c) SAP AG 2005, 2012.