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
  private IFeaturePlugin findFeaturePlugin(String id, String version, int match) {

    for (int i = 0; i < fPlugins.size(); i++) {
      IFeaturePlugin fp = (IFeaturePlugin) fPlugins.get(i);
      String pid = fp.getId();
      String pversion = fp.getVersion();
      if (VersionUtil.compare(pid, pversion, id, version, match)) return fp;
    }
    return null;
  }
Ejemplo n.º 3
0
  private boolean hasRequiredAttributes() {
    // Verify that all the required attributes are
    // defined.
    if (id == null) return false;
    if (version == null) return false;

    for (int i = 0; i < fChildren.size(); i++) {
      IFeatureChild child = (IFeatureChild) fChildren.elementAt(i);
      if (child.getId() == null || child.getVersion() == null) return false;
    }
    for (int i = 0; i < fPlugins.size(); i++) {
      IFeaturePlugin plugin = (IFeaturePlugin) fPlugins.elementAt(i);
      if (plugin.getId() == null || plugin.getVersion() == null) return false;
    }
    for (int i = 0; i < fData.size(); i++) {
      IFeatureData entry = (IFeatureData) fData.elementAt(i);
      if (entry.getId() == null) return false;
    }
    for (int i = 0; i < fImports.size(); i++) {
      IFeatureImport iimport = (IFeatureImport) fImports.elementAt(i);
      if (iimport.getId() == null) return false;
    }
    return true;
  }