use ids when installing contributions

This commit is contained in:
pesckal
2011-10-26 06:08:28 +00:00
parent 6857d776ee
commit 067d51deaa
2 changed files with 24 additions and 6 deletions
@@ -168,6 +168,19 @@ public class ContributionManager {
return null;
}
static File getSketchbookContribFolder(Base base, Type type) {
switch (type) {
case LIBRARY:
case LIBRARY_COMPILATION:
return base.getSketchbookLibrariesFolder();
case TOOL:
return base.getSketchbookToolsFolder();
case MODE:
return base.getSketchbookModesFolder();
}
return null;
}
static InstalledContribution create(Base base, Type type, File folder) {
switch (type) {
case LIBRARY:
@@ -286,17 +299,16 @@ public class ContributionManager {
String libFolderName = newLib.getFolder().getName();
File libraryDestination = editor.getBase().getSketchbookLibrariesFolder();
File libraryDestination = ContributionManager
.getSketchbookContribFolder(editor.getBase(), newLib.getType());
File newLibDest = new File(libraryDestination, libFolderName);
for (InstalledContribution oldLib : oldLibs) {
// XXX: Handle other cases when installing libraries.
// -What if a library by the same name is already installed?
// -What if newLibDest exists, but isn't used by an existing library?
if (oldLib.getFolder().exists() && oldLib.getFolder().equals(newLibDest)) {
if ((oldLib.getFolder().exists() && oldLib.getFolder().equals(newLibDest))
|| (oldLib.getId() != null && oldLib.getId().equals(newLib.getId()))) {
if (ContributionManager.requiresRestart(newLib)) {
if (ContributionManager.requiresRestart(oldLib)) {
// XXX: We can't replace stuff, soooooo.... do something different
if (!backupContribution(editor, oldLib, false, statusBar)) {
return null;
@@ -30,6 +30,7 @@ import processing.app.*;
public abstract class InstalledContribution implements Contribution {
protected String name; // "pdf" or "PDF Export"
protected String id; // 1
protected String category; // "Sound"
protected String authorList; // Ben Fry
protected String url; // http://processing.org
@@ -52,6 +53,7 @@ public abstract class InstalledContribution implements Contribution {
properties = Base.readSettings(propertiesFile);
name = properties.get("name");
id = properties.get("id");
category = ContributionListing.getCategory(properties.get("category"));
if (name == null) {
name = folder.getName();
@@ -86,6 +88,10 @@ public abstract class InstalledContribution implements Contribution {
return name;
}
public String getId() {
return id;
}
public String getAuthorList() {
return authorList;
}