Class HandlyXtextEditorCallback
- All Implemented Interfaces:
org.eclipse.xtext.ui.editor.IXtextEditorCallback
Multiple Xtext editor instances may simultaneously be open for a given source file, each with its own underlying document, but only one of them (the most recently used one) is connected to the source file's working copy.
Note that this class relies on the language-specific implementation of
IInputElementProvider
being available through injection.
Also, HandlyXtextDocument
and other classes pertaining to
Handly/Xtext integration should be bound if this callback is configured.
For example:
public Class<? extends IInputElementProvider> bindIInputElementProvider() { return FooInputElementProvider.class; } public void configureXtextEditorCallback(Binder binder) { binder.bind(IXtextEditorCallback.class).annotatedWith(Names.named( HandlyXtextEditorCallback.class.getName())).to( HandlyXtextEditorCallback.class); } public Class<? extends XtextDocument> bindXtextDocument() { return HandlyXtextDocument.class; } public Class<? extends IReconciler> bindIReconciler() { return HandlyXtextReconciler.class; } public Class<? extends DirtyStateEditorSupport> bindDirtyStateEditorSupport() { return HandlyDirtyStateEditorSupport.class; // or its subclass }
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.xtext.ui.editor.IXtextEditorCallback
org.eclipse.xtext.ui.editor.IXtextEditorCallback.NullImpl
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected ISourceFile
acquireWorkingCopy
(org.eclipse.xtext.ui.editor.XtextEditor editor) Attempts to acquire a working copy for the corresponding source file of the editor.void
afterCreatePartControl
(org.eclipse.xtext.ui.editor.XtextEditor editor) protected void
afterSelectionChange
(org.eclipse.xtext.ui.editor.XtextEditor editor, org.eclipse.jface.viewers.ISelection selection) Notifies that the selection has changed in the editor.void
afterSetInput
(org.eclipse.xtext.ui.editor.XtextEditor editor) void
beforeDispose
(org.eclipse.xtext.ui.editor.XtextEditor editor) void
beforeSetInput
(org.eclipse.xtext.ui.editor.XtextEditor editor) protected ISourceFile
getSourceFile
(org.eclipse.xtext.ui.editor.XtextEditor editor) Returns the corresponding source file for the editor.protected final ISourceFile
getWorkingCopy
(org.eclipse.xtext.ui.editor.XtextEditor editor) Returns the working copy that the editor is connected to, ornull
if the editor is not currently connected to a working copy.protected void
releaseWorkingCopy
(org.eclipse.xtext.ui.editor.XtextEditor editor, ISourceFile workingCopy) Releases the given working copy that was acquired via a call toacquireWorkingCopy
.protected void
setHighlightRange
(org.eclipse.xtext.ui.editor.XtextEditor editor, org.eclipse.jface.viewers.ISelection selection) Sets the highlighted range of the editor according to the selection.void
setInputElementProvider
(IInputElementProvider provider) Methods inherited from class org.eclipse.xtext.ui.editor.IXtextEditorCallback.NullImpl
afterSave, onValidateEditorInputState
-
Constructor Details
-
HandlyXtextEditorCallback
public HandlyXtextEditorCallback()
-
-
Method Details
-
setInputElementProvider
-
afterCreatePartControl
public void afterCreatePartControl(org.eclipse.xtext.ui.editor.XtextEditor editor) - Specified by:
afterCreatePartControl
in interfaceorg.eclipse.xtext.ui.editor.IXtextEditorCallback
- Overrides:
afterCreatePartControl
in classorg.eclipse.xtext.ui.editor.IXtextEditorCallback.NullImpl
-
beforeDispose
public void beforeDispose(org.eclipse.xtext.ui.editor.XtextEditor editor) - Specified by:
beforeDispose
in interfaceorg.eclipse.xtext.ui.editor.IXtextEditorCallback
- Overrides:
beforeDispose
in classorg.eclipse.xtext.ui.editor.IXtextEditorCallback.NullImpl
-
beforeSetInput
public void beforeSetInput(org.eclipse.xtext.ui.editor.XtextEditor editor) - Specified by:
beforeSetInput
in interfaceorg.eclipse.xtext.ui.editor.IXtextEditorCallback
- Overrides:
beforeSetInput
in classorg.eclipse.xtext.ui.editor.IXtextEditorCallback.NullImpl
-
afterSetInput
public void afterSetInput(org.eclipse.xtext.ui.editor.XtextEditor editor) - Specified by:
afterSetInput
in interfaceorg.eclipse.xtext.ui.editor.IXtextEditorCallback
- Overrides:
afterSetInput
in classorg.eclipse.xtext.ui.editor.IXtextEditorCallback.NullImpl
-
afterSelectionChange
protected void afterSelectionChange(org.eclipse.xtext.ui.editor.XtextEditor editor, org.eclipse.jface.viewers.ISelection selection) Notifies that the selection has changed in the editor.This implementation invokes
setHighlightRange(editor, selection)
if the selection is notnull
.- Parameters:
editor
- nevernull
selection
- may benull
or empty
-
setHighlightRange
protected void setHighlightRange(org.eclipse.xtext.ui.editor.XtextEditor editor, org.eclipse.jface.viewers.ISelection selection) Sets the highlighted range of the editor according to the selection.This implementation schedules a background job to set the highlight range asynchronously.
- Parameters:
editor
- nevernull
selection
- nevernull
-
getSourceFile
Returns the corresponding source file for the editor.This implementation uses the injected
IInputElementProvider
to obtain anIElement
corresponding to the editor input and returns theIElement
if it is anISourceFile
.- Parameters:
editor
- nevernull
- Returns:
- the corresponding source file, or
null
if none
-
getWorkingCopy
Returns the working copy that the editor is connected to, ornull
if the editor is not currently connected to a working copy.Note that multiple Xtext editor instances may simultaneously be open for a given source file, each with its own underlying document, but only one of them (the most recently used one) is connected to the source file's working copy.
- Parameters:
editor
- nevernull
- Returns:
- the working copy that the editor is connected to, or
null
if the editor is not currently connected to a working copy
-
acquireWorkingCopy
protected ISourceFile acquireWorkingCopy(org.eclipse.xtext.ui.editor.XtextEditor editor) throws org.eclipse.core.runtime.CoreException Attempts to acquire a working copy for the corresponding source file of the editor. A working copy acquired by this method must be released eventually via a call toreleaseWorkingCopy
.This implementation obtains the corresponding source file for the editor via
getSourceFile(XtextEditor)
and, if the source file implementsISourceFileImplExtension
, invokesbecomeWorkingCopy_
on it providing a working copy buffer backed by the editor and an Xtext-specific working copy callback, and returns the acquired working copy. Otherwise,null
is returned.- Parameters:
editor
- nevernull
- Returns:
- the acquired working copy, or
null
if no working copy can be acquired - Throws:
org.eclipse.core.runtime.CoreException
- if the working copy could not be acquired successfully
-
releaseWorkingCopy
protected void releaseWorkingCopy(org.eclipse.xtext.ui.editor.XtextEditor editor, ISourceFile workingCopy) Releases the given working copy that was acquired via a call toacquireWorkingCopy
.This implementation invokes
((ISourceFileImplExtension)workingCopy).
.releaseWorkingCopy_()
- Parameters:
editor
- nevernull
workingCopy
- nevernull
-