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