Package org.eclipse.ui

Examples of org.eclipse.ui.IFileEditorMapping


    /**
     * Visually checks the previously-specified elements in this dialog's list
     * viewer.
     */
    private void checkInitialSelections() {
        IFileEditorMapping editorMappings[] = ((EditorRegistry) PlatformUI
        .getWorkbench().getEditorRegistry()).getUnifiedMappings();
        ArrayList selectedMappings = new ArrayList();
        for (int i = 0; i < editorMappings.length; i++) {
            IFileEditorMapping mapping = editorMappings[i];
            //Check for both extension and label matches
            if (this.initialSelections.contains(mapping.getExtension())) {
                listViewer.setChecked(mapping, true);
                selectedMappings.add(mapping.getExtension());
            } else {
                if (this.initialSelections.contains(mapping.getLabel())) {
                    listViewer.setChecked(mapping, true);
                    selectedMappings.add(mapping.getLabel());
                }
            }
        }
        //Now add in the ones not selected to the user defined list
        Iterator initialIterator = this.initialSelections.iterator();
View Full Code Here


        // Get the input children.
        IFileEditorMapping[] children = getInput();
        List list = new ArrayList();
        // Build a list of selected children.
        for (int i = 0; i < children.length; ++i) {
            IFileEditorMapping element = children[i];
            if (listViewer.getChecked(element)) {
        list.add(element.getExtension());
      }
        }
        addUserDefinedEntries(list);
        setResult(list);
        super.okPressed();
View Full Code Here

      String [] extensions = type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
      for (int j = 0; j < extensions.length; j++) {
        String extension = extensions[j];
        boolean found = false;
        for (Iterator k = allMappings.iterator(); k.hasNext();) {
          IFileEditorMapping mapping = (IFileEditorMapping) k.next();
          if ("*".equals(mapping.getName()) && extension.equals(mapping.getExtension())) { //$NON-NLS-1$
            found = true;
            break;
          }
        }
        if (!found) {
          MockMapping mockMapping = new MockMapping(type, "*", extension); //$NON-NLS-1$
          allMappings.add(mockMapping);
        }
      }
   
      String [] filenames = type.getFileSpecs(IContentType.FILE_NAME_SPEC);
      for (int j = 0; j < filenames.length; j++) {
        String wholename = filenames[j];
        int idx = wholename.indexOf('.');       
        String name = idx == -1 ? wholename : wholename.substring(0, idx);
        String extension = idx == -1 ? "" : wholename.substring(idx + 1); //$NON-NLS-1$
       
        boolean found = false;
        for (Iterator k = allMappings.iterator(); k.hasNext();) {
          IFileEditorMapping mapping = (IFileEditorMapping) k.next();
          if (name.equals(mapping.getName()) && extension.equals(mapping.getExtension())) {
            found = true;
            break;
          }
        }
        if (!found) {
View Full Code Here

         * Return the objects related to the filename
         * @param fileName
         * @return the objects related to the filename
     */
    public IEditorDescriptor[] getRelatedObjects(String fileName) {
      IFileEditorMapping mapping = getMappingFor(fileName);
      if (mapping == null) {
        return EMPTY;
      }
     
      return mapping.getEditors();
    }
View Full Code Here

        }

        // Find the index at which to insert the new entry.
        String newFilename = (newName + (newExtension == null
                || newExtension.length() == 0 ? "" : "." + newExtension)).toUpperCase();//$NON-NLS-1$ //$NON-NLS-2$
        IFileEditorMapping resourceType;
        TableItem[] items = resourceTypeTable.getItems();
        boolean found = false;
        int i = 0;

        while (i < items.length && !found) {
            resourceType = (IFileEditorMapping) items[i].getData();
            int result = newFilename.compareToIgnoreCase(resourceType
                    .getLabel());
            if (result == 0) {
                // Same resource type not allowed!
                MessageDialog
                        .openInformation(
View Full Code Here

      // 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.IFileEditorMapping

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.