Class ToggleSelectionBookmarkHandler
java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.core.commands.AbstractHandler
com.e1c.g5.v8.dt.internal.bookmarks.ui.commands.AbstractBookmarkHandler
com.e1c.g5.v8.dt.internal.bookmarks.ui.commands.AbstractToggleBookmarkHandler
com.e1c.g5.v8.dt.internal.bookmarks.ui.commands.ToggleSelectionBookmarkHandler
- All Implemented Interfaces:
org.eclipse.core.commands.IHandler
,org.eclipse.core.commands.IHandler2
Toggles bookmarks from selection and caret line.
- If current line (selection end) contains bookmarks then those bookmarks are deleted.
- Otherwise, a new bookmark is created for the current (selection end) line.
- If something is selected, then this is used as bookmark content.
- If nothing is selected, then current line (trimmed content+location) is used for bookmark. Current line is not the caret line but rather is the first line of selection. When nothing is selected then there is still a selection object that points to the caret line in coordinates of the document rather than view that could be folded.
- If multiple lines are selected, then the first line of the selection is used to determine which bookmarks are to be deleted and what should be the location of the bookmarks. This is a bit different from "jump to bookmark" behaviour in bookmarks view that puts caret to the last line of multiline bookmark. However, standard text editors display bookmark marker on the left rule on the first rather than last line of multiline bookmark.
- The handler ignores invocations when current view part
is not a
ITextEditor
(and cannot be adapted to it), selection is not aITextSelection
or editor's input is not aIResource
(and cannot be adapted to it). This should support EDT's granular editors (likeConfigurationEditor
andFormEditor
) consisting of multiple tabs some of which are not text editors as well as regular Eclipse text editors.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected OptionalInt
calculateActiveLine
(org.eclipse.ui.texteditor.ITextEditor editor) Calculates document line where bookmark us supposed to be added or deleted.protected void
createBookmark
(org.eclipse.ui.texteditor.ITextEditor editor, org.eclipse.core.resources.IResource resource, int activeLine) Creates a bookmark.Methods inherited from class com.e1c.g5.v8.dt.internal.bookmarks.ui.commands.AbstractToggleBookmarkHandler
createBookmark, createBookmarkForLine, createBookmarkForSelection, executeWithTextEditor
Methods inherited from class com.e1c.g5.v8.dt.internal.bookmarks.ui.commands.AbstractBookmarkHandler
calculateMultilineBookmarkLine, calculateMultilineBookmarkOffset, execute, findBookmarksWithLines, findDocument, findMarkerModel, findTextSelection
Methods inherited from class org.eclipse.core.commands.AbstractHandler
addHandlerListener, dispose, fireHandlerChanged, hasListeners, isEnabled, isHandled, removeHandlerListener, setBaseEnabled, setEnabled
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
-
Constructor Details
-
ToggleSelectionBookmarkHandler
public ToggleSelectionBookmarkHandler()
-
-
Method Details
-
calculateActiveLine
Description copied from class:AbstractToggleBookmarkHandler
Calculates document line where bookmark us supposed to be added or deleted.- Specified by:
calculateActiveLine
in classAbstractToggleBookmarkHandler
- Parameters:
editor
- Editor where bookmark is to be added or deleted. Must not benull
.- Returns:
- 0-based document line number where bookmarks has to be added or deleted
or an empty value if active line cannot be determined. Never
null
.
-
createBookmark
protected void createBookmark(org.eclipse.ui.texteditor.ITextEditor editor, org.eclipse.core.resources.IResource resource, int activeLine) Description copied from class:AbstractToggleBookmarkHandler
Creates a bookmark.- Specified by:
createBookmark
in classAbstractToggleBookmarkHandler
- Parameters:
editor
- Editor where bookmark is to be created. Must not benull
.resource
- Resource that is being edited. Must not benull
.activeLine
- 0-based document line where bookmark is to be created.
-