LPEX
3.6.8

com.ibm.lpex.alef
Class LpexAbstractDecoratedTextEditor

java.lang.Object
  extended by EditorPart
      extended by com.ibm.lpex.alef.LpexAbstractTextEditor
          extended by com.ibm.lpex.alef.LpexStatusTextEditor
              extended by com.ibm.lpex.alef.LpexAbstractDecoratedTextEditor
Direct Known Subclasses:
LpexTextEditor

public abstract class LpexAbstractDecoratedTextEditor
extends LpexStatusTextEditor

A line oriented, LPEX-based abstract base implementation of an extended text editor. An intermediate editor comprising functionality not present in the leaner LpexAbstractTextEditor, but which may be used in heavy weight (and especially source editing) editors, such as a change (quick diff) ruler.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.ibm.lpex.alef.LpexAbstractTextEditor
LpexAbstractTextEditor.ColumnSupport, LpexAbstractTextEditor.IdMapEntry, LpexAbstractTextEditor.TextEditorSavable
 
Field Summary
protected  IAnnotationAccess fAnnotationAccess
          Helper for accessing annotation from the perspective of this editor.
protected  SourceViewerDecorationSupport fSourceViewerDecorationSupport
          Helper for managing the decoration support of this editor's viewer.
 
Fields inherited from class com.ibm.lpex.alef.LpexAbstractTextEditor
ACTION_MAP, DEFAULT_EDITOR_CONTEXT_MENU_ID, DEFAULT_RULER_CONTEXT_MENU_ID, fErrorLabel, PREFERENCE_COLOR_BACKGROUND, PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, PREFERENCE_HYPERLINK_KEY_MODIFIER, PREFERENCE_HYPERLINK_KEY_MODIFIER_MASK, PREFERENCE_HYPERLINKS_ENABLED, PREFERENCE_RULER_CONTRIBUTIONS, VERTICAL_RULER_WIDTH
 
Constructor Summary
LpexAbstractDecoratedTextEditor()
          Creates a new LPEX text editor.
 
Method Summary
protected  void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support)
          Configures the decoration support for this editor's source viewer.
protected  void createActions()
          Creates this editor's standard actions.
protected  IAnnotationAccess createAnnotationAccess()
          Creates the annotation access for this editor.
protected  IVerticalRulerColumn createAnnotationRulerColumn(CompositeRuler ruler)
          Creates the annotation ruler column.
protected  LineChangeHover createChangeHover()
          Creates and returns a LineChangeHover to be used on this editor's change ruler column.
protected  IColumnSupport createColumnSupport()
          Creates the column support to be used by this editor to manage the contributed ruler columns.
protected  CompositeRuler createCompositeRuler()
          Creates a composite ruler to be used as the vertical ruler for annotations, quick diff, and revision annotations by this editor.
protected  IVerticalRulerColumn createLineNumberRulerColumn()
          Creates a new line number change ruler column (quick diff, revisions) that is appropriately initialized.
protected  IOverviewRuler createOverviewRuler(ISharedTextColors sharedColors)
           
 void createPartControl(Composite parent)
          Creates the SWT controls for this workbench part.
protected  ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles)
          Create the source viewer (an LpexSourceViewer) to be used by this editor.
protected  IVerticalRuler createVerticalRuler()
          Overrides LpexAbstractTextEditor's to create the composite ruler used by this editor.
 void dispose()
          Disposes this part and discards all part state.
protected  void disposeDocumentProvider()
          Disposes of the connection with the document provider.
protected  void doSetInput(IEditorInput input)
          Internal processing of setting/changing the input to this editor.
 Object getAdapter(Class adapter)
          Return the object which is an instance of the given class associated with this object, or null if no such object can be found.
protected  IAnnotationAccess getAnnotationAccess()
          Returns the annotation access.
protected  MarkerAnnotationPreferences getAnnotationPreferences()
          Returns the annotation preferences.
 IDocumentProvider getDocumentProvider()
          Returns this text editor's document provider.
protected  IOverviewRuler getOverviewRuler()
          Optionally creates and returns the overview ruler.
protected  ISharedTextColors getSharedColors()
           
protected  SourceViewerDecorationSupport getSourceViewerDecorationSupport(ISourceViewer viewer)
          Returns the source viewer decoration support.
 void gotoMarker(IMarker marker)
          Sets the cursor in the primary window of the editor to the specified marker, and selects its corresponding text using the default selection mode.
protected  void handlePreferenceStoreChanged(PropertyChangeEvent event)
          Handles a property-change event describing a change of the editor's preference store.
protected  void hideOverviewRuler()
          Hides the overview ruler.
protected  void initializeEditor()
          Initializes this editor.
protected  void initializeLineNumberRulerColumn(LpexLineNumberChangeRulerColumn rulerColumn)
          Initializes the given line number change ruler column from the preference store.
 boolean isChangeInformationShowing()
          Returns the quick diff display state.
 boolean isEditable()
          Returns whether the text in this text editor can be changed by the user.
protected  boolean isErrorStatus(IStatus status)
          Returns whether the given status indicates an error.
protected  boolean isLineNumberRulerVisible()
          This method returns false.
protected  boolean isOverviewRulerVisible()
          Returns whether the overview ruler should be visible.
protected  boolean isPrefQuickDiffAlwaysOn()
          Returns whether quick diff info should be visible upon opening an editor according to the Eclipse preference store settings.
protected  void performSaveAs(IProgressMonitor progressMonitor)
          Prompts the user for the workspace path of a file resource, and saves the document there.
protected  void performSaveAs(IProgressMonitor progressMonitor, String fileName)
          Prompts the user for the workspace path of a file resource, and saves the document there.
protected  void rulerContextMenuAboutToShow(IMenuManager menu)
          Sets up the vertical ruler's context (pop-up) menu before it is made visible.
protected  void setDocumentProvider(IEditorInput input)
          Sets the editor's document provider.
 void showChangeInformation(boolean show)
          Sets the display of quick diff information.
protected  void showOverviewRuler()
          Shows the overview ruler.
 void showRevisionInformation(RevisionInformation info, String quickDiffProviderId)
           
 boolean validateEditorInputState()
          Validates the state of the given editor input.
 
Methods inherited from class com.ibm.lpex.alef.LpexStatusTextEditor
createStatusControl, doRevertToSaved, getStatusBanner, getStatusHeader, getStatusMessage, handleEditorInputChanged, handleElementContentReplaced, sanityCheckState, updatePartControl, updateStatusField
 
Methods inherited from class com.ibm.lpex.alef.LpexAbstractTextEditor
addAction, addAction, addGroup, addLines, addRulerContextMenuListener, adjustHighlightRange, affectsTextPresentation, availableOpenNewView, canHandleMove, close, createContextMenuListener, createContextMenuManager, createEmptyNavigationLocation, createNavigationActions, createNavigationLocation, createViewPreferenceNodes, createViewPreferencePage, doSave, doSaveAs, editorContextMenuAboutToShow, editorSaved, enableSanityChecking, enableStateValidation, findAnnotation, firePropertyChange, getAction, getActiveLpexView, getActiveLpexWindow, getActiveSaveables, getContextMenuListener, getCoverage, getCursorPosition, getEditorContextMenuId, getFirstLpexView, getFirstLpexWindow, getHelpContextId, getHighlightRange, getInputResource, getKeyBindingScopes, getLpexView, getLpexWindow, getOrientation, getPreferenceStore, getProgressMonitor, getRangeIndicator, getReadonlyTitleImage, getRulerContextMenuId, getRulerMouseListener, getSaveables, getSelectionProvider, getSourceViewer, getSourceViewerConfiguration, getStatusField, getStatusLineManager, getVerticalRuler, gotoAnnotation, handleDelegate, handleExceptionOnSave, init, initializeDragAndDrop, initializeLpexView, internalInit, isDirty, isEditorInputIncludedInContextMenu, isEditorInputModifiable, isEditorInputReadOnly, isNavigationTarget, isSaveAsAllowed, isVisible, markAsPropertyDependentAction, markInNavigationHistory, modelOffset2WidgetOffset, openSaveErrorDialog, performLpexCommand, performRevert, performSave, rememberSelection, removeActionActivationCode, removeRulerContextMenuListener, resetHighlightRange, restoreSelection, safelySanityCheckState, selectAndReveal, setAction, setActionActivationCode, setCompatibilityMode, setDocumentSection, setEditorContextMenuId, setFocus, setHelpContextId, setHighlightRange, setInput, setInputWithNotify, setKeyBindingScopes, setKeyBindingScopes, setLanguageHelp, setPreferenceStore, setRangeIndicator, setRulerContextMenuId, setSourceViewerConfiguration, setStatusField, setStatusLineErrorMessage, setStatusLineMessage, showHighlightRangeOnly, showsHighlightRangeOnly, updateContributedRulerColumns, updateProfile, updatePropertyDependentActions, updateState, updateStatusFields, validateState, widgetContentsSet, widgetOffset2ModelOffset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fAnnotationAccess

protected IAnnotationAccess fAnnotationAccess
Helper for accessing annotation from the perspective of this editor.

This field should not be referenced by subclasses. It is protected for API compatibility reasons and will be made private soon. Use getAnnotationAccess() instead.


fSourceViewerDecorationSupport

protected SourceViewerDecorationSupport fSourceViewerDecorationSupport
Helper for managing the decoration support of this editor's viewer.

This field should not be referenced by subclasses. It is protected for API compatibility reasons and will be made private soon. Use getSourceViewerDecorationSupport(ISourceViewer) instead.

Constructor Detail

LpexAbstractDecoratedTextEditor

public LpexAbstractDecoratedTextEditor()
Creates a new LPEX text editor.

Method Detail

initializeEditor

protected void initializeEditor()
Initializes this editor. Subclasses may reimplement.

The implementation of this method in LpexAbstractDecoratedTextEditor does nothing. In Eclipse's AbstractDecoratedTextEditor it is indicated that if subclasses do not change the contract, this method should not be extended, i.e., do not call super.initializeEditor(), in order to avoid the temporary creation of objects that are immediately overwritten by subclasses.


dispose

public void dispose()
Description copied from class: LpexAbstractTextEditor
Disposes this part and discards all part state. From this point on, the part will not be referenced within the workbench. Note that many query methods may return null after the editor is disposed.

The AbstractTextEditor implementation of this IWorkbenchPart method may be extended by subclasses. Subclasses must call super.dispose().

This method is called at the end of the part lifecycle: release any resources, fonts, images, etc. held by the part. The part control has already been disposed, so there is no need to dispose it here.

Overrides:
dispose in class LpexAbstractTextEditor
See Also:
IWorkbenchPart

createSourceViewer

protected ISourceViewer createSourceViewer(Composite parent,
                                           IVerticalRuler ruler,
                                           int styles)
Description copied from class: LpexAbstractTextEditor
Create the source viewer (an LpexSourceViewer) to be used by this editor. Subclasses may reimplement this method.

Called from createPartControl().

Overrides:
createSourceViewer in class LpexAbstractTextEditor
Parameters:
parent - the parent control
ruler - the vertical ruler
styles - style bits, SWT.WRAP is currently not supported
Returns:
the source viewer

getSharedColors

protected ISharedTextColors getSharedColors()

createOverviewRuler

protected IOverviewRuler createOverviewRuler(ISharedTextColors sharedColors)

createAnnotationAccess

protected IAnnotationAccess createAnnotationAccess()
Creates the annotation access for this editor.

Returns:
the created annotation access

configureSourceViewerDecorationSupport

protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support)
Configures the decoration support for this editor's source viewer. Subclasses may override this method, but should call their superclass's implementation at some point.

Parameters:
support - the decoration support to configure

createPartControl

public void createPartControl(Composite parent)
Description copied from class: LpexStatusTextEditor
Creates the SWT controls for this workbench part. Clients should not call this method (the workbench calls this method when it needs to, which may be never).

For implementors, this is a multi-step process: 1. Create one or more controls within the parent; 2. Set the parent layout as needed; 3. Register any global actions with the IActionService; 4. Register any popup menus with the IActionService; 5. Register a selection provider with the ISelectionService (optional).

Overrides:
createPartControl in class LpexStatusTextEditor
Parameters:
parent - the parent control
See Also:
IWorkbenchPart

isOverviewRulerVisible

protected boolean isOverviewRulerVisible()
Returns whether the overview ruler should be visible.

Returns:
whether the overview ruler is visible

showChangeInformation

public void showChangeInformation(boolean show)
Sets the display of quick diff information.

Overrides:
showChangeInformation in class LpexAbstractTextEditor
See Also:
ITextEditorExtension3

isChangeInformationShowing

public boolean isChangeInformationShowing()
Returns the quick diff display state.

Overrides:
isChangeInformationShowing in class LpexAbstractTextEditor
See Also:
ITextEditorExtension3

showRevisionInformation

public void showRevisionInformation(RevisionInformation info,
                                    String quickDiffProviderId)
Overrides:
showRevisionInformation in class LpexAbstractTextEditor

isLineNumberRulerVisible

protected boolean isLineNumberRulerVisible()
This method returns false. LPEX has its own prefix area to display line or sequence numbers. See the prefixArea parameter. AbstractDecoratedTextEditor: this method returns whether the line number ruler column should be visible according to the preference store settings; subclasses may override this method to provide a custom preference setting.

Returns:
true if the line numbers should be visible

isPrefQuickDiffAlwaysOn

protected boolean isPrefQuickDiffAlwaysOn()
Returns whether quick diff info should be visible upon opening an editor according to the Eclipse preference store settings.

Returns:
true if the quick diff should be visible

initializeLineNumberRulerColumn

protected void initializeLineNumberRulerColumn(LpexLineNumberChangeRulerColumn rulerColumn)
Initializes the given line number change ruler column from the preference store.

Parameters:
rulerColumn - the ruler column to be initialized

createLineNumberRulerColumn

protected IVerticalRulerColumn createLineNumberRulerColumn()
Creates a new line number change ruler column (quick diff, revisions) that is appropriately initialized. Note that line numbers as such are displayed in LPEX in its own prefix area.

Returns:
the created LpexLineNumberChangeRulerColumn

createChangeHover

protected LineChangeHover createChangeHover()
Creates and returns a LineChangeHover to be used on this editor's change ruler column. This hover determines the text to show as hover for a certain line or range of lines in the document.

The implementation of this method returns an LpexLineChangeHover. Subclasses may override.

Returns:
the change hover to be used by this editors quick diff display

createVerticalRuler

protected IVerticalRuler createVerticalRuler()
Overrides LpexAbstractTextEditor's to create the composite ruler used by this editor. Returns createCompositeRuler().

Subclasses should not override this method, but rather createCompositeRuler if they want to contribute their own vertical ruler implementation. If not an instance of LpexCompositeRuler is returned, the built-in ruler columns (line numbers, annotations) will not work.

May become final in the future.

Overrides:
createVerticalRuler in class LpexAbstractTextEditor
Returns:
null
See Also:
LpexAbstractTextEditor.createVerticalRuler()

createCompositeRuler

protected CompositeRuler createCompositeRuler()
Creates a composite ruler to be used as the vertical ruler for annotations, quick diff, and revision annotations by this editor. Subclasses may reimplement this method.

Returns:
a new LpexCompositeRuler

createAnnotationRulerColumn

protected IVerticalRulerColumn createAnnotationRulerColumn(CompositeRuler ruler)
Creates the annotation ruler column. Subclasses may re-implement or extend.

Parameters:
ruler - the composite ruler that the column will be added to
Returns:
a new LpexAnnotationRulerColumn

createColumnSupport

protected final IColumnSupport createColumnSupport()
Description copied from class: LpexAbstractTextEditor
Creates the column support to be used by this editor to manage the contributed ruler columns. The default implementation of this method in LpexAbstractTextEditor does nothing except return null. Subclasses may re-implement this method using the LpexAbstractTextEditor.ColumnSupport, e.g., by returning new ColumnSupport(this, RulerColumnRegistry.getDefault());.

Note: If you override this method to provide column support, you must also override LpexAbstractTextEditor.createVerticalRuler() to return an LpexCompositeRuler.

Overrides:
createColumnSupport in class LpexAbstractTextEditor
Returns:
the column support, or null if none

handlePreferenceStoreChanged

protected void handlePreferenceStoreChanged(PropertyChangeEvent event)
Description copied from class: LpexAbstractTextEditor
Handles a property-change event describing a change of the editor's preference store. Subclasses may extend.

LPEX's own default settings are stored in its own defaultProfile. In AbstractTextEditor this method updates any preference-related editor properties (its font; foreground, background, selection, and find-scope colours, carets), most of which are not used in LpexAbstractTextEditor.

Overrides:
handlePreferenceStoreChanged in class LpexAbstractTextEditor
Parameters:
event - the property change event

showOverviewRuler

protected void showOverviewRuler()
Shows the overview ruler.


hideOverviewRuler

protected void hideOverviewRuler()
Hides the overview ruler.


getAnnotationAccess

protected IAnnotationAccess getAnnotationAccess()
Returns the annotation access.

Returns:
the annotation access

getOverviewRuler

protected IOverviewRuler getOverviewRuler()
Optionally creates and returns the overview ruler.

Returns:
the overview ruler

getSourceViewerDecorationSupport

protected SourceViewerDecorationSupport getSourceViewerDecorationSupport(ISourceViewer viewer)
Returns the source viewer decoration support.

Parameters:
viewer - the viewer for which to return a decoration support
Returns:
the source viewer decoration support

getAnnotationPreferences

protected MarkerAnnotationPreferences getAnnotationPreferences()
Returns the annotation preferences.

Returns:
the annotation preferences

gotoMarker

public void gotoMarker(IMarker marker)
Sets the cursor in the primary window of the editor to the specified marker, and selects its corresponding text using the default selection mode.

If the editor is dirty (can be saved), all the marker ranges have been changed according to the text manipulations. However, those changes are not yet propagated to the marker manager. Therefore, when opening a marker, the marker's position in the editor must be determined as it might differ from the position stated in the marker.

Parameters:
marker - the marker to go to

isEditable

public boolean isEditable()
Description copied from class: LpexAbstractTextEditor
Returns whether the text in this text editor can be changed by the user. This method returns document provider's isModifiable() indication for our editor input.

Overrides:
isEditable in class LpexAbstractTextEditor
Returns:
true if it can be edited, or false if it is read only
See Also:
ITextEditor

validateEditorInputState

public boolean validateEditorInputState()
Description copied from class: LpexAbstractTextEditor
Validates the state of the given editor input. The predominate intent of this method is to take any action probably necessary to ensure that the input can be persistently changed.

Overrides:
validateEditorInputState in class LpexStatusTextEditor
Returns:
true if the input was validated, false otherwise
See Also:
ITextEditorExtension2

isErrorStatus

protected boolean isErrorStatus(IStatus status)
Returns whether the given status indicates an error. Subclasses may override. For an explanation why we override this method see: bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=42230

Overrides:
isErrorStatus in class LpexStatusTextEditor
Parameters:
status - the status to be checked
Returns:
true if the status indicates an error, or
false otherwise
See Also:
StatusTextEditor

createActions

protected void createActions()
Description copied from class: LpexAbstractTextEditor
Creates this editor's standard actions.

Actions handled in here are the standard Eclipse editor actions defined in ITextEditorActionConstants and IWorkbenchActionConstants, and some of the context menu actions.

The standard editor actions will be connected to the workbench global actions in LpexContextContributor -> BasicTextEditorActionContributor (see #doSetActiveEditor(): setGlobalActionHandler() for ITextEditorActionConstants.UNDO, REDO, CUT, COPY, PASTE, DELETE, SELECT_ALL, FIND, PRINT, REVERT; and setAction() for retargeted ITextEditorActionConstants.FIND_NEXT, FIND_PREVIOUS, FIND_INCREMENTAL, GOTO_LINE).

For LPEX's contributions to the Eclipse context, see LpexContextContributor.

Subclasses may extend.

Overrides:
createActions in class LpexAbstractTextEditor

getAdapter

public Object getAdapter(Class adapter)
Description copied from class: LpexAbstractTextEditor
Return the object which is an instance of the given class associated with this object, or null if no such object can be found.

IAdaptable is an interface for an adaptable object. Adaptable objects can be dynamically extended to provide different interfaces (or "adapters"). Adapters are created by adapter factories, which are in turn managed by type by adapter managers.

Overrides:
getAdapter in class LpexAbstractTextEditor
See Also:
IAdaptable

setDocumentProvider

protected void setDocumentProvider(IEditorInput input)
Description copied from class: LpexAbstractTextEditor
Sets the editor's document provider. This method must be called before the editor's control is created.

IDocumentProvider is an interface used by the ITextEditor to interact with its input element based on the input element's textual representation as IDocument. A document provider may be shared between multiple editors.

Overrides:
setDocumentProvider in class LpexAbstractTextEditor
Parameters:
input - the document provider

getDocumentProvider

public IDocumentProvider getDocumentProvider()
Description copied from class: LpexAbstractTextEditor
Returns this text editor's document provider.

Overrides:
getDocumentProvider in class LpexAbstractTextEditor
See Also:
ITextEditor

disposeDocumentProvider

protected void disposeDocumentProvider()
Description copied from class: LpexAbstractTextEditor
Disposes of the connection with the document provider. Subclasses may extend.

Overrides:
disposeDocumentProvider in class LpexAbstractTextEditor

doSetInput

protected void doSetInput(IEditorInput input)
                   throws CoreException
Description copied from class: LpexAbstractTextEditor
Internal processing of setting/changing the input to this editor. Called from within a workspace runnable from init() (shortly after the part construction), directly from setInput(), and from handleEditorInputChanged().

This method does the actual setting of the editor input. It closes the editor if input is null. It disconnects from any previous editor input and its document provider, and connects to the new one. Subclasses may extend.

Overrides:
doSetInput in class LpexStatusTextEditor
Parameters:
input - the (new) input to be set; if null, this text editor is being closed
Throws:
CoreException - if the input cannot be connected to the document provider (i.e., it is not understood by this part)

performSaveAs

protected void performSaveAs(IProgressMonitor progressMonitor)
Prompts the user for the workspace path of a file resource, and saves the document there.

Overrides:
performSaveAs in class LpexAbstractTextEditor
Parameters:
progressMonitor - the progress monitor to be used
See Also:
performSaveAs(IProgressMonitor,String), #performSaveAs(IProgressMonitor,IFile)

performSaveAs

protected void performSaveAs(IProgressMonitor progressMonitor,
                             String fileName)
Prompts the user for the workspace path of a file resource, and saves the document there.

Overrides:
performSaveAs in class LpexAbstractTextEditor
Parameters:
progressMonitor - the progress monitor to be used
fileName - initial file name in the dialog
See Also:
performSaveAs(IProgressMonitor), #performSaveAs(IProgressMonitor,IFile)

rulerContextMenuAboutToShow

protected void rulerContextMenuAboutToShow(IMenuManager menu)
Description copied from class: LpexAbstractTextEditor
Sets up the vertical ruler's context (pop-up) menu before it is made visible.

Subclasses may extend to add other actions.

Overrides:
rulerContextMenuAboutToShow in class LpexAbstractTextEditor
Parameters:
menu - the menu

LPEX
3.6.8

Copyright © 2013 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.