use of org.eclipse.ui.texteditor.AbstractTextEditor in project titan.EclipsePlug-ins by eclipse.
the class OpenDeclaration method selectAndRevealRegion.
/**
* Opens an editor for the provided declaration, and in this editor the
* location of the declaration is revealed and highlighted.
*
* @param file
* The file to open.
* @param offset
* The start position of the declaration to select.
* @param endOffset
* The end position of the declaration to select.
* @param select
* Select the given region if true.
*/
private void selectAndRevealRegion(final IFile file, final int offset, final int endOffset, final boolean select) {
IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
if (desc == null) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(EDITORNOTFOUND);
return;
}
if (!select) {
return;
}
try {
IWorkbenchPage page = targetEditor.getSite().getPage();
IEditorPart editorPart = page.openEditor(new FileEditorInput(file), desc.getId());
if (editorPart != null) {
// not AbstractTextEditor.
if (editorPart instanceof ConfigEditor) {
((AbstractTextEditor) ((ConfigEditor) editorPart).getEditor()).selectAndReveal(offset, endOffset - offset);
} else if (editorPart instanceof AbstractTextEditor) {
((AbstractTextEditor) editorPart).selectAndReveal(offset, endOffset - offset);
}
}
} catch (PartInitException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
use of org.eclipse.ui.texteditor.AbstractTextEditor in project titan.EclipsePlug-ins by eclipse.
the class OpenDeclaration method selectAndRevealDeclaration.
/**
* Opens an editor for the provided declaration, and in this editor the
* location of the declaration is revealed and selected.
*
* @param declaration
* the declaration to reveal
*/
private void selectAndRevealDeclaration(final Location location) {
IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(location.getFile().getName());
if (desc == null) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(ASN1EDITORNOTFOUND);
return;
}
try {
IWorkbenchPage page = targetEditor.getSite().getPage();
IEditorPart editorPart = page.openEditor(new FileEditorInput((IFile) location.getFile()), desc.getId());
if (editorPart != null && (editorPart instanceof AbstractTextEditor)) {
((AbstractTextEditor) editorPart).selectAndReveal(location.getOffset(), location.getEndOffset() - location.getOffset());
}
} catch (PartInitException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
use of org.eclipse.ui.texteditor.AbstractTextEditor in project xtext-eclipse by eclipse.
the class TextChangeCombinerTest method openInEditor.
protected ITextEditor openInEditor(IFile file) throws PartInitException {
FileEditorInput fileEditorInput = new FileEditorInput(file);
AbstractTextEditor editor = (AbstractTextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(fileEditorInput, "org.eclipse.ui.DefaultTextEditor");
return editor;
}
Aggregations