| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -345,11 +345,11 @@ public File getReferenceFolder() { | |||
| 345 | 345 | public void rebuildLibraryList() { | |
| 346 | 346 | //new Exception("Rebuilding library list").printStackTrace(System.out); | |
| 347 | 347 | // reset the table mapping imports to libraries | |
| 348 | - HashMap<String, List<Library>> importToLibraryTable = new HashMap<>(); | ||
| 348 | + Map<String, List<Library>> newTable = new HashMap<>(); | ||
| 349 | 349 | ||
| 350 | 350 | Library core = getCoreLibrary(); | |
| 351 | 351 | if (core != null) { | |
| 352 | - core.addPackageList(importToLibraryTable); | ||
| 352 | + core.addPackageList(newTable); | ||
| 353 | 353 | } | |
| 354 | 354 | ||
| 355 | 355 | coreLibraries = Library.list(librariesFolder); | |
@@ -367,28 +367,16 @@ public void rebuildLibraryList() { | |||
| 367 | 367 | coreLibraries.addAll(foundationLibraries); | |
| 368 | 368 | contribLibraries.removeAll(foundationLibraries); | |
| 369 | 369 | ||
| 370 | - /* | ||
| 371 | - File sketchbookLibs = Base.getSketchbookLibrariesFolder(); | ||
| 372 | - File videoFolder = new File(sketchbookLibs, "video"); | ||
| 373 | - if (videoFolder.exists()) { | ||
| 374 | - coreLibraries.add(new Library(videoFolder)); | ||
| 375 | - } | ||
| 376 | - File soundFolder = new File(sketchbookLibs, "sound"); | ||
| 377 | - if (soundFolder.exists()) { | ||
| 378 | - coreLibraries.add(new Library(soundFolder)); | ||
| 379 | - } | ||
| 380 | - */ | ||
| 381 | - | ||
| 382 | 370 | for (Library lib : coreLibraries) { | |
| 383 | - lib.addPackageList(importToLibraryTable); | ||
| 371 | + lib.addPackageList(newTable); | ||
| 384 | 372 | } | |
| 385 | 373 | ||
| 386 | 374 | for (Library lib : contribLibraries) { | |
| 387 | - lib.addPackageList(importToLibraryTable); | ||
| 375 | + lib.addPackageList(newTable); | ||
| 388 | 376 | } | |
| 389 | 377 | ||
| 390 | 378 | // Make this Map thread-safe | |
| 391 | - this.importToLibraryTable = Collections.unmodifiableMap(importToLibraryTable); | ||
| 379 | + importToLibraryTable = Collections.unmodifiableMap(newTable); | ||
| 392 | 380 | ||
| 393 | 381 | if (base != null) { | |
| 394 | 382 | base.getEditors().forEach(Editor::librariesChanged); | |
@@ -630,6 +618,18 @@ public void actionPerformed(ActionEvent e) { | |||
| 630 | 618 | } | |
| 631 | 619 | ||
| 632 | 620 | ||
| 621 | + /** | ||
| 622 | + * Require examples to explicitly state that they're compatible with this | ||
| 623 | + * Mode before they're included. Helpful for Modes like p5js or Python | ||
| 624 | + * where the .java examples cannot be used. | ||
| 625 | + * @since 3.2 | ||
| 626 | + * @return true if an examples package must list this Mode's identifier | ||
| 627 | + */ | ||
| 628 | + public boolean requireExampleCompatibility() { | ||
| 629 | + return false; | ||
| 630 | + } | ||
| 631 | + | ||
| 632 | + | ||
| 633 | 633 | /** | |
| 634 | 634 | * Override this to control the order of the first set of example folders | |
| 635 | 635 | * and how they appear in the examples window. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,7 @@ | |||
| 6 | 6 | import java.util.Map; | |
| 7 | 7 | ||
| 8 | 8 | import processing.app.Base; | |
| 9 | + import processing.app.Mode; | ||
| 9 | 10 | import processing.core.PApplet; | |
| 10 | 11 | import processing.data.StringDict; | |
| 11 | 12 | import processing.data.StringList; | |
@@ -57,11 +58,16 @@ static private StringList parseModeList(StringDict properties) { | |||
| 57 | 58 | * active editor | |
| 58 | 59 | */ | |
| 59 | 60 | static public boolean isCompatible(Base base, StringDict props) { | |
| 60 | - String currentIdentifier = | ||
| 61 | - base.getActiveEditor().getMode().getIdentifier(); | ||
| 61 | + Mode mode = base.getActiveEditor().getMode(); | ||
| 62 | + String currentIdentifier = mode.getIdentifier(); | ||
| 62 | 63 | StringList compatibleList = parseModeList(props); | |
| 63 | 64 | if (compatibleList.size() == 0) { | |
| 64 | - return true; // if no mode specified, assume compatible everywhere | ||
| 65 | + if (mode.requireExampleCompatibility()) { | ||
| 66 | + // for p5js (and maybe Python), examples must specify that they work | ||
| 67 | + return false; | ||
| 68 | + } | ||
| 69 | + // if no Mode specified, assume compatible everywhere | ||
| 70 | + return true; | ||
| 65 | 71 | } | |
| 66 | 72 | for (String c : compatibleList) { | |
| 67 | 73 | if (c.equals(currentIdentifier)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -342,8 +342,7 @@ protected DefaultMutableTreeNode buildTree() { | |||
| 342 | 342 | e.printStackTrace(); | |
| 343 | 343 | } | |
| 344 | 344 | ||
| 345 | - DefaultMutableTreeNode contributedExamplesNode = | ||
| 346 | - buildContribTree(); | ||
| 345 | + DefaultMutableTreeNode contributedExamplesNode = buildContribTree(); | ||
| 347 | 346 | if (contributedExamplesNode.getChildCount() > 0) { | |
| 348 | 347 | root.add(contributedExamplesNode); | |
| 349 | 348 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,6 +20,9 @@ o saying "no" to save changes is the same as "cancel" on windows? | |||
| 20 | 20 | X can't reproduce | |
| 21 | 21 | X add printStackTrace() method that can be overridden | |
| 22 | 22 | X https://github.com/processing/processing/issues/222 | |
| 23 | + X write preferences.txt using a temporary file | ||
| 24 | + X also save the previous version as preferences.old | ||
| 25 | + X https://github.com/processing/processing/issues/4614 | ||
| 23 | 26 | _ update launch4j to 3.9 | |
| 24 | 27 | _ https://sourceforge.net/projects/launch4j/files/launch4j-3/3.9/ | |
| 25 | 28 | ||
@@ -41,6 +44,7 @@ X implement templates | |||
| 41 | 44 | _ write short docs | |
| 42 | 45 | _ https://github.com/processing/processing/issues/4306 | |
| 43 | 46 | _ https://github.com/processing/processing/issues/4352 | |
| 47 | + X add Mode.requireExampleCompatibility() | ||
| 44 | 48 | ||
| 45 | 49 | contrib | |
| 46 | 50 | X use HTML to print | |
| Back | FazBrowse Home | New Git URL |
0 commit comments