if (conflicts.size() > 0) {
StringBuffer message = new StringBuffer();
message.append("Package " + packageName + " requires the following packages:\n\n");
Iterator<Dependency> depI = dependencies.iterator();
while (depI.hasNext()) {
Dependency d = depI.next();
message.append("\t" + d +"\n");
}
message.append("\nThere are conflicting dependencies:\n\n");
Set<String> pNames = conflicts.keySet();
Iterator<String> pNameI = pNames.iterator();
while (pNameI.hasNext()) {
String pName = pNameI.next();
message.append("Conflicts for " + pName + "\n");
List<Dependency> confsForPackage = conflicts.get(pName);
Iterator<Dependency> confs = confsForPackage.iterator();
while (confs.hasNext()) {
Dependency problem = confs.next();
message.append("\t" + problem + "\n");
}
}
JOptionPane.showConfirmDialog(PackageManager.this, message.toString(),
"Weka Package Manager", JOptionPane.OK_OPTION);
// bail out here
//return null;
m_unsuccessfulInstalls.add(packageToInstall);
continue;
}
// Next check all dependencies against what is installed and
// inform the user about which installed packages will be altered. Also
// build the list of only those packages that need to be installed or
// upgraded (excluding those that are already installed and are OK).
List<PackageConstraint> needsUpgrade = new ArrayList<PackageConstraint>();
List<Package> finalListToInstall = new ArrayList<Package>();
Iterator<Dependency> depI = dependencies.iterator();
boolean depsOk = true;
while (depI.hasNext()) {
Dependency toCheck = depI.next();
if (toCheck.getTarget().getPackage().isInstalled()) {
String toCheckName =
toCheck.getTarget().getPackage().
getPackageMetaDataElement("PackageName").toString();
try {
Package installedVersion = WekaPackageManager.getInstalledPackageInfo(toCheckName);
if (!toCheck.getTarget().checkConstraint(installedVersion)) {
needsUpgrade.add(toCheck.getTarget());
Package mostRecent = toCheck.getTarget().getPackage();
if (toCheck.getTarget() instanceof
org.pentaho.packageManagement.VersionPackageConstraint) {
mostRecent =
WekaPackageManager.mostRecentVersionWithRespectToConstraint(toCheck.getTarget());
}
finalListToInstall.add(mostRecent);
}
} catch (Exception ex) {
ex.printStackTrace();
displayErrorDialog("An error has occurred while checking " +
"package dependencies", ex);
// bail out here
//return null;
depsOk = false;
break;
}
} else {
try {
Package mostRecent = toCheck.getTarget().getPackage();
if (toCheck.getTarget() instanceof
org.pentaho.packageManagement.VersionPackageConstraint) {
mostRecent =
WekaPackageManager.mostRecentVersionWithRespectToConstraint(toCheck.getTarget());
}
finalListToInstall.add(mostRecent);
} catch (Exception ex) {
ex.printStackTrace();
displayErrorDialog("An error has occurred while checking " +