Class AbstractToggleBookmarkHandler
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
- All Implemented Interfaces:
org.eclipse.core.commands.IHandler
,org.eclipse.core.commands.IHandler2
- Direct Known Subclasses:
ToggleRulerBookmarkHandler
,ToggleSelectionBookmarkHandler
Abstract base for toggle bookmark handlers.
Children are responsible for determining active line in the document
via
calculateActiveLine(ITextEditor)
.
That is the line where bookmark is about to be toggled.
If child is not able to determine the line then
no bookmarks will be added or deleted.
If there are bookmarks on this line then they are deleted.
Otherwise, child is responsible for creating a new bookmark
via createBookmark(ITextEditor, IResource, int)
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract 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.core.resources.IResource resource, Map<String, Object> bookmarkAttributes) Creates bookmark on a specified resource with specified attributes.protected abstract void
createBookmark
(org.eclipse.ui.texteditor.ITextEditor editor, org.eclipse.core.resources.IResource resource, int activeLine) Creates a bookmark.protected void
createBookmarkForLine
(org.eclipse.core.resources.IResource resource, int bookmarkLine, org.eclipse.ui.texteditor.ITextEditor editor) Creates bookmark for editor's line.protected void
createBookmarkForSelection
(org.eclipse.core.resources.IResource resource, org.eclipse.jface.text.ITextSelection selection) Creates bookmark from editor's selection.protected void
executeWithTextEditor
(org.eclipse.ui.texteditor.ITextEditor editor, org.eclipse.core.resources.IResource resource) Handles command in text editor.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
-
AbstractToggleBookmarkHandler
public AbstractToggleBookmarkHandler()
-
-
Method Details
-
calculateActiveLine
Calculates document line where bookmark us supposed to be added or deleted.- 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 abstract void createBookmark(org.eclipse.ui.texteditor.ITextEditor editor, org.eclipse.core.resources.IResource resource, int activeLine) Creates a bookmark.- 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.
-
executeWithTextEditor
protected void executeWithTextEditor(org.eclipse.ui.texteditor.ITextEditor editor, org.eclipse.core.resources.IResource resource) Description copied from class:AbstractBookmarkHandler
Handles command in text editor.- Specified by:
executeWithTextEditor
in classAbstractBookmarkHandler
- Parameters:
editor
- Text editor being active. Must not benull
.resource
- Resource being edited in active text editor. Must not benull
.
-
createBookmark
protected void createBookmark(org.eclipse.core.resources.IResource resource, Map<String, Object> bookmarkAttributes) Creates bookmark on a specified resource with specified attributes. Ignores bookmark creation errors after logging them.- Parameters:
resource
- Resource on which to create bookmark. Must not benull
.bookmarkAttributes
- Characteristics of new bookmark. Must not benull
.- See Also:
-
MarkerUtilities.setCharEnd(Map, int)
MarkerUtilities.setCharStart(Map, int)
MarkerUtilities.setLineNumber(Map, int)
MarkerUtilities.setMessage(Map, String)
-
createBookmarkForLine
protected void createBookmarkForLine(org.eclipse.core.resources.IResource resource, int bookmarkLine, org.eclipse.ui.texteditor.ITextEditor editor) Creates bookmark for editor's line. Bookmark characteristics are determined as per#calculateLineBookmarkAttributes(ITextEditor, ITextSelection)
.- Parameters:
resource
- Resource being edited. Must not benull
.bookmarkLine
- Line for which to create bookmark. Must not benull
.editor
- Editor in which bookmark is being created. Must not benull
.
-
createBookmarkForSelection
protected void createBookmarkForSelection(org.eclipse.core.resources.IResource resource, org.eclipse.jface.text.ITextSelection selection) Creates bookmark from editor's selection. Bookmark characteristics are determined as percalculateSelectionBookmarkAttributes(ITextSelection)
.- Parameters:
resource
- Resource being edited. Must not benull
.selection
- Editor's selection from which to create bookmark. Must not benull
.
-