|
SWT LPEX v3.0.5 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.ui.part.WorkbenchPart
org.eclipse.ui.part.EditorPart
com.ibm.lpex.alef.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 editor error log (see the editorLog
editor parameter)Lpex
stand-alone editor on the editor profile (see the defaultProfile
editor parameter).Keys already defined (e.g., by the active base 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 replaced with the editor's part id. If the editor is instructed
to run in version 1.0 context menu registration compatibility mode, 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 replaced with the editor's part id. If the editor is instructed
to run in version 1.0 context menu registration compatibility mode, 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 LpexTextEditor) { LpexTextEditor lpexEditor = (LpexTextEditor)editor; LpexView lpexView = lpexEditor.getLpexView(); 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() } |
LpexTextEditor
,
getLpexView()
,
getFirstLpexView()
,
getLpexWindow()
,
getFirstLpexWindow()
Field Summary | |
---|---|
protected static com.ibm.lpex.alef.LpexAbstractTextEditor.IdMapEntry[] |
ACTION_MAP
Mapping between Eclipse action definition names and LPEX actions. |
static String |
DEFAULT_EDITOR_CONTEXT_MENU_ID
Menu id for the editor context menu. |
static String |
DEFAULT_RULER_CONTEXT_MENU_ID
Menu id for the ruler context menu. |
protected String |
fErrorLabel
The error message shown in the status line in the case of failed information look up. |
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()
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)
Add 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. |
INavigationLocation |
createEmptyNavigationLocation()
|
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()
|
void |
createPartControl(Composite parent)
The LpexAbstractTextEditor implementation of this IWorkbenchPart method creates the vertical ruler and
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()
Create the vertical ruler (an LpexVerticalRuler) to be used by this editor. |
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()
Dispose this part and discard 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 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. |
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. |
String |
getEOL()
Return the line delimiter used by the document currently handled by this text editor. |
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()
Retrieve 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. |
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 String |
getRulerContextMenuId()
Returns the ruler's context menu id. |
protected MouseListener |
getRulerMouseListener()
Creates and returns the listener on this editor's vertical ruler. |
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. |
IVerticalRuler |
getVerticalRuler()
Returns this editor's vertical ruler. |
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. |
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()
|
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. |
boolean |
isEditorInputModifiable()
Returns whether the editor's input can be persistently modified. |
boolean |
isEditorInputReadOnly()
Returns whether the editor's input is read-only. |
boolean |
isSaveAsAllowed()
Returns true if the "Save as" operation is supported by the target. |
boolean |
isSaveOnCloseNeeded()
Returns whether the contents of this editor should be saved when the editor is closed. |
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 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)
Remove 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. |
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 |
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. |
void |
showChangeInformation(boolean show)
|
void |
showHighlightRangeOnly(boolean showHighlightRangeOnly)
Configure the editor to show, or not show, the highlight range exclusively. |
boolean |
showsHighlightRangeOnly()
Query whether the editor is configured to show the highlight range only, or all of the input element's textual representation. |
void |
updateProfile()
Deprecated. Will be removed! You must extend updateProfile(LpexView) instead. |
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. |
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 org.eclipse.ui.part.EditorPart |
---|
getEditorInput, getEditorSite, getTitleToolTip, setContentDescription, setInitializationData, setPartName |
Methods inherited from class org.eclipse.ui.part.WorkbenchPart |
---|
addPropertyListener, getConfigurationElement, getContentDescription, getDefaultImage, getPartName, getSite, getTitle, getTitleImage, removePropertyListener, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy |
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 |
public static final String DEFAULT_EDITOR_CONTEXT_MENU_ID
public static final String DEFAULT_RULER_CONTEXT_MENU_ID
protected static final int VERTICAL_RULER_WIDTH
protected static final com.ibm.lpex.alef.LpexAbstractTextEditor.IdMapEntry[] ACTION_MAP
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()
getDocumentProvider
in interface ITextEditor
ITextEditor.getDocumentProvider()
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()
getSelectionProvider
in interface ITextEditor
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 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 default settings are stored in its own defaultProfile. In TextViewer, this method updates any preference-related editor properties (its font; foreground, background, selection, and find-scope colours, carets).
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.init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
public void init(IEditorSite site, IEditorInput input) throws PartInitException
init
in interface IEditorPart
PartInitException
IEditorPart.init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
protected IVerticalRuler createVerticalRuler()
protected 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
public void createPartControl(Composite parent)
IWorkbenchPart
method creates the vertical ruler and
source viewer. Subclasses may extend.
This is a multistep process:
createPartControl
in interface IWorkbenchPart
IWorkbenchPart.createPartControl(org.eclipse.swt.widgets.Composite)
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)public final void setInput(IEditorInput input)
setInput
in interface IReusableEditor
EditorPart.setInput(org.eclipse.ui.IEditorInput)
protected void setPreferenceStore(IPreferenceStore store)
store
- the preference store, or null
to unset the
preference storepublic void close(boolean save)
close
in interface ITextEditor
save
- true
if unsaved changed should be saved, or
false
if unsaved changed should be discardedITextEditor.close(boolean)
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.
dispose
in interface IWorkbenchPart
IWorkbenchPart.dispose()
protected void disposeDocumentProvider()
public void doSave(IProgressMonitor progressMonitor)
The implementation of this IEditorPart
method may be
extended by subclasses.
doSave
in interface ISaveablePart
progressMonitor
- the progress monitor for communicating result state, or
null
ISaveablePart.doSave(org.eclipse.core.runtime.IProgressMonitor)
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, false
otherwiseprotected void validateState(IEditorInput input)
input
- the input to be validatedprotected 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 monitorpublic void doSaveAs()
The LpexAbstractTextEditor implementation of this
IEditorPart
method calls performSaveAs()
.
doSaveAs
in interface ISaveablePart
ISaveablePart.doSaveAs()
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.
isSaveAsAllowed
in interface ISaveablePart
false
ISaveablePart.isSaveAsAllowed()
public boolean isSaveOnCloseNeeded()
isSaveOnCloseNeeded
in interface ISaveablePart
true
if the contents of the editor should be saved
on close, or false
if the contents are expendableEditorPart.isSaveOnCloseNeeded()
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).
isDirty
in interface ISaveablePart
EditorPart.isDirty()
public void doRevertToSaved()
The implementation of this ITextEditor
method may be
extended by subclasses.
doRevertToSaved
in interface ITextEditor
ITextEditor.doRevertToSaved()
protected void performRevert()
protected void handleElementContentReplaced()
public void setAction(String actionName, IAction action)
setAction
in interface ITextEditor
actionName
- name of the action (e.g., "SelectAll")action
- the JFace IAction, or null
to remove itITextEditor.setAction(String, IAction)
public IAction getAction(String actionName)
null
is returned.
getAction
in interface ITextEditor
actionName
- action name, e.g., "cut"ITextEditor.getAction(String)
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()
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.
getAdapter
in interface IAdaptable
IAdaptable.getAdapter(java.lang.Class)
public void setFocus()
setFocus
in interface IWorkbenchPart
IWorkbenchPart.setFocus()
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:
If the user modifies this key-binding scope, for example by subclassing this
method or by calling it with a different scopes
parameter from
within the updateProfile() hook, it is assumed that any new scope(s) used
extend or augment the LPEX scope set in here: 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 editor profile in
effect (see also the updateProfile.baseProfile editor parameter).
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()
showsHighlightRangeOnly
in interface ITextEditor
ITextEditor.showsHighlightRangeOnly()
public void showHighlightRangeOnly(boolean showHighlightRangeOnly)
showHighlightRangeOnly
in interface ITextEditor
ITextEditor.showHighlightRangeOnly(boolean)
public void setHighlightRange(int offset, int len, boolean moveCursor)
setHighlightRange
in interface ITextEditor
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.setHighlightRange(int,int,boolean)
public IRegion getHighlightRange()
getHighlightRange
in interface ITextEditor
ITextEditor.getHighlightRange()
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.
setActionActivationCode
in interface ITextEditor
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.setActionActivationCode(String,char,int,int)
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.
removeActionActivationCode
in interface ITextEditor
actionName
- action nameITextEditor.removeActionActivationCode(String)
public void resetHighlightRange()
resetHighlightRange
in interface ITextEditor
ITextEditor.resetHighlightRange()
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)
selectAndReveal
in interface ITextEditor
start
- the offset of the selectionlen
- the length of the selectionITextEditor.selectAndReveal(int, int)
public INavigationLocation createEmptyNavigationLocation()
public INavigationLocation createNavigationLocation()
protected void markInNavigationHistory()
protected void editorSaved()
protected void firePropertyChange(int property)
property
- the id of the property that changedWorkbenchPart.firePropertyChange(int)
public void setStatusField(IStatusField field, String category)
setStatusField
in interface ITextEditorExtension
field
- the status field to be used, or null
to remove
a previous settingcategory
- the status information categoryITextEditorExtension.setStatusField(org.eclipse.ui.texteditor.IStatusField,String)
protected IStatusField getStatusField(String category)
category
- the status category
protected void updateStatusField(String category)
category
- the status categoryprotected void updateStatusFields()
protected String getCursorPosition()
public boolean isEditable()
isEditable
in interface ITextEditor
ITextEditor.isEditable()
public boolean isEditorInputReadOnly()
isEditorInputReadOnly
in interface ITextEditorExtension
ITextEditorExtension.isEditorInputReadOnly()
public boolean isEditorInputModifiable()
ITextEditorExtension2.isEditorInputModifiable()
public void addRulerContextMenuListener(IMenuListener listener)
addRulerContextMenuListener
in interface ITextEditorExtension
ITextEditorExtension.addRulerContextMenuListener(IMenuListener)
public void removeRulerContextMenuListener(IMenuListener listener)
removeRulerContextMenuListener
in interface ITextEditorExtension
ITextEditorExtension.removeRulerContextMenuListener(IMenuListener)
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)
public boolean isChangeInformationShowing()
public LpexView getLpexView()
public LpexView getFirstLpexView()
public LpexView getActiveLpexView()
LpexMultiWindow.activeWindowChanged(com.ibm.lpex.core.LpexWindow)
public LpexWindow getLpexWindow()
public LpexWindow getFirstLpexWindow()
public LpexWindow getActiveLpexWindow()
LpexMultiWindow.activeWindowChanged(com.ibm.lpex.core.LpexWindow)
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()
updateProfile(LpexView)
instead.
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 do a total parse.
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)
This hook is used, for example, by WSED's z/OS Tools to trim trailing spaces spaces for a newly-opened document. Because the undo stack is cleared in here, this cannot be done in updateProfile(), which is called every time default editor settings are changed:
// (a) set source encoding first lpexView.doDefaultCommand("set sourceEncoding " + remoteEncoding); // (b) set sequence numbers (defined in terms of byte columns in the source encoding) lpexView.doDefaultCommand("set sequenceNumbers 73 8"); // (c) trim trailing spaces (now that sequence numbers are gone from the elements) if (lpexView.queryOn("current.save.trim")) { lpexView.trimDocument(); lpexView.doDefaultCommand("undo clear"); // since we've trimmed blanks, we must ignore them on file compare lpexView.doDefaultCommand("set compare.ignoreTrailingBlanks on"); } |
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 issuedprotected 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()
public String getEOL()
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)
|
SWT LPEX v3.0.5 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |