use of org.eclipse.ui.IEditorDescriptor in project tesb-studio-se by Talend.
the class RouteResourceEditorUtil method findPreferEditor.
/**
* find a prefer editor from all existing editors according to the
* fileExtensions
*
* @param fileExtension
* @return
*/
private String findPreferEditor(RouteResourceInput fileEditorInput) {
String editorId = RouteResourceEditor.ID;
Object underlingFile = fileEditorInput.getAdapter(IFile.class);
if (underlingFile == null) {
return editorId;
}
IEditorDescriptor ed = null;
try {
ed = IDE.getEditorDescriptor((IFile) underlingFile, true);
} catch (PartInitException e) {
return editorId;
}
if (ed == null) {
return editorId;
}
String id = ed.getId();
if (id == null || id.trim() == null) {
return editorId;
}
return id;
}
use of org.eclipse.ui.IEditorDescriptor in project translationstudio8 by heartsome.
the class XLIFFEditor method init.
/**
* 启动编辑器。
*
* @param site
* the site
* @param input
* the input
* @throws PartInitException
* the part init exception
* @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite,
* org.eclipse.ui.IEditorInput)
*/
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("init(IEditorSite site, IEditorInput input)");
}
setSite(site);
setInput(input);
// 设置Editor标题栏的显示名称,否则名称用plugin.xml中的name属性
setPartName(input.getName());
Image oldTitleImage = titleImage;
if (input != null) {
IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId());
ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null;
titleImage = imageDesc != null ? imageDesc.createImage() : null;
}
setTitleImage(titleImage);
if (oldTitleImage != null && !oldTitleImage.isDisposed()) {
oldTitleImage.dispose();
}
getSite().setSelectionProvider(this);
}
use of org.eclipse.ui.IEditorDescriptor in project xtext-eclipse by eclipse.
the class ClassFileBasedOpenerContributor method collectSourceFileOpeners.
@Override
public boolean collectSourceFileOpeners(IEditorPart editor, IAcceptor<FileOpener> acceptor) {
if (!(editor instanceof XtextEditor) && editor.getEditorInput() != null) {
try {
IClassFile classFile = (IClassFile) editor.getEditorInput().getAdapter(IClassFile.class);
if (classFile == null) {
return false;
}
ITrace trace = traceForTypeRootProvider.getTraceToSource(classFile);
if (trace == null) {
return false;
}
for (ILocationInResource location : trace.getAllAssociatedLocations()) {
String name = location.getAbsoluteResourceURI().getURI().lastSegment();
IEditorDescriptor editorDescriptor = IDE.getEditorDescriptor(name);
acceptor.accept(createEditorOpener(editor.getEditorInput(), editorDescriptor.getId()));
return true;
}
} catch (PartInitException e) {
LOG.error(e.getMessage(), e);
}
}
return false;
}
use of org.eclipse.ui.IEditorDescriptor in project xtext-eclipse by eclipse.
the class OriginalEditorSelector method getXtextEditor.
protected IEditorDescriptor getXtextEditor(URI uri) {
IResourceServiceProvider serviceProvider = resourceServiceProviderRegistry.getResourceServiceProvider(uri);
if (serviceProvider != null) {
XtextEditorInfo editorInfo = serviceProvider.get(XtextEditorInfo.class);
if (editorInfo != null) {
IEditorRegistry editorRegistry = workbench.getEditorRegistry();
IEditorDescriptor result = editorRegistry.findEditor(editorInfo.getEditorId());
// null is ok
return result;
}
}
return null;
}
use of org.eclipse.ui.IEditorDescriptor in project xtext-eclipse by eclipse.
the class XtextEditor method getDefaultImage.
@Override
public Image getDefaultImage() {
IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId());
ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null;
return imageDesc != null ? imageHelper.getImage(imageDesc) : super.getDefaultImage();
}
Aggregations