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

public abstract class AbstractToggleBookmarkHandler extends AbstractBookmarkHandler
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected 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 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractToggleBookmarkHandler

      public AbstractToggleBookmarkHandler()
  • Method Details

    • calculateActiveLine

      protected abstract OptionalInt calculateActiveLine(org.eclipse.ui.texteditor.ITextEditor editor)
      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 be null.
      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 be null.
      resource - Resource that is being edited. Must not be null.
      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 class AbstractBookmarkHandler
      Parameters:
      editor - Text editor being active. Must not be null.
      resource - Resource being edited in active text editor. Must not be null.
    • 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 be null.
      bookmarkAttributes - Characteristics of new bookmark. Must not be null.
      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 be null.
      bookmarkLine - Line for which to create bookmark. Must not be null.
      editor - Editor in which bookmark is being created. Must not be null.
    • 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 per calculateSelectionBookmarkAttributes(ITextSelection).
      Parameters:
      resource - Resource being edited. Must not be null.
      selection - Editor's selection from which to create bookmark. Must not be null.