diff --git a/android/todo.txt b/android/todo.txt index 4bb5229fd..8a4d36e3b 100644 --- a/android/todo.txt +++ b/android/todo.txt @@ -1,6 +1,7 @@ 0204 android X Android emulator not launching on Windows with 2.0 alpha releases X http://code.google.com/p/processing/issues/detail?id=899 +X http://code.google.com/p/processing/issues/detail?id=769 X /opt/android using version #s again? fix build script (earlier) X smooth() is now the default diff --git a/app/src/processing/app/Library.java b/app/src/processing/app/Library.java index 08fea85fa..b72cb4455 100644 --- a/app/src/processing/app/Library.java +++ b/app/src/processing/app/Library.java @@ -219,27 +219,33 @@ public class Library extends InstalledContribution { * imports to specific libraries. * @param importToLibraryTable mapping from package names to Library objects */ - public void addPackageList(HashMap importToLibraryTable) { +// public void addPackageList(HashMap importToLibraryTable) { + public void addPackageList(HashMap> importToLibraryTable) { // PApplet.println(packages); for (String pkg : packageList) { - // pw.println(pkg + "\t" + libraryFolder.getAbsolutePath()); - Library library = importToLibraryTable.get(pkg); - if (library != null) { - if (!packageWarningMap.containsKey(pkg)) { - packageWarningMap.put(pkg, null); +// pw.println(pkg + "\t" + libraryFolder.getAbsolutePath()); +// PApplet.println(pkg + "\t" + getName()); +// Library library = importToLibraryTable.get(pkg); + ArrayList libraries = importToLibraryTable.get(pkg); + if (libraries == null) { + libraries = new ArrayList(); + importToLibraryTable.put(pkg, libraries); + } else { + if (Base.DEBUG) { System.err.println("The library found in"); System.err.println(getPath()); System.err.println("conflicts with"); - System.err.println(library.getPath()); - System.err.println("which already defines the package " + pkg); + for (Library library : libraries) { + System.err.println(library.getPath()); + } + System.err.println("which already define(s) the package " + pkg); System.err.println("If you have a line in your sketch that reads"); System.err.println("import " + pkg + ".*;"); System.err.println("Then you'll need to first remove one of those libraries."); System.err.println(); } - } else { - importToLibraryTable.put(pkg, this); } + libraries.add(this); } } diff --git a/app/src/processing/app/Mode.java b/app/src/processing/app/Mode.java index 11d2cbbd5..93b44962b 100644 --- a/app/src/processing/app/Mode.java +++ b/app/src/processing/app/Mode.java @@ -25,7 +25,8 @@ public abstract class Mode { // protected Tool formatter; // maps imported packages to their library folder - protected HashMap importToLibraryTable; +// protected HashMap importToLibraryTable; + protected HashMap> importToLibraryTable; // these menus are shared so that they needn't be rebuilt for all windows // each time a sketch is created, renamed, or moved. @@ -115,7 +116,8 @@ public abstract class Mode { // System.out.println("rebuildLibraryList()"); // reset the table mapping imports to libraries - importToLibraryTable = new HashMap(); +// importToLibraryTable = new HashMap(); + importToLibraryTable = new HashMap>(); coreLibraries = Library.list(librariesFolder); contribLibraries = Library.list(base.getSketchbookLibrariesFolder()); @@ -129,8 +131,28 @@ public abstract class Mode { } - public Library getLibrary(String name) { - return importToLibraryTable.get(name); + public Library getLibrary(String pkgName) throws SketchException { + ArrayList libraries = importToLibraryTable.get(pkgName); + if (libraries == null) { + return null; + + } else if (libraries.size() > 1) { + String primary = "More than one library is competing for this sketch."; + String secondary = "The import " + pkgName + " points to multiple libraries:
"; + for (Library library : libraries) { + String location = library.getPath(); + if (location.startsWith(getLibrariesFolder().getAbsolutePath())) { + location = "part of Processing"; + } + secondary += "" + library.getName() + " (" + location + ")
"; + } + secondary += "Extra libraries need to be removed before this sketch can be used."; + Base.showWarningTiered("Duplicate Library Problem", primary, secondary, null); + throw new SketchException("Duplicate libraries found for " + pkgName + "."); + + } else { + return libraries.get(0); + } } diff --git a/todo.txt b/todo.txt index f73e0d38d..89b9cf069 100644 --- a/todo.txt +++ b/todo.txt @@ -4,6 +4,9 @@ X http://code.google.com/p/processing/issues/detail?id=877 X make note of when library is not available (serial) with error msg X i.e. if running in 64-bit mode on OS X, can't do serial X update to Java 6u29 for Linux and Windows (OS X now updated) +X don't show library conflict warning until someone tries to build +X with code that actually calls on one of those packages +X too many people seem to think this is an error fixed in 2.0a3 X Commenting via menu or shortcut does not set sketch to "need save" @@ -18,10 +21,6 @@ X otherwise ppl are copying really large files into a jar... _ move Movie Maker out to its own separate tool package (with separate build) _ http://code.google.com/p/processing/issues/detail?id=837 -_ don't show library conflict warning until someone tries to build -_ with code that actually calls on one of those packages -_ too many people seem to think this is an error - _ bad tool brings down the environment _ http://code.google.com/p/processing/issues/detail?id=798