|
LPEX 4.4.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object EditorPart com.ibm.lpex.alef.LpexAbstractTextEditor
public abstract class LpexAbstractTextEditor
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.
LPEX actions, their assigned keys, and commands new or (re)defined in here for running in the Eclipse workbench:
Lpex
Lpex
window. The availability of the action can be controlled directly by the solution editor
Lpex
stand-alone editor on the LPEX editor log / defaults
profileKeys 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.
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() } |
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 |
---|
public static final String PREFERENCE_COLOR_BACKGROUND
AbstractTextEditor.Color.Background
public static final String PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT
AbstractTextEditor.Color.Background.SystemDefault
public static final String PREFERENCE_HYPERLINKS_ENABLED
public static final String PREFERENCE_HYPERLINK_KEY_MODIFIER
public static final String PREFERENCE_HYPERLINK_KEY_MODIFIER_MASK
PREFERENCE_HYPERLINK_KEY_MODIFIER
cannot be resolved to valid SWT modifier bits. String value.
PREFERENCE_HYPERLINK_KEY_MODIFIER
,
Constant Field Valuespublic static final String PREFERENCE_RULER_CONTRIBUTIONS
RulerColumnPreferenceAdapter
.
public static final String DEFAULT_EDITOR_CONTEXT_MENU_ID
"#LpexEditorContext"
).
public static final String DEFAULT_RULER_CONTEXT_MENU_ID
#LpexRulerContext"
).
protected static final int VERTICAL_RULER_WIDTH
protected final String fErrorLabel
Constructor Detail |
---|
protected LpexAbstractTextEditor()
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 |
---|
public IDocumentProvider getDocumentProvider()
ITextEditor
protected final IPreferenceStore getPreferenceStore()
null
if none has been setprotected final Annotation getRangeIndicator()
null
if none installedprotected final SourceViewerConfiguration getSourceViewerConfiguration()
null
before the editor's part has been created and after disposalprotected final ISourceViewer getSourceViewer()
null
before the editor's part has been created and after disposalpublic final IVerticalRuler getVerticalRuler()
null
before the editor's part has been created and after disposalprotected final String getEditorContextMenuId()
null
before the editor's part has been createdprotected final String getRulerContextMenuId()
null
before the editor's part has been createdprotected void setDocumentProvider(IDocumentProvider provider)
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.
provider
- the document providerprotected void setSourceViewerConfiguration(SourceViewerConfiguration configuration)
LpexSourceViewerConfiguration
.
configuration
- the source viewer configuration objectLpexSourceViewerConfiguration
protected void setRangeIndicator(Annotation rangeIndicator)
rangeIndicator
- the annotationprotected void setEditorContextMenuId(String contextMenuId)
contextMenuId
- the context menu idprotected void setRulerContextMenuId(String contextMenuId)
contextMenuId
- the context menu idprotected final void setCompatibilityMode(boolean compatible)
compatible
- true
if compatibility mode is enabledpublic ISelectionProvider getSelectionProvider()
null
if the editor has been disposedprotected void rememberSelection()
Subclasses should implement this method including all necessary state. This default implementation remembers the textual range only and is thus purely syntactic.
restoreSelection()
protected void restoreSelection()
rememberSelection
. Subclasses may reimplement this method and thereby semantically adapt the
remembered selection. This default implementation just selects the remembered textual range.
rememberSelection()
protected IMenuListener createContextMenuListener()
protected final IMenuListener getContextMenuListener()
protected final MouseListener getRulerMouseListener()
protected boolean affectsTextPresentation(PropertyChangeEvent event)
false
. May be
reimplemented by subclasses.
event
- the event which should be investigated
true
if the event describes a preference change affecting the editor's presentationprotected void handlePreferenceStoreChanged(PropertyChangeEvent event)
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.
event
- the property change eventprotected final void internalInit(IWorkbenchWindow window, IEditorSite site, IEditorInput input) throws PartInitException
init
method of IEditorPart
. Subclasses replacing init
may choose to call this method in their
implementation.
window
- the workbench windowsite
- the editor's siteinput
- the editor input for the editor being created
PartInitException
- if doSetInput(IEditorInput)
fails or gets canceledIEditorPart
public void init(IEditorSite site, IEditorInput input) throws PartInitException
PartInitException
IEditorPart
protected IVerticalRuler createVerticalRuler()
null
. Subclasses may reimplement this method.
Called from createPartControl().
protected void updateContributedRulerColumns(LpexCompositeRuler ruler)
ruler
- the LPEX composite ruler to add contributions toprotected IColumnSupport createColumnSupport()
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
.
null
if noneprotected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles)
Called from createPartControl().
parent
- the parent controlruler
- the vertical rulerstyles
- style bits, SWT.WRAP
is currently not supported
protected void initializeDragAndDrop(ISourceViewer viewer)
viewer
- the viewerpublic void createPartControl(Composite parent)
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:
createPartControl
:
createPartControl
:
IWorkbenchPart
protected MenuManager createContextMenuManager(String text, String id)
The default implementation of this method returns a new org.eclipse.jface.action.MenuManager. Subclasses may reimplement this method.
protected boolean isEditorInputIncludedInContextMenu()
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.
true
if the editor input should be consideredprotected Image getReadonlyTitleImage()
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; |
protected void setDocumentProvider(IEditorInput input)
input
- the input of this editorprotected void doSetInput(IEditorInput input) throws CoreException
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.
input
- the (new) input to be set; if null
, this text editor is being closed
CoreException
- if the input cannot be connected to the document provider (i.e., it is not understood by this part)protected final void setInputWithNotify(IEditorInput input)
EditorPart
public final void setInput(IEditorInput input)
EditorPart
protected void setPreferenceStore(IPreferenceStore store)
store
- the preference store, or null
to remove the preference storepublic void close(boolean save)
save
- true
if unsaved changed should be saved, or false
if unsaved changed should be discardedITextEditor
public void dispose()
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.
IWorkbenchPart
protected void disposeDocumentProvider()
public void doSave(IProgressMonitor progressMonitor)
The implementation of this IEditorPart
method may be extended by subclasses.
progressMonitor
- the progress monitor for communicating result state, or null
IEditorPart
protected void enableSanityChecking(boolean enable)
enable
- true
if sanity checking should be enabled, or false
otherwiseprotected void safelySanityCheckState(IEditorInput input)
input
- the editor input whose state is to be checkedprotected void sanityCheckState(IEditorInput input)
input
- the editor input whose state is to be checkedprotected void enableStateValidation(boolean enable)
enable
- true
if state validation should be enabled, or false
otherwiseprotected void validateState(IEditorInput input)
input
- the input to be validatedpublic boolean validateEditorInputState()
true
if the input was validated, false
otherwiseITextEditorExtension2
protected void updateState(IEditorInput input)
input
- the input to be validatedprotected void performSave(boolean overwrite, IProgressMonitor progressMonitor)
overwrite
- indicates whether or not overwriting is allowedprogressMonitor
- the monitor in which to run the operationprotected void handleExceptionOnSave(CoreException exception, IProgressMonitor progressMonitor)
exception
- the exception to handleprogressMonitor
- the progress monitorprotected void openSaveErrorDialog(String title, String message, CoreException exception)
title
- the dialog titlemessage
- the message to displayexception
- the exception to handlepublic void doSaveAs()
The LpexAbstractTextEditor implementation of this IEditorPart
method calls performSaveAs()
.
IEditorPart
protected void performSaveAs(IProgressMonitor progressMonitor)
progressMonitor
- the progress monitor for communicating result state, or null
performSaveAs(IProgressMonitor,String)
protected void performSaveAs(IProgressMonitor progressMonitor, String fileName)
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
performSaveAs(IProgressMonitor)
public boolean isSaveAsAllowed()
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.
false
IEditorPart
public boolean isDirty()
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).
EditorPart
public void doRevertToSaved()
The implementation of this ITextEditor
method may be extended by subclasses.
ITextEditor
protected void performRevert()
protected void handleElementContentReplaced()
public void setAction(String actionName, IAction action)
actionName
- name of the action (e.g., "SelectAll")action
- the JFace IAction, or null
to remove itITextEditor
public IAction getAction(String actionName)
null
is returned.
actionName
- action name, e.g., "cut"ITextEditor
public void markAsPropertyDependentAction(String actionId, boolean mark)
actionId
- the action idmark
- true
if the action is property dependentprotected void updatePropertyDependentActions()
protected void createNavigationActions()
Subclasses may extend.
protected void createActions()
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.
protected final void addAction(IMenuManager menu, String actionName)
menu
- menu to add the actionactionName
- name of the action (e.g., "cut")protected final void addAction(IMenuManager menu, String group, String actionName)
menu
- the menu to add the action togroup
- the group in the menuactionName
- the name of the action to addprotected final void addGroup(IMenuManager menu, String existingGroup, String newGroup)
menu
- the menu to add the new group toexistingGroup
- the group after which to insert the new groupnewGroup
- the new groupprotected void rulerContextMenuAboutToShow(IMenuManager menu)
Subclasses may extend to add other actions.
menu
- the menuprotected void editorContextMenuAboutToShow(IMenuManager menu)
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"); |
menu
- the menugetLpexView()
protected IStatusLineManager getStatusLineManager()
public Object getAdapter(Class required)
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.
IAdaptable
public void setFocus()
IWorkbenchPart
protected void setHelpContextId(String helpContextId)
helpContextId
- the help context idsetLanguageHelp(com.ibm.lpex.alef.LpexLanguageHelp)
protected final String getHelpContextId()
null
if none has been setprotected void setLanguageHelp(LpexLanguageHelp lsh)
setHelpContextId(java.lang.String)
protected void setKeyBindingScopes(String[] scopes)
Sets the key-binding scopes for the focus, or otherwise primary view of this editor.
setKeyBindingScopes(LpexView,String[])
protected void setKeyBindingScopes(LpexView lpexView, String[] scopes)
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:
The user may modify this key-binding scope, for example
scopes
parameter from within the updateProfile() hook.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); } |
lpexView
- a document view of this editorscopes
- an array of key-binding scope identifier(s) to set for this viewgetKeyBindingScopes(LpexView)
protected String[] getKeyBindingScopes(LpexView lpexView)
null
if none set yet, or if the given lpexView is null
setKeyBindingScopes(LpexView,String[])
protected IProgressMonitor getProgressMonitor()
protected void handleEditorInputChanged()
public boolean showsHighlightRangeOnly()
ITextEditor
public void showHighlightRangeOnly(boolean showHighlightRangeOnly)
ITextEditor
public void setHighlightRange(int offset, int len, boolean moveCursor)
offset
- the offset of the highlighted rangelen
- the length of the highlighted rangemoveCursor
- true
move the cursor to the start of the highlighted range, or false
leave the cursor as isITextEditor
public IRegion getHighlightRange()
ITextEditor
public void setActionActivationCode(String actionName, char activationCharacter, int activationKeyCode, int activationStateMask)
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.
actionName
- Eclipse action nameactivationCharacter
- the activation code characteractivationKeyCode
- the activation code key code, or -1 for wild cardactivationStateMask
- the activation code state mask, or SWT.DEFAULT for wild cardITextEditor
public void removeActionActivationCode(String actionName)
Removes any installed activation code for the specified action. If no activation code is installed, this method does not have any effect.
actionName
- action nameITextEditor
public void resetHighlightRange()
ITextEditor
protected void adjustHighlightRange(int offset, int len)
offset
- the offset of the range which at least should be highlightedlen
- the length of the range which at least should be highlightedpublic void selectAndReveal(int start, int len)
start
- the offset of the selectionlen
- the length of the selectionITextEditor
protected void selectAndReveal(int selectionStart, int selectionLength, int revealStart, int revealLength)
selectionStart
- the offset of the selectionselectionLength
- the length of the selectionrevealStart
- the offset of the revealed rangerevealLength
- the length of the revealed rangepublic INavigationLocation createEmptyNavigationLocation()
restoreState
will be sent to the location to restore its state.
INavigationLocationProvider
public INavigationLocation createNavigationLocation()
INavigationLocationProvider
protected void markInNavigationHistory()
protected void editorSaved()
protected void firePropertyChange(int property)
property
- the id of the property that changedWorkbenchPart
public void setStatusField(IStatusField field, String category)
field
- the status field to be used, or null
to remove a previous settingcategory
- the status information categoryITextEditorExtension
protected IStatusField getStatusField(String category)
category
- the status category
protected void handleCursorPositionChanged()
protected void updateStatusField(String category)
category
- the status categoryprotected void updateStatusFields()
protected String getCursorPosition()
public boolean isEditable()
true
if it can be edited, or false
if it is read onlyITextEditor
public boolean isEditorInputReadOnly()
isEditable()
, as it talks about the editor input, i.e., the domain
element, and not about the editor document.
true
if the editor input is read-onlyITextEditorExtension
public boolean isEditorInputModifiable()
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.
true
if the editor input is modifiableITextEditorExtension2
public void addRulerContextMenuListener(IMenuListener listener)
ITextEditorExtension
public void removeRulerContextMenuListener(IMenuListener listener)
ITextEditorExtension
protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement)
true
. Subclasses may reimplement.
originalElement
- the original elementmovedElement
- the moved element
protected static final int widgetOffset2ModelOffset(ISourceViewer viewer, int widgetOffset)
-1
if there is no such offset.
viewer
- the source viewerwidgetOffset
- the widget offset
-1
protected static final int modelOffset2WidgetOffset(ISourceViewer viewer, int modelOffset)
-1
if there is no such
offset.
viewer
- the source viewermodelOffset
- the model offset
-1
protected static final IRegion getCoverage(ISourceViewer viewer)
viewer
- the viewer go return the coverage for
protected static final boolean isVisible(ISourceViewer viewer, int offset, int len)
viewer
- the source vieweroffset
- the offset of the regionlen
- the length of the region
true
if visiblepublic void showChangeInformation(boolean show)
ITextEditorExtension3
public boolean isChangeInformationShowing()
ITextEditorExtension3
protected void setStatusLineErrorMessage(String message)
message
- message to be setprotected void setStatusLineMessage(String message)
message
- message to be setpublic Annotation gotoAnnotation(boolean forward)
forward
- true
if search direction is forward, false
if backward
null
if noneisNavigationTarget(Annotation)
,
findAnnotation(int, int, boolean, Position)
protected Annotation findAnnotation(int offset, int length, boolean forward, Position annotationPosition)
offset
- the region offsetlength
- the region lengthforward
- true
for forwards, false
for backwardannotationPosition
- the position of the found annotation
protected boolean isNavigationTarget(Annotation annotation)
annotation
- the annotation
true
if this is a target, false
otherwisepublic void showRevisionInformation(RevisionInformation info, String quickDiffProviderId)
public Saveable[] getSaveables()
public Saveable[] getActiveSaveables()
public int getOrientation()
WorkbenchPart
public LpexView getLpexView()
public LpexView getFirstLpexView()
public LpexView getActiveLpexView()
public LpexWindow getLpexWindow()
public LpexWindow getFirstLpexWindow()
public LpexWindow getActiveLpexWindow()
public void initializeLpexView(LpexView 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.
lpexView
- the primary or secondary view being initializedwidgetContentsSet(LpexView)
,
updateProfile(LpexView)
public void updateProfile(LpexView lpexView)
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.
lpexView
- the primary or secondary document view whose profile is being updatedinitializeLpexView(com.ibm.lpex.core.LpexView)
,
widgetContentsSet(com.ibm.lpex.core.LpexView)
,
handleDelegate(com.ibm.lpex.core.LpexView)
protected void widgetContentsSet(LpexView lpexView)
lpexView
- the primary view of the documentinitializeLpexView(LpexView)
,
updateProfile(LpexView)
protected boolean availableOpenNewView(LpexView lpexView)
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.
lpexView
- the document view for which the action availability is queriedprotected boolean performLpexCommand(LpexView lpexView)
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.
lpexView
- the document view from which the request was issued
true
protected void handleDelegate(LpexView lpexView)
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().
lpexView
- the Lpex document view whose actions and commands are delegated to usupdateProfile(LpexView)
protected boolean setDocumentSection(int linesBeforeStart, int linesAfterEnd)
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.
addLines(com.ibm.lpex.core.LpexView, int)
protected boolean addLines(LpexView lpexView, int lineNeeded)
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.
lpexView
- the LPEX text-widget viewlineNeeded
- 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
setDocumentSection(int, int)
protected IResource getInputResource()
protected void createViewPreferenceNodes(LpexSourceViewer lpexSourceViewer)
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.
LpexViewPreferenceNode
,
LpexSourceViewer.createViewPreferenceNodes(com.ibm.lpex.alef.LpexSourceViewer)
protected IPreferencePage createViewPreferencePage(LpexView lpexView, int nodeType)
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.
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
LpexSourceViewer.createViewPreferencePage(com.ibm.lpex.core.LpexView, int)
|
LPEX 4.4.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |