public static IEditingModel getOpenModel(IDocument doc) {
    Iterator it = fOpenPDEEditors.values().iterator();
    while (it.hasNext()) {
      ArrayList list = (ArrayList) it.next();
      for (int i = 0; i < list.size(); i++) {
        PDEFormEditor e = (PDEFormEditor) list.get(i);
        IPluginModelBase model = (IPluginModelBase) e.getAggregateModel();
        if (model instanceof IBundlePluginModelBase) {
          IBundleModel bModel = ((IBundlePluginModelBase) model).getBundleModel();
          if (bModel instanceof IEditingModel && doc == ((IEditingModel) bModel).getDocument())
            return (IEditingModel) bModel;
          ISharedExtensionsModel eModel = ((IBundlePluginModelBase) model).getExtensionsModel();
          if (eModel instanceof IEditingModel && doc == ((IEditingModel) eModel).getDocument())
            return (IEditingModel) eModel;
        }

        //				IBuildModel bModel = model.getBuildModel();
        //				if (bModel instanceof IEditingModel &&
        //						doc == ((IEditingModel)bModel).getDocument())
        //					return (IEditingModel)bModel;

        if (model instanceof IEditingModel && doc == ((IEditingModel) model).getDocument())
          return (IEditingModel) model;
      }
    }
    return null;
  }
  public void addSelectedFilesToTargetList() {
    ISelection selection = sourceFileViewer.getSelection();

    if (isValidSourceFileViewerSelection(selection)) {
      java.util.List list = null;
      if (selection instanceof IStructuredSelection) {
        list = ((IStructuredSelection) selection).toList();

        if (list != null) {
          list = ((IStructuredSelection) selection).toList();
          for (Iterator i = list.iterator(); i.hasNext(); ) {
            IResource resource = (IResource) i.next();
            if (resource instanceof IFile) {
              // Check if its in the list. Don't add it if it is.
              String resourceName = resource.getFullPath().toString();
              if (selectedListBox.indexOf(resourceName) == -1) selectedListBox.add(resourceName);
            }
          }
          setFiles(selectedListBox.getItems());
        }

        setAddButtonEnabled(false);

        if (selectedListBox.getItemCount() > 0) {
          removeAllButton.setEnabled(true);
          if (isFileMandatory) setPageComplete(true);
          if (selectedListBox.getSelectionCount() > 0) setRemoveButtonEnabled(true);
          else setRemoveButtonEnabled(false);
        }
      }
    }
  }
 /** Dispose the receiver and clear out the references. */
 public void dispose() {
   final IHandlerService handlerService =
       (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
   final Iterator iterator = activations.iterator();
   while (iterator.hasNext()) {
     handlerService.deactivateHandler((IHandlerActivation) iterator.next());
   }
   activations.clear();
 }
  public XMLComparePreferencePage() {
    super();

    fIdMaps = new HashMap();
    XMLPlugin plugin = XMLPlugin.getDefault();
    HashMap PluginIdMaps = plugin.getIdMaps();
    Set keySet = PluginIdMaps.keySet();
    for (Iterator iter = keySet.iterator(); iter.hasNext(); ) {
      String key = (String) iter.next();
      fIdMaps.put(key, ((HashMap) PluginIdMaps.get(key)).clone());
    }
    fIdMapsInternal = plugin.getIdMapsInternal();

    fIdExtensionToName = new HashMap();
    HashMap PluginIdExtensionToName = plugin.getIdExtensionToName();
    keySet = PluginIdExtensionToName.keySet();
    for (Iterator iter = keySet.iterator(); iter.hasNext(); ) {
      String key = (String) iter.next();
      fIdExtensionToName.put(key, PluginIdExtensionToName.get(key));
    }

    fOrderedElements = new HashMap();
    HashMap PluginOrderedElements = plugin.getOrderedElements();
    keySet = PluginOrderedElements.keySet();
    for (Iterator iter = keySet.iterator(); iter.hasNext(); ) {
      String key = (String) iter.next();
      fOrderedElements.put(key, ((ArrayList) PluginOrderedElements.get(key)).clone());
    }

    fOrderedElementsInternal = plugin.getOrderedElementsInternal();
  }
 public void setVisible(boolean visible) {
   if (visible == true) {
     if (fFilters != null) {
       sourceFileViewer.resetFilters();
       for (Iterator i = fFilters.iterator(); i.hasNext(); )
         sourceFileViewer.addFilter((ViewerFilter) i.next());
     }
     sourceFileViewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
   }
   super.setVisible(visible);
 }
 protected static void setOrdered(IdMap idmap, ArrayList idmapOrdered) {
   ArrayList Ordered = new ArrayList();
   for (Iterator iter_ordered = idmapOrdered.iterator(); iter_ordered.hasNext(); ) {
     Mapping mapping = new Mapping();
     String signature = (String) iter_ordered.next();
     int end_of_signature = signature.lastIndexOf(SIGN_SEPARATOR, signature.length() - 2);
     if (end_of_signature < XMLStructureCreator.ROOT_ID.length() + 1)
       mapping.setSignature(""); // $NON-NLS-1$
     else
       mapping.setSignature(
           signature.substring(XMLStructureCreator.ROOT_ID.length() + 1, end_of_signature));
     mapping.setElement(signature.substring(end_of_signature + 1, signature.length() - 1));
     Ordered.add(mapping);
   }
   idmap.setOrdered(Ordered);
 }
  private void editIdMap(Shell shell) {
    TableItem[] items = fIdMapsTable.getSelection();
    if (items.length > 0) {
      IdMap idmap = (IdMap) items[0].getData();
      XMLCompareEditCopyIdMapDialog dialog =
          new XMLCompareEditCopyIdMapDialog(shell, idmap, fIdMaps, fIdMapsInternal);
      if (dialog.open() == Window.OK) {
        String new_idmapName = dialog.getResult();
        if (!fIdMaps.containsKey(new_idmapName)) {
          // copy over id mappings
          Vector newMappings = new Vector();
          IdMap newIdMap = new IdMap(new_idmapName, false, newMappings);
          HashMap newIdmapHM = new HashMap();
          fIdMaps.put(newIdMap.getName(), newIdmapHM);
          Vector Mappings = idmap.getMappings();
          for (Enumeration enumeration = Mappings.elements(); enumeration.hasMoreElements(); ) {
            Mapping mapping = (Mapping) enumeration.nextElement();
            Mapping newMapping =
                new Mapping(mapping.getElement(), mapping.getSignature(), mapping.getIdAttribute());
            newMappings.add(newMapping);
            newIdmapHM.put(newMapping.getKey(), newMapping.getIdAttribute());
          }
          // copy over ordered entries
          ArrayList orderedAL = idmap.getOrdered();
          if (orderedAL != null && orderedAL.size() > 0) {
            ArrayList newOrderedAL = new ArrayList();
            newIdMap.setOrdered(newOrderedAL);
            ArrayList idmapOrdered = new ArrayList();
            fOrderedElements.put(newIdMap.getName(), idmapOrdered);
            for (Iterator iter = orderedAL.iterator(); iter.hasNext(); ) {
              Mapping ordered = (Mapping) iter.next();
              Mapping newOrdered = new Mapping(ordered.getElement(), ordered.getSignature());
              newOrderedAL.add(newOrdered);
              idmapOrdered.add(newOrdered.getKey());
            }
          }

          newIdMapsTableItem(newIdMap, true);
          selectionChanged();
        }
      }
    }
  }
 protected void selectionChanged() {
   TableItem[] items = fIdMapsTable.getSelection();
   if (items.length > 0) {
     // Refresh Mappings Table
     fMappingsTable.removeAll();
     Vector Mappings = ((IdMap) items[0].getData()).getMappings();
     for (Enumeration enumeration = Mappings.elements(); enumeration.hasMoreElements(); ) {
       newMappingsTableItem((Mapping) enumeration.nextElement(), false);
     }
     // Refresh Ordered Table
     fOrderedTable.removeAll();
     ArrayList Ordered = ((IdMap) items[0].getData()).getOrdered();
     if (Ordered != null) {
       for (Iterator iter_ordered = Ordered.iterator(); iter_ordered.hasNext(); ) {
         newOrderedTableItem((Mapping) iter_ordered.next(), false);
       }
     }
   }
   updateEnabledState();
 }
  // --------------------------------------------------------------------------------
  private void drawItem(String parentFieldName, TreeItem parentItem, Map data, boolean expand) {
    Iterator p = data.keySet().iterator();
    while (p.hasNext()) {
      String key = (String) p.next();
      if (!data.containsKey(key)) {
        continue;
      }
      Object value = data.get(key);

      TreeItem newItem = new TreeItem(parentItem, SWT.NONE);
      newItem.setText(1, getClassName(value));

      String fieldName = parentFieldName + "." + key;
      if (fieldName.startsWith(".")) {
        fieldName = fieldName.substring(1);
      }
      newItem.setData("fieldName", fieldName);
      newItem.setData("value", value);
      fieldNameTreeItemMap.put(fieldName, newItem);

      if (value == null) {
        newItem.setText(key + " : null");
        newItem.setImage(nullImage);
      } else if (value instanceof Map) {
        newItem.setText(key);
        newItem.setImage(mapImage);
        drawItem(fieldName, newItem, (Map) value, expand);
      } else if (value instanceof List) {
        newItem.setText(key);
        newItem.setImage(listImage);
        drawItem(fieldName, newItem, (List) value, expand);
      } else {
        setItemInfo(newItem, key, value);
      }

      if (expand) {
        parentItem.setExpanded(expand);
        newItem.setExpanded(expand);
      }
    }
  }
  protected void fillIdMapsTable() {
    // fill user idmaps from plugin.xml
    fillIdMaps(true);

    // fill user idmaps from Preference Store
    fillIdMaps(false);

    // add user idmaps that have ordered entries but no id mappings
    // they do not appear in the preference store with name IDMAP_PREFERENCE_NAME
    Set OrderedKeys = fOrderedElements.keySet();
    Set IdMapKeys = fIdMaps.keySet();
    for (Iterator iter_orderedElements = OrderedKeys.iterator(); iter_orderedElements.hasNext(); ) {
      String IdMapName = (String) iter_orderedElements.next();
      if (!IdMapKeys.contains(IdMapName)) {
        IdMap idmap = new IdMap(IdMapName, false);
        ArrayList idmapOrdered = (ArrayList) fOrderedElements.get(IdMapName);
        setOrdered(idmap, idmapOrdered);
        newIdMapsTableItem(idmap, false);
      }
    }
  }
 private void fillIdMaps(boolean internal) {
   HashMap IdMaps = (internal) ? fIdMapsInternal : fIdMaps;
   HashMap OrderedElements = (internal) ? fOrderedElementsInternal : fOrderedElements;
   Set IdMapKeys = IdMaps.keySet();
   for (Iterator iter_internal = IdMapKeys.iterator(); iter_internal.hasNext(); ) {
     String IdMapName = (String) iter_internal.next();
     Vector Mappings = new Vector();
     IdMap idmap = new IdMap(IdMapName, internal, Mappings);
     // create mappings of internal idmaps
     HashMap idmapHM = (HashMap) IdMaps.get(IdMapName);
     Set idmapKeys = idmapHM.keySet();
     for (Iterator iter_idmap = idmapKeys.iterator(); iter_idmap.hasNext(); ) {
       Mapping mapping = new Mapping();
       String signature = (String) iter_idmap.next();
       int end_of_signature = signature.lastIndexOf(SIGN_SEPARATOR, signature.length() - 2);
       if (end_of_signature < XMLStructureCreator.ROOT_ID.length() + 1)
         mapping.setSignature(""); // $NON-NLS-1$
       else
         mapping.setSignature(
             signature.substring(XMLStructureCreator.ROOT_ID.length() + 1, end_of_signature));
       mapping.setElement(signature.substring(end_of_signature + 1, signature.length() - 1));
       mapping.setIdAttribute((String) idmapHM.get(signature));
       Mappings.add(mapping);
     }
     // create ordered mappings
     ArrayList idmapOrdered = (ArrayList) OrderedElements.get(IdMapName);
     if (idmapOrdered != null) {
       setOrdered(idmap, idmapOrdered);
     }
     // set extension
     if (fIdExtensionToName.containsValue(IdMapName)) {
       Set keySet = fIdExtensionToName.keySet();
       String extension = new String();
       for (Iterator iter = keySet.iterator(); iter.hasNext(); ) {
         extension = (String) iter.next();
         if (((String) fIdExtensionToName.get(extension)).equals(IdMapName)) break;
       }
       idmap.setExtension(extension);
     }
     newIdMapsTableItem(idmap, false);
   }
 }
Beispiel #12
0
  private ArrayList convertPkgList(ArrayList pkgList) {
    ArrayList conList = new ArrayList();
    Iterator it = pkgList.iterator();
    while (it.hasNext()) {
      CallData cd = (CallData) it.next();
      TestNode tn = null;
      if (alreadyDone.containsKey(cd)) {
        tn = (TestNode) alreadyDone.get(cd);
      } else {
        tn = new TestNode();
        tn.setData(cd.getData());
        alreadyDone.put(cd, tn);
        if (cd.getChildren().size() != 0) {
          tn.setChildren(convertPkgList(cd.getChildren()));
        }
        if (cd.getOutputs().size() != 0) {
          tn.setOutputs(convertPkgList(cd.getOutputs()));
        }
      }
      conList.add(tn);
    }

    return conList;
  }
  public static void handleAddRequired(IProductPlugin[] plugins, boolean includeOptional) {
    if (plugins.length == 0) return;

    ArrayList<BundleDescription> list = new ArrayList<BundleDescription>(plugins.length);
    for (int i = 0; i < plugins.length; i++) {
      list.add(TargetPlatformHelper.getState().getBundle(plugins[i].getId(), null));
    }
    DependencyCalculator calculator = new DependencyCalculator(includeOptional);
    calculator.findDependencies(list.toArray());

    BundleDescription[] bundles = TargetPlatformHelper.getState().getBundles();
    for (int i = 0; i < bundles.length; i++) {
      HostSpecification host = bundles[i].getHost();
      if (host != null
          && !("org.eclipse.ui.workbench.compatibility"
              .equals(bundles[i].getSymbolicName())) // $NON-NLS-1$
          && calculator.containsPluginId(host.getName())) {
        calculator.findDependency(bundles[i]);
      }
    }

    Collection<?> dependencies = calculator.getBundleIDs();

    IProduct product = plugins[0].getProduct();
    IProductModelFactory factory = product.getModel().getFactory();
    IProductPlugin[] requiredPlugins = new IProductPlugin[dependencies.size()];
    int i = 0;
    Iterator<?> iter = dependencies.iterator();
    while (iter.hasNext()) {
      String id = iter.next().toString();
      IProductPlugin plugin = factory.createPlugin();
      plugin.setId(id);
      requiredPlugins[i++] = plugin;
    }
    product.addPlugins(requiredPlugins);
  }