コード例 #1
0
 /**
  * Finds a feature with the same id and version as a site feature. If feature is not found, but
  * feature with a M.m.s.qualifier exists it will be returned.
  *
  * @param siteFeature
  * @return IFeature or null
  */
 public static IFeature findFeature(ISiteFeature siteFeature) {
   IFeatureModel model =
       PDECore.getDefault()
           .getFeatureModelManager()
           .findFeatureModelRelaxed(siteFeature.getId(), siteFeature.getVersion());
   if (model != null) return model.getFeature();
   return null;
 }
コード例 #2
0
  private boolean canAdd(IFeatureModel candidate) {
    ISiteFeature[] features = fModel.getSite().getFeatures();
    IFeature cfeature = candidate.getFeature();

    for (int i = 0; i < features.length; i++) {
      ISiteFeature bfeature = features[i];
      if (bfeature.getId().equals(cfeature.getId())
          && bfeature.getVersion().equals(cfeature.getVersion())) return false;
    }
    return true;
  }
コード例 #3
0
 private ISiteFeature findRealFeature(SiteFeatureAdapter adapter) {
   ISiteFeature featureCopy = adapter.feature;
   ISiteFeature[] features = fModel.getSite().getFeatures();
   for (int i = 0; i < features.length; i++) {
     if (features[i].getId().equals(featureCopy.getId())
         && features[i].getVersion().equals(featureCopy.getVersion())) {
       return features[i];
     }
   }
   return null;
 }
コード例 #4
0
 private void removeCategory(ISiteFeature aFeature, String catName) {
   try {
     if (aFeature == null) return;
     ISiteCategory[] cats = aFeature.getCategories();
     for (int i = 0; i < cats.length; i++) {
       if (catName.equals(cats[i].getName()))
         aFeature.removeCategories(new ISiteCategory[] {cats[i]});
     }
   } catch (CoreException e) {
   }
 }
コード例 #5
0
 private void addCategory(ISiteFeature aFeature, String catName) {
   try {
     if (aFeature == null) return;
     ISiteCategory[] cats = aFeature.getCategories();
     for (int j = 0; j < cats.length; j++) {
       if (cats[j].getName().equals(catName)) return;
     }
     ISiteCategory cat = fModel.getFactory().createCategory(aFeature);
     cat.setName(catName);
     expandCategory(catName);
     aFeature.addCategories(new ISiteCategory[] {cat});
   } catch (CoreException e) {
   }
 }
コード例 #6
0
 private boolean handleRemoveSiteFeatureAdapter(SiteFeatureAdapter adapter) {
   try {
     ISiteFeature feature = adapter.feature;
     if (adapter.category == null) {
       fModel.getSite().removeFeatures(new ISiteFeature[] {feature});
     } else {
       removeCategory(feature, adapter.category);
       if (feature.getCategories().length == 0)
         fModel.getSite().removeFeatures(new ISiteFeature[] {feature});
     }
     return true;
   } catch (CoreException e) {
   }
   return false;
 }
コード例 #7
0
 public static ISiteFeature createSiteFeature(ISiteModel model, IFeatureModel featureModel)
     throws CoreException {
   IFeature feature = featureModel.getFeature();
   ISiteFeature sfeature = model.getFactory().createFeature();
   sfeature.setId(feature.getId());
   sfeature.setVersion(feature.getVersion());
   // sfeature.setURL(model.getBuildModel().getSiteBuild().getFeatureLocation()
   // + "/" + feature.getId() + "_" + feature.getVersion() + ".jar");
   // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
   sfeature.setURL(
       "features/"
           + feature.getId()
           + "_"
           + formatVersion(feature.getVersion())
           + ".jar"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
   sfeature.setOS(feature.getOS());
   sfeature.setWS(feature.getWS());
   sfeature.setArch(feature.getArch());
   sfeature.setNL(feature.getNL());
   sfeature.setIsPatch(isFeaturePatch(feature));
   return sfeature;
 }
コード例 #8
0
 /**
  * Creates a new site feature instance with the same settings as the given source feature.
  *
  * @param model site model to create the feature from
  * @param sourceFeature the feature to copy settings out of
  * @return a new site feature instance
  * @throws CoreException
  */
 private ISiteFeature copySiteFeature(ISiteModel model, ISiteFeature sourceFeature)
     throws CoreException {
   ISiteFeature sfeature = model.getFactory().createFeature();
   sfeature.setId(sourceFeature.getId());
   sfeature.setVersion(sourceFeature.getVersion());
   sfeature.setURL(sourceFeature.getURL());
   sfeature.setOS(sourceFeature.getOS());
   sfeature.setWS(sourceFeature.getWS());
   sfeature.setArch(sourceFeature.getArch());
   sfeature.setNL(sourceFeature.getNL());
   sfeature.setIsPatch(sourceFeature.isPatch());
   return sfeature;
 }