Package org.eclipse.ui.internal.registry

Examples of org.eclipse.ui.internal.registry.EditorRegistry


        }
      }
      Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
      shell.setCursor(busy);
      // Get the external editors available
      EditorRegistry reg = (EditorRegistry) WorkbenchPlugin.getDefault()
          .getEditorRegistry();
      externalEditors = reg.getSortedEditorsFromOS();
      externalEditors = filterEditors(externalEditors);
      externalEditorImages = getImages(externalEditors);
      // Clean up
      shell.setCursor(null);
      busy.dispose();
View Full Code Here


  /**
   * Returns the internal editors
   */
  protected IEditorDescriptor[] getInternalEditors() {
    if (internalEditors == null) {
      EditorRegistry reg = (EditorRegistry) WorkbenchPlugin.getDefault()
          .getEditorRegistry();
      internalEditors = reg.getSortedEditorsFromPlugins();
      internalEditors = filterEditors(internalEditors);
      internalEditorImages = getImages(internalEditors);
    }
    return internalEditors;
  }
View Full Code Here

     * by this plug-in.
     */

    public IEditorRegistry getEditorRegistry() {
        if (editorRegistry == null) {
            editorRegistry = new EditorRegistry();
        }
        return editorRegistry;
    }
View Full Code Here

    // Update the file associations if they have changed due to an import
    if (IPreferenceConstants.RESOURCES.equals(propertyName)) {
      IEditorRegistry registry = WorkbenchPlugin.getDefault()
          .getEditorRegistry();
      if (registry instanceof EditorRegistry) {
        EditorRegistry editorRegistry = (EditorRegistry) registry;
        IPreferenceStore store = WorkbenchPlugin.getDefault()
            .getPreferenceStore();
        Reader reader = null;
        try {
          String xmlString = store
              .getString(IPreferenceConstants.RESOURCES);
          if (xmlString != null && xmlString.length() > 0) {
            reader = new StringReader(xmlString);
            // Build the editor map.
            HashMap editorMap = new HashMap();
            int i = 0;
            IEditorDescriptor[] descriptors = editorRegistry
                .getSortedEditorsFromPlugins();
            // Get the internal editors
            for (i = 0; i < descriptors.length; i++) {
              IEditorDescriptor descriptor = descriptors[i];
              editorMap.put(descriptor.getId(), descriptor);
            }
            // Get the external (OS) editors
            descriptors = editorRegistry.getSortedEditorsFromOS();
            for (i = 0; i < descriptors.length; i++) {
              IEditorDescriptor descriptor = descriptors[i];
              editorMap.put(descriptor.getId(), descriptor);
            }
            // Update the file to editor(s) mappings
            editorRegistry.readResources(editorMap, reader);
          }
        } catch (WorkbenchException e) {
          e.printStackTrace();
        } finally {
          if (reader != null) {
View Full Code Here

                }
                item.setImage(getImage(editor));
            }
           
            // now add any content type editors
      EditorRegistry registry = (EditorRegistry) WorkbenchPlugin
          .getDefault().getEditorRegistry();
      IContentType[] contentTypes = Platform.getContentTypeManager()
          .findContentTypesFor(resourceType.getLabel());
      for (int i = 0; i < contentTypes.length; i++) {
        array = registry.getEditorsForContentType(contentTypes[i]);
        for (int j = 0; j < array.length; j++) {
          IEditorDescriptor editor = array[j];
          // don't add duplicates
          TableItem[] items = editorTable.getItems();
          TableItem foundItem = null;
View Full Code Here

        TableItem[] items = resourceTypeTable.getItems();
        FileEditorMapping[] resourceTypes = new FileEditorMapping[items.length];
        for (int i = 0; i < items.length; i++) {
            resourceTypes[i] = (FileEditorMapping) (items[i].getData());
        }
        EditorRegistry registry = (EditorRegistry) WorkbenchPlugin.getDefault()
                .getEditorRegistry(); // cast to allow save to be called
        registry.setFileEditorMappings(resourceTypes);
        registry.saveAssociations();
       
        PrefUtil.savePrefs();
        return true;
    }
View Full Code Here

    }
    return isAJEditorDefault;
  }

  private void makeAJEditorDefault() {
    EditorRegistry registry = (EditorRegistry) PlatformUI.getWorkbench().getEditorRegistry();

    IFileEditorMapping[] mappings = registry.getFileEditorMappings();
    for (IFileEditorMapping mapping : mappings) {
      if (mapping.getExtension().equals("java")) {
        if (mapping instanceof FileEditorMapping) {
          IEditorDescriptor desc = registry.findEditor(AspectJEditor.ASPECTJ_EDITOR_ID);
          ((FileEditorMapping) mapping).setDefaultEditor((EditorDescriptor) desc);
        }
      }
    }
    registry.setFileEditorMappings((FileEditorMapping[]) mappings);
    registry.saveAssociations();
  }
View Full Code Here

  private static class SetupClassFileAssociationRunnable implements Runnable
  {
    public void run()
    {
      EditorRegistry registry = (EditorRegistry) PlatformUI.getWorkbench()
          .getEditorRegistry();

      // Will not work because this will not persist across sessions
      // registry.setDefaultEditor("*.class", id);

      IFileEditorMapping[] mappings = registry.getFileEditorMappings();

      // Search Class file editor mappings
      IFileEditorMapping classNoSource = null;
      IFileEditorMapping classPlain = null;
      for (IFileEditorMapping mapping : mappings)
      {
        if (mapping.getExtension().equals("class without source"))
        {
          classNoSource = mapping;
        }
        else if (mapping.getExtension().equals("class"))
        {
          classPlain = mapping;
        }
      }
      IEditorDescriptor jdtClassViewer = registry.findEditor(JDT_EDITOR_ID);

      // * If there is a "class without source" type - handle this and revert
      // "class" to the default handler.
      // * Else register as the default handler for "class"

      if (classNoSource != null)
      {
        // Got a "class without source" type - default to handle this and
        // un-default from the "class" type
        registry.setDefaultEditor("." + classNoSource.getExtension(),
            EDITOR_ID);

        if (classPlain != null)
        {
          if (jdtClassViewer != null)
          {
            // Restore the default class viewer as the default
            // "class with source" viewer
            registry.setDefaultEditor("." + classPlain.getExtension(),
                JDT_EDITOR_ID);
          }

          for (IEditorDescriptor editorDesc : classPlain.getEditors())
          {
            if (editorDesc.getId().startsWith(JD_EDITOR_ID))
            {
              // Unmap the default JD Eclipse editor
              ((FileEditorMapping) classPlain)
                  .removeEditor((EditorDescriptor) editorDesc);
            }
          }
        }
      }
      else if (classPlain != null)
      {
        // Only got a class file type - default to decompile this
        registry.setDefaultEditor("." + classPlain.getExtension(), EDITOR_ID);
      }

      // Save updates
      registry.setFileEditorMappings((FileEditorMapping[]) mappings);
      registry.saveAssociations();
    }
View Full Code Here

TOP

Related Classes of org.eclipse.ui.internal.registry.EditorRegistry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.