org.eclipse.ui.internal.registry.EditorRegistry Java Examples
The following examples show how to use
org.eclipse.ui.internal.registry.EditorRegistry.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: N4JSApplicationWorkbenchWindowAdvisor.java From n4js with Eclipse Public License 1.0 | 6 votes |
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(); }
Example #2
Source File: Util.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
public static void resetDefaultEditor(String extension) { EditorRegistry editorRegistry = (EditorRegistry) PlatformUI.getWorkbench().getEditorRegistry(); IFileEditorMapping[] editorMappings = editorRegistry.getFileEditorMappings(); // Search the file=>editor mappings for the specified extension for (IFileEditorMapping editorMapping : editorMappings) { if (extension.equals(editorMapping.getExtension())) { FileEditorMapping internalMapping = (FileEditorMapping) editorMapping; // Only need to do anything if there's an explicit default set if (internalMapping.getDeclaredDefaultEditors().length > 0) { // Clear any default editor associations for this extension List<IEditorDescriptor> list = new ArrayList<IEditorDescriptor>(); internalMapping.setDefaultEditors(list); // Save the updated editor registry to disk editorRegistry.saveAssociations(); // TODO: remove GWTPluginLog.logInfo("Reset default editor for extension: " + extension); } break; } } }
Example #3
Source File: JavaDecompilerPlugin.java From jd-eclipse with GNU General Public License v3.0 | 4 votes |
public void run() { EditorRegistry registry = (EditorRegistry)WorkbenchPlugin.getDefault().getEditorRegistry(); IFileEditorMapping[] mappings = registry.getFileEditorMappings(); IFileEditorMapping c = null; IFileEditorMapping cws = null; // Search Class file editor mappings for (IFileEditorMapping mapping : mappings) { if (mapping.getExtension().equals("class")) { // ... Helios 3.6, Indigo 3.7, Juno 4.2, Kepler 4.3, ... c = mapping; } else if (mapping.getExtension().equals("class without source")) { // Juno 4.2, Kepler 4.3, ... cws = mapping; } } if ((c != null) && (cws != null)) { // Search JD editor descriptor on "class" extension for (IEditorDescriptor descriptor : c.getEditors()) { if (descriptor.getId().equals(EDITOR_ID)) { // Remove JD editor on "class" extension ((FileEditorMapping)c).removeEditor((EditorDescriptor)descriptor); // Set JD as default editor on "class without source" extension registry.setDefaultEditor("." + cws.getExtension(), descriptor.getId()); break; } } // Restore the default editor for "class" extension IEditorDescriptor defaultClassFileEditor = registry.findEditor(JavaUI.ID_CF_EDITOR); if (defaultClassFileEditor != null) { registry.setDefaultEditor("." + c.getExtension(), JavaUI.ID_CF_EDITOR); } registry.setFileEditorMappings((FileEditorMapping[]) mappings); registry.saveAssociations(); } }
Example #4
Source File: BonitaStudioWorkbenchAdvisor.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public void earlyStartup() { if (PlatformUtil.isHeadless()) { return;//Do not execute earlyStartup in headless mode } final IConfigurationElement[] elements = BonitaStudioExtensionRegistryManager.getInstance() .getConfigurationElements( "org.bonitasoft.studio.common.poststartup"); //$NON-NLS-1$ for (final IConfigurationElement elem : elements) { final Workbench workbench = (Workbench) PlatformUI.getWorkbench(); try { IPostStartupContribution contrib = (IPostStartupContribution) ContextInjectionFactory .make(Platform.getBundle(elem.getDeclaringExtension().getNamespaceIdentifier()) .loadClass(elem.getAttribute("class")), workbench.getContext()); Display.getDefault().asyncExec(contrib::execute); } catch (InjectionException | ClassNotFoundException | InvalidRegistryObjectException e) { BonitaStudioLog.error(e); } } preLoad(); // Fix issue with asciidoctor plugin overriding text content-type final EditorRegistry editorRegistry = (EditorRegistry) WorkbenchPlugin.getDefault().getEditorRegistry(); IFileEditorMapping[] fileEditorMappings = editorRegistry.getFileEditorMappings(); List<IFileEditorMapping> mappings = Stream.of(fileEditorMappings).collect(Collectors.toList()); FileEditorMapping mapping = new FileEditorMapping("*", "log"); mapping.setDefaultEditor(editorRegistry.findEditor("org.eclipse.ui.DefaultTextEditor")); mappings.add(mapping); Display.getDefault().asyncExec(()-> editorRegistry.setFileEditorMappings(mappings.toArray(new FileEditorMapping[] {}))); editorRegistry.setDefaultEditor("*.txt", "org.eclipse.ui.DefaultTextEditor"); final long startupDuration = System.currentTimeMillis() - BonitaStudioApplication.START_TIME; BonitaStudioLog.info("Startup duration : " + DateUtil.getDisplayDuration(startupDuration), ApplicationPlugin.PLUGIN_ID); ApplicationPlugin.getDefault().getPreferenceStore().setDefault(FIRST_STARTUP, true); if (isFirstStartup()) { new OpenReleaseNoteHandler().setFocus(false).asView().openBrowser(); } ApplicationPlugin.getDefault().getPreferenceStore().setValue(FIRST_STARTUP, false); }