Interface IToolBehaviorProvider
-
- All Known Implementing Classes:
DefaultToolBehaviorProvider
public interface IToolBehaviorProvider
The Interface IToolBehaviorProvider.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
dispose()
Dispose.boolean
equalsBusinessObjects(java.lang.Object o1, java.lang.Object o2)
Decides if business objects are equal.java.lang.Object
getAdapter(java.lang.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, java.lang.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.java.lang.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.DiagramScrollingBehavior
getDiagramScrollingBehavior()
Deprecated.Scroll bar based infinite canvas is a workaround for GEF limitations.java.lang.String
getDirectEditingInvalidNotificationTitle(IDirectEditingFeature feature, IDirectEditingContext context)
Returns the title of the popup that appears when a user provides an invalid input for direct editing.ICustomFeature
getDoubleClickFeature(IDoubleClickContext context)
Returns a feature which will be executed at at double click.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 currentLocationInfo)
Returns the location info which will be used for direct editing if the framework cannot decide this.IPaletteCompartmentEntry[]
getPalette()
Return the palette entries for the palette of the graphical editor.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.PictogramElement[]
getSelections(PictogramElement selection)
ICustomFeature
getSingleClickFeature(ISingleClickContext context)
Returns a feature which will be executed at at a single click on an already selected shape.java.lang.String
getTitleToolTip()
Returns a tooltip for the workbench titlebar.java.lang.Object
getToolTip(GraphicsAlgorithm graphicsAlgorithm)
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
isMultiSelectionEnabled()
Indicates if the selection of multiple elements is enabled.boolean
isShowFlyoutPalette()
Indicates whether flyout palette will be shown or not.boolean
isShowGuides()
Indicates whether guides will be shown or not.boolean
isShowMarqueeTool()
Indicates whether the marquee tool shall be added to the palette or notboolean
isShowSelectionTool()
Indicates whether the selection tool shall be added to the palette or notboolean
isStayActiveAfterExecution(IConnectionCreationToolEntry connectionCreationToolEntry)
Defines if the tool created for the givenIConnectionCreationToolEntry
stays active after a connection has been created or not.void
postExecute(IExecutionInfo executionInfo)
Called after execution on stack.void
preExecute(IExecutionInfo executionInfo)
Called before execution on stack.
-
-
-
Method Detail
-
getContextButtonPad
IContextButtonPadData getContextButtonPad(IPictogramElementContext context)
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.- 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.
-
getContextMenu
IContextMenuEntry[] getContextMenu(ICustomContext context)
Returns the context menu for the current mouse location.- Parameters:
context
- the custom context which contains the info about the location where the context menu appears.- Returns:
- the context menu
-
getPalette
IPaletteCompartmentEntry[] getPalette()
Return the palette entries for the palette of the graphical editor. Typically these entries are a subset of CreateFeatures and CreateConnectionFeatures which are provided by the feature provider.- Returns:
- the palette entries
-
getDoubleClickFeature
ICustomFeature getDoubleClickFeature(IDoubleClickContext context)
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).- Parameters:
context
- contains information where the double click gesture has happened- Returns:
- the feature to execute
-
getSingleClickFeature
ICustomFeature getSingleClickFeature(ISingleClickContext context)
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.- Parameters:
context
- contains information where the single click gesture has happened- Returns:
- the feature to execute
- Since:
- 0.10
-
getCommandFeature
ICustomFeature getCommandFeature(CustomContext context, java.lang.String hint)
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.- Parameters:
context
- the contexthint
- the hint specified in the command binding- Returns:
- the feature
- Since:
- 0.10
-
getDecorators
IDecorator[] getDecorators(PictogramElement pe)
Returns 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
,IColorDecorator
andIBorderDecorator
are supported forShape
s; forConnection
s onlyIColorDecorator
s are supported and they can only be used to change the foreground color of theConnection
.- Parameters:
pe
- the pictogram element- Returns:
- the decorators
-
getAdapter
java.lang.Object getAdapter(java.lang.Class<?> type)
Returns the adapter for the specified key. This method will be called in the getAdapter() method of the graphical editor.- Parameters:
type
- the type- Returns:
- the adapter
-
getSelection
PictogramElement getSelection(PictogramElement originalPe, PictogramElement[] oldSelection)
Override this method if you want to change the default selection on mouse click.- Parameters:
originalPe
- the original pictogram elementoldSelection
- 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
-
getSelections
PictogramElement[] getSelections(PictogramElement selection)
- Since:
- 0.16
-
getDiagramScrollingBehavior
@Deprecated DiagramScrollingBehavior getDiagramScrollingBehavior()
Deprecated.Scroll bar based infinite canvas is a workaround for GEF limitations.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.- Returns:
- The DiagramScrollingBehavior
- See Also:
DefaultToolBehaviorProvider.getDiagramScrollingBehavior()
-
getZoomLevels
double[] getZoomLevels()
Gets the zoom levels.- Returns:
- the zoom levels
-
dispose
void dispose()
Dispose.
-
getSelectionInfoForShape
IShapeSelectionInfo getSelectionInfoForShape(Shape shape)
Return the selection info for the given shape.- Parameters:
shape
- the shape- Returns:
- the shape selection info
- Since:
- 0.10
-
getSelectionInfoForAnchor
IAnchorSelectionInfo getSelectionInfoForAnchor(Anchor anchor)
Return the selection info for the given anchor.- Parameters:
anchor
- the anchor- Returns:
- the anchor selection info
- Since:
- 0.10
-
getSelectionInfoForConnection
IConnectionSelectionInfo getSelectionInfoForConnection(Connection connection)
Return the selection info for the given connection.- Parameters:
connection
- the connection- Returns:
- the connection selection info
- Since:
- 0.10
-
getLocationInfo
ILocationInfo getLocationInfo(PictogramElement pe, ILocationInfo currentLocationInfo)
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.- Parameters:
pe
- the active and selected pictogram elementcurrentLocationInfo
- the current location info determined by the framework- Returns:
- the location info for the given selected pictogram element
-
preExecute
void preExecute(IExecutionInfo executionInfo)
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.- Parameters:
executionInfo
- info about content to be executed
-
postExecute
void postExecute(IExecutionInfo executionInfo)
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.- Parameters:
executionInfo
- info about content to be executed
-
getToolTip
java.lang.Object getToolTip(GraphicsAlgorithm graphicsAlgorithm)
Returns the tooltip to be attached to the graphical representation of the given graphics algorithm.
It can either be a String, creating a simple tooltip, or an AbstractText. In the latter case, a rich text label would be created, respecting the contained
TextStyle
s.Since the pictogram element doesn't belong to the diagram, you have to be careful with the
Color
s andFont
s used in theTextStyle
s within theAbstractText
. They should be created and added to the diagram beforehand, preferably in the add feature that created the given graphicsAlgorithm, i.e.:Somewhere in the add method of the addFeature :
manageFont(diagram, "Verdana", 9, true, false);
Inside the getRichToolTip:
Font font = manageFont(getDiagramTypeProvider().getDiagram(), "Verdana", 9, true, false); textStyle.setFont(font);
This will ensure resource management for both fonts and colors, and prevent transaction read-only errors if trying to add a font o a color to the diagram without a write transaction.
Note: Be extremely careful when adding rich text tooltips to an previously existing diagram. Since the pictograms may have already been added to the diagram, the tooltip may cause an
IllegalStateException
if trying to use a resource that was not previously added to the diagram.- Parameters:
graphicsAlgorithm
- the graphics algorithm- Returns:
- the tooltip
- Since:
- 0.10
-
getSelectionBorder
GraphicsAlgorithm getSelectionBorder(PictogramElement pe)
The returned graphics algorithm defines the selection border and the rectangle where the context buttons appear at.- Parameters:
pe
- the pictogram element- Returns:
- the graphics algorithm which defines the selection border
-
getContentArea
GraphicsAlgorithm getContentArea(ContainerShape cs)
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.- Parameters:
cs
- the container shape- Returns:
- the graphics algorithm acting as technical container
-
getClickArea
GraphicsAlgorithm[] getClickArea(PictogramElement pe)
The returned graphics algorithm's define the area where the user can click to select the shape.- Parameters:
pe
- the pictogram element- Returns:
- the click area
-
getChopboxAnchorArea
GraphicsAlgorithm getChopboxAnchorArea(PictogramElement pe)
Provides the graphics algorithm that defines the outline for the given pictogram element's chopbox Anchor.- 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
java.lang.String getTitleToolTip()
Returns a tooltip for the workbench titlebar.- Returns:
- a tooltip or
null
to indicate that the default from the graphics framework will be used
-
isShowGuides
boolean isShowGuides()
Indicates whether guides will be shown or not.- Returns:
true
, if guides should be shown
-
isShowFlyoutPalette
boolean isShowFlyoutPalette()
Indicates whether flyout palette will be shown or not.- Returns:
true
, if flyout palette should be shown- Since:
- 0.9
-
isShowSelectionTool
boolean isShowSelectionTool()
Indicates whether the selection tool shall be added to the palette or not- Returns:
true
, if the selection tool shall be added,false
otherwise- Since:
- 0.9
-
isShowMarqueeTool
boolean isShowMarqueeTool()
Indicates whether the marquee tool shall be added to the palette or not- Returns:
true
, if the marquee tool shall be added,false
otherwise- Since:
- 0.9
-
isMultiSelectionEnabled
boolean isMultiSelectionEnabled()
Indicates if the selection of multiple elements is enabled. Override this method and returnfalse
if an editor with single selection behavior is needed.- Returns:
false
, if single selection is enforced
-
isConnectionSelectionEnabled
boolean isConnectionSelectionEnabled()
Indicates if the selection of connections is enabled.- Returns:
true
, if selection of connections is enabled
-
getContributorId
java.lang.String getContributorId()
Returns the contributor ID for the tabbed property sheet page.- Returns:
- the contributor ID for the tabbed property sheet page.
-
equalsBusinessObjects
boolean equalsBusinessObjects(java.lang.Object o1, java.lang.Object o2)
Decides if business objects are equal. The framework uses this method only for EMF business objects. For the non-EMF case,IIndependenceSolver
is responsible.- Returns:
- true if the business objects are deemed equal, false otherwise.
- Since:
- 0.8
-
getLineSelectionWidth
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
orPolygon
forShape
s andConnection
s) 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).- Parameters:
polyline
- thePolyline
object to get the selection width for- Returns:
- an int representing the allowed tolerance for clicking in pixels
- Since:
- 0.9
-
isStayActiveAfterExecution
boolean isStayActiveAfterExecution(IConnectionCreationToolEntry connectionCreationToolEntry)
Defines if the tool created for the givenIConnectionCreationToolEntry
stays active after a connection has been created or not. The default behavior in the GEF framework istrue
, which is also the return value of the default implementation inDefaultToolBehaviorProvider.isStayActiveAfterExecution(IConnectionCreationToolEntry)
. This method is queried by the framework when the tool is created from the palette entry.- Returns:
true
in case the tool should stay active after execution,false
otherwise.- Since:
- 0.11
-
getDirectEditingInvalidNotificationTitle
java.lang.String getDirectEditingInvalidNotificationTitle(IDirectEditingFeature feature, IDirectEditingContext context)
Returns the title of the popup that appears when a user provides an invalid input for direct editing. The default implementation returns 'Can not edit value'.- Parameters:
feature
- TheIDirectEditingFeature
that was invokedcontext
- TheIDirectEditingContext
that was used.- Returns:
- A
String
representing the title of the popup to present to the user. - Since:
- 0.15
-
-