Class AnnotationEditor

java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.ui.part.WorkbenchPart
org.eclipse.ui.part.EditorPart
org.eclipse.ui.texteditor.AbstractTextEditor
org.eclipse.ui.texteditor.StatusTextEditor
org.apache.uima.caseditor.editor.AnnotationEditor
All Implemented Interfaces:
EventListener, ICasEditor, org.eclipse.core.runtime.IAdaptable, org.eclipse.core.runtime.IExecutableExtension, org.eclipse.ui.IEditorPart, org.eclipse.ui.INavigationLocationProvider, org.eclipse.ui.IPersistable, org.eclipse.ui.IPersistableEditor, org.eclipse.ui.IReusableEditor, org.eclipse.ui.ISaveablePart, org.eclipse.ui.ISaveablesSource, org.eclipse.ui.ISelectionListener, org.eclipse.ui.IWorkbenchPart, org.eclipse.ui.IWorkbenchPart2, org.eclipse.ui.IWorkbenchPart3, org.eclipse.ui.part.IWorkbenchPartOrientation, org.eclipse.ui.texteditor.ITextEditor, org.eclipse.ui.texteditor.ITextEditorExtension, org.eclipse.ui.texteditor.ITextEditorExtension2, org.eclipse.ui.texteditor.ITextEditorExtension3, org.eclipse.ui.texteditor.ITextEditorExtension4, org.eclipse.ui.texteditor.ITextEditorExtension5, org.eclipse.ui.texteditor.ITextEditorExtension6

public final class AnnotationEditor extends org.eclipse.ui.texteditor.StatusTextEditor implements ICasEditor, org.eclipse.ui.ISelectionListener
An editor to annotate text.
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.eclipse.ui.texteditor.AbstractTextEditor

    org.eclipse.ui.texteditor.AbstractTextEditor.AbstractSelectionChangedListener, org.eclipse.ui.texteditor.AbstractTextEditor.ColumnSupport, org.eclipse.ui.texteditor.AbstractTextEditor.IdMapEntry, org.eclipse.ui.texteditor.AbstractTextEditor.LineEndAction, org.eclipse.ui.texteditor.AbstractTextEditor.LineStartAction, org.eclipse.ui.texteditor.AbstractTextEditor.SelectionProvider, org.eclipse.ui.texteditor.AbstractTextEditor.TextEditorSavable

    Nested classes/interfaces inherited from interface org.eclipse.ui.texteditor.ITextEditorExtension3

    org.eclipse.ui.texteditor.ITextEditorExtension3.InsertMode
  • Field Summary

    Fields inherited from class org.eclipse.ui.texteditor.AbstractTextEditor

    ACTION_MAP, COMMON_EDITOR_CONTEXT_MENU_ID, COMMON_RULER_CONTEXT_MENU_ID, DEFAULT_EDITOR_CONTEXT_MENU_ID, DEFAULT_RULER_CONTEXT_MENU_ID, fErrorLabel, PREFERENCE_COLOR_BACKGROUND, PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, PREFERENCE_COLOR_FIND_SCOPE, PREFERENCE_COLOR_FOREGROUND, PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, PREFERENCE_COLOR_SELECTION_BACKGROUND, PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT, PREFERENCE_COLOR_SELECTION_FOREGROUND, PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT, PREFERENCE_FONT, PREFERENCE_HOVER_ENRICH_MODE, PREFERENCE_HYPERLINK_KEY_MODIFIER, PREFERENCE_HYPERLINK_KEY_MODIFIER_MASK, PREFERENCE_HYPERLINKS_ENABLED, PREFERENCE_NAVIGATION_SMART_HOME_END, PREFERENCE_RULER_CONTRIBUTIONS, PREFERENCE_SHOW_CARET_OFFSET, PREFERENCE_SHOW_CARRIAGE_RETURN, PREFERENCE_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES, PREFERENCE_SHOW_ENCLOSED_SPACES, PREFERENCE_SHOW_ENCLOSED_TABS, PREFERENCE_SHOW_LEADING_IDEOGRAPHIC_SPACES, PREFERENCE_SHOW_LEADING_SPACES, PREFERENCE_SHOW_LEADING_TABS, PREFERENCE_SHOW_LINE_FEED, PREFERENCE_SHOW_SELECTION_SIZE, PREFERENCE_SHOW_TRAILING_IDEOGRAPHIC_SPACES, PREFERENCE_SHOW_TRAILING_SPACES, PREFERENCE_SHOW_TRAILING_TABS, PREFERENCE_SHOW_WHITESPACE_CHARACTERS, PREFERENCE_TEXT_DRAG_AND_DROP_ENABLED, PREFERENCE_USE_CUSTOM_CARETS, PREFERENCE_WHITESPACE_CHARACTER_ALPHA_VALUE, PREFERENCE_WIDE_CARET, PREFERENCE_WORD_WRAP_ENABLED, TAG_SELECTION_HORIZONTAL_PIXEL, TAG_SELECTION_LENGTH, TAG_SELECTION_OFFSET, TAG_SELECTION_TOP_PIXEL, VERTICAL_RULER_WIDTH

    Fields inherited from interface org.eclipse.ui.IEditorPart

    PROP_DIRTY, PROP_INPUT

    Fields inherited from interface org.eclipse.ui.texteditor.ITextEditorExtension3

    INSERT, SMART_INSERT

    Fields inherited from interface org.eclipse.ui.IWorkbenchPart

    PROP_TITLE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an new AnnotationEditor object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds the annotation listener.
    void
    Adds the cas editor input listener.
    protected void
    Creates custom annotation actions: Annotate Action Smart Annotate Action Delete Annotations Action Find Annotate Action.
    void
    createPartControl(org.eclipse.swt.widgets.Composite parent)
    Configures the editor.
    protected org.eclipse.jface.text.source.ISourceViewer
    createSourceViewer(org.eclipse.swt.widgets.Composite parent, org.eclipse.jface.text.source.IVerticalRuler ruler, int styles)
     
    protected org.eclipse.swt.widgets.Control
    createStatusControl(org.eclipse.swt.widgets.Composite parent, org.eclipse.core.runtime.IStatus status)
     
    void
     
    protected void
    doSetInput(org.eclipse.ui.IEditorInput input)
     
    protected void
    editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager menu)
     
    getAdapter(Class adapter)
    Retrieves annotation editor adapters.
    Creates a list of all AnnotationEditor which are currently opened.
    Returns the current annotation type.
    Retrieves an AnnotationStyle from the underlying storage.
    int
    Returns the caret position relative to the start of the text.
    Gets the cas document provider.
    Returns the current AnnotationDocument of this editor.
    Retrieves the currently selected annotation.
    org.eclipse.swt.graphics.Point
    Returns the selection.
    Gets the shown annotation types.
    Retrieves the tooltip of the title.
    protected void
    Used to inform about input changes.
    void
    init(org.eclipse.ui.IEditorSite site, org.eclipse.ui.IEditorInput input)
     
    boolean
    Checks if the current instance is editable.
    boolean
    Text is not editable, cause of the nature of the annotation editor.
    protected boolean
    isErrorStatus(org.eclipse.core.runtime.IStatus status)
     
    void
    Removes the annotation listener.
    void
    Removes the cas editor input listener.
    void
    Reopen editor with new type system.
    void
    selectionChanged(org.eclipse.ui.IWorkbenchPart part, org.eclipse.jface.viewers.ISelection selection)
    Notifies the current instance about selection changes in the workbench.
    void
    Sets the new annotation type.
    void
    Sets an annotation style.
    void
    setShownAnnotationType(Type type, boolean isShown)
    Sets the shown annotation type.
    void
    Sets the shown annotation types.
    void
    showView(String viewName)
    Show view.
    void
    Synchronizes all annotations with the eclipse annotation painter.

    Methods inherited from class org.eclipse.ui.texteditor.StatusTextEditor

    doRevertToSaved, getStatusBanner, getStatusHeader, getStatusMessage, handleEditorInputChanged, sanityCheckState, setFocus, updatePartControl, updateStatusField, validateEditorInputState

    Methods inherited from class org.eclipse.ui.texteditor.AbstractTextEditor

    addAction, addAction, addGroup, addRulerContextMenuListener, adjustHighlightRange, affectsTextPresentation, canHandleMove, close, configureInsertMode, containsSavedState, createColumnSupport, createContextMenuListener, createEmptyNavigationLocation, createNavigationActions, createNavigationLocation, createUndoRedoActions, createVerticalRuler, disposeDocumentProvider, doGetSelection, doRestoreState, doSave, doSaveAs, doSetSelection, editorSaved, enableOverwriteMode, enableSanityChecking, enableStateValidation, findAnnotation, firePropertyChange, getAction, getActiveSaveables, getContextMenuListener, getCoverage, getCursorListener, getCursorPosition, getDocumentProvider, getEditorContextMenuId, getFontPropertyPreferenceKey, getHelpContextId, getHighlightRange, getInitialWordWrapStatus, getInsertMode, getLegalInsertModes, getPreferenceStore, getProgressMonitor, getRangeIndicator, getRulerContextMenuId, getRulerMouseListener, getSaveables, getSelectionChangedListener, getSelectionProvider, getSourceViewer, getSourceViewerConfiguration, getStatusField, getStatusLineManager, getUndoRedoOperationApprover, getVerticalRuler, gotoAnnotation, handleCursorPositionChanged, handleExceptionOnSave, handleInsertModeChanged, handlePreferenceStoreChanged, initializeDragAndDrop, initializeViewerColors, installCodeMiningProviders, installTabsToSpacesConverter, installTextDragAndDrop, internalInit, isBlockSelectionModeEnabled, isBlockSelectionModeSupported, isChangeInformationShowing, isDirty, isEditorInputIncludedInContextMenu, isEditorInputReadOnly, isInInsertMode, isNavigationTarget, isSaveAsAllowed, isSpacesAsTabsDeletionEnabled, isTabsToSpacesConversionEnabled, isVisible, isWordWrapEnabled, isWordWrapSupported, markAsContentDependentAction, markAsPropertyDependentAction, markAsSelectionDependentAction, markAsStateDependentAction, markInNavigationHistory, modelOffset2WidgetOffset, openSaveErrorDialog, performRevert, performSave, performSaveAs, rememberSelection, removeActionActivationCode, removeRulerContextMenuListener, resetHighlightRange, restoreSelection, restoreState, rulerContextMenuAboutToShow, safelySanityCheckState, saveState, selectAndReveal, selectAndReveal, setAction, setActionActivationCode, setBlockSelectionMode, setCompatibilityMode, setDocumentProvider, setDocumentProvider, setEditorContextMenuId, setHelpContextId, setHighlightRange, setInput, setInputWithNotify, setInsertMode, setKeyBindingScopes, setPreferenceStore, setRangeIndicator, setRulerContextMenuId, setSourceViewerConfiguration, setStatusField, setStatusLineErrorMessage, setStatusLineMessage, setWordWrap, showChangeInformation, showHighlightRangeOnly, showRevisionInformation, showsHighlightRangeOnly, uninstallTabsToSpacesConverter, uninstallTextDragAndDrop, updateContentDependentActions, updateContributedRulerColumns, updateIndentPrefixes, updatePropertyDependentActions, updateSelectionDependentActions, updateState, updateStateDependentActions, updateStatusFields, validateState, widgetOffset2ModelOffset

    Methods inherited from class org.eclipse.ui.part.EditorPart

    checkSite, getEditorInput, getEditorSite, isSaveOnCloseNeeded, setContentDescription, setInitializationData, setPartName

    Methods inherited from class org.eclipse.ui.part.WorkbenchPart

    addPartPropertyListener, addPropertyListener, firePartPropertyChanged, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, removePartPropertyListener, removePropertyListener, setPartProperty, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy

    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

    Methods inherited from interface org.eclipse.ui.IEditorPart

    getEditorInput, getEditorSite

    Methods inherited from interface org.eclipse.ui.ISaveablePart

    doSave, doSaveAs, isDirty, isSaveAsAllowed, isSaveOnCloseNeeded

    Methods inherited from interface org.eclipse.ui.IWorkbenchPart

    addPropertyListener, getSite, getTitle, getTitleImage, removePropertyListener, setFocus
  • Constructor Details

    • AnnotationEditor

      public AnnotationEditor()
      Creates an new AnnotationEditor object.
  • Method Details

    • init

      public void init(org.eclipse.ui.IEditorSite site, org.eclipse.ui.IEditorInput input) throws org.eclipse.ui.PartInitException
      Specified by:
      init in interface org.eclipse.ui.IEditorPart
      Overrides:
      init in class org.eclipse.ui.texteditor.AbstractTextEditor
      Throws:
      org.eclipse.ui.PartInitException
    • getCasDocumentProvider

      public CasDocumentProvider getCasDocumentProvider()
      Description copied from interface: ICasEditor
      Gets the cas document provider.
      Specified by:
      getCasDocumentProvider in interface ICasEditor
      Returns:
      the cas document provider
    • getTitleToolTip

      public String getTitleToolTip()
      Retrieves the tooltip of the title.
      Specified by:
      getTitleToolTip in interface org.eclipse.ui.IWorkbenchPart
      Overrides:
      getTitleToolTip in class org.eclipse.ui.part.EditorPart
      Returns:
      string of tooltip
    • getAdapter

      public Object getAdapter(Class adapter)
      Retrieves annotation editor adapters.
      Specified by:
      getAdapter in interface org.eclipse.core.runtime.IAdaptable
      Overrides:
      getAdapter in class org.eclipse.ui.texteditor.AbstractTextEditor
      Parameters:
      adapter - the adapter
      Returns:
      an adapter or null
    • createSourceViewer

      protected org.eclipse.jface.text.source.ISourceViewer createSourceViewer(org.eclipse.swt.widgets.Composite parent, org.eclipse.jface.text.source.IVerticalRuler ruler, int styles)
      Overrides:
      createSourceViewer in class org.eclipse.ui.texteditor.AbstractTextEditor
    • createPartControl

      public void createPartControl(org.eclipse.swt.widgets.Composite parent)
      Configures the editor.
      Specified by:
      createPartControl in interface org.eclipse.ui.IWorkbenchPart
      Overrides:
      createPartControl in class org.eclipse.ui.texteditor.StatusTextEditor
      Parameters:
      parent - the parent
    • isEditable

      public boolean isEditable()
      Checks if the current instance is editable.
      Specified by:
      isEditable in interface org.eclipse.ui.texteditor.ITextEditor
      Overrides:
      isEditable in class org.eclipse.ui.texteditor.AbstractTextEditor
      Returns:
      false
    • handleElementContentReplaced

      protected void handleElementContentReplaced()
      Used to inform about input changes.
      Overrides:
      handleElementContentReplaced in class org.eclipse.ui.texteditor.StatusTextEditor
    • doSetInput

      protected void doSetInput(org.eclipse.ui.IEditorInput input) throws org.eclipse.core.runtime.CoreException
      Overrides:
      doSetInput in class org.eclipse.ui.texteditor.StatusTextEditor
      Throws:
      org.eclipse.core.runtime.CoreException
    • isErrorStatus

      protected boolean isErrorStatus(org.eclipse.core.runtime.IStatus status)
      Overrides:
      isErrorStatus in class org.eclipse.ui.texteditor.StatusTextEditor
    • editorContextMenuAboutToShow

      protected void editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager menu)
      Overrides:
      editorContextMenuAboutToShow in class org.eclipse.ui.texteditor.AbstractTextEditor
    • getDocument

      public ICasDocument getDocument()
      Returns the current AnnotationDocument of this editor.
      Specified by:
      getDocument in interface ICasEditor
      Returns:
      current AnnotationDocument
    • reopenEditorWithNewTypeSystem

      public void reopenEditorWithNewTypeSystem()
      Description copied from interface: ICasEditor
      Reopen editor with new type system.
      Specified by:
      reopenEditorWithNewTypeSystem in interface ICasEditor
    • getAnnotationMode

      public Type getAnnotationMode()
      Returns the current annotation type.
      Returns:
      - current annotation type
    • setAnnotationMode

      public void setAnnotationMode(Type type)
      Sets the new annotation type.
      Parameters:
      type - the new annotation mode
    • getShownAnnotationTypes

      public Collection<Type> getShownAnnotationTypes()
      Gets the shown annotation types.
      Returns:
      the shown annotation types
    • setShownAnnotationType

      public void setShownAnnotationType(Type type, boolean isShown)
      Sets the shown annotation type.
      Parameters:
      type - the type
      isShown - the is shown
    • setShownAnnotationTypes

      public void setShownAnnotationTypes(Collection<Type> types)
      Sets the shown annotation types.
      Parameters:
      types - the new shown annotation types
    • getAnnotationStyle

      public AnnotationStyle getAnnotationStyle(Type type)
      Retrieves an AnnotationStyle from the underlying storage.
      Parameters:
      type - the type
      Returns:
      the annotation style
    • setAnnotationStyle

      public void setAnnotationStyle(AnnotationStyle style)
      Sets an annotation style. Note: Internal usage only!
      Parameters:
      style - the new annotation style
    • syncAnnotationTypes

      public void syncAnnotationTypes()
      Synchronizes all annotations with the eclipse annotation painter.
    • addAnnotationListener

      public void addAnnotationListener(IAnnotationEditorModifyListener listener)
      Adds the annotation listener.
      Parameters:
      listener - the listener
    • removeAnnotationListener

      public void removeAnnotationListener(IAnnotationEditorModifyListener listener)
      Removes the annotation listener.
      Parameters:
      listener - the listener
    • addCasEditorInputListener

      public void addCasEditorInputListener(ICasEditorInputListener listener)
      Description copied from interface: ICasEditor
      Adds the cas editor input listener.
      Specified by:
      addCasEditorInputListener in interface ICasEditor
      Parameters:
      listener - the listener
    • removeCasEditorInputListener

      public void removeCasEditorInputListener(ICasEditorInputListener listener)
      Description copied from interface: ICasEditor
      Removes the cas editor input listener.
      Specified by:
      removeCasEditorInputListener in interface ICasEditor
      Parameters:
      listener - the listener
    • getSelection

      public org.eclipse.swt.graphics.Point getSelection()
      Returns the selection.
      Returns:
      - the selection
    • getSelectedAnnotations

      public List<AnnotationFS> getSelectedAnnotations()
      Retrieves the currently selected annotation. TODO: make this private ??? clients can use selections for this ...
      Returns:
      the selected annotations or an empty list
    • getCaretOffset

      public int getCaretOffset()
      Returns the caret position relative to the start of the text.
      Returns:
      the caret position relative to the start of the text
    • showView

      public void showView(String viewName)
      Show view.
      Parameters:
      viewName - the view name
    • isEditorInputModifiable

      public boolean isEditorInputModifiable()
      Text is not editable, cause of the nature of the annotation editor. This does not mean, that the annotations are not editable.
      Specified by:
      isEditorInputModifiable in interface org.eclipse.ui.texteditor.ITextEditorExtension2
      Overrides:
      isEditorInputModifiable in class org.eclipse.ui.texteditor.AbstractTextEditor
      Returns:
      false
    • selectionChanged

      public void selectionChanged(org.eclipse.ui.IWorkbenchPart part, org.eclipse.jface.viewers.ISelection selection)
      Notifies the current instance about selection changes in the workbench.
      Specified by:
      selectionChanged in interface org.eclipse.ui.ISelectionListener
      Parameters:
      part - the part
      selection - the selection
    • createActions

      protected void createActions()
      Creates custom annotation actions: Annotate Action Smart Annotate Action Delete Annotations Action Find Annotate Action.
      Overrides:
      createActions in class org.eclipse.ui.texteditor.AbstractTextEditor
    • dispose

      public void dispose()
      Specified by:
      dispose in interface org.eclipse.ui.IWorkbenchPart
      Overrides:
      dispose in class org.eclipse.ui.texteditor.AbstractTextEditor
    • getAnnotationEditors

      public static AnnotationEditor[] getAnnotationEditors()
      Creates a list of all AnnotationEditor which are currently opened.
      Returns:
      the annotation editors
    • createStatusControl

      protected org.eclipse.swt.widgets.Control createStatusControl(org.eclipse.swt.widgets.Composite parent, org.eclipse.core.runtime.IStatus status)
      Overrides:
      createStatusControl in class org.eclipse.ui.texteditor.StatusTextEditor