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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ISourceFileacquireWorkingCopy(org.eclipse.xtext.ui.editor.XtextEditor editor) Attempts to acquire a working copy for the corresponding source file of the editor.voidafterCreatePartControl(org.eclipse.xtext.ui.editor.XtextEditor editor) protected voidafterSelectionChange(org.eclipse.xtext.ui.editor.XtextEditor editor, org.eclipse.jface.viewers.ISelection selection) Notifies that the selection has changed in the editor.voidafterSetInput(org.eclipse.xtext.ui.editor.XtextEditor editor) voidbeforeDispose(org.eclipse.xtext.ui.editor.XtextEditor editor) voidbeforeSetInput(org.eclipse.xtext.ui.editor.XtextEditor editor) protected ISourceFilegetSourceFile(org.eclipse.xtext.ui.editor.XtextEditor editor) Returns the corresponding source file for the editor.protected final ISourceFilegetWorkingCopy(org.eclipse.xtext.ui.editor.XtextEditor editor) Returns the working copy that the editor is connected to, ornullif the editor is not currently connected to a working copy.protected voidreleaseWorkingCopy(org.eclipse.xtext.ui.editor.XtextEditor editor, ISourceFile workingCopy) Releases the given working copy that was acquired via a call toacquireWorkingCopy.protected voidsetHighlightRange(org.eclipse.xtext.ui.editor.XtextEditor editor, org.eclipse.jface.viewers.ISelection selection) Sets the highlighted range of the editor according to the selection.voidsetInputElementProvider(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:
afterCreatePartControlin interfaceorg.eclipse.xtext.ui.editor.IXtextEditorCallback- Overrides:
afterCreatePartControlin classorg.eclipse.xtext.ui.editor.IXtextEditorCallback.NullImpl
-
beforeDispose
public void beforeDispose(org.eclipse.xtext.ui.editor.XtextEditor editor) - Specified by:
beforeDisposein interfaceorg.eclipse.xtext.ui.editor.IXtextEditorCallback- Overrides:
beforeDisposein classorg.eclipse.xtext.ui.editor.IXtextEditorCallback.NullImpl
-
beforeSetInput
public void beforeSetInput(org.eclipse.xtext.ui.editor.XtextEditor editor) - Specified by:
beforeSetInputin interfaceorg.eclipse.xtext.ui.editor.IXtextEditorCallback- Overrides:
beforeSetInputin classorg.eclipse.xtext.ui.editor.IXtextEditorCallback.NullImpl
-
afterSetInput
public void afterSetInput(org.eclipse.xtext.ui.editor.XtextEditor editor) - Specified by:
afterSetInputin interfaceorg.eclipse.xtext.ui.editor.IXtextEditorCallback- Overrides:
afterSetInputin 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- nevernullselection- may benullor 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- nevernullselection- nevernull
-
getSourceFile
Returns the corresponding source file for the editor.This implementation uses the injected
IInputElementProviderto obtain anIElementcorresponding to the editor input and returns theIElementif it is anISourceFile.- Parameters:
editor- nevernull- Returns:
- the corresponding source file, or
nullif none
-
getWorkingCopy
Returns the working copy that the editor is connected to, ornullif 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
nullif 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,nullis returned.- Parameters:
editor- nevernull- Returns:
- the acquired working copy, or
nullif 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- nevernullworkingCopy- nevernull
-