()
| 296 | |
| 297 | |
| 298 | protected DefaultMutableTreeNode buildTree() { |
| 299 | DefaultMutableTreeNode root = new DefaultMutableTreeNode(); //"Examples"); |
| 300 | |
| 301 | try { |
| 302 | // Get the list of Mode-specific examples, in the order the Mode wants |
| 303 | // to present them (i.e. Basics, then Topics, then Demos...) |
| 304 | File[] examples = mode.getExampleCategoryFolders(); |
| 305 | |
| 306 | for (File subFolder : examples) { |
| 307 | DefaultMutableTreeNode subNode = new DefaultMutableTreeNode(subFolder.getName()); |
| 308 | if (base.addSketches(subNode, subFolder, true)) { |
| 309 | root.add(subNode); |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | DefaultMutableTreeNode foundationLibraries = |
| 314 | new DefaultMutableTreeNode(Language.text("examples.core_libraries")); |
| 315 | |
| 316 | // Get examples for core libraries |
| 317 | for (Library lib : mode.coreLibraries) { |
| 318 | if (lib.hasExamples()) { |
| 319 | DefaultMutableTreeNode libNode = new DefaultMutableTreeNode(lib.getName()); |
| 320 | if (base.addSketches(libNode, lib.getExamplesFolder(), true)) { |
| 321 | foundationLibraries.add(libNode); |
| 322 | } |
| 323 | } |
| 324 | } |
| 325 | if (foundationLibraries.getChildCount() > 0) { |
| 326 | root.add(foundationLibraries); |
| 327 | } |
| 328 | |
| 329 | // Get examples for third party libraries |
| 330 | DefaultMutableTreeNode contributedLibExamples = new |
| 331 | DefaultMutableTreeNode(Language.text("examples.libraries")); |
| 332 | for (Library lib : mode.contribLibraries) { |
| 333 | if (lib.hasExamples()) { |
| 334 | DefaultMutableTreeNode libNode = |
| 335 | new DefaultMutableTreeNode(lib.getName()); |
| 336 | base.addSketches(libNode, lib.getExamplesFolder(), true); |
| 337 | contributedLibExamples.add(libNode); |
| 338 | } |
| 339 | } |
| 340 | if (contributedLibExamples.getChildCount() > 0) { |
| 341 | root.add(contributedLibExamples); |
| 342 | } |
| 343 | } catch (IOException e) { |
| 344 | e.printStackTrace(); |
| 345 | } |
| 346 | |
| 347 | DefaultMutableTreeNode contributedExamplesNode = buildContribTree(); |
| 348 | if (contributedExamplesNode.getChildCount() > 0) { |
| 349 | root.add(contributedExamplesNode); |
| 350 | } |
| 351 | |
| 352 | return root; |
| 353 | } |
| 354 | |
| 355 |
no test coverage detected