use of org.eclipse.ui.IEditorDescriptor in project webtools.sourceediting by eclipse.
the class TaglibJarHyperlink method open.
public void open() {
// $NON-NLS-1$
IEditorInput input = new URLFileHyperlink.StorageEditorInput(new ZipStorage(fZipFilePath.toFile(), "META-INF/taglib.tld"));
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);
}
}
use of org.eclipse.ui.IEditorDescriptor in project webtools.sourceediting by eclipse.
the class AbstractOpenOn method getEditorId.
/**
* Determines the editor associated with the given file name
*
* @param filename
* @return editor id of the editor associated with the given file name
*/
private String getEditorId(String filename) {
IWorkbench workbench = PlatformUI.getWorkbench();
IEditorRegistry editorRegistry = workbench.getEditorRegistry();
IEditorDescriptor descriptor = editorRegistry.getDefaultEditor(filename);
if (descriptor != null)
return descriptor.getId();
return EditorsUI.DEFAULT_TEXT_EDITOR_ID;
}
use of org.eclipse.ui.IEditorDescriptor in project n4js by eclipse.
the class N4JSApplicationWorkbenchWindowAdvisor method updateDefaultEditorMappingIfAbsent.
private void updateDefaultEditorMappingIfAbsent() {
final EditorRegistry registry = (EditorRegistry) WorkbenchPlugin.getDefault().getEditorRegistry();
for (final IFileEditorMapping editorMapping : registry.getFileEditorMappings()) {
final IEditorDescriptor defaultEditor = editorMapping.getDefaultEditor();
if (null == defaultEditor) {
final String extension = editorMapping.getExtension();
LOGGER.info("No default editor is associated with files with extension: '." + extension + "'.");
final IEditorDescriptor defaultTextEditor = registry.findEditor(DEFAULT_TEXT_EDITOR_ID);
if (null != defaultTextEditor) {
((FileEditorMapping) editorMapping).setDefaultEditor(defaultTextEditor);
String editorName = defaultTextEditor.getLabel();
if (null == editorName) {
editorName = defaultTextEditor.getId();
}
if (null != editorName) {
LOGGER.info("Associated files with extension " + extension + " with '" + editorName + "'.");
}
}
}
}
registry.saveAssociations();
PrefUtil.savePrefs();
}
use of org.eclipse.ui.IEditorDescriptor in project liferay-ide by liferay.
the class DefaultScriptEditorHelper method getEditorId.
public String getEditorId() {
IContentType contentType = Platform.getContentTypeManager().getContentType("org.eclipse.core.runtime.text");
IWorkbench workBench = PlatformUI.getWorkbench();
IEditorRegistry editRegistry = workBench.getEditorRegistry();
IEditorDescriptor defaultEditorDescriptor = editRegistry.getDefaultEditor("default.txt", contentType);
return defaultEditorDescriptor.getId();
}
use of org.eclipse.ui.IEditorDescriptor in project liferay-ide by liferay.
the class OpenPortletResourceAction method findEditor.
/**
* @param file
* @return
*/
protected IEditorDescriptor findEditor(IFile file) {
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
IContentType contentType = IDE.getContentType(file);
IEditorDescriptor editorDescriptor = registry.getDefaultEditor(file.getName(), contentType);
if (editorDescriptor == null) {
// no editor associated...
return null;
}
return editorDescriptor;
}
Aggregations