use of org.eclipse.ui.IEditorDescriptor 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(TTCNPPEDITORNOTFOUND);
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.IEditorDescriptor in project epp.mpc by eclipse.
the class AskMarketplaceForFileSupportStrategy method getEditorDescriptor.
public IEditorDescriptor getEditorDescriptor(final String fileName, final IEditorRegistry editorRegistry) throws CoreException, OperationCanceledException {
final IEditorDescriptor defaultDescriptor = createDefaultDescriptor(fileName, editorRegistry);
Job mpcJob = new DiscoverFileSupportJob(editorRegistry, defaultDescriptor, fileName);
mpcJob.setPriority(Job.INTERACTIVE);
mpcJob.setUser(false);
mpcJob.schedule();
return defaultDescriptor;
}
use of org.eclipse.ui.IEditorDescriptor in project webtools.sourceediting by eclipse.
the class WorkspaceFileHyperlink method getEditorLabel.
private String getEditorLabel() throws CoreException {
final IContentDescription description = fFile.getContentDescription();
final IEditorDescriptor defaultEditor = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(fFile.getName(), description != null ? description.getContentType() : null);
return defaultEditor != null ? defaultEditor.getLabel() : null;
}
use of org.eclipse.ui.IEditorDescriptor in project webtools.sourceediting by eclipse.
the class ExternalFileHyperlink method open.
public void open() {
if (fHyperlinkFile != null) {
IEditorInput input = new ExternalFileEditorInput(fHyperlinkFile);
IEditorDescriptor descriptor;
try {
descriptor = IDE.getEditorDescriptor(input.getName(), true);
if (descriptor != null) {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IDE.openEditor(page, input, descriptor.getId(), true);
}
} catch (PartInitException e) {
Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
}
}
}
use of org.eclipse.ui.IEditorDescriptor in project webtools.sourceediting by eclipse.
the class URLFileHyperlink method open.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.text.hyperlink.IHyperlink#open()
*/
public void open() {
if (fURL != null) {
IEditorInput input = new StorageEditorInput(new URLStorage(fURL));
IEditorDescriptor descriptor;
try {
descriptor = IDE.getEditorDescriptor(input.getName());
if (descriptor != null) {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IDE.openEditor(page, input, descriptor.getId(), true);
}
} catch (PartInitException e) {
Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
}
}
}
Aggregations