/** * 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; }
/** * Recursively gets the ID of required features of this feature and adds them to the list * * @param model feature model to get requirements of * @param requiredFeatureList collector for the required features */ private void getFeatureDependencies( IFeatureModel model, IFeatureModel[] allFeatures, ArrayList requiredFeatureList) { IFeature feature = model.getFeature(); IFeatureImport[] featureImports = feature.getImports(); for (int i = 0; i < featureImports.length; i++) { if (featureImports[i].getType() == IFeatureImport.FEATURE) { for (int j = 0; j < allFeatures.length; j++) { if (allFeatures[j].getFeature().getId().equals(featureImports[i].getId())) { requiredFeatureList.add(allFeatures[j]); getFeatureDependencies(allFeatures[j], allFeatures, requiredFeatureList); break; } } } } IFeatureChild[] featureIncludes = feature.getIncludedFeatures(); for (int i = 0; i < featureIncludes.length; i++) { requiredFeatureList.add(featureIncludes[i].getId()); for (int j = 0; j < allFeatures.length; j++) { if (allFeatures[j].getFeature().getId().equals(featureIncludes[i].getId())) { requiredFeatureList.add(allFeatures[j]); getFeatureDependencies(allFeatures[j], allFeatures, requiredFeatureList); break; } } } }
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; }
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; }
@Override public void initialize(IManagedForm form) { IFeatureModel model = (IFeatureModel) getPage().getModel(); if (model != null) model.addModelChangedListener(this); super.initialize(form); }
@Override public void dispose() { IFeatureModel model = (IFeatureModel) getPage().getModel(); if (model != null) model.removeModelChangedListener(this); super.dispose(); }