public final class TextSelectionTool extends AbstractSelectionRendererTool implements ModifierActivated
Tool
used to select textual page content. Panning is performed upon mouse motion events
during which the modifier state matches the one set with setActivationModifiers(int)
(this defaults to the left mouse button). Beyond that, the number of mouse clicks used to
initiate the selection determines the Granularity
with which text is selected:
setExportHandler(ExportHandler)
). In
addition, other tools can attach functionality to selected areas by listening on the
ToolManager
for changes to properties starting with the string
ToolManager.getToolPropertyPrefix(AreaSelectionTool.class)
and querying
AbstractSelectionRendererTool.getSelections()
.Tool.ActivationRequest
DEFAULT_ACTIVE_SELECTION_COLOR, DEFAULT_SELECTION_COLOR, LINE_ENDING, SEL_BUS_PROPERTY_PREFIX
activeGesture, currentPage, enableContextToolbar, isActive, lastRenderControls, lastRenderedPageBounds
DEFAULT_PRIORITY, MAX_PRIORITY, MIN_PRIORITY
Constructor and Description |
---|
TextSelectionTool() |
Modifier and Type | Method and Description |
---|---|
void |
contribute(ContributionContext context,
MenuBuilder contextMenu)
This method is called in order to give the menu contributor a chance to contribute context menu
entries via the supplied
MenuBuilder . |
protected Tool.ActivationRequest |
getActivationFeedback(MouseEditEvent e)
Provide feedback for the user about what would happen, if the mouse were pressed at the current
location.
|
int |
getActivationModifiers()
Get the mask of modifier keys (Shift, Control, Alt etc.) and mouse buttons (left, right etc.)
to be used to activate this tool.
|
protected Tool.ActivationRequest |
getActivationRequestForMousePressed(MouseEditEvent e)
Return the auto-activation request for this this tool in response to the given mouse press.
|
protected com.levigo.jadice.swing.internal.ui.HoverToolbar |
getContextToolbar() |
ExportHandler<Selection> |
getExportHandler() |
List<MenuContributor> |
getMenuContributors() |
protected Point |
getPreferredToolbarLocation() |
protected Rectangle |
getUnionSelectionBounds(Page p,
List<? extends Selection> selections) |
protected Rectangle |
getUnionSelectionBounds(Page p,
List<? extends Selection> selections,
RenderControls rc,
Rectangle pageBounds) |
protected void |
handleMouseDragged(MouseEditEvent e,
boolean isActive)
Invoked when a mouse button is pressed on a component and then dragged.
|
protected void |
handleMousePressed(MouseEditEvent e,
boolean isActive)
Invoked when a mouse button has been pressed on a component.
|
boolean |
isEnableDragExport() |
boolean |
isEnableHoverToolbar() |
void |
setActivationModifiers(int activationModifiers)
Set the mask of modifier keys (Shift, Control, Alt etc.) and mouse buttons (left, right etc.)
to be used to activate this tool.
|
protected void |
setActive(boolean active)
Receive notification from the tool manager about the tool's active state.
|
void |
setEnableDragExport(boolean enableDragExport)
Set whether to enable the export of selected text using a drag-and-drop transfer.
|
void |
setEnableHoverToolbar(boolean enableHoverToolbar)
Set whether to enable the hover toolbar which contains functions pertaining to the selection.
|
void |
setExportHandler(ExportHandler<Selection> exportHandler) |
protected void |
setManager(ToolManager manager)
Receives the
ToolManager instance, which the Tool implementation has been
registered for. |
void |
setRemoveOnClick(boolean removeOnClick)
specifies if the selection should be removed on a single click using the mouse.
|
void |
setSelections(List<Selection> s) |
protected boolean |
shallHandleEditEvent(boolean isActive,
EditEvent e)
Override this method in order to determine whether the given even shall be handled at all.
|
protected boolean |
shallRemoveOnClick(MouseEditEvent e) |
protected boolean |
toolbarShallBeActive() |
afterHandleEditEvent, clearSelection, doGetSelections, doSetActiveSelection, doSetSelections, getActiveSelection, getActiveSelectionColor, getSelectedText, getSelectionColor, getSelections, handleEditEvent, isRemoveOnClick, render, renderSelections, setActiveSelectionColor, setSelectionColor, updateTextSelection
activateToolbar, autoscroll, beforeHandleEditEvent, checkForRenderGeometryChange, deactivateToolbar, endGesture, getActiveGesture, getCurrentPage, getUndoManager, handleEditEventPreDispatch, isEnableContextToolbar, serviceGesture, setEnableContextToolbar, startGesture, switchFocus, updateToolbarLocation, updateToolbarVisibility
getActivationRequest, getActivationRequestForKeyPressed, getActivationRequestForMouseDragged, getCursor, getDispatchPriority, getManager, getRenderPriority, handleKeyPressed, handleKeyReleased, handleKeyTyped, handleMouseClicked, handleMouseEntered, handleMouseExited, handleMouseMoved, handleMouseReleased, handleMouseWheelMoved, propagatePropertyChange, setCursor, setEnabled, setStatusFeedback
protected boolean shallHandleEditEvent(boolean isActive, EditEvent e)
com.levigo.jadice.swing.internal.tool.AbstractBaseTool
shallHandleEditEvent
in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool
true
if the event shall be handled, false
otherwiseprotected void handleMouseDragged(MouseEditEvent e, boolean isActive)
Tool
MOUSE_DRAGGED
events will continue to be delivered to the component where the drag
originated until the mouse button is released (regardless of whether the mouse position is
within the bounds of the component).
Due to platform-dependent Drag&Drop implementations, MOUSE_DRAGGED
events may
not be delivered during a native Drag&Drop operation.
handleMouseDragged
in class Tool
isActive
- whether this tool is currently activeprotected Tool.ActivationRequest getActivationFeedback(MouseEditEvent e)
Tool
MouseEvent.MOUSE_MOVED
events. If this
method returns null
no feedback is provided at all.
The activation request returned from this method is the same object that is used during
Tool.getActivationRequestForKeyPressed(KeyEditEvent)
to signal the auto-activation
candidacy.
This method should only return an activation request if it will actually candidate for
auto-activation later on using Tool.getActivationRequestForMousePressed(MouseEditEvent)
or
Tool.getActivationRequestForMouseDragged(MouseEditEvent)
.getActivationFeedback
in class Tool
protected Tool.ActivationRequest getActivationRequestForMousePressed(MouseEditEvent e)
Tool
Tool.ActivationRequest
, it becomes eligible for auto-activation.
However, the final decision about which tool will actually be activated is up to the
ToolActivationPolicy
used be the tool manager.getActivationRequestForMousePressed
in class Tool
e
- the KeyEditEvent
Tool.ActivationRequest
or null
if the tool does not seek to be
auto-activated at this time.protected void handleMousePressed(MouseEditEvent e, boolean isActive)
Tool
handleMousePressed
in class Tool
isActive
- whether this tool is currently activepublic void setRemoveOnClick(boolean removeOnClick)
setRemoveOnClick
in class AbstractSelectionRendererTool
removeOnClick
- true
if the selection should be removed on clickprotected boolean shallRemoveOnClick(MouseEditEvent e)
shallRemoveOnClick
in class AbstractSelectionRendererTool
public void contribute(ContributionContext context, MenuBuilder contextMenu)
MenuContributor
MenuBuilder
.contribute
in interface MenuContributor
contribute
in class Tool
context
- the ContributionContext
which provides contribution context informationscontextMenu
- the MenuBuilder
to which the tool may contribute entries.public void setEnableDragExport(boolean enableDragExport)
public boolean isEnableDragExport()
protected boolean toolbarShallBeActive()
toolbarShallBeActive
in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool
protected Point getPreferredToolbarLocation()
getPreferredToolbarLocation
in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool
protected Rectangle getUnionSelectionBounds(Page p, List<? extends Selection> selections)
protected Rectangle getUnionSelectionBounds(Page p, List<? extends Selection> selections, RenderControls rc, Rectangle pageBounds)
protected com.levigo.jadice.swing.internal.ui.HoverToolbar getContextToolbar()
getContextToolbar
in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool
public void setEnableHoverToolbar(boolean enableHoverToolbar)
public boolean isEnableHoverToolbar()
protected void setManager(ToolManager manager)
Tool
ToolManager
instance, which the Tool
implementation has been
registered for. If the Tool
is deregistered
this
method will be called with null.setManager
in class AbstractSelectionRendererTool
public List<MenuContributor> getMenuContributors()
public ExportHandler<Selection> getExportHandler()
public void setExportHandler(ExportHandler<Selection> exportHandler)
public void setActivationModifiers(int activationModifiers)
InputEvent.getModifiersEx()
, i.e. it must use the InputEvent
constants
containing _DOWN_
in their name.
Default: use just the left mouse button.
setActivationModifiers
in interface ModifierActivated
ModifierActivated.setActivationModifiers(int)
public int getActivationModifiers()
getActivationModifiers
in interface ModifierActivated
ModifierActivated.setActivationModifiers(int)
protected void setActive(boolean active)
Tool
setActive
in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool
Copyright © 2024 levigo holding gmbh. All rights reserved.