Package org.eclipse.ui

Examples of org.eclipse.ui.IEditorDescriptor


    }

    // Phase 1: check editors that have their own matching strategy
    for (Iterator i = editorList.iterator(); i.hasNext();) {
      EditorReference editor = (EditorReference) i.next();
      IEditorDescriptor desc = editor.getDescriptor();
      if (desc != null) {
        IEditorMatchingStrategy matchingStrategy = desc
            .getEditorMatchingStrategy();
        if (matchingStrategy != null) {
          i.remove(); // We're handling this one here, so remove it
          // from the list.
          if (matchingStrategy.matches(editor, input)) {
View Full Code Here


                String itemName = item.getName();
                if (!item.isRestored()) {
                    item.restoreState();
                }
                IEditorInput input = item.getInput();
                IEditorDescriptor desc = item.getDescriptor();
                if (input == null || desc == null) {
                    String title = WorkbenchMessages.OpenRecent_errorTitle;
                    String msg = NLS.bind(WorkbenchMessages.OpenRecent_unableToOpen,  itemName );
                    MessageDialog.openWarning(window.getShell(), title, msg);
                    history.remove(item);
                } else {
                    page.openEditor(input, desc.getId());
                }
            } catch (PartInitException e2) {
                String title = WorkbenchMessages.OpenRecent_errorTitle;
                MessageDialog.openWarning(window.getShell(), title, e2
                        .getMessage());
View Full Code Here

    /**
     * Add external editors to the editor mapping.
     */
    private void addExternalEditorsToEditorMap() {
        IEditorDescriptor desc = null;

        // Add registered editors (may include external editors).
        FileEditorMapping maps[] = typeEditorMappings.allMappings();
        for (int i = 0; i < maps.length; i++) {
            FileEditorMapping map = maps[i];
            IEditorDescriptor[] descArray = map.getEditors();
            for (int n = 0; n < descArray.length; n++) {
                desc = descArray[n];
                mapIDtoEditor.put(desc.getId(), desc);
            }
        }
    }
View Full Code Here

     *       The editor descriptor
     * @return <code>true</code> if the editors list contains the editor descriptor
     */
    private boolean contains(List editorsArray,
            IEditorDescriptor editorDescriptor) {
        IEditorDescriptor currentEditorDescriptor = null;
        Iterator i = editorsArray.iterator();
        while (i.hasNext()) {
            currentEditorDescriptor = (IEditorDescriptor) i.next();
            if (currentEditorDescriptor.getId()
                    .equals(editorDescriptor.getId())) {
        return true;
      }
        }
        return false;
View Full Code Here

    /**
     * Rebuild the internal editor mapping.
     */
    private void rebuildInternalEditorMap() {
        Iterator itr = null;
        IEditorDescriptor desc = null;

        // Allocate a new map.
        mapIDtoEditor = initialIdToEditorMap(mapIDtoEditor.size());

        // Add plugin editors.
        itr = sortedEditorsFromPlugins.iterator();
        while (itr.hasNext()) {
            desc = (IEditorDescriptor) itr.next();
            mapIDtoEditor.put(desc.getId(), desc);
        }
    }
View Full Code Here

   * @return the editor for a file with a given content type
   * @since 3.1
   */
  private IEditorDescriptor getEditorForContentType(String filename,
      IContentType contentType) {
    IEditorDescriptor desc = null;
    Object[] contentTypeResults = findRelatedObjects(contentType, filename, relatedRegistry);
    if (contentTypeResults != null && contentTypeResults.length > 0) {
      desc = (IEditorDescriptor) contentTypeResults[0];
    }
    return desc;
View Full Code Here

        if (filename == null) {
      return getDefaultImage();
    }

    if (contentType != null) {
      IEditorDescriptor desc = getEditorForContentType(filename, contentType);
      if (desc != null) {
        ImageDescriptor anImage = (ImageDescriptor) extensionImages.get(desc)
        if (anImage != null) {
          return anImage;
        }
        anImage = desc.getImageDescriptor();
        extensionImages.put(desc, anImage);
        return anImage;       
      }
    }
        // Lookup in the cache first...
        String key = mappingKeyFor(filename);
        ImageDescriptor anImage = (ImageDescriptor) extensionImages.get(key);
        if (anImage != null) {
      return anImage;
    }

        // See if we have a mapping for the filename or extension
        FileEditorMapping[] mapping = getMappingForFilename(filename);
        for (int i = 0; i < 2; i++) {
            if (mapping[i] != null) {
                // Lookup in the cache first...
                String mappingKey = mappingKeyFor(mapping[i]);
                ImageDescriptor mappingImage = (ImageDescriptor) extensionImages
                        .get(key);
                if (mappingImage != null) {
          return mappingImage;
        }
                // Create it and cache it
                IEditorDescriptor editor = mapping[i].getDefaultEditor();
                if (editor != null) {
                    mappingImage = editor.getImageDescriptor();
                    extensionImages.put(mappingKey, mappingImage);
                    return mappingImage;
                }
            }
        }
View Full Code Here

      }
    }
     
    // add all non-default editors to the list
    for (Iterator i = nonDefaultFileEditors.iterator(); i.hasNext();) {
      IEditorDescriptor editor = (IEditorDescriptor) i.next();
      if (!allRelated.contains(editor) && !WorkbenchActivityHelper.filterItem(editor)) {
        allRelated.add(editor);
      }
    }
   
View Full Code Here

        editorTable.removeAll();
        FileEditorMapping resourceType = getSelectedResourceType();
        if (resourceType != null) {
            IEditorDescriptor[] array = resourceType.getEditors();
            for (int i = 0; i < array.length; i++) {
                IEditorDescriptor editor = array[i];
                TableItem item = new TableItem(editorTable, SWT.NULL);
                item.setData(DATA_EDITOR, editor);
                // Check if it is the default editor
                String defaultString = null;
                if (resourceType != null) {
                    if (resourceType.getDefaultEditor() == editor && resourceType.isDeclaredDefaultEditor(editor)) {
            defaultString = WorkbenchMessages.FileEditorPreference_defaultLabel;
          }
                }

                if (defaultString != null) {
                    item.setText(editor.getLabel() + " " + defaultString); //$NON-NLS-1$
                } else {
                    item.setText(editor.getLabel());
                }
                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;
          for (int k = 0; k < items.length; k++) {
            if (items[k].getData(DATA_EDITOR).equals(editor)) {
              foundItem = items[k];
              break;
            }
          }
          if (foundItem == null) {
            TableItem item = new TableItem(editorTable, SWT.NULL);
            item.setData(DATA_EDITOR, editor);
            item.setData(DATA_FROM_CONTENT_TYPE, contentTypes[i]);
            setLockedItemText(item, editor.getLabel());
            item.setImage(getImage(editor));
          } else { // update the item to reflect its origin
            foundItem.setData(DATA_FROM_CONTENT_TYPE, contentTypes[i]);
            setLockedItemText(foundItem, foundItem.getText());
          }
View Full Code Here

    }

    private static String getEditorId(File file) {
        IWorkbench workbench = PlatformUI.getWorkbench();
        IEditorRegistry editorRegistry = workbench.getEditorRegistry();
        IEditorDescriptor descriptor = editorRegistry.getDefaultEditor(file.getName(), getContentType(file));
        if (descriptor != null) {
            return descriptor.getId();
        }
        return EditorsUI.DEFAULT_TEXT_EDITOR_ID;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.ui.IEditorDescriptor

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.