public class HandlyXtextEditorCallback
extends org.eclipse.xtext.ui.editor.IXtextEditorCallback.NullImpl
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
}
| Constructor and Description |
|---|
HandlyXtextEditorCallback() |
| Modifier and Type | Method and Description |
|---|---|
protected 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 ISourceFile |
getWorkingCopy(org.eclipse.xtext.ui.editor.XtextEditor editor)
Returns the working copy that the editor is connected to, or
null
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 to
acquireWorkingCopy. |
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) |
@Inject public void setInputElementProvider(IInputElementProvider provider)
public void afterCreatePartControl(org.eclipse.xtext.ui.editor.XtextEditor editor)
afterCreatePartControl in interface org.eclipse.xtext.ui.editor.IXtextEditorCallbackafterCreatePartControl in class org.eclipse.xtext.ui.editor.IXtextEditorCallback.NullImplpublic void beforeDispose(org.eclipse.xtext.ui.editor.XtextEditor editor)
beforeDispose in interface org.eclipse.xtext.ui.editor.IXtextEditorCallbackbeforeDispose in class org.eclipse.xtext.ui.editor.IXtextEditorCallback.NullImplpublic void beforeSetInput(org.eclipse.xtext.ui.editor.XtextEditor editor)
beforeSetInput in interface org.eclipse.xtext.ui.editor.IXtextEditorCallbackbeforeSetInput in class org.eclipse.xtext.ui.editor.IXtextEditorCallback.NullImplpublic void afterSetInput(org.eclipse.xtext.ui.editor.XtextEditor editor)
afterSetInput in interface org.eclipse.xtext.ui.editor.IXtextEditorCallbackafterSetInput in class org.eclipse.xtext.ui.editor.IXtextEditorCallback.NullImplprotected void afterSelectionChange(org.eclipse.xtext.ui.editor.XtextEditor editor,
org.eclipse.jface.viewers.ISelection selection)
This implementation invokes setHighlightRange(editor, selection)
if the selection is not null.
editor - never nullselection - may be null or emptyprotected void setHighlightRange(org.eclipse.xtext.ui.editor.XtextEditor editor,
org.eclipse.jface.viewers.ISelection selection)
This implementation schedules a background job to set the highlight range asynchronously.
editor - never nullselection - never nullprotected ISourceFile getSourceFile(org.eclipse.xtext.ui.editor.XtextEditor editor)
This implementation uses the injected IInputElementProvider
to obtain an IElement corresponding to the editor input
and returns the IElement if it is an ISourceFile.
editor - never nullnull if noneprotected final ISourceFile getWorkingCopy(org.eclipse.xtext.ui.editor.XtextEditor editor)
null
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.
editor - never nullnull
if the editor is not currently connected to a working copyprotected ISourceFile acquireWorkingCopy(org.eclipse.xtext.ui.editor.XtextEditor editor) throws org.eclipse.core.runtime.CoreException
releaseWorkingCopy.
This implementation obtains the corresponding source file for the
editor via getSourceFile(XtextEditor) and, if the source file
implements ISourceFileImplExtension, invokes becomeWorkingCopy_ 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.
editor - never nullnull
if no working copy can be acquiredorg.eclipse.core.runtime.CoreException - if the working copy could not be acquired successfullyprotected void releaseWorkingCopy(org.eclipse.xtext.ui.editor.XtextEditor editor,
ISourceFile workingCopy)
acquireWorkingCopy.
This implementation invokes ((ISourceFileImplExtension)workingCopy)..
releaseWorkingCopy_()
editor - never nullworkingCopy - never nullCopyright (c) 2014, 2020 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0