| 355 | |
| 356 | |
| 357 | public Library getLibrary(String pkgName) throws SketchException { |
| 358 | List<Library> libraries = importToLibraryTable.get(pkgName); |
| 359 | if (libraries == null) { |
| 360 | return null; |
| 361 | |
| 362 | } else if (libraries.size() > 1) { |
| 363 | String primary = "More than one library is competing for this sketch."; |
| 364 | String secondary = "The import " + pkgName + " points to multiple libraries:<br>"; |
| 365 | for (Library library : libraries) { |
| 366 | String location = library.getPath(); |
| 367 | if (location.startsWith(getLibrariesFolder().getAbsolutePath())) { |
| 368 | location = "part of Processing"; |
| 369 | } |
| 370 | secondary += "<b>" + library.getName() + "</b> (" + location + ")<br>"; |
| 371 | } |
| 372 | secondary += "Extra libraries need to be removed before this sketch can be used."; |
| 373 | Messages.showWarningTiered("Duplicate Library Problem", primary, secondary, null); |
| 374 | throw new SketchException("Duplicate libraries found for " + pkgName + "."); |
| 375 | |
| 376 | } else { |
| 377 | return libraries.get(0); |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | |
| 382 | // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |