Ejemplo n.º 1
1
 public void computeImports() throws CoreException {
   // some existing imports may valid and can be preserved
   Vector preservedImports = new Vector(fImports.size());
   // new imports
   ArrayList newImports = new ArrayList();
   IPluginModelBase model = null;
   for (int i = 0; i < fPlugins.size(); i++) {
     IFeaturePlugin fp = (IFeaturePlugin) fPlugins.get(i);
     ModelEntry entry = PluginRegistry.findEntry(fp.getId());
     if (entry == null) continue;
     IPluginModelBase[] models = entry.getActiveModels();
     for (int j = 0; j < models.length; j++) {
       IPluginModelBase m = models[j];
       if (fp.getVersion().equals(m.getPluginBase().getVersion())
           || fp.getVersion().equals("0.0.0")) // $NON-NLS-1$
       model = m;
     }
     if (model != null) {
       addPluginImports(preservedImports, newImports, model.getPluginBase());
       if (model.isFragmentModel()) {
         BundleDescription desc = model.getBundleDescription();
         if (desc == null) continue;
         HostSpecification hostSpec = desc.getHost();
         String id = hostSpec.getName();
         String version = null;
         int match = IMatchRules.NONE;
         VersionRange versionRange = hostSpec.getVersionRange();
         if (!(versionRange == null || VersionRange.emptyRange.equals(versionRange))) {
           version =
               versionRange.getMinimum() != null ? versionRange.getMinimum().toString() : null;
           match = PluginBase.getMatchRule(versionRange);
         }
         addNewDependency(id, version, match, preservedImports, newImports);
       }
     }
   }
   // preserve imports of features
   for (int i = 0; i < fImports.size(); i++) {
     IFeatureImport iimport = (IFeatureImport) fImports.get(i);
     if (iimport.getType() == IFeatureImport.FEATURE) preservedImports.add(iimport);
   }
   // removed = old - preserved
   Vector removedImports = ((Vector) fImports.clone());
   removedImports.removeAll(preservedImports);
   // perform remove
   fImports = preservedImports;
   if (removedImports.size() > 0) {
     fireStructureChanged(
         (IFeatureImport[]) removedImports.toArray(new IFeatureImport[removedImports.size()]),
         IModelChangedEvent.REMOVE);
   }
   // perform add
   if (newImports.size() > 0) {
     fImports.addAll(newImports);
     fireStructureChanged(
         (IFeatureImport[]) newImports.toArray(new IFeatureImport[newImports.size()]),
         IModelChangedEvent.INSERT);
   }
 }
Ejemplo n.º 2
0
 public static Enumeration compoundEnumerations(Enumeration list1, Enumeration list2) {
   if (list2 == null || !list2.hasMoreElements()) return list1;
   if (list1 == null || !list1.hasMoreElements()) return list2;
   Vector compoundResults = new Vector();
   while (list1.hasMoreElements()) compoundResults.add(list1.nextElement());
   while (list2.hasMoreElements()) {
     Object item = list2.nextElement();
     if (!compoundResults.contains(item)) // don't add duplicates
     compoundResults.add(item);
   }
   return compoundResults.elements();
 }
Ejemplo n.º 3
0
 public void addImports(IFeatureImport[] iimports) throws CoreException {
   ensureModelEditable();
   for (int i = 0; i < iimports.length; i++) {
     fImports.add(iimports[i]);
     ((FeatureImport) iimports[i]).setInTheModel(true);
   }
   fireStructureChanged(iimports, IModelChangedEvent.INSERT);
 }
Ejemplo n.º 4
0
 public void addIncludedFeatures(IFeatureChild[] features) throws CoreException {
   ensureModelEditable();
   for (int i = 0; i < features.length; i++) {
     fChildren.add(features[i]);
     ((FeatureChild) features[i]).setInTheModel(true);
   }
   fireStructureChanged(features, IModelChangedEvent.INSERT);
 }
Ejemplo n.º 5
0
 public void addData(IFeatureData[] newData) throws CoreException {
   ensureModelEditable();
   for (int i = 0; i < newData.length; i++) {
     fData.add(newData[i]);
     ((FeatureData) newData[i]).setInTheModel(true);
   }
   fireStructureChanged(newData, IModelChangedEvent.INSERT);
 }
Ejemplo n.º 6
0
 public void addPlugins(IFeaturePlugin[] newPlugins) throws CoreException {
   ensureModelEditable();
   for (int i = 0; i < newPlugins.length; i++) {
     fPlugins.add(newPlugins[i]);
     ((FeaturePlugin) newPlugins[i]).setInTheModel(true);
   }
   fireStructureChanged(newPlugins, IModelChangedEvent.INSERT);
 }
Ejemplo n.º 7
0
 private void parseRequires(Node node) {
   NodeList children = node.getChildNodes();
   for (int i = 0; i < children.getLength(); i++) {
     Node child = children.item(i);
     if (child.getNodeType() == Node.ELEMENT_NODE) {
       if (child.getNodeName().equalsIgnoreCase("import")) { // $NON-NLS-1$
         IFeatureImport iimport = getModel().getFactory().createImport();
         ((FeatureImport) iimport).parse(child);
         ((FeatureImport) iimport).setInTheModel(true);
         fImports.add(iimport);
       }
     }
   }
 }
Ejemplo n.º 8
0
  protected void parse(Node node) {
    super.parse(node);
    fProviderName = getNodeAttribute(node, "provider-name"); // $NON-NLS-1$
    fPlugin = getNodeAttribute(node, "plugin"); // $NON-NLS-1$
    fOs = getNodeAttribute(node, "os"); // $NON-NLS-1$
    fWs = getNodeAttribute(node, "ws"); // $NON-NLS-1$
    fNl = getNodeAttribute(node, "nl"); // $NON-NLS-1$
    fArch = getNodeAttribute(node, "arch"); // $NON-NLS-1$
    fImageName = getNodeAttribute(node, "image"); // $NON-NLS-1$
    fColocationAffinity = getNodeAttribute(node, "colocation-affinity"); // $NON-NLS-1$
    fApplication = getNodeAttribute(node, "application"); // $NON-NLS-1$
    fPrimary = getBooleanAttribute(node, "primary"); // $NON-NLS-1$
    fExclusive = getBooleanAttribute(node, "exclusive"); // $NON-NLS-1$
    NodeList children = node.getChildNodes();
    fValid = true;

    for (int i = 0; i < children.getLength(); i++) {
      Node child = children.item(i);
      if (child.getNodeType() == Node.ELEMENT_NODE) {
        String tag = child.getNodeName().toLowerCase(Locale.ENGLISH);
        if (tag.equals("description")) { // $NON-NLS-1$
          IFeatureInfo info = getModel().getFactory().createInfo(IFeature.INFO_DESCRIPTION);
          ((FeatureInfo) info).setInTheModel(true);
          ((FeatureInfo) info).parse(child);
          fInfos[IFeature.INFO_DESCRIPTION] = info;
        } else if (tag.equals("license")) { // $NON-NLS-1$
          IFeatureInfo info = getModel().getFactory().createInfo(IFeature.INFO_LICENSE);
          ((FeatureInfo) info).setInTheModel(true);
          ((FeatureInfo) info).parse(child);
          fInfos[IFeature.INFO_LICENSE] = info;
        } else if (tag.equals("copyright")) { // $NON-NLS-1$
          IFeatureInfo info = getModel().getFactory().createInfo(IFeature.INFO_COPYRIGHT);
          ((FeatureInfo) info).setInTheModel(true);
          ((FeatureInfo) info).parse(child);
          fInfos[IFeature.INFO_COPYRIGHT] = info;
        } else if (tag.equals("url")) { // $NON-NLS-1$
          if (fUrl == null) {
            fUrl = getModel().getFactory().createURL();
            ((FeatureURL) fUrl).setInTheModel(true);
            ((FeatureURL) fUrl).parse(child);
          }
        } else if (tag.equals("requires")) { // $NON-NLS-1$
          parseRequires(child);
        } else if (tag.equals("install-handler")) { // $NON-NLS-1$
          IFeatureInstallHandler handler = getModel().getFactory().createInstallHandler();
          ((FeatureInstallHandler) handler).parse(child);
          ((FeatureInstallHandler) handler).setInTheModel(true);
          this.fHandler = handler;
        } else if (tag.equals("plugin")) { // $NON-NLS-1$
          IFeaturePlugin plugin = getModel().getFactory().createPlugin();
          ((FeaturePlugin) plugin).parse(child);
          ((FeaturePlugin) plugin).setInTheModel(true);
          fPlugins.add(plugin);
        } else if (tag.equals("data")) { // $NON-NLS-1$
          IFeatureData newData = getModel().getFactory().createData();
          ((FeatureData) newData).parse(child);
          ((FeatureData) newData).setInTheModel(true);
          fData.add(newData);
        } else if (tag.equals("includes")) { // $NON-NLS-1$
          IFeatureChild newChild = getModel().getFactory().createChild();
          ((FeatureChild) newChild).parse(child);
          ((FeatureChild) newChild).setInTheModel(true);
          this.fChildren.add(newChild);
        }
      }
    }
    fValid = hasRequiredAttributes();
  }