Package org.eclipse.graphiti.tb
Class DefaultToolBehaviorProvider
java.lang.Object
org.eclipse.graphiti.tb.DefaultToolBehaviorProvider
- All Implemented Interfaces:
IToolBehaviorProvider
The Class DefaultToolBehaviorProvider.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static intIdentifier for a generic context button, used insetGenericContextButtons(IContextButtonPadData, PictogramElement, int).protected static intIdentifier for a generic context button, used insetGenericContextButtons(IContextButtonPadData, PictogramElement, int).protected static intIdentifier for a generic context button, used insetGenericContextButtons(IContextButtonPadData, PictogramElement, int).static final intThe default selection width (the tolerance area a user can click to still select) a lathy object (e.g.protected static final IContextMenuEntry[]The Constant NO_CONTEXT_MENU_ENTRIES.protected int -
Constructor Summary
ConstructorsConstructorDescriptionDefaultToolBehaviorProvider(IDiagramTypeProvider diagramTypeProvider) Creates a newDefaultToolBehaviorProvider. -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Dispose.booleanequalsBusinessObjects(Object o1, Object o2) Default Implementation.protected ILocationReturns the location of the graphics algorithm in absolute coordinates.protected ILocationReturns the location of the graphics algorithm associated to the pictogram element in absolute coordinates.getAdapter(Class<?> type) Returns the adapter for the specified key.Provides the graphics algorithm that defines the outline for the given pictogram element's chopbox Anchor.The returned graphics algorithm's define the area where the user can click to select the shape.getCommandFeature(CustomContext context, String hint) Command features can do anything, but they are tied to an external command.The returned graphics algorithm defines the technical container for active children.Returns the context button pad data for the given pictogram element context.getContextMenu(ICustomContext context) Returns the context menu for the current mouse location.Returns the contributor ID for the tabbed property sheet page.Returns decorators which will be used at rendering time to decorate the graphical representation of the given pictogram element.Deprecated.Scroll bar based infinite canvas is a workaround for Bug 195527 and can be harmed by GEF modifications.protected IDiagramTypeProviderGets the diagram type provider.getDirectEditingInvalidNotificationTitle(IDirectEditingFeature feature, IDirectEditingContext context) Returns the title of the popup that appears when a user provides an invalid input for direct editing.getDoubleClickFeature(IDoubleClickContext context) Returns a feature which will be executed at at double click.protected IFeatureProviderGets the feature provider.intgetLineSelectionWidth(Polyline polyline) Is asked to return the selection width (the tolerance area a user can click to still select) a lathy object (e.g.getLocationInfo(PictogramElement pe, ILocationInfo locationInfo) Returns the location info which will be used for direct editing if the framework cannot decide this.Default implementation: creates a connection and an object compartment.getSelection(PictogramElement originalPe, PictogramElement[] oldSelection) Override this method if you want to change the default selection on mouse click.The returned graphics algorithm defines the selection border and the rectangle where the context buttons appear at.getSelectionInfoForAnchor(Anchor anchor) Return the selection info for the given anchor.getSelectionInfoForConnection(Connection connection) Return the selection info for the given connection.getSelectionInfoForShape(Shape shape) Return the selection info for the given shape.getSelections(PictogramElement selection) getSingleClickFeature(ISingleClickContext context) Returns a feature which will be executed at at a single click on an already selected shape.Returns a tooltip for the workbench titlebar.Returns the tooltip to be attached to the graphical representation of the given graphics algorithm.double[]Gets the zoom levels.booleanIndicates if the selection of connections is enabled.booleanbooleanIndicates if the selection of multiple elements is enabled.boolean.booleanIndicates whether guides will be shown or not.boolean.boolean.booleanisStayActiveAfterExecution(IConnectionCreationToolEntry connectionCreationToolEntry) Defines if the tool created for the givenIConnectionCreationToolEntrystays active after a connection has been created or not.booleanisStayActiveAfterExecution(IObjectCreationToolEntry objectCreationToolEntry) Defines if the tool created for the givenIObjectCreationToolEntrystays active after an object has been created or not.voidpostExecute(IExecutionInfo executionInfo) Called after execution on stack.voidpreExecute(IExecutionInfo executionInfo) Called before execution on stack.protected voidsetGenericContextButtons(IContextButtonPadData data, PictogramElement pe, int identifiers) Sets the defined generic context buttons to the given IContextButtonPadData.
-
Field Details
-
DEFAULT_LINE_SELECTION_WIDTH
public static final int DEFAULT_LINE_SELECTION_WIDTHThe default selection width (the tolerance area a user can click to still select) a lathy object (e.g.PolylineorPolygonforShapes andConnections) in the diagram. Is returned in the default implementation ofgetLineSelectionWidth(Polyline).- Since:
- 0.9
- See Also:
-
THRESHOLD_FOR_LONG_RUNNING_OPERATION
protected int THRESHOLD_FOR_LONG_RUNNING_OPERATION -
CONTEXT_BUTTON_UPDATE
protected static int CONTEXT_BUTTON_UPDATEIdentifier for a generic context button, used insetGenericContextButtons(IContextButtonPadData, PictogramElement, int). -
CONTEXT_BUTTON_REMOVE
protected static int CONTEXT_BUTTON_REMOVEIdentifier for a generic context button, used insetGenericContextButtons(IContextButtonPadData, PictogramElement, int). -
CONTEXT_BUTTON_DELETE
protected static int CONTEXT_BUTTON_DELETEIdentifier for a generic context button, used insetGenericContextButtons(IContextButtonPadData, PictogramElement, int). -
NO_CONTEXT_MENU_ENTRIES
The Constant NO_CONTEXT_MENU_ENTRIES.
-
-
Constructor Details
-
DefaultToolBehaviorProvider
Creates a newDefaultToolBehaviorProvider.- Parameters:
diagramTypeProvider- the diagram type provider
-
-
Method Details
-
dispose
public void dispose()Description copied from interface:IToolBehaviorProviderDispose.- Specified by:
disposein interfaceIToolBehaviorProvider
-
getAdapter
Description copied from interface:IToolBehaviorProviderReturns the adapter for the specified key. This method will be called in the getAdapter() method of the graphical editor.- Specified by:
getAdapterin interfaceIToolBehaviorProvider- Parameters:
type- the type- Returns:
- the adapter
-
getSelection
Description copied from interface:IToolBehaviorProviderOverride this method if you want to change the default selection on mouse click.- Specified by:
getSelectionin interfaceIToolBehaviorProvider- Parameters:
originalPe- the original pictogram elementoldSelection- the old selection- Returns:
- an active pictogram element to be selected instead; return
nullif there should not be a special selection behavior; if there should not be a selection simply return the diagram
-
getSelections
- Specified by:
getSelectionsin interfaceIToolBehaviorProvider- Since:
- 0.16
-
getSelectionInfoForConnection
Description copied from interface:IToolBehaviorProviderReturn the selection info for the given connection.- Specified by:
getSelectionInfoForConnectionin interfaceIToolBehaviorProvider- Parameters:
connection- the connection- Returns:
- the connection selection info
- Since:
- 0.10
-
getContextButtonPad
Description copied from interface:IToolBehaviorProviderReturns 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:
getContextButtonPadin interfaceIToolBehaviorProvider- 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
Returns the location of the graphics algorithm associated to the pictogram element in absolute coordinates. Also seegetAbsoluteLocation(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
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
Description copied from interface:IToolBehaviorProviderReturns the context menu for the current mouse location.- Specified by:
getContextMenuin interfaceIToolBehaviorProvider- Parameters:
context- the custom context which contains the info about the location where the context menu appears.- Returns:
- the context menu
-
getLocationInfo
Description copied from interface:IToolBehaviorProviderReturns 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:
getLocationInfoin interfaceIToolBehaviorProvider- Parameters:
pe- the active and selected pictogram elementlocationInfo- the current location info determined by the framework- Returns:
- the location info for the given selected pictogram element
-
getDoubleClickFeature
Description copied from interface:IToolBehaviorProviderReturns 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:
getDoubleClickFeaturein interfaceIToolBehaviorProvider- Parameters:
context- contains information where the double click gesture has happened- Returns:
- the feature to execute
-
getSingleClickFeature
Description copied from interface:IToolBehaviorProviderReturns 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:
getSingleClickFeaturein interfaceIToolBehaviorProvider- Parameters:
context- contains information where the single click gesture has happened- Returns:
- the feature to execute
- Since:
- 0.10
-
getCommandFeature
Description copied from interface:IToolBehaviorProviderCommand 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:
getCommandFeaturein interfaceIToolBehaviorProvider- Parameters:
context- the contexthint- the hint specified in the command binding- Returns:
- the feature
- Since:
- 0.10
-
getPalette
Default implementation: creates a connection and an object compartment. Adds all connection creation features and creation features.- Specified by:
getPalettein interfaceIToolBehaviorProvider- Returns:
- the palette entries
-
getDecorators
Description copied from interface:IToolBehaviorProviderReturns decorators which will be used at rendering time to decorate the graphical representation of the given pictogram element. Adding or removing decorators will not make the diagram dirty.
Decorators of typeIImageDecorator,IColorDecoratorandIBorderDecoratorare supported forShapes; forConnections onlyIColorDecorators are supported and they can only be used to change the foreground color of theConnection.- Specified by:
getDecoratorsin interfaceIToolBehaviorProvider- Parameters:
pe- the pictogram element- Returns:
- the decorators
-
getSelectionInfoForShape
Description copied from interface:IToolBehaviorProviderReturn the selection info for the given shape.- Specified by:
getSelectionInfoForShapein interfaceIToolBehaviorProvider- Parameters:
shape- the shape- Returns:
- the shape selection info
- Since:
- 0.10
-
getSelectionInfoForAnchor
Description copied from interface:IToolBehaviorProviderReturn the selection info for the given anchor.- Specified by:
getSelectionInfoForAnchorin interfaceIToolBehaviorProvider- Parameters:
anchor- the anchor- Returns:
- the anchor selection info
- Since:
- 0.10
-
getZoomLevels
public double[] getZoomLevels()Description copied from interface:IToolBehaviorProviderGets the zoom levels.- Specified by:
getZoomLevelsin interfaceIToolBehaviorProvider- Returns:
- the zoom levels
-
getDiagramScrollingBehavior
Deprecated.Scroll bar based infinite canvas is a workaround for Bug 195527 and can be harmed by GEF modifications. It will be removed thenDescription copied from interface:IToolBehaviorProviderOverride 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:
getDiagramScrollingBehaviorin interfaceIToolBehaviorProvider- Returns:
- The DiagramScrollingBehavior
- See Also:
-
getDiagramTypeProvider
Gets the diagram type provider.- Returns:
- the diagram type provider
-
getFeatureProvider
Gets the feature provider.- Returns:
- the feature provider
-
preExecute
Description copied from interface:IToolBehaviorProviderCalled 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:
preExecutein interfaceIToolBehaviorProvider- Parameters:
executionInfo- info about content to be executed
-
postExecute
Description copied from interface:IToolBehaviorProviderCalled 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:
postExecutein interfaceIToolBehaviorProvider- Parameters:
executionInfo- info about content to be executed
-
getToolTip
Returns the tooltip to be attached to the graphical representation of the given graphics algorithm.- Specified by:
getToolTipin interfaceIToolBehaviorProvider- Parameters:
graphicsAlgorithm- the graphics algorithm- Returns:
- the tooltip
- Since:
- 0.10
-
getSelectionBorder
Description copied from interface:IToolBehaviorProviderThe returned graphics algorithm defines the selection border and the rectangle where the context buttons appear at.- Specified by:
getSelectionBorderin interfaceIToolBehaviorProvider- Parameters:
pe- the pictogram element- Returns:
- the graphics algorithm which defines the selection border
-
getClickArea
Description copied from interface:IToolBehaviorProviderThe returned graphics algorithm's define the area where the user can click to select the shape.- Specified by:
getClickAreain interfaceIToolBehaviorProvider- Parameters:
pe- the pictogram element- Returns:
- the click area
-
getChopboxAnchorArea
Description copied from interface:IToolBehaviorProviderProvides the graphics algorithm that defines the outline for the given pictogram element's chopbox Anchor.- Specified by:
getChopboxAnchorAreain interfaceIToolBehaviorProvider- 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
Description copied from interface:IToolBehaviorProviderReturns a tooltip for the workbench titlebar.- Specified by:
getTitleToolTipin interfaceIToolBehaviorProvider- Returns:
- a tooltip or
nullto indicate that the default from the graphics framework will be used
-
isShowGuides
public boolean isShowGuides()Description copied from interface:IToolBehaviorProviderIndicates whether guides will be shown or not.- Specified by:
isShowGuidesin interfaceIToolBehaviorProvider- Returns:
true, if guides should be shown
-
getContentArea
Description copied from interface:IToolBehaviorProviderThe 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:
getContentAreain interfaceIToolBehaviorProvider- Parameters:
cs- the container shape- Returns:
- the graphics algorithm acting as technical container
-
getContributorId
Description copied from interface:IToolBehaviorProviderReturns the contributor ID for the tabbed property sheet page.- Specified by:
getContributorIdin interfaceIToolBehaviorProvider- Returns:
- the contributor ID for the tabbed property sheet page.
-
isDefaultBendPointRenderingActive
public boolean isDefaultBendPointRenderingActive() -
isMultiSelectionEnabled
public boolean isMultiSelectionEnabled()Description copied from interface:IToolBehaviorProviderIndicates if the selection of multiple elements is enabled. Override this method and returnfalseif an editor with single selection behavior is needed.- Specified by:
isMultiSelectionEnabledin interfaceIToolBehaviorProvider- Returns:
false, if single selection is enforced
-
isConnectionSelectionEnabled
public boolean isConnectionSelectionEnabled()Description copied from interface:IToolBehaviorProviderIndicates if the selection of connections is enabled.- Specified by:
isConnectionSelectionEnabledin interfaceIToolBehaviorProvider- Returns:
true, if selection of connections is enabled
-
equalsBusinessObjects
Default Implementation. Customers requested the possibility to plug in equality decision based on object identity.- Specified by:
equalsBusinessObjectsin interfaceIToolBehaviorProvider- Returns:
- true if the business objects are deemed equal, false otherwise.
-
isShowFlyoutPalette
public boolean isShowFlyoutPalette(). This default implementation returnstrueand tells the framework to show the palette.- Specified by:
isShowFlyoutPalettein interfaceIToolBehaviorProvider- Returns:
true- Since:
- 0.9
-
isShowSelectionTool
public boolean isShowSelectionTool(). This default implementation returnstrueand tells the framework to show the selection tool entry in the palette.- Specified by:
isShowSelectionToolin interfaceIToolBehaviorProvider- Returns:
true- Since:
- 0.9
-
isShowMarqueeTool
public boolean isShowMarqueeTool(). This default implementation returnstrueand tells the framework to show the marquee tool entry in the palette.- Specified by:
isShowMarqueeToolin interfaceIToolBehaviorProvider- Returns:
true- Since:
- 0.9
-
getLineSelectionWidth
Is asked to return the selection width (the tolerance area a user can click to still select) a lathy object (e.g.PolylineorPolygonforShapes andConnections) 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 returnsDEFAULT_LINE_SELECTION_WIDTHwith the value 5 for all shapes.- Specified by:
getLineSelectionWidthin interfaceIToolBehaviorProvider- Parameters:
polyline- thePolylineobject to get the selection width for- Returns:
- an int representing the allowed tolerance for clicking in pixels
- Since:
- 0.9
-
isStayActiveAfterExecution
Defines if the tool created for the givenIObjectCreationToolEntrystays active after an object has been created or not. The default behavior in the GEF framework isfalse, which is also the return value of this default implementation.- Specified by:
isStayActiveAfterExecutionin interfaceIToolBehaviorProvider- Returns:
truein case the tool should stay active after execution,falseotherwise.- Since:
- 0.19
-
isStayActiveAfterExecution
Defines if the tool created for the givenIConnectionCreationToolEntrystays active after a connection has been created or not. The default behavior in the GEF framework istrue, which is also the return value of this default implementation.- Specified by:
isStayActiveAfterExecutionin interfaceIToolBehaviorProvider- Returns:
truein case the tool should stay active after execution,falseotherwise.- Since:
- 0.11
-
getDirectEditingInvalidNotificationTitle
public String getDirectEditingInvalidNotificationTitle(IDirectEditingFeature feature, IDirectEditingContext context) Returns the title of the popup that appears when a user provides an invalid input for direct editing. This default implementation returns 'Can not edit value'.- Specified by:
getDirectEditingInvalidNotificationTitlein interfaceIToolBehaviorProvider- Parameters:
feature- TheIDirectEditingFeaturethat was invokedcontext- TheIDirectEditingContextthat was used.- Returns:
- A
Stringrepresenting the title of the popup to present to the user. - Since:
- 0.15
-