private void addNewDependency( String id, String version, int match, List preservedImports, List newImports) throws CoreException { if (findFeaturePlugin(id, version, match) != null) { // don't add imports to local plug-ins return; } if (findImport(preservedImports, id, version, match) != null) { // already seen return; } if (findImport(newImports, id, version, match) != null) { // already seen return; } IFeatureImport iimport = findImport(fImports, id, version, match); if (iimport != null) { // import still valid preservedImports.add(iimport); return; } // a new one is needed iimport = getModel().getFactory().createImport(); iimport.setId(id); iimport.setVersion(version); iimport.setMatch(match); ((FeatureImport) iimport).setInTheModel(true); newImports.add(iimport); }
/** * Finds a given import in the list * * @param imports list of imports * @param id * @param version * @param match * @return IFeatureImport or null */ private IFeatureImport findImport(List imports, String id, String version, int match) { for (int i = 0; i < imports.size(); i++) { IFeatureImport iimport = (IFeatureImport) imports.get(i); if (iimport.getId().equals(id)) { if (version == null) return iimport; if (version.equals(iimport.getVersion()) && match == iimport.getMatch()) return iimport; } } return null; }