/** * 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 needsJavaNature(IFeatureModel model) { IFeatureInstallHandler handler = model.getFeature().getInstallHandler(); if (handler == null) { return false; } String libName = handler.getLibrary(); if (libName == null || libName.length() <= 0) { return false; } File lib = new File(model.getInstallLocation(), libName); return lib.exists(); }
private void setClasspath(IProject project, IFeatureModel model, IProgressMonitor monitor) throws JavaModelException { IJavaProject jProject = JavaCore.create(project); IClasspathEntry jreCPEntry = JavaCore.newContainerEntry( new Path("org.eclipse.jdt.launching.JRE_CONTAINER")); // $NON-NLS-1$ String libName = model.getFeature().getInstallHandler().getLibrary(); IClasspathEntry handlerCPEntry = JavaCore.newLibraryEntry(project.getFullPath().append(libName), null, null); jProject.setRawClasspath(new IClasspathEntry[] {jreCPEntry, handlerCPEntry}, monitor); }
private void createProject(IFeatureModel model, IProgressMonitor monitor) throws CoreException { String name = model.getFeature().getId(); IFeaturePlugin[] plugins = model.getFeature().getPlugins(); for (int i = 0; i < plugins.length; i++) { if (name.equals(plugins[i].getId())) { name += "-feature"; // $NON-NLS-1$ break; } } String task = NLS.bind(MDEUIMessages.FeatureImportWizard_operation_creating2, name); monitor.beginTask(task, 9); try { IProject project = fRoot.getProject(name); if (project.exists() || new File(project.getParent().getLocation().toFile(), name).exists()) { if (queryReplace(project)) { if (!project.exists()) project.create(new SubProgressMonitor(monitor, 1)); project.delete(true, true, new SubProgressMonitor(monitor, 1)); try { RepositoryProvider.unmap(project); } catch (TeamException e) { } } else { return; } } else { monitor.worked(1); } IProjectDescription description = MDEPlugin.getWorkspace().newProjectDescription(name); if (fTargetPath != null) description.setLocation(fTargetPath.append(name)); project.create(description, new SubProgressMonitor(monitor, 1)); if (!project.isOpen()) { project.open(null); } File featureDir = new File(model.getInstallLocation()); importContent( featureDir, project.getFullPath(), FileSystemStructureProvider.INSTANCE, null, new SubProgressMonitor(monitor, 1)); IFolder folder = project.getFolder("META-INF"); // $NON-NLS-1$ if (folder.exists()) { folder.delete(true, null); } if (fBinary) { // Mark this project so that we can show image overlay // using the label decorator project.setPersistentProperty( MDECore.EXTERNAL_PROJECT_PROPERTY, MDECore.BINARY_PROJECT_VALUE); } createBuildProperties(project); setProjectNatures(project, model, monitor); if (project.hasNature(JavaCore.NATURE_ID)) setClasspath(project, model, monitor); } finally { monitor.done(); } }