com.ibm.lpex.alef
Class LpexAbstractTextEditor

java.lang.Object
  |
  +--org.eclipse.ui.part.WorkbenchPart
        |
        +--org.eclipse.ui.part.EditorPart
              |
              +--com.ibm.lpex.alef.LpexAbstractTextEditor
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, org.eclipse.ui.IEditorPart, org.eclipse.core.runtime.IExecutableExtension, org.eclipse.ui.texteditor.ITextEditor, org.eclipse.ui.IWorkbenchPart
Direct Known Subclasses:
LpexTextEditor

public abstract class LpexAbstractTextEditor
extends org.eclipse.ui.part.EditorPart
implements org.eclipse.ui.texteditor.ITextEditor

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.

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.

See Also:
LpexTextEditor, getLpexView(), getLpexWindow()

Field Summary
static java.lang.String DEFAULT_EDITOR_CONTEXT_MENU_ID
          Menu id for the editor context menu.
static java.lang.String DEFAULT_RULER_CONTEXT_MENU_ID
          Menu id for the ruler context menu.
protected static int VERTICAL_RULER_WIDTH
          The width of the vertical ruler.
 
Fields inherited from interface org.eclipse.ui.IEditorPart
PROP_DIRTY, PROP_INPUT
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Constructor Summary
protected LpexAbstractTextEditor()
          Create a new text editor.
 
Method Summary
protected  void addAction(org.eclipse.jface.action.IMenuManager menu, java.lang.String actionName)
          Convenience method to add the action installed under the given action name to the given menu.
protected  void addAction(org.eclipse.jface.action.IMenuManager menu, java.lang.String group, java.lang.String actionId)
          Convenience method to add the action installed under the given action id to the specified group of the menu.
protected  void addGroup(org.eclipse.jface.action.IMenuManager menu, java.lang.String existingGroup, java.lang.String newGroup)
          Convenience method to add a new group after the specified group.
protected  boolean addLines(LpexView lpexView, int neededLine)
          Hook for managing an LPEX text-widget document section.
 void addMark(org.eclipse.core.resources.IMarker marker)
          Create an LPEX mark corresponding to the given Eclipse marker.
protected  void adjustHighlightRange(int offset, int len)
          Adjust the highlight range so that at least the specified range is highlighted.
 void close(boolean save)
          Close this text editor, after optionally saving changes.
protected  void createActions()
          Create this editor's standard actions.
 void createPartControl(org.eclipse.swt.widgets.Composite parent)
          The LpexAbstractTextEditor implementation of this IWorkbenchPart method creates the vertical ruler and source viewer.
protected  org.eclipse.ui.actions.WorkspaceModifyOperation createSaveOperation(boolean overwrite)
          Create a workspace-modify operation which saves the content of the editor to the editor's input element.
protected  org.eclipse.jface.text.source.ISourceViewer createSourceViewer(org.eclipse.swt.widgets.Composite parent, org.eclipse.jface.text.source.IVerticalRuler ruler, int styles)
          Create the source viewer (an LpexSourceViewer) to be used by this editor.
protected  org.eclipse.jface.text.source.IVerticalRuler createVerticalRuler()
          Create the vertical ruler (an LpexVerticalRuler) to be used by this editor.
 void dispose()
          Dispose this part and discard all part state.
 void doRevertToSaved()
          Abandon all modifications applied to the editor's input element's textual presentation since the last save operation.
 void doSave(org.eclipse.core.runtime.IProgressMonitor progressMonitor)
          Save the contents of the target.
 void doSaveAs()
          Save the contents of the target to another object.
protected  void doSetInput(org.eclipse.ui.IEditorInput input)
          Internal processing of setting/changing the input to this editor.
protected  void editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager menu)
          Set up this editor's context (popup) menu before it is made visible.
protected  void firePropertyChange(int property)
          Fire a property-changed event.
 org.eclipse.jface.action.IAction getAction(java.lang.String actionName)
          Return the action which has been installed (i.e., cached in here) under the specified action name (id).
 java.lang.Object getAdapter(java.lang.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  org.eclipse.jface.action.IMenuListener getContextMenuListener()
          Create and return the listener on this editor's context menus.
 org.eclipse.ui.texteditor.IDocumentProvider getDocumentProvider()
          Return this text editor's document provider.
protected  java.lang.String getEditorContextMenuId()
          Return the editor's context menu id.
 java.lang.String getEOL()
          Return the line delimiter used by the document currently handled by this text editor.
protected  java.lang.String getHelpContextId()
          Return the editor's help context id.
 org.eclipse.jface.text.IRegion getHighlightRange()
          Return the highlighted range of this text editor.
 LpexView getLpexView()
          Convenience method to retrieve the underlying LPEX text-widget view on the document.
 LpexWindow getLpexWindow()
          Convenience method to retrieve the underlying LPEX text-widget window (an SWT Composite).
protected  org.eclipse.jface.preference.IPreferenceStore getPreferenceStore()
          Return this editor's preference store.
protected  org.eclipse.jface.text.source.Annotation getRangeIndicator()
          Return this editor's range indicator.
protected  java.lang.String getRulerContextMenuId()
          Return the ruler's context menu id.
protected  org.eclipse.swt.events.MouseListener getRulerMouseListener()
          Create and return the listener on this editor's vertical ruler.
 org.eclipse.jface.viewers.ISelectionProvider getSelectionProvider()
          Return the editor's selection provider.
protected  org.eclipse.jface.text.source.ISourceViewer getSourceViewer()
          Return the editor's source viewer.
protected  org.eclipse.jface.text.source.SourceViewerConfiguration getSourceViewerConfiguration()
          Return the editor's source viewer configuration.
 org.eclipse.jface.text.source.IVerticalRuler getVerticalRuler()
          Return the editor's vertical ruler.
 void gotoMarker(org.eclipse.core.resources.IMarker marker)
          Set the cursor in the editor to the specified marker, and emphasize accordingly.
protected  void handleEditorInputChanged()
          Handle an external change of the editor's input element.
protected  void handleExceptionOnSave(org.eclipse.core.runtime.CoreException exception, org.eclipse.core.runtime.IProgressMonitor progressMonitor)
          Handle the given save exception.
protected  void handlePreferenceStoreChanged(org.eclipse.jface.util.PropertyChangeEvent event)
          Handle a property-change event describing a change of the editor's preference store.
 void init(org.eclipse.ui.IEditorSite site, org.eclipse.ui.IEditorInput input)
          Initialize this editor with the given editor site and input.
 void initializeLpexView(LpexView lpexView)
          Hook to initialize a newly instantiated LpexView during the construction of this text editor's SourceViewer.
 boolean isDirty()
           
 boolean isEditable()
          Return whether the text in this text editor can be changed by the user.
 boolean isSaveAsAllowed()
          Return true if the "Save as" operation is supported by the target.
 boolean isSaveOnCloseNeeded()
          Return whether the contents of this editor should be saved when the editor is closed.
protected  void performSaveAs(org.eclipse.core.runtime.IProgressMonitor progressMonitor)
          Perform a "Save as", and report the result state back to the given progress monitor.
protected  void performSaveOperation(org.eclipse.ui.actions.WorkspaceModifyOperation operation, org.eclipse.core.runtime.IProgressMonitor progressMonitor)
          Perform the given save operation and handle errors appropriately.
 void removeActionActivationCode(java.lang.String actionName)
          This method is not currently implemented in LpexAbstractTextEditor.
 void resetHighlightRange()
          Reset the highlight range.
protected  void rulerContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager menu)
          Set up the vertical ruler's context (popup) menu before it is made visible.
 void selectAndReveal(int start, int len)
          Select and reveal the specified range in this text editor.
 void setAction(java.lang.String actionName, org.eclipse.jface.action.IAction action)
          Install (i.e., cache in here) the given action under the specified action name (id).
 void setActionActivationCode(java.lang.String actionName, char activationCharacter, int activationKeyCode, int activationStateMask)
          This method is not currently implemented in LpexAbstractTextEditor.
protected  void setDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider provider)
          Set the editor's document provider.
protected  void 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(java.lang.String contextMenuId)
          Set this editor's context menu id.
 void setFocus()
          Ask the part to take focus within the workbench.
protected  void setHelpContextId(java.lang.String helpContextId)
          Set the editor's help context id.
 void setHighlightRange(int start, int len, boolean moveCursor)
          Set the highlight range to the specified region.
 void setInput(org.eclipse.ui.IEditorInput input)
          Set the input to this editor.
protected  void setPreferenceStore(org.eclipse.jface.preference.IPreferenceStore store)
          Set this editor's preference store.
protected  void setRangeIndicator(org.eclipse.jface.text.source.Annotation rangeIndicator)
          Set the annotation which this editor uses to represent the highlight range if the editor is configured to show the entire document.
protected  void setRulerContextMenuId(java.lang.String contextMenuId)
          Set the ruler's context menu id.
protected  void setSourceViewerConfiguration(org.eclipse.jface.text.source.SourceViewerConfiguration configuration)
          Set this editor's source viewer configuration used to configure its internal source viewer.
 void showHighlightRangeOnly(boolean showHighlightRangeOnly)
          Configure the editor to show / not show the highlight range only.
 boolean showsHighlightRangeOnly()
          Query whether the editor is configured to show the highlight range only, or all of the input element's textual representation.
 void updateMarkers()
          Bring the location of this editor's input resource markers back in sync with the location of LpexView's corresponding marks.
 void updateProfile()
          Extend this method for post-updateProfile command processing.
 
Methods inherited from class org.eclipse.ui.part.EditorPart
getEditorInput, getEditorSite, getTitleToolTip
 
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPropertyListener, getConfigurationElement, getDefaultImage, getSite, getTitle, getTitleImage, removePropertyListener, setInitializationData, setSite, setTitle, setTitleImage, setTitleToolTip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.ui.IEditorPart
getEditorInput, getEditorSite
 
Methods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener
 

Field Detail

DEFAULT_EDITOR_CONTEXT_MENU_ID

public static final java.lang.String DEFAULT_EDITOR_CONTEXT_MENU_ID
Menu id for the editor context menu.

DEFAULT_RULER_CONTEXT_MENU_ID

public static final java.lang.String DEFAULT_RULER_CONTEXT_MENU_ID
Menu id for the ruler context menu.

VERTICAL_RULER_WIDTH

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

LpexAbstractTextEditor

protected LpexAbstractTextEditor()
Create a new text editor. It initializes the editor and ruler context menu ids with the predefined names. If not explicitly set, this editor uses an LpexSourceViewerConfiguration to configure its source viewer. This viewer does not have a range indicator installed.
Method Detail

getDocumentProvider

public org.eclipse.ui.texteditor.IDocumentProvider getDocumentProvider()
Return this text editor's document provider.
Specified by:
getDocumentProvider in interface org.eclipse.ui.texteditor.ITextEditor
See Also:
ITextEditor.getDocumentProvider()

getPreferenceStore

protected final org.eclipse.jface.preference.IPreferenceStore getPreferenceStore()
Return 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

getRangeIndicator

protected final org.eclipse.jface.text.source.Annotation getRangeIndicator()
Return this editor's range indicator.

getSourceViewerConfiguration

protected final org.eclipse.jface.text.source.SourceViewerConfiguration getSourceViewerConfiguration()
Return the editor's source viewer configuration.

getSourceViewer

protected final org.eclipse.jface.text.source.ISourceViewer getSourceViewer()
Return the editor's source viewer.

getVerticalRuler

public final org.eclipse.jface.text.source.IVerticalRuler getVerticalRuler()
Return the editor's vertical ruler.

getEditorContextMenuId

protected final java.lang.String getEditorContextMenuId()
Return the editor's context menu id.

getHelpContextId

protected final java.lang.String getHelpContextId()
Return the editor's help context id.

getRulerContextMenuId

protected final java.lang.String getRulerContextMenuId()
Return the ruler's context menu id.

setDocumentProvider

protected void setDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider provider)
Set 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(org.eclipse.jface.text.source.SourceViewerConfiguration configuration)
Set 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(org.eclipse.jface.text.source.Annotation rangeIndicator)
Set 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 uses a DefaultRangeIndicator.
Parameters:
rangeIndicator - the annotation

setEditorContextMenuId

protected void setEditorContextMenuId(java.lang.String contextMenuId)
Set this editor's context menu id.
Parameters:
contextMenuId - the context menu id

setRulerContextMenuId

protected void setRulerContextMenuId(java.lang.String contextMenuId)
Set the ruler's context menu id.
Parameters:
contextMenuId - the context menu id

isEditable

public boolean isEditable()
Return whether the text in this text editor can be changed by the user. Preferred method: use the LPEX readonly parameter.
Specified by:
isEditable in interface org.eclipse.ui.texteditor.ITextEditor
See Also:
ITextEditor.isEditable()

getSelectionProvider

public org.eclipse.jface.viewers.ISelectionProvider getSelectionProvider()
Return the editor's selection provider.
Specified by:
getSelectionProvider in interface org.eclipse.ui.texteditor.ITextEditor

getContextMenuListener

protected final org.eclipse.jface.action.IMenuListener getContextMenuListener()
Create and return the listener on this editor's context menus.
Returns:
the menu listener

getRulerMouseListener

protected final org.eclipse.swt.events.MouseListener getRulerMouseListener()
Create and return the listener on this editor's vertical ruler.
Returns:
the mouse listener

handlePreferenceStoreChanged

protected void handlePreferenceStoreChanged(org.eclipse.jface.util.PropertyChangeEvent event)
Handle a property-change event describing a change of the editor's preference store.

The implementation of this method in LpexAbstractTextEditor does nothing. TextViewer updates any preference-related editor properties (namely, its font). LPEX's default settings are stored in its defaultProfile, not in a preference store.

Parameters:
event - the property change event

init

public void init(org.eclipse.ui.IEditorSite site,
                 org.eclipse.ui.IEditorInput input)
          throws org.eclipse.ui.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 automically at the end of the lifecycle. Clients must not call this method.
Specified by:
init in interface org.eclipse.ui.IEditorPart
Overrides:
init in class org.eclipse.ui.part.EditorPart
See Also:
IEditorPart.init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)

createVerticalRuler

protected org.eclipse.jface.text.source.IVerticalRuler createVerticalRuler()
Create the vertical ruler (an LpexVerticalRuler) to be used by this editor. Subclasses may reimplement this method.
Returns:
the vertical ruler

createSourceViewer

protected org.eclipse.jface.text.source.ISourceViewer createSourceViewer(org.eclipse.swt.widgets.Composite parent,
                                                                         org.eclipse.jface.text.source.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
Returns:
the source viewer

createPartControl

public void createPartControl(org.eclipse.swt.widgets.Composite parent)
The LpexAbstractTextEditor implementation of this IWorkbenchPart method creates the vertical ruler and source viewer. Subclasses may extend.

This is a multistep process:

  1. create one or more controls within the parent
  2. set the parent layout as needed
  3. hook focus on each of the controls - when focus is gained, notify all focus listeners
  4. register any global actions with the IActionService
  5. register any popup menus with the IActionService.

Specified by:
createPartControl in interface org.eclipse.ui.IWorkbenchPart
Overrides:
createPartControl in class org.eclipse.ui.part.WorkbenchPart
See Also:
IWorkbenchPart.createPartControl(org.eclipse.swt.widgets.Composite)

doSetInput

protected void doSetInput(org.eclipse.ui.IEditorInput input)
                   throws org.eclipse.core.runtime.CoreException
Internal processing of setting/changing the input to this editor. Called from init() (shortly after the part construction), from setInput(), and from handleEditorInputChanged().
Parameters:
input - the (new) input to be set; if null, this text editor is being closed
Throws:
org.eclipse.core.runtime.CoreException - if input cannot be connected to the document provider (is not understood by this part)

setInput

public final void setInput(org.eclipse.ui.IEditorInput input)
Set the input to this editor. Overrides EditorPart's, but doSetInput() - called in here - will eventually call EditorPart's setInput() as well.
Overrides:
setInput in class org.eclipse.ui.part.EditorPart
See Also:
EditorPart.setInput(org.eclipse.ui.IEditorInput)

setPreferenceStore

protected void setPreferenceStore(org.eclipse.jface.preference.IPreferenceStore store)
Set this editor's preference store. This method must be called before the editor's control is created. LPEX's default settings are stored in its defaultProfile, not in the preference store.
Parameters:
store - the new preference store

close

public void close(boolean save)
Close this text editor, after optionally saving changes.
Specified by:
close in interface org.eclipse.ui.texteditor.ITextEditor
Parameters:
save - true if unsaved changed should be saved, or false if unsaved changed should be discarded
See Also:
ITextEditor.close(boolean)

dispose

public void dispose()
Dispose this part and discard all part state. From this point on, the part will not be referenced within the workbench.

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.

Specified by:
dispose in interface org.eclipse.ui.IWorkbenchPart
Overrides:
dispose in class org.eclipse.ui.part.WorkbenchPart
See Also:
IWorkbenchPart.dispose()

doSave

public void doSave(org.eclipse.core.runtime.IProgressMonitor progressMonitor)
Save 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.

Specified by:
doSave in interface org.eclipse.ui.IEditorPart
Overrides:
doSave in class org.eclipse.ui.part.EditorPart
See Also:
IEditorPart.doSave(org.eclipse.core.runtime.IProgressMonitor)

createSaveOperation

protected org.eclipse.ui.actions.WorkspaceModifyOperation createSaveOperation(boolean overwrite)
Create a workspace-modify operation which saves the content of the editor to the editor's input element. Clients may reimplement this method.
Parameters:
overwrite - indicates whether the editor input element may be overwritten if necessary
Returns:
the save operation

performSaveOperation

protected void performSaveOperation(org.eclipse.ui.actions.WorkspaceModifyOperation operation,
                                    org.eclipse.core.runtime.IProgressMonitor progressMonitor)
Perform the given save operation and handle errors appropriately.
Parameters:
operation - the operation to be performed
progressMonitor - the monitor in which to run the operation

handleExceptionOnSave

protected void handleExceptionOnSave(org.eclipse.core.runtime.CoreException exception,
                                     org.eclipse.core.runtime.IProgressMonitor progressMonitor)
Handle 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

doSaveAs

public void doSaveAs()
Save 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 calls performSaveAs(null).

Specified by:
doSaveAs in interface org.eclipse.ui.IEditorPart
Overrides:
doSaveAs in class org.eclipse.ui.part.EditorPart
See Also:
IEditorPart.doSaveAs()

performSaveAs

protected void performSaveAs(org.eclipse.core.runtime.IProgressMonitor progressMonitor)
Perform a "Save as", and report 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

isSaveAsAllowed

public boolean isSaveAsAllowed()
Return 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.
Specified by:
isSaveAsAllowed in interface org.eclipse.ui.IEditorPart
Overrides:
isSaveAsAllowed in class org.eclipse.ui.part.EditorPart
See Also:
IEditorPart.isSaveAsAllowed()

isSaveOnCloseNeeded

public boolean isSaveOnCloseNeeded()
Return whether the contents of this editor should be saved when the editor is closed.
Specified by:
isSaveOnCloseNeeded in interface org.eclipse.ui.IEditorPart
Overrides:
isSaveOnCloseNeeded in class org.eclipse.ui.part.EditorPart
Returns:
true if the contents of the editor should be saved on close, or false if the contents are expendable
See Also:
IEditorPart.isSaveOnCloseNeeded()

isDirty

public boolean isDirty()
Specified by:
isDirty in interface org.eclipse.ui.IEditorPart
Overrides:
isDirty in class org.eclipse.ui.part.EditorPart

doRevertToSaved

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

Specified by:
doRevertToSaved in interface org.eclipse.ui.texteditor.ITextEditor
See Also:
ITextEditor.doRevertToSaved()

setAction

public void setAction(java.lang.String actionName,
                      org.eclipse.jface.action.IAction action)
Install (i.e., cache in here) the given action under the specified action name (id).
Specified by:
setAction in interface org.eclipse.ui.texteditor.ITextEditor
Parameters:
actionName - name of the action (e.g., "SelectAll")
action - the JFace IAction
See Also:
ITextEditor.setAction(java.lang.String, org.eclipse.jface.action.IAction)

getAction

public org.eclipse.jface.action.IAction getAction(java.lang.String actionName)
Return the action which has been installed (i.e., cached in here) under the specified action name (id). If no action has been installed, the method returns null.
Specified by:
getAction in interface org.eclipse.ui.texteditor.ITextEditor
See Also:
ITextEditor.getAction(java.lang.String)

createActions

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

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

Subclasses may extend this method.


addAction

protected final void addAction(org.eclipse.jface.action.IMenuManager menu,
                               java.lang.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., "SelectAll")

addAction

protected final void addAction(org.eclipse.jface.action.IMenuManager menu,
                               java.lang.String group,
                               java.lang.String actionId)
Convenience method to add the action installed under the given action id to the specified group of the menu.

addGroup

protected final void addGroup(org.eclipse.jface.action.IMenuManager menu,
                              java.lang.String existingGroup,
                              java.lang.String newGroup)
Convenience method to add a new group after the specified group.

rulerContextMenuAboutToShow

protected void rulerContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager menu)
Set up the vertical ruler's context (popup) menu before it is made visible.

Subclasses may extend to add other actions.

Parameters:
menu - the menu

editorContextMenuAboutToShow

protected void editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager menu)
Set up this editor's context (popup) menu before it is made visible. Contribute LPEX's actions defined by the current.popup parameter, and also add "Add bookmark/task" as per Eclipse norms.

Subclasses may extend to add other actions.

Parameters:
menu - the menu

getAdapter

public java.lang.Object getAdapter(java.lang.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.

Specified by:
getAdapter in interface org.eclipse.core.runtime.IAdaptable
Overrides:
getAdapter in class org.eclipse.ui.part.WorkbenchPart
See Also:
IAdaptable.getAdapter(Class)

setFocus

public void setFocus()
Ask the part to take focus within the workbench. Gives focus to the LpexWindow.
Specified by:
setFocus in interface org.eclipse.ui.IWorkbenchPart
Overrides:
setFocus in class org.eclipse.ui.part.WorkbenchPart
See Also:
IWorkbenchPart.setFocus()

setHelpContextId

protected void setHelpContextId(java.lang.String helpContextId)
Set the editor's help context id.
Parameters:
helpContextId - the help context id

gotoMarker

public void gotoMarker(org.eclipse.core.resources.IMarker marker)
Set the cursor in the editor to the specified marker, and emphasize accordingly.

Eclipse markers registered against the resource file being edited are maintained by LPEX during editing (as corresponding LPEX marks are created for them). Markers not registered with the resource may be out-of-sync with the current status of the document being edited.

Specified by:
gotoMarker in interface org.eclipse.ui.IEditorPart
Overrides:
gotoMarker in class org.eclipse.ui.part.EditorPart
See Also:
EditorPart.gotoMarker(org.eclipse.core.resources.IMarker), addMark(org.eclipse.core.resources.IMarker)

handleEditorInputChanged

protected void handleEditorInputChanged()
Handle an external change of the editor's input element.

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.
Specified by:
showsHighlightRangeOnly in interface org.eclipse.ui.texteditor.ITextEditor
See Also:
ITextEditor.showsHighlightRangeOnly()

showHighlightRangeOnly

public void showHighlightRangeOnly(boolean showHighlightRangeOnly)
Configure the editor to show / not show the highlight range only.
Specified by:
showHighlightRangeOnly in interface org.eclipse.ui.texteditor.ITextEditor
See Also:
ITextEditor.showHighlightRangeOnly(boolean)

setHighlightRange

public void setHighlightRange(int start,
                              int len,
                              boolean moveCursor)
Set the highlight range to the specified region.
Specified by:
setHighlightRange in interface org.eclipse.ui.texteditor.ITextEditor
See Also:
ITextEditor.setHighlightRange(int, int, boolean)

getHighlightRange

public org.eclipse.jface.text.IRegion getHighlightRange()
Return the highlighted range of this text editor.
Specified by:
getHighlightRange in interface org.eclipse.ui.texteditor.ITextEditor
See Also:
ITextEditor.getHighlightRange()

setActionActivationCode

public void setActionActivationCode(java.lang.String actionName,
                                    char activationCharacter,
                                    int activationKeyCode,
                                    int activationStateMask)
This method is not currently implemented in LpexAbstractTextEditor. Preferred method: use the set keyAction LPEX command.
Specified by:
setActionActivationCode in interface org.eclipse.ui.texteditor.ITextEditor
Parameters:
actionName - LPEX action name
See Also:
ITextEditor.setActionActivationCode(String, char, int, int)

removeActionActivationCode

public void removeActionActivationCode(java.lang.String actionName)
This method is not currently implemented in LpexAbstractTextEditor. Preferred method: use the set keyAction LPEX command.
Specified by:
removeActionActivationCode in interface org.eclipse.ui.texteditor.ITextEditor
Parameters:
actionName - LPEX action name
See Also:
ITextEditor.removeActionActivationCode(String)

resetHighlightRange

public void resetHighlightRange()
Reset the highlight range.
Specified by:
resetHighlightRange in interface org.eclipse.ui.texteditor.ITextEditor
See Also:
ITextEditor.resetHighlightRange()

adjustHighlightRange

protected void adjustHighlightRange(int offset,
                                    int len)
Adjust 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
length - the length of the range which at least should be highlighted

selectAndReveal

public void selectAndReveal(int start,
                            int len)
Select and reveal the specified range in this text editor.
Specified by:
selectAndReveal in interface org.eclipse.ui.texteditor.ITextEditor
Parameters:
offset - the offset of the selection
len - the length of the selection
See Also:
ITextEditor.selectAndReveal(int, int)

firePropertyChange

protected void firePropertyChange(int property)
Fire a property-changed event.
Overrides:
firePropertyChange in class org.eclipse.ui.part.WorkbenchPart
Parameters:
property - the id of the property that changed
See Also:
WorkbenchPart.firePropertyChange(int)

getLpexView

public LpexView getLpexView()
Convenience method to retrieve the underlying LPEX text-widget view on the document.

getLpexWindow

public LpexWindow getLpexWindow()
Convenience method to retrieve the underlying LPEX text-widget window (an SWT Composite).

initializeLpexView

public void initializeLpexView(LpexView lpexView)
Hook to initialize a newly instantiated LpexView during the construction of this text editor's SourceViewer.

Extend this method to set any file/view-specific parameters for this LpexView.

Here you may set any "File Open" preference-page settings for your solution's plugin, such as sequenceNumbers, sourceEncoding, save.textLimit, and save.trim. The updateProfile command will be called later.

See Also:
updateProfile()

updateProfile

public void updateProfile()
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, etc. Ensure you also call super.updateProfile().

Called when a new LpexSourceViewer is created (an LPEX document is opened), and whenever the updateProfile command is issued afterwards.

See Also:
initializeLpexView(com.ibm.lpex.core.LpexView)

setDocumentSection

protected void 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 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.

See Also:
addLines(com.ibm.lpex.core.LpexView, int)

addLines

protected boolean addLines(LpexView lpexView,
                           int neededLine)
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.

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)

addMark

public void addMark(org.eclipse.core.resources.IMarker marker)
Create an LPEX mark corresponding to the given Eclipse marker. LPEX marks are maintained in sync with the text during editing. LPEX marks are created automatically for an IFile / IProject resource handled by this text editor.

The mark is defined inside the currently-loaded LPEX document section, and assumes that the marker is defined in an IDocument corresponding to this section.


updateMarkers

public void updateMarkers()
Bring the location of this editor's input resource markers back in sync with the location of LpexView's corresponding marks. This positional update of the markers takes place on every save operation.

As LPEX doesn't keep the IDocument and, consequently, its listeneres up-to-date, during an edit session the up-to-date location of a marker can only be established from the corresponding LPEX mark set in LpexView.

Markers are defined, and have corresponding LPEX marks set, inside the currently-loaded LPEX document section.


getEOL

public java.lang.String getEOL()
Return the line delimiter used by the document currently handled by this text editor. This method assumes that a consistent line separator is used throughout the document (i.e., throughout the original underlying file resource).