MCPcopy Index your code
hub / github.com/benfry/processing4 / buildTree

Method buildTree

app/src/processing/app/ui/ExamplesFrame.java:284–339  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

ExamplesFrameMethod · 0.95

Calls 10

textMethod · 0.95
buildContribTreeMethod · 0.95
addSketchesMethod · 0.80
hasExamplesMethod · 0.80
getNameMethod · 0.45
addMethod · 0.45
getExamplesFolderMethod · 0.45
getChildCountMethod · 0.45
printStackTraceMethod · 0.45

Tested by

no test coverage detected