LPEX
4.4.0

com.ibm.lpex.alef
Class LpexAbstractTextEditor

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

public abstract class LpexAbstractTextEditor
extends EditorPart

A line oriented, LPEX-based abstract base implementation of a text editor. Subclasses are responsible for configuring the editor appropriately. LpexTextEditor is one such example.

Actions and commands

LPEX actions, their assigned keys, and commands new or (re)defined in here for running in the Eclipse workbench:

Keys already defined (for example, by the active base editor profile and by the user profile) to an action different from nullAction are not redefined in here.

LpexAbstractTextEditor

If a subclass calls setEditorContextMenuId the argument is used as the id under which the editor's context menu is registered for extensions. If no id is set, the context menu is registered under editor_id.EditorContext, whereby editor_id is the editor's part id. If the editor is set to run in version 1.0 context menu registration compatibility mode (see setCompatibilityMode(boolean)), the latter form of the registration even happens if a context menu id has been set via setEditorContextMenuId. If no id is set while in compatibility mode, the menu is registered under DEFAULT_EDITOR_CONTEXT_MENU_ID.

If a subclass calls setRulerContextMenuId the arguments is used as the id under which the ruler's context menu is registered for extensions. If no id is set, the context menu is registered under editor_id.RulerContext, whereby editor_id is the editor's part id. If the editor is set to run in version 1.0 context menu registration compatibility mode (see setCompatibilityMode(boolean)), the latter form of the registration even happens if a context menu id has been set via setRulerContextMenuId. If no id is set while in compatibility mode, the menu is registered under DEFAULT_RULER_CONTEXT_MENU_ID.

Several AbstractTextEditor classes, methods, and fields are not available in LpexAbstractTextEditor. Most programming of the underlying LPEX widget should be done directly via its LpexView and LpexWindow.

Always use LpexView to set the text of the edited document. For example:

  
 IEditorPart editor = IWorkbenchPage.getActiveEditor();
 // (a) Using LPEX
 if (editor instanceof LpexAbstractTextEditor)
  {
   LpexAbstractTextEditor lpexEditor = (LpexAbstractTextEditor)editor;
   LpexView lpexView = lpexEditor.getActiveLpexView();
   if (lpexView != null)
    {
     lpexView.doDefaultCommand("insertText " + text); // insert text at cursor 
     LpexView.doGlobalCommand("screenShow document"); // refresh display
    }
  }
 // (b) Using the Eclipse editor
 else
  {
   // . . . get DocumentProvider, get IDocument, do replace()
  }
 

See Also:
getFirstLpexView(), getActiveLpexView(), getLpexView(), getFirstLpexWindow(), getActiveLpexWindow(), getLpexWindow()

Nested Class Summary
protected static class LpexAbstractTextEditor.ColumnSupport
          Implements the ruler column support for the given LPEX text editor.
protected static class LpexAbstractTextEditor.IdMapEntry
          Maps an Eclipse action definition name to an LPEX action.
protected static class LpexAbstractTextEditor.TextEditorSavable
          This text editor's savable.
 
Field Summary
static String DEFAULT_EDITOR_CONTEXT_MENU_ID
          Default menu id for the editor context menu ("#LpexEditorContext").
static String DEFAULT_RULER_CONTEXT_MENU_ID
          Default menu id for the ruler context menu ("#LpexRulerContext").
protected  String fErrorLabel
          The error message shown in the status line in the case of failed information look up.
static String PREFERENCE_COLOR_BACKGROUND
          Key used to look up background color preference (for e.g., the quick diff ruler).
static String PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT
          Key used to look up background color system default preference (for e.g., the quick diff ruler).
static String PREFERENCE_HYPERLINK_KEY_MODIFIER
          A named preference that controls the key modifier for hyperlinks.
static String PREFERENCE_HYPERLINK_KEY_MODIFIER_MASK
          A named preference that controls the key modifier mask for hyperlinks.
static String PREFERENCE_HYPERLINKS_ENABLED
          A named preference that controls if hyperlinks are turned on or off.
static String PREFERENCE_RULER_CONTRIBUTIONS
          A named preference that controls the visible ruler column contributions.
protected static int VERTICAL_RULER_WIDTH
          The width of the vertical ruler.
 
Constructor Summary
protected LpexAbstractTextEditor()
          Creates a new text editor.
 
Method Summary
protected  void addAction(IMenuManager menu, String actionName)
          Convenience method to add the action installed under the given action name to the given menu.
protected  void addAction(IMenuManager menu, String group, String actionName)
          Convenience method to add the action installed under the given action name to the specified group of the given menu.
protected  void addGroup(IMenuManager menu, String existingGroup, String newGroup)
          Convenience method to add a new menu group after the specified group.
protected  boolean addLines(LpexView lpexView, int lineNeeded)
          Hook for managing an LPEX text-widget document section.
 void addRulerContextMenuListener(IMenuListener listener)
          Adds a ruler context-menu listener to the editor.
protected  void adjustHighlightRange(int offset, int len)
          Adjusts the highlight range so that at least the specified range is highlighted.
protected  boolean affectsTextPresentation(PropertyChangeEvent event)
          Determines whether the given preference change affects the editor's presentation.
protected  boolean availableOpenNewView(LpexView lpexView)
          Returns the availability of the openNewView action defined in here.
protected  boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement)
          Returns whether this editor can handle the move of the original element so that it ends up being the moved element.
 void close(boolean save)
          Closes this text editor, after optionally saving changes.
protected  void createActions()
          Creates this editor's standard actions.
protected  IColumnSupport createColumnSupport()
          Creates the column support to be used by this editor to manage the contributed ruler columns.
protected  IMenuListener createContextMenuListener()
          Creates the listener on this editor's context menus.
protected  MenuManager createContextMenuManager(String text, String id)
          Creates a window's context menu manager.
 INavigationLocation createEmptyNavigationLocation()
          Creates an empty navigation location.
protected  void createNavigationActions()
          Creates action entries for those LPEX actions that correspond to Eclipse's actions being mapped to its SWT StyledText actions in AbstractTextEditor.
 INavigationLocation createNavigationLocation()
          Creates a navigation location describing the current state.
 void createPartControl(Composite parent)
          The LpexAbstractTextEditor implementation of this IWorkbenchPart method creates a vertical ruler and the source viewer.
protected  ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles)
          Create the source viewer (an LpexSourceViewer) to be used by this editor.
protected  IVerticalRuler createVerticalRuler()
          Subclass LpexAbstractDecoratedTextEditor creates an LpexCompositeRuler.
protected  void createViewPreferenceNodes(LpexSourceViewer lpexSourceViewer)
          Hook to allow the solution plug-in create custom preference node(s) for view-scoped preference page(s) for this editor's source viewer.
protected  IPreferencePage createViewPreferencePage(LpexView lpexView, int nodeType)
          Factory method to create a view-scoped preference page to be used by this editor's source viewer.
 void dispose()
          Disposes this part and discards all part state.
protected  void disposeDocumentProvider()
          Disposes of the connection with the document provider.
 void doRevertToSaved()
          Abandons all modifications applied to the editor's input element's textual presentation since the last save operation.
 void doSave(IProgressMonitor progressMonitor)
          Saves the contents of the target.
 void doSaveAs()
          Saves the contents of the target to another object.
protected  void doSetInput(IEditorInput input)
          Internal processing of setting/changing the input to this editor.
protected  void editorContextMenuAboutToShow(IMenuManager menu)
          Sets up the pop-up (context) menu of this editor's active view before it is made visible.
protected  void editorSaved()
          Hook which gets called when the editor has been saved.
protected  void enableSanityChecking(boolean enable)
          Enables/disables sanity checking.
protected  void enableStateValidation(boolean enable)
          Enables/disables state validation.
protected  Annotation findAnnotation(int offset, int length, boolean forward, Position annotationPosition)
          Returns the annotation closest to the given range respecting the given direction.
protected  void firePropertyChange(int property)
          Fire a property-changed event.
 IAction getAction(String actionName)
          Returns the user or global Eclipse action which has been installed (i.e., cached in here) under the specified action name.
 LpexView getActiveLpexView()
          Convenience method to retrieve the active document view of the underlying LPEX text widget.
 LpexWindow getActiveLpexWindow()
          Convenience method to retrieve the active window of the underlying LPEX text widget.
 Saveable[] getActiveSaveables()
           
 Object getAdapter(Class required)
          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  IMenuListener getContextMenuListener()
          Creates and returns the listener on this editor's context menus.
protected static IRegion getCoverage(ISourceViewer viewer)
          Returns the minimal region of the given source viewer's document that completely comprises everything that is visible in the viewer's widget.
protected  String getCursorPosition()
          Returns a description of the cursor position suitable for display in the Eclipse status field.
 IDocumentProvider getDocumentProvider()
          Returns this text editor's document provider.
protected  String getEditorContextMenuId()
          Returns this editor's context menu id.
 LpexView getFirstLpexView()
          Convenience method to retrieve the primary document view of the underlying LPEX text widget.
 LpexWindow getFirstLpexWindow()
          Convenience method to retrieve the primary window of the underlying LPEX text widget.
protected  String getHelpContextId()
          Returns the editor's edit-area help context id.
 IRegion getHighlightRange()
          Returns the highlighted range of this text editor.
protected  IResource getInputResource()
          Returns the IResource underlying our editor input (file / storage).
protected  String[] getKeyBindingScopes(LpexView lpexView)
          Returns the key-binding scopes set for a view of this editor.
 LpexView getLpexView()
          Convenience method to retrieve the focus document view of the underlying LPEX text widget, or otherwise the primary view.
 LpexWindow getLpexWindow()
          Convenience method to retrieve the focus window of the underlying LPEX text widget, or otherwise the primary window.
 int getOrientation()
          Returns the orientation of this workbench part.
protected  IPreferenceStore getPreferenceStore()
          Returns this editor's preference store.
protected  IProgressMonitor getProgressMonitor()
          Returns the progress monitor related to this editor.
protected  Annotation getRangeIndicator()
          Returns this editor's range indicator.
protected  Image getReadonlyTitleImage()
          Returns the read-only title image of this editor part.
protected  String getRulerContextMenuId()
          Returns the ruler's context menu id.
protected  MouseListener getRulerMouseListener()
          Creates and returns the listener on this editor's vertical ruler.
 Saveable[] getSaveables()
           
 ISelectionProvider getSelectionProvider()
          Returns this editor's selection provider.
protected  ISourceViewer getSourceViewer()
          Returns this editor's source viewer.
protected  SourceViewerConfiguration getSourceViewerConfiguration()
          Returns this editor's source viewer configuration.
protected  IStatusField getStatusField(String category)
          Returns the current status field for the given status category.
protected  IStatusLineManager getStatusLineManager()
          Returns the status line manager of this editor.
 IVerticalRuler getVerticalRuler()
          Returns this editor's vertical ruler.
 Annotation gotoAnnotation(boolean forward)
          Jumps to the next annotation according to the given direction.
protected  void handleCursorPositionChanged()
           
protected  void handleDelegate(LpexView lpexView)
          Redirect Lpex actions and commands to run in this plug-in's context.
protected  void handleEditorInputChanged()
          Handles an external change of the editor's input element.
protected  void handleElementContentReplaced()
          Performs any additional action necessary after the input document's content has been replaced.
protected  void handleExceptionOnSave(CoreException exception, IProgressMonitor progressMonitor)
          Handles the given save exception.
protected  void handlePreferenceStoreChanged(PropertyChangeEvent event)
          Handles a property-change event describing a change of the editor's preference store.
 void init(IEditorSite site, IEditorInput input)
          Initialize this editor with the given editor site and input.
protected  void initializeDragAndDrop(ISourceViewer viewer)
          Initializes the drag and drop support for the given viewer based on provided editor adapter for drop target listeners.
 void initializeLpexView(LpexView lpexView)
          Hook to initialize a newly instantiated primary or secondary LpexView used by this text editor's LpexSourceViewer.
protected  void internalInit(IWorkbenchWindow window, IEditorSite site, IEditorInput input)
          Implements the init method of IEditorPart.
 boolean isChangeInformationShowing()
          Returns the quick diff display state.
 boolean isDirty()
          Returns whether the contents of this editor have changed since the last save operation.
 boolean isEditable()
          Returns whether the text in this text editor can be changed by the user.
protected  boolean isEditorInputIncludedInContextMenu()
          Sets whether the editor input should be included when adding object contributions to this editor's context menu.
 boolean isEditorInputModifiable()
          Returns whether the editor's input can be persistently modified.
 boolean isEditorInputReadOnly()
          Returns whether the editor's input is read-only.
protected  boolean isNavigationTarget(Annotation annotation)
          Returns whether the given annotation is configured as a target for the "Go to Next/Previous Annotation" actions.
 boolean isSaveAsAllowed()
          Returns true if the "Save as" operation is supported by the target.
protected static boolean isVisible(ISourceViewer viewer, int offset, int len)
          Returns whether the given region is visible in the given source viewer.
 void markAsPropertyDependentAction(String actionId, boolean mark)
          Marks or unmarks the given action to be updated on property changes.
protected  void markInNavigationHistory()
          Writes a check mark of the given situation into the navigation history.
protected static int modelOffset2WidgetOffset(ISourceViewer viewer, int modelOffset)
          Returns the offset of the given source viewer's text widget that corresponds to the given model offset.
protected  void openSaveErrorDialog(String title, String message, CoreException exception)
          Presents an error dialog to the user when a problem happens during save.
protected  boolean performLpexCommand(LpexView lpexView)
          Opens the "Lpex" sample editor in package com.ibm.lpex.samples for a new view on the document.
protected  void performRevert()
          Performs revert and handles errors appropriately.
protected  void performSave(boolean overwrite, IProgressMonitor progressMonitor)
          Performs the save and handles errors appropriately.
protected  void performSaveAs(IProgressMonitor progressMonitor)
          Performs a "Save as", and reports the result state back to the given progress monitor.
protected  void performSaveAs(IProgressMonitor progressMonitor, String fileName)
          Performs a "Save as", and reports the result state back to the given progress monitor.
protected  void rememberSelection()
          Remembers the current selection of this editor.
 void removeActionActivationCode(String actionName)
          The preferred method is to define and use LPEX actions, and associate them with keys using the set keyAction LPEX command.
 void removeRulerContextMenuListener(IMenuListener listener)
          Removes a ruler context-menu listener from the editor.
 void resetHighlightRange()
          Resets the highlight range.
protected  void restoreSelection()
          Restores a selection previously remembered by rememberSelection.
protected  void rulerContextMenuAboutToShow(IMenuManager menu)
          Sets up the vertical ruler's context (pop-up) menu before it is made visible.
protected  void safelySanityCheckState(IEditorInput input)
          Checks the state of the given editor input if sanity checking is enabled.
protected  void sanityCheckState(IEditorInput input)
          Checks the state of the given editor input.
 void selectAndReveal(int start, int len)
          Selects and reveals the specified range in this text editor.
protected  void selectAndReveal(int selectionStart, int selectionLength, int revealStart, int revealLength)
          Selects and reveals the specified ranges in this text editor.
 void setAction(String actionName, IAction action)
          Installs or removes the given user or global Eclipse action under the specified action name.
 void setActionActivationCode(String actionName, char activationCharacter, int activationKeyCode, int activationStateMask)
          The preferred method is to define and use LPEX actions, and associate them with keys using the set keyAction LPEX command.
protected  void setCompatibilityMode(boolean compatible)
          Sets the context menu registration 1.0 compatibility mode.
protected  void setDocumentProvider(IDocumentProvider provider)
          Sets the editor's document provider.
protected  void setDocumentProvider(IEditorInput input)
          Hook method for setting the document provider for the given input.
protected  boolean setDocumentSection(int linesBeforeStart, int linesAfterEnd)
          Establish the boundaries of the LPEX document section that was loaded or is going to be loaded in the text widget, and initiate the management of this document section.
protected  void setEditorContextMenuId(String contextMenuId)
          Sets this editor's pop-up (context) menu id.
 void setFocus()
          Ask the part to take focus within the workbench.
protected  void setHelpContextId(String helpContextId)
          Sets the editor's edit-area help context id.
 void setHighlightRange(int offset, int len, boolean moveCursor)
          Sets the highlight range to the specified region.
 void setInput(IEditorInput input)
          Sets the input to this editor.
protected  void setInputWithNotify(IEditorInput input)
          Sets the input to this editor and fires a PROP_INPUT property change if the input has changed.
protected  void setKeyBindingScopes(LpexView lpexView, String[] scopes)
          Sets the key-binding scopes for a view of this editor.
protected  void setKeyBindingScopes(String[] scopes)
          Do not use this method.
protected  void setLanguageHelp(LpexLanguageHelp lsh)
          Set the provider for this editor's LPEX document parser language-sensitive help (LSH).
protected  void setPreferenceStore(IPreferenceStore store)
          Sets this editor's preference store.
protected  void setRangeIndicator(Annotation rangeIndicator)
          Sets the annotation which this editor uses to represent the highlight range if the editor is configured to show the entire document.
protected  void setRulerContextMenuId(String contextMenuId)
          Sets the ruler's pop-up (context) menu id.
protected  void setSourceViewerConfiguration(SourceViewerConfiguration configuration)
          Sets this editor's source viewer configuration used to configure its internal source viewer.
 void setStatusField(IStatusField field, String category)
          Informs the editor which status field is to be used when posting status information in the given category.
protected  void setStatusLineErrorMessage(String message)
          Sets the given message as error message to this editor's status line.
protected  void setStatusLineMessage(String message)
          Sets the given message as message to this editor's status line.
 void showChangeInformation(boolean show)
          Sets the display of quick diff information.
 void showHighlightRangeOnly(boolean showHighlightRangeOnly)
          Configure the editor to show, or not show, the highlight range exclusively.
 void showRevisionInformation(RevisionInformation info, String quickDiffProviderId)
           
 boolean showsHighlightRangeOnly()
          Query whether the editor is configured to show the highlight range only, or all of the input element's textual representation.
protected  void updateContributedRulerColumns(LpexCompositeRuler ruler)
          Adds enabled ruler contributions to the vertical ruler.
 void updateProfile(LpexView lpexView)
          Extend this method for post-updateProfile command processing.
protected  void updatePropertyDependentActions()
          Updates all property dependent actions.
protected  void updateState(IEditorInput input)
          Updates the state of the given editor input, such as the readonly flag.
protected  void updateStatusField(String category)
          Updates the Eclipse status field for the given category.
protected  void updateStatusFields()
          Updates all status fields.
 boolean validateEditorInputState()
          Validates the state of the given editor input.
protected  void validateState(IEditorInput input)
          Validates the state of the given editor input.
protected  void widgetContentsSet(LpexView lpexView)
          Hook called once the LPEX text widget contents have been (re-)set from the Eclipse IDocument.
protected static int widgetOffset2ModelOffset(ISourceViewer viewer, int widgetOffset)
          Returns the offset of the given source viewer's document that corresponds to the given widget offset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREFERENCE_COLOR_BACKGROUND

public static final String PREFERENCE_COLOR_BACKGROUND
Key used to look up background color preference (for e.g., the quick diff ruler). Value: AbstractTextEditor.Color.Background

See Also:
Constant Field Values

PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT

public static final String PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT
Key used to look up background color system default preference (for e.g., the quick diff ruler). Value: AbstractTextEditor.Color.Background.SystemDefault

See Also:
Constant Field Values

PREFERENCE_HYPERLINKS_ENABLED

public static final String PREFERENCE_HYPERLINKS_ENABLED
A named preference that controls if hyperlinks are turned on or off. Boolean value.

See Also:
Constant Field Values

PREFERENCE_HYPERLINK_KEY_MODIFIER

public static final String PREFERENCE_HYPERLINK_KEY_MODIFIER
A named preference that controls the key modifier for hyperlinks. String value.

See Also:
Constant Field Values

PREFERENCE_HYPERLINK_KEY_MODIFIER_MASK

public static final String PREFERENCE_HYPERLINK_KEY_MODIFIER_MASK
A named preference that controls the key modifier mask for hyperlinks. The value is only used if the value of PREFERENCE_HYPERLINK_KEY_MODIFIER cannot be resolved to valid SWT modifier bits. String value.

See Also:
PREFERENCE_HYPERLINK_KEY_MODIFIER, Constant Field Values

PREFERENCE_RULER_CONTRIBUTIONS

public static final String PREFERENCE_RULER_CONTRIBUTIONS
A named preference that controls the visible ruler column contributions. String value, should be read using a RulerColumnPreferenceAdapter.

See Also:
Constant Field Values

DEFAULT_EDITOR_CONTEXT_MENU_ID

public static final String DEFAULT_EDITOR_CONTEXT_MENU_ID
Default menu id for the editor context menu ("#LpexEditorContext").

See Also:
Constant Field Values

DEFAULT_RULER_CONTEXT_MENU_ID

public static final String DEFAULT_RULER_CONTEXT_MENU_ID
Default menu id for the ruler context menu ("#LpexRulerContext").

See Also:
Constant Field Values

VERTICAL_RULER_WIDTH

protected static final int VERTICAL_RULER_WIDTH
The width of the vertical ruler.

See Also:
Constant Field Values

fErrorLabel

protected final String fErrorLabel
The error message shown in the status line in the case of failed information look up.

Constructor Detail

LpexAbstractTextEditor

protected LpexAbstractTextEditor()
Creates a new text editor. If not explicitly set, this editor uses an LpexSourceViewerConfiguration to configure its source viewer. This viewer does not have a range indicator installed, nor any menu id set. By default, the created editor runs in 1.0 context menu registration compatibility mode.

Method Detail

getDocumentProvider

public IDocumentProvider getDocumentProvider()
Returns this text editor's document provider.

See Also:
ITextEditor

getPreferenceStore

protected final IPreferenceStore getPreferenceStore()
Returns this editor's preference store. LPEX's default settings are stored in its defaultProfile, not in the editor's preference store.

Returns:
this editor's preference store, or null if none has been set

getRangeIndicator

protected final Annotation getRangeIndicator()
Returns this editor's range indicator.

Returns:
the editor's range indicator, or null if none installed

getSourceViewerConfiguration

protected final SourceViewerConfiguration getSourceViewerConfiguration()
Returns this editor's source viewer configuration.

Returns:
the editor's source viewer configuration, or null before the editor's part has been created and after disposal

getSourceViewer

protected final ISourceViewer getSourceViewer()
Returns this editor's source viewer.

Returns:
the editor's source viewer, or null before the editor's part has been created and after disposal

getVerticalRuler

public final IVerticalRuler getVerticalRuler()
Returns this editor's vertical ruler.

Returns:
the editor's vertical ruler, or null before the editor's part has been created and after disposal

getEditorContextMenuId

protected final String getEditorContextMenuId()
Returns this editor's context menu id.

Returns:
the editor's context (pop-up) menu id, or null before the editor's part has been created

getRulerContextMenuId

protected final String getRulerContextMenuId()
Returns the ruler's context menu id.

Returns:
the ruler context (pop-up) menu id, or null before the editor's part has been created

setDocumentProvider

protected void setDocumentProvider(IDocumentProvider provider)
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.

Parameters:
provider - the document provider

setSourceViewerConfiguration

protected void setSourceViewerConfiguration(SourceViewerConfiguration configuration)
Sets this editor's source viewer configuration used to configure its internal source viewer. This method must be called before the editor's control is created. If not, this editor uses a default LpexSourceViewerConfiguration.

Parameters:
configuration - the source viewer configuration object
See Also:
LpexSourceViewerConfiguration

setRangeIndicator

protected void setRangeIndicator(Annotation rangeIndicator)
Sets the annotation which this editor uses to represent the highlight range if the editor is configured to show the entire document. If the range indicator is not set, this editor will not show a range indication.

Parameters:
rangeIndicator - the annotation

setEditorContextMenuId

protected void setEditorContextMenuId(String contextMenuId)
Sets this editor's pop-up (context) menu id.

Parameters:
contextMenuId - the context menu id

setRulerContextMenuId

protected void setRulerContextMenuId(String contextMenuId)
Sets the ruler's pop-up (context) menu id.

Parameters:
contextMenuId - the context menu id

setCompatibilityMode

protected final void setCompatibilityMode(boolean compatible)
Sets the context menu registration 1.0 compatibility mode. See class description for more details.

Parameters:
compatible - true if compatibility mode is enabled

getSelectionProvider

public ISelectionProvider getSelectionProvider()
Returns this editor's selection provider.

Returns:
the selection provider, or null if the editor has been disposed

rememberSelection

protected void rememberSelection()
Remembers the current selection of this editor. This method is called when, e.g., the content of the editor is about to be reverted to the saved state. This method remembers the selection in a semantic format, i.e., in a format which allows to restore the selection even if the originally selected text is no longer part of the editor's content.

Subclasses should implement this method including all necessary state. This default implementation remembers the textual range only and is thus purely syntactic.

See Also:
restoreSelection()

restoreSelection

protected void restoreSelection()
Restores a selection previously remembered by rememberSelection. Subclasses may reimplement this method and thereby semantically adapt the remembered selection. This default implementation just selects the remembered textual range.

See Also:
rememberSelection()

createContextMenuListener

protected IMenuListener createContextMenuListener()
Creates the listener on this editor's context menus.

Returns:
the created menu listener

getContextMenuListener

protected final IMenuListener getContextMenuListener()
Creates and returns the listener on this editor's context menus.

Returns:
the menu listener

getRulerMouseListener

protected final MouseListener getRulerMouseListener()
Creates and returns the listener on this editor's vertical ruler. The vertical ruler works in conjunction with the primary window.

Returns:
the mouse listener

affectsTextPresentation

protected boolean affectsTextPresentation(PropertyChangeEvent event)
Determines whether the given preference change affects the editor's presentation. This implementation always returns false. May be reimplemented by subclasses.

Parameters:
event - the event which should be investigated
Returns:
true if the event describes a preference change affecting the editor's presentation

handlePreferenceStoreChanged

protected void handlePreferenceStoreChanged(PropertyChangeEvent event)
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.

Parameters:
event - the property change event

internalInit

protected final void internalInit(IWorkbenchWindow window,
                                  IEditorSite site,
                                  IEditorInput input)
                           throws PartInitException
Implements the init method of IEditorPart. Subclasses replacing init may choose to call this method in their implementation.

Parameters:
window - the workbench window
site - the editor's site
input - the editor input for the editor being created
Throws:
PartInitException - if doSetInput(IEditorInput) fails or gets canceled
See Also:
IEditorPart

init

public void init(IEditorSite site,
                 IEditorInput input)
          throws PartInitException
Initialize this editor with the given editor site and input. This method is automatically called shortly after the part construction; it marks the start of the part's lifecycle. The IWorkbenchPart.dispose() method will be called automatically at the end of the lifecycle. Clients must not call this method.

Throws:
PartInitException
See Also:
IEditorPart

createVerticalRuler

protected IVerticalRuler createVerticalRuler()
Subclass LpexAbstractDecoratedTextEditor creates an LpexCompositeRuler. The default implementation of this method in LpexAbstractTextEditor does nothing except return null. Subclasses may reimplement this method.

Called from createPartControl().

Returns:
null

updateContributedRulerColumns

protected void updateContributedRulerColumns(LpexCompositeRuler ruler)
Adds enabled ruler contributions to the vertical ruler. Clients may extend or replace.

Parameters:
ruler - the LPEX composite ruler to add contributions to

createColumnSupport

protected IColumnSupport createColumnSupport()
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 createVerticalRuler() to return an LpexCompositeRuler.

Returns:
the column support, or null if none

createSourceViewer

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

Called from createPartControl().

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

initializeDragAndDrop

protected void initializeDragAndDrop(ISourceViewer viewer)
Initializes the drag and drop support for the given viewer based on provided editor adapter for drop target listeners.

Parameters:
viewer - the viewer

createPartControl

public void createPartControl(Composite parent)
The LpexAbstractTextEditor implementation of this IWorkbenchPart method creates a vertical ruler and the source viewer.

Subclasses may extend this method. Besides extending this method, the behavior of createPartControl may be customized by calling, extending, or replacing the following methods:
Subclasses may supply customized implementations for some members using the following methods before createPartControl is invoked:

Subclasses may replace the following methods called from within createPartControl: Subclasses may extend the following methods called from within createPartControl:

See Also:
IWorkbenchPart

createContextMenuManager

protected MenuManager createContextMenuManager(String text,
                                               String id)
Creates a window's context menu manager. Called for both the primary and secondary windows.

The default implementation of this method returns a new org.eclipse.jface.action.MenuManager. Subclasses may reimplement this method.


isEditorInputIncludedInContextMenu

protected boolean isEditorInputIncludedInContextMenu()
Sets whether the editor input should be included when adding object contributions to this editor's context menu.

The default implementation of this method returns true. Override to return false if you want to stop those external editor context menu contributions which are related to the editorInput (CVS operations, etc.) from being added by default.

Returns:
true if the editor input should be considered

getReadonlyTitleImage

protected Image getReadonlyTitleImage()
Returns the read-only title image of this editor part. The default implementation of this method returns the regular image of this editor found in the editor descriptor.

You may subclass to return a different image. Since this image is managed by the editor part itself, you must not dispose the returned image. The example below returns a grayed-out version of the default editor icon:

  
 Image titleImage = super.getReadonlyTitleImage();
 if (titleImage != null)
  {
   Image tempImage = titleImage;
   titleImage = new Image(titleImage.getDevice(), titleImage, SWT.IMAGE_DISABLE); 
   tempImage.dispose();
  }
 return titleImage;
 


setDocumentProvider

protected void setDocumentProvider(IEditorInput input)
Hook method for setting the document provider for the given input. Called while updating the document provider for the new editor input. This default implementation does nothing. Clients may reimplement: this is the method in which you can configure the appropriate implicit document provider for the given editor input.

Parameters:
input - the input of this editor

doSetInput

protected void doSetInput(IEditorInput input)
                   throws CoreException
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.

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)

setInputWithNotify

protected final void setInputWithNotify(IEditorInput input)
Sets the input to this editor and fires a PROP_INPUT property change if the input has changed. Note that firing a property change may cause other objects to reach back and invoke methods on the editor. Care should be taken not to call this method until the editor has fully updated its internal state to reflect the new input.

See Also:
EditorPart

setInput

public final void setInput(IEditorInput input)
Sets the input to this editor. Overrides EditorPart's, but doSetInput() - called from setInputWithNotify() - will eventually call EditorPart's setInput() as well.

See Also:
EditorPart

setPreferenceStore

protected void setPreferenceStore(IPreferenceStore store)
Sets this editor's preference store. This method must be called before the editor's control is created. Note that LPEX's own default settings are stored in its own defaultProfile, not in the preference store.

Parameters:
store - the preference store, or null to remove the preference store

close

public void close(boolean save)
Closes this text editor, after optionally saving changes.

Parameters:
save - true if unsaved changed should be saved, or false if unsaved changed should be discarded
See Also:
ITextEditor

dispose

public void dispose()
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.

See Also:
IWorkbenchPart

disposeDocumentProvider

protected void disposeDocumentProvider()
Disposes of the connection with the document provider. Subclasses may extend.


doSave

public void doSave(IProgressMonitor progressMonitor)
Saves the contents of the target. If the save is successful, the editor fires a property-changed event, reflecting the new dirty state.

The implementation of this IEditorPart method may be extended by subclasses.

Parameters:
progressMonitor - the progress monitor for communicating result state, or null
See Also:
IEditorPart

enableSanityChecking

protected void enableSanityChecking(boolean enable)
Enables/disables sanity checking.

Parameters:
enable - true if sanity checking should be enabled, or false otherwise

safelySanityCheckState

protected void safelySanityCheckState(IEditorInput input)
Checks the state of the given editor input if sanity checking is enabled.

Parameters:
input - the editor input whose state is to be checked

sanityCheckState

protected void sanityCheckState(IEditorInput input)
Checks the state of the given editor input.

Parameters:
input - the editor input whose state is to be checked

enableStateValidation

protected void enableStateValidation(boolean enable)
Enables/disables state validation.

Parameters:
enable - true if state validation should be enabled, or false otherwise

validateState

protected void validateState(IEditorInput input)
Validates the state of the given editor input. The predominant intent of this method is to take any action probably necessary to ensure that the input can be persistently changed.

Parameters:
input - the input to be validated

validateEditorInputState

public boolean validateEditorInputState()
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.

Returns:
true if the input was validated, false otherwise
See Also:
ITextEditorExtension2

updateState

protected void updateState(IEditorInput input)
Updates the state of the given editor input, such as the readonly flag.

Parameters:
input - the input to be validated

performSave

protected void performSave(boolean overwrite,
                           IProgressMonitor progressMonitor)
Performs the save and handles errors appropriately.

Parameters:
overwrite - indicates whether or not overwriting is allowed
progressMonitor - the monitor in which to run the operation

handleExceptionOnSave

protected void handleExceptionOnSave(CoreException exception,
                                     IProgressMonitor progressMonitor)
Handles the given save exception. If the exception reports an out-of-sync situation, this is reported to the user. Otherwise, the exception is generically reported.

Parameters:
exception - the exception to handle
progressMonitor - the progress monitor

openSaveErrorDialog

protected void openSaveErrorDialog(String title,
                                   String message,
                                   CoreException exception)
Presents an error dialog to the user when a problem happens during save. Subclasses may override the given title and message.

Parameters:
title - the dialog title
message - the message to display
exception - the exception to handle

doSaveAs

public void doSaveAs()
Saves the contents of the target to another object. If the save is successful, the editor should fire a property-changed event, reflecting the new dirty state and input object.

The LpexAbstractTextEditor implementation of this IEditorPart method calls performSaveAs().

See Also:
IEditorPart

performSaveAs

protected void performSaveAs(IProgressMonitor progressMonitor)
Performs a "Save as", and reports the result state back to the given progress monitor. This default implementation does nothing. Subclasses may reimplement.

Parameters:
progressMonitor - the progress monitor for communicating result state, or null
See Also:
performSaveAs(IProgressMonitor,String)

performSaveAs

protected void performSaveAs(IProgressMonitor progressMonitor,
                             String fileName)
Performs a "Save as", and reports the result state back to the given progress monitor. This default implementation does nothing. Subclasses may reimplement.

Parameters:
fileName - name of the file to save to (initial file for the Save As dialog)
progressMonitor - the progress monitor for communicating result state, or null
See Also:
performSaveAs(IProgressMonitor)

isSaveAsAllowed

public boolean isSaveAsAllowed()
Returns true if the "Save as" operation is supported by the target. Overrides EditorPart's. The implementation of this IEditorPart method returns false. Subclasses may override.

Returns:
false
See Also:
IEditorPart

isDirty

public boolean isDirty()
Returns whether the contents of this editor have changed since the last save operation. If this value changes, the part must fire a property listener event with PROP_DIRTY.

What's returned by this method determines both the display, in the viewer label, of the dirty indication '*' which follows the file name, and the enablement of the Save menu items (which are only enabled on modified documents in Eclipse).

See Also:
EditorPart

doRevertToSaved

public void doRevertToSaved()
Abandons all modifications applied to the editor's input element's textual presentation since the last save operation.

The implementation of this ITextEditor method may be extended by subclasses.

See Also:
ITextEditor

performRevert

protected void performRevert()
Performs revert and handles errors appropriately. Subclasses may extend.


handleElementContentReplaced

protected void handleElementContentReplaced()
Performs any additional action necessary after the input document's content has been replaced. Clients may extend this method.


setAction

public void setAction(String actionName,
                      IAction action)
Installs or removes the given user or global Eclipse action under the specified action name. The action is cached in here in a list of active actions, and is also registered with the key-binding service.

Parameters:
actionName - name of the action (e.g., "SelectAll")
action - the JFace IAction, or null to remove it
See Also:
ITextEditor

getAction

public IAction getAction(String actionName)
Returns the user or global Eclipse action which has been installed (i.e., cached in here) under the specified action name. If no action under this name has been installed, or contributed via plugin.xml (extension point "org.eclipse.ui.editorActions") null is returned.

Parameters:
actionName - action name, e.g., "cut"
See Also:
ITextEditor

markAsPropertyDependentAction

public void markAsPropertyDependentAction(String actionId,
                                          boolean mark)
Marks or unmarks the given action to be updated on property changes.

Parameters:
actionId - the action id
mark - true if the action is property dependent

updatePropertyDependentActions

protected void updatePropertyDependentActions()
Updates all property dependent actions.


createNavigationActions

protected void createNavigationActions()
Creates action entries for those LPEX actions that correspond to Eclipse's actions being mapped to its SWT StyledText actions in AbstractTextEditor. Used in the key-binding service to reroute the Eclipse-defined actions to LPEX's.

Subclasses may extend.


createActions

protected void createActions()
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.


addAction

protected final void addAction(IMenuManager menu,
                               String actionName)
Convenience method to add the action installed under the given action name to the given menu.

Parameters:
menu - menu to add the action
actionName - name of the action (e.g., "cut")

addAction

protected final void addAction(IMenuManager menu,
                               String group,
                               String actionName)
Convenience method to add the action installed under the given action name to the specified group of the given menu.

Parameters:
menu - the menu to add the action to
group - the group in the menu
actionName - the name of the action to add

addGroup

protected final void addGroup(IMenuManager menu,
                              String existingGroup,
                              String newGroup)
Convenience method to add a new menu group after the specified group.

Parameters:
menu - the menu to add the new group to
existingGroup - the group after which to insert the new group
newGroup - the new group

rulerContextMenuAboutToShow

protected void rulerContextMenuAboutToShow(IMenuManager menu)
Sets up the vertical ruler's context (pop-up) menu before it is made visible.

Subclasses may extend to add other actions.

Parameters:
menu - the menu

editorContextMenuAboutToShow

protected void editorContextMenuAboutToShow(IMenuManager menu)
Sets up the pop-up (context) menu of this editor's active view before it is made visible. The implementation of this method in LpexAbstractTextEditor contributes LPEX's actions defined by the current.popup parameter, and adds a "Save" action as per Eclipse norms.

Subclasses may extend to add other actions. LPEX document parsers normally use LpexCommonParser.getPopupItems(int) to update the popup editor parameter itself.

The LPEX "Source" submenu is assigned an id of MSG_POPUP_SOURCEMENU. The example below adds a separator and an action to the end of the "Source" submenu:

  
  super.editorContextMenuAboutToShow(menu);
  IMenuManager m = menu.findMenuUsingPath(LpexConstants.MSG_POPUP_SOURCEMENU); 
  m.add(new Separator());
  addAction(m, "myAction");
 

Parameters:
menu - the menu
See Also:
getLpexView()

getStatusLineManager

protected IStatusLineManager getStatusLineManager()
Returns the status line manager of this editor.

Returns:
the status line manager of this editor

getAdapter

public Object getAdapter(Class required)
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.

See Also:
IAdaptable

setFocus

public void setFocus()
Ask the part to take focus within the workbench. Gives keyboard input focus to the last-focused widget in the last-focused LpexWindow.

See Also:
IWorkbenchPart

setHelpContextId

protected void setHelpContextId(String helpContextId)
Sets the editor's edit-area help context id.

Parameters:
helpContextId - the help context id
See Also:
setLanguageHelp(com.ibm.lpex.alef.LpexLanguageHelp)

getHelpContextId

protected final String getHelpContextId()
Returns the editor's edit-area help context id.

Returns:
the editor's help context id, or null if none has been set

setLanguageHelp

protected void setLanguageHelp(LpexLanguageHelp lsh)
Set the provider for this editor's LPEX document parser language-sensitive help (LSH). When LSH is registered, a help request in the edit area will display the language-sensitive help, rather than the editor context help.

See Also:
setHelpContextId(java.lang.String)

setKeyBindingScopes

protected void setKeyBindingScopes(String[] scopes)
Do not use this method. It is provided solely for compatibility with Eclipse's AbstractTextEditor. Use setKeyBindingScopes(LpexView,String[]) instead.

Sets the key-binding scopes for the focus, or otherwise primary view of this editor.

See Also:
setKeyBindingScopes(LpexView,String[])

setKeyBindingScopes

protected void setKeyBindingScopes(LpexView lpexView,
                                   String[] scopes)
Sets the key-binding scopes for a view of this editor.

Each time the updateProfile command is run in a document view of this editor, and before the updateProfile(LpexView) user hook is invoked, this method is called to set the LPEX key-binding scope for the LPEX editor profile in effect in that particular view. The scope set is one of:

See also eclipse/plugins/com.ibm.lpex_n.n.n/plugin.xml.

The user may modify this key-binding scope, for example

In either case, it is assumed that any new scope(s) being set extend or augment the LPEX scope set in here: editor actions are always registered with the Eclipse key-binding service for all the 'commands' that are defined in the LPEX scope that corresponds to the LPEX editor profile in effect (see also the updateProfile.baseProfile editor parameter).

Here's an example of adding a solution editor's own key-binding scope, in addition to the LPEX's scopes:

  
  protected void.setKeyBindingScopes(LpexView lpexView, String[] scopes) 
  {
   String[] solutionEditorScopes = new String[scopes.length + 1];
   // 1.- first LPEX's own scope(s)
   int i = 0;
   while (i < scopes.length)
    {
     solutionEditorScopes[i] = scopes[i];
    }
   // 2.- add solution editor's
   solutionEditorScopes[i] = "com.myCompany.mySolutionEditor.myScope";
   // set all scopes in the editor
   super.setKeyBindingScopes(lpexView, solutionEditorScopes);
  }
 

Parameters:
lpexView - a document view of this editor
scopes - an array of key-binding scope identifier(s) to set for this view
See Also:
getKeyBindingScopes(LpexView)

getKeyBindingScopes

protected String[] getKeyBindingScopes(LpexView lpexView)
Returns the key-binding scopes set for a view of this editor.

Returns:
the key-binding scopes set for the specified editor view, or
null if none set yet, or if the given lpexView is null
See Also:
setKeyBindingScopes(LpexView,String[])

getProgressMonitor

protected IProgressMonitor getProgressMonitor()
Returns the progress monitor related to this editor. It should not be necessary to extend this method.

Returns:
the progress monitor related to this editor

handleEditorInputChanged

protected void handleEditorInputChanged()
Handles an external change of the editor's input element. Subclasses may extend.


showsHighlightRangeOnly

public boolean showsHighlightRangeOnly()
Query whether the editor is configured to show the highlight range only, or all of the input element's textual representation.

See Also:
ITextEditor

showHighlightRangeOnly

public void showHighlightRangeOnly(boolean showHighlightRangeOnly)
Configure the editor to show, or not show, the highlight range exclusively.

See Also:
ITextEditor

setHighlightRange

public void setHighlightRange(int offset,
                              int len,
                              boolean moveCursor)
Sets the highlight range to the specified region. Called, for example, from the outline view, when the selection changes.

Parameters:
offset - the offset of the highlighted range
len - the length of the highlighted range
moveCursor - true move the cursor to the start of the highlighted range, or false leave the cursor as is
See Also:
ITextEditor

getHighlightRange

public IRegion getHighlightRange()
Returns the highlighted range of this text editor.

See Also:
ITextEditor

setActionActivationCode

public void setActionActivationCode(String actionName,
                                    char activationCharacter,
                                    int activationKeyCode,
                                    int activationStateMask)
The preferred method is to define and use LPEX actions, and associate them with keys using the set keyAction LPEX command.

Sets the given activation code for the specified Eclipse action. If there is an activation code already registered, it is replaced.

The activation code consists of the same information as a KeyEvent. If the activation code is triggered and the associated action is enabled, the action is performed and the triggering KeyEvent is considered consumed. If the action is disabled, the KeyEvent is passed on to the text widget unmodified. Thus, action activation codes and action accelerators differ in their model of event consumption.

The key code parameter can be -1 to indicate a wild card. The state mask parameter can be SWT.DEFAULT to indicate a wild card.

Parameters:
actionName - Eclipse action name
activationCharacter - the activation code character
activationKeyCode - the activation code key code, or -1 for wild card
activationStateMask - the activation code state mask, or SWT.DEFAULT for wild card
See Also:
ITextEditor

removeActionActivationCode

public void removeActionActivationCode(String actionName)
The preferred method is to define and use LPEX actions, and associate them with keys using the set keyAction LPEX command.

Removes any installed activation code for the specified action. If no activation code is installed, this method does not have any effect.

Parameters:
actionName - action name
See Also:
ITextEditor

resetHighlightRange

public void resetHighlightRange()
Resets the highlight range.

See Also:
ITextEditor

adjustHighlightRange

protected void adjustHighlightRange(int offset,
                                    int len)
Adjusts the highlight range so that at least the specified range is highlighted. Subclasses may re-implement this method.

Parameters:
offset - the offset of the range which at least should be highlighted
len - the length of the range which at least should be highlighted

selectAndReveal

public void selectAndReveal(int start,
                            int len)
Selects and reveals the specified range in this text editor.

Parameters:
start - the offset of the selection
len - the length of the selection
See Also:
ITextEditor

selectAndReveal

protected void selectAndReveal(int selectionStart,
                               int selectionLength,
                               int revealStart,
                               int revealLength)
Selects and reveals the specified ranges in this text editor.

Parameters:
selectionStart - the offset of the selection
selectionLength - the length of the selection
revealStart - the offset of the revealed range
revealLength - the length of the revealed range
Since:
4.2

createEmptyNavigationLocation

public INavigationLocation createEmptyNavigationLocation()
Creates an empty navigation location. The message restoreState will be sent to the location to restore its state.

See Also:
INavigationLocationProvider

createNavigationLocation

public INavigationLocation createNavigationLocation()
Creates a navigation location describing the current state.

See Also:
INavigationLocationProvider

markInNavigationHistory

protected void markInNavigationHistory()
Writes a check mark of the given situation into the navigation history.


editorSaved

protected void editorSaved()
Hook which gets called when the editor has been saved. Subclasses may extend.


firePropertyChange

protected void firePropertyChange(int property)
Fire a property-changed event.

Parameters:
property - the id of the property that changed
See Also:
WorkbenchPart

setStatusField

public void setStatusField(IStatusField field,
                           String category)
Informs the editor which status field is to be used when posting status information in the given category.

Parameters:
field - the status field to be used, or null to remove a previous setting
category - the status information category
See Also:
ITextEditorExtension

getStatusField

protected IStatusField getStatusField(String category)
Returns the current status field for the given status category.

Parameters:
category - the status category
Returns:
the current status field for the given status category

handleCursorPositionChanged

protected void handleCursorPositionChanged()
Since:
4.2

updateStatusField

protected void updateStatusField(String category)
Updates the Eclipse status field for the given category.

Parameters:
category - the status category

updateStatusFields

protected void updateStatusFields()
Updates all status fields. Called by LpexStatusTextEditor#updatePartControl().


getCursorPosition

protected String getCursorPosition()
Returns a description of the cursor position suitable for display in the Eclipse status field. The information returned is based on the latest status line information notifications received from LPEX. Note that status line notifications are not being received when the LPEX status line is on.

Returns:
a description of the cursor position

isEditable

public boolean isEditable()
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.

Returns:
true if it can be edited, or false if it is read only
See Also:
ITextEditor

isEditorInputReadOnly

public boolean isEditorInputReadOnly()
Returns whether the editor's input is read-only. This method is orthogonal to isEditable(), as it talks about the editor input, i.e., the domain element, and not about the editor document.

Returns:
true if the editor input is read-only
See Also:
ITextEditorExtension

isEditorInputModifiable

public boolean isEditorInputModifiable()
Returns whether the editor's input can be persistently modified. This method is orthogonal to isEditorInputReadOnly(), as read-only elements may be modifiable, and writable elements may not be modifiable. If the given element is not connected to this document provider, the result is undefined. Document providers are allowed to use a cache to answer this question, i.e., there can be a difference between the "real" state of the element and the return value.

Returns:
true if the editor input is modifiable
See Also:
ITextEditorExtension2

addRulerContextMenuListener

public void addRulerContextMenuListener(IMenuListener listener)
Adds a ruler context-menu listener to the editor.

See Also:
ITextEditorExtension

removeRulerContextMenuListener

public void removeRulerContextMenuListener(IMenuListener listener)
Removes a ruler context-menu listener from the editor.

See Also:
ITextEditorExtension

canHandleMove

protected boolean canHandleMove(IEditorInput originalElement,
                                IEditorInput movedElement)
Returns whether this editor can handle the move of the original element so that it ends up being the moved element. By default this method returns true. Subclasses may reimplement.

Parameters:
originalElement - the original element
movedElement - the moved element
Returns:
whether this editor can handle the move of the original element so that it ends up being the moved element

widgetOffset2ModelOffset

protected static final int widgetOffset2ModelOffset(ISourceViewer viewer,
                                                    int widgetOffset)
Returns the offset of the given source viewer's document that corresponds to the given widget offset. Returns -1 if there is no such offset.

Parameters:
viewer - the source viewer
widgetOffset - the widget offset
Returns:
the corresponding offset in the source viewer's document or -1

modelOffset2WidgetOffset

protected static final int modelOffset2WidgetOffset(ISourceViewer viewer,
                                                    int modelOffset)
Returns the offset of the given source viewer's text widget that corresponds to the given model offset. Returns -1 if there is no such offset.

Parameters:
viewer - the source viewer
modelOffset - the model offset
Returns:
the corresponding offset in the source viewer's text widget or -1

getCoverage

protected static final IRegion getCoverage(ISourceViewer viewer)
Returns the minimal region of the given source viewer's document that completely comprises everything that is visible in the viewer's widget.

Parameters:
viewer - the viewer go return the coverage for
Returns:
the minimal region of the source viewer's document comprising the contents of the viewer's widget

isVisible

protected static final boolean isVisible(ISourceViewer viewer,
                                         int offset,
                                         int len)
Returns whether the given region is visible in the given source viewer.

Parameters:
viewer - the source viewer
offset - the offset of the region
len - the length of the region
Returns:
true if visible

showChangeInformation

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

See Also:
ITextEditorExtension3

isChangeInformationShowing

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

See Also:
ITextEditorExtension3

setStatusLineErrorMessage

protected void setStatusLineErrorMessage(String message)
Sets the given message as error message to this editor's status line.

Parameters:
message - message to be set

setStatusLineMessage

protected void setStatusLineMessage(String message)
Sets the given message as message to this editor's status line.

Parameters:
message - message to be set

gotoAnnotation

public Annotation gotoAnnotation(boolean forward)
Jumps to the next annotation according to the given direction.

Parameters:
forward - true if search direction is forward, false if backward
Returns:
the selected annotation or null if none
See Also:
isNavigationTarget(Annotation), findAnnotation(int, int, boolean, Position)

findAnnotation

protected Annotation findAnnotation(int offset,
                                    int length,
                                    boolean forward,
                                    Position annotationPosition)
Returns the annotation closest to the given range respecting the given direction. If an annotation is found, the annotation's current position is copied into the provided annotationPosition.

Parameters:
offset - the region offset
length - the region length
forward - true for forwards, false for backward
annotationPosition - the position of the found annotation
Returns:
the found annotation

isNavigationTarget

protected boolean isNavigationTarget(Annotation annotation)
Returns whether the given annotation is configured as a target for the "Go to Next/Previous Annotation" actions.

Parameters:
annotation - the annotation
Returns:
true if this is a target, false otherwise

showRevisionInformation

public void showRevisionInformation(RevisionInformation info,
                                    String quickDiffProviderId)

getSaveables

public Saveable[] getSaveables()

getActiveSaveables

public Saveable[] getActiveSaveables()

getOrientation

public int getOrientation()
Returns the orientation of this workbench part. LPEX editors are always left-to-right.

See Also:
WorkbenchPart

getLpexView

public LpexView getLpexView()
Convenience method to retrieve the focus document view of the underlying LPEX text widget, or otherwise the primary view.

Returns:
null if the text widget was not yet created, or was disposed

getFirstLpexView

public LpexView getFirstLpexView()
Convenience method to retrieve the primary document view of the underlying LPEX text widget.

Returns:
null if the text widget was not yet created, or was disposed

getActiveLpexView

public LpexView getActiveLpexView()
Convenience method to retrieve the active document view of the underlying LPEX text widget. The active view is that which has the input focus, or otherwise had it lately and will be given the input focus when the LPEX text widget regains focus.

Returns:
null if the text widget was not yet created, or was disposed

getLpexWindow

public LpexWindow getLpexWindow()
Convenience method to retrieve the focus window of the underlying LPEX text widget, or otherwise the primary window.

Returns:
null if the text widget was not yet created, or was disposed

getFirstLpexWindow

public LpexWindow getFirstLpexWindow()
Convenience method to retrieve the primary window of the underlying LPEX text widget.

Returns:
null if the text widget was not yet created, or was disposed

getActiveLpexWindow

public LpexWindow getActiveLpexWindow()
Convenience method to retrieve the active window of the underlying LPEX text widget. The active window is that which has the input focus, or otherwise had it lately and will be given the input focus when the LPEX text widget regains focus.

Returns:
null if the text widget was not yet created, or was disposed

initializeLpexView

public void initializeLpexView(LpexView lpexView)
Hook to initialize a newly instantiated primary or secondary LpexView used by this text editor's LpexSourceViewer. Extend this method to set any file- and view-specific parameters for this LpexView.

Here, for example, you may set for a primary view any "File Open" preference-page settings for your solution's plug-in, such as sequenceNumbers, sourceEncoding, save.textLimit, save.trim, and other document-scope settings.

The updateProfile command will be run later.

Parameters:
lpexView - the primary or secondary view being initialized
See Also:
widgetContentsSet(LpexView), updateProfile(LpexView)

updateProfile

public void updateProfile(LpexView lpexView)
Extend this method for post-updateProfile command processing. For example, define your own LPEX actions and assign them to keys, define your own LPEX commands, set style attributes for LPEX style characters you use, etc. Here, you may also call setLanguageHelp(com.ibm.lpex.alef.LpexLanguageHelp) when the language-documentation plug-in for the LPEX document parser running in this editor's text viewer is available.

Called when a new LpexSourceViewer is created (an LPEX document has been opened, and is, at this point, already loaded in the editor), a secondary view is created on the document, and whenever the updateProfile command is issued afterwards. A document parser has been instantiated for this view and called to initialize.

Parameters:
lpexView - the primary or secondary document view whose profile is being updated
See Also:
initializeLpexView(com.ibm.lpex.core.LpexView), widgetContentsSet(com.ibm.lpex.core.LpexView), handleDelegate(com.ibm.lpex.core.LpexView)

widgetContentsSet

protected void widgetContentsSet(LpexView lpexView)
Hook called once the LPEX text widget contents have been (re-)set from the Eclipse IDocument. When the LpexSourceViewer is first created for this editor, this notification is sent some time after the initializeLpexView() user hook. This notification is eventually followed by an updateProfile(LpexView).

Parameters:
lpexView - the primary view of the document
See Also:
initializeLpexView(LpexView), updateProfile(LpexView)

availableOpenNewView

protected boolean availableOpenNewView(LpexView lpexView)
Returns the availability of the openNewView action defined in here. This also determines the enable state of the View > Open new view context menu item in the specified document view.

The implementation of this method in LpexAbstractTextEditor returns true unless current.splitWindow is on and the maximum number of split windows has been reached. Subclasses may extend.

Parameters:
lpexView - the document view for which the action availability is queried

performLpexCommand

protected boolean performLpexCommand(LpexView lpexView)
Opens the "Lpex" sample editor in package com.ibm.lpex.samples for a new view on the document.

This method is called by the openNewView action and command when window splitting is disabled (the current.splitWindow parameter is off).

Subclasses may override if this functionality is not desirable.

Parameters:
lpexView - the document view from which the request was issued
Returns:
true

handleDelegate

protected void handleDelegate(LpexView lpexView)
Redirect Lpex actions and commands to run in this plug-in's context. This method handles the redirection of actions and commands in com.ibm.samples.Lpex views of this editor's document. Additional Lpex views of this text editor's document may be opened with the openNewView action and command.

Actions redefined in here: help, rename, save, saveAs, get. Commands redefined in here: help, load, save. Extend this method to redefine additional actions and commands of an Lpex document view, for examples those actions and commands your application already redefines in updateProfile().

Parameters:
lpexView - the Lpex document view whose actions and commands are delegated to us
See Also:
updateProfile(LpexView)

setDocumentSection

protected boolean setDocumentSection(int linesBeforeStart,
                                     int linesAfterEnd)
Establish the boundaries of the LPEX document section that was loaded or is going to be loaded in the text widget, and initiate the management of this document section.

Note that this feature is only made available for certain specific text editor applications. Normally, the LPEX text widget loads and operates on a complete document (underlying resource).

This method requires the LPEX text widget to have been already created. Initially, it must be called after calling super.createSourceViewer(), if the method createSourceViewer() is extended, or otherwise at any time after createPartControl(). Afterwards, this method may be called following document-section updates triggered by addLines() notifications.

A call to this method may fail under certain circumstances. For example, you cannot use the document section feature when several views have been opened on the same document. In such a case false will be returned.

Returns:
false if unsuccessful
See Also:
addLines(com.ibm.lpex.core.LpexView, int)

addLines

protected boolean addLines(LpexView lpexView,
                           int lineNeeded)
Hook for managing an LPEX text-widget document section.

This method is invoked when it was determined that the currently-loaded LPEX text-widget document section should be expanded. A minimum of about two screen rows of lines is expected to be loaded around the current (cursor) line at any time.

The current implementation of this method does nothing beyond returning false. The DocumentAdapter of this editor's text viewer is currently suspended from listening to both the Eclipse document and the LPEX document when calling this hook.

Parameters:
lpexView - the LPEX text-widget view
lineNeeded - the first line before the currently-loaded LPEX document section, or the last line after the currently-loaded LPEX document section, in the range of lines with which the current document section must be expanded; lineNeeded already includes the minimum threshold indicated
Returns:
true = try to restore the original position in the view (this is recommended when e.g., the document section was updated by replacing the entire contents of the text widget)
See Also:
setDocumentSection(int, int)

getInputResource

protected IResource getInputResource()
Returns the IResource underlying our editor input (file / storage). It is used to retrieve the IProject for save-as operations.


createViewPreferenceNodes

protected void createViewPreferenceNodes(LpexSourceViewer lpexSourceViewer)
Hook to allow the solution plug-in create custom preference node(s) for view-scoped preference page(s) for this editor's source viewer.

A custom preference node is a subclass of LpexViewPreferenceNode. Custom nodes are added after the LPEX built-in view-scoped preference nodes, in the order in which they are created.

See Also:
LpexViewPreferenceNode, LpexSourceViewer.createViewPreferenceNodes(com.ibm.lpex.alef.LpexSourceViewer)

createViewPreferencePage

protected IPreferencePage createViewPreferencePage(LpexView lpexView,
                                                   int nodeType)
Factory method to create a view-scoped preference page to be used by this editor's source viewer.

Extend this method to create customized preference page(s) for the view-scoped preference node(s). The default implementation returns null, letting the source viewer create its own default view preference pages for the LPEX built-in node types.

Parameters:
nodeType - preference node type, one of
LpexViewPreferenceNode.VIEW_BASE_PREFERENCE_NODE, LpexViewPreferenceNode.VIEW_PARSER_PREFERENCE_NODE, LpexViewPreferenceNode.VIEW_SEQUENCE_NUMBERS_PREFERENCE_NODE, LpexViewPreferenceNode.VIEW_SOURCE_ENCODING_PREFERENCE_NODE
See Also:
LpexSourceViewer.createViewPreferencePage(com.ibm.lpex.core.LpexView, int)

LPEX
4.4.0

Copyright � 2016 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.