/**
  * 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;
 }
  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;
  }
 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;
 }
 /**
  * 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;
 }