List of usage examples for javax.swing.tree DefaultMutableTreeNode add
public void add(MutableTreeNode newChild)
newChild
from its parent and makes it a child of this node by adding it to the end of this node's child array. From source file:org.openengsb.ui.admin.wiringPage.WiringPage.java
@SuppressWarnings("serial") private IModel<TreeModel> createEndpointsModel(final Class<? extends Domain> domainType) { return new LoadableDetachableModel<TreeModel>() { @Override// w w w .j a v a 2 s . co m protected TreeModel load() { DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Domain endpoints"); if (domainType != null) { for (Domain d : wiringService.getDomainEndpoints(domainType, "*")) { String id = d.getInstanceId(); if (id != null) { DefaultMutableTreeNode child = new DefaultMutableTreeNode(id); rootNode.add(child); } } } return new DefaultTreeModel(rootNode); } }; }
From source file:org.openengsb.ui.admin.wiringPage.WiringPage.java
private TreeModel createContextModel() { DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Contexts"); for (String c : getAvailableContexts()) { rootNode.add(new DefaultMutableTreeNode(c)); }/* ww w . j a v a 2s.c om*/ return new DefaultTreeModel(rootNode); }
From source file:org.optaplanner.benchmark.impl.aggregator.swingui.BenchmarkAggregatorFrame.java
private DefaultMutableTreeNode initBenchmarkHierarchy(boolean solverFirst) { DefaultMutableTreeNode parentNode = new DefaultMutableTreeNode(new MixedCheckBox("Planner benchmarks")); for (PlannerBenchmarkResult plannerBenchmarkResult : plannerBenchmarkResultList) { DefaultMutableTreeNode plannerNode = new DefaultMutableTreeNode( createPlannerBenchmarkCheckBox(plannerBenchmarkResult)); parentNode.add(plannerNode); if (solverFirst) { for (SolverBenchmarkResult solverBenchmarkResult : plannerBenchmarkResult .getSolverBenchmarkResultList()) { DefaultMutableTreeNode solverNode = new DefaultMutableTreeNode( createSolverBenchmarkCheckBox(solverBenchmarkResult)); plannerNode.add(solverNode); for (ProblemBenchmarkResult problemBenchmarkResult : plannerBenchmarkResult .getUnifiedProblemBenchmarkResultList()) { DefaultMutableTreeNode problemNode = new DefaultMutableTreeNode( createProblemBenchmarkCheckBox(problemBenchmarkResult)); solverNode.add(problemNode); initSingleBenchmarkNodes(solverBenchmarkResult, problemBenchmarkResult, problemNode); }// w w w .j ava 2s. com } } else { for (ProblemBenchmarkResult problemBenchmarkResult : plannerBenchmarkResult .getUnifiedProblemBenchmarkResultList()) { DefaultMutableTreeNode problemNode = new DefaultMutableTreeNode( createProblemBenchmarkCheckBox(problemBenchmarkResult)); plannerNode.add(problemNode); for (SolverBenchmarkResult solverBenchmarkResult : plannerBenchmarkResult .getSolverBenchmarkResultList()) { DefaultMutableTreeNode solverNode = new DefaultMutableTreeNode( createSolverBenchmarkCheckBox(solverBenchmarkResult)); problemNode.add(solverNode); initSingleBenchmarkNodes(solverBenchmarkResult, problemBenchmarkResult, solverNode); } } } } return parentNode; }
From source file:org.optaplanner.benchmark.impl.aggregator.swingui.BenchmarkAggregatorFrame.java
private void initSingleBenchmarkNodes(SolverBenchmarkResult solverBenchmarkResult, ProblemBenchmarkResult problemBenchmarkResult, DefaultMutableTreeNode problemNode) { for (SingleBenchmarkResult singleBenchmarkResult : solverBenchmarkResult.getSingleBenchmarkResultList()) { if (singleBenchmarkResult.getProblemBenchmarkResult().equals(problemBenchmarkResult)) { DefaultMutableTreeNode singleBenchmarkNode = resultCheckBoxMapping.get(singleBenchmarkResult); if (singleBenchmarkNode != null) { problemNode.add(singleBenchmarkNode); } else { DefaultMutableTreeNode singleNode = new DefaultMutableTreeNode( createSingleBenchmarkCheckBox(singleBenchmarkResult)); problemNode.add(singleNode); resultCheckBoxMapping.put(singleBenchmarkResult, singleNode); }//ww w . ja va 2 s. c o m } } }
From source file:org.pentaho.reporting.designer.core.welcome.SamplesTreeBuilder.java
/** * Creates a list of SampleReports located in the /samples directory. *///from w w w . j av a 2s. c om private static void processDirectory(final DefaultMutableTreeNode root, final File dir, final HashMap cachedEntries, final ResourceManager resourceManager) { try { final File[] dirs = dir.listFiles(DIRECTORY_FILTER); if (dirs == null) { return; } for (final File f : dirs) { final DefaultMutableTreeNode dirNode = new DirectoryNode(f.getName()); root.add(dirNode); processDirectory(dirNode, f, cachedEntries, resourceManager); } //Now add sample files final File[] samplesArray = dir.listFiles(REPORT_FILES_FILTER); if (samplesArray == null) { return; } Arrays.sort(samplesArray); for (final File f : samplesArray) { final SampleReport entryFromCache = (SampleReport) cachedEntries.get(f.getAbsolutePath()); if (entryFromCache == null) { final SampleReport tempRpt = new SampleReport(f, resourceManager); if (StringUtils.isEmpty(tempRpt.getReportName()) == false) { final SampleNode sample = new SampleNode(tempRpt.getReportName(), tempRpt.getFileName()); root.add(sample); } cachedEntries.put(f.getAbsolutePath(), tempRpt); } else { if (StringUtils.isEmpty(entryFromCache.getReportName()) == false) { final SampleNode sample = new SampleNode(entryFromCache.getReportName(), entryFromCache.getFileName()); root.add(sample); } } } } catch (Exception se) { logger.error("Cannot access Application directory", se);// NON-NLS } }
From source file:org.photovault.swingui.volumetree.VolumeTreeController.java
void addVolume(VolumeTreeNode node) { DefaultMutableTreeNode tn = new DefaultMutableTreeNode(node); DefaultMutableTreeNode loadingNode = new DefaultMutableTreeNode("loading"); tn.add(loadingNode); rootNode.add(tn);/*from w ww . j a v a 2 s . com*/ }
From source file:org.sleuthkit.autopsy.experimental.autoingest.FileExporterSettingsPanel.java
/** * Go through the ruleSet and populate the JList * * @param ruleToBeSelected The path to the rule that should be selected * after populating the tree *///w w w . j a v a 2 s . c o m void populateRuleTree(String ruleToBeSelected) { TreePath ttt = new TreePath(rootNode); Enumeration<TreePath> expandedDescendants = trRuleList.getExpandedDescendants(ttt); expandedNodes = (expandedDescendants == null ? new ArrayList<>() : Collections.list(expandedDescendants)); if (rootNode != null) { rootNode.removeAllChildren(); } for (Rule rule : exportRuleSet.getRules().values()) { String ruleName = rule.getName(); DefaultMutableTreeNode ruleNode = new DefaultMutableTreeNode( new Item(ruleName, ROOTNODE, ItemType.RULE)); rootNode.add(ruleNode); FileMIMETypeCondition fileMIMETypeCondition = rule.getFileMIMETypeCondition(); if (fileMIMETypeCondition != null) { ruleNode.add( new DefaultMutableTreeNode(new Item("MIME Type", ruleName, ItemType.MIME_TYPE_CLAUSE))); } List<FileSizeCondition> fileSizeConditions = rule.getFileSizeConditions(); for (FileSizeCondition fsc : fileSizeConditions) { ruleNode.add(new DefaultMutableTreeNode(new Item("File Size", ruleName, ItemType.SIZE_CLAUSE))); } for (Rule.ArtifactCondition artifact : rule.getArtifactConditions()) { DefaultMutableTreeNode clauseNode = new DefaultMutableTreeNode( new Item(artifact.getTreeDisplayName(), ruleName, ItemType.ARTIFACT_CLAUSE)); ruleNode.add(clauseNode); } } ((DefaultTreeModel) trRuleList.getModel()).reload(); // Re-expand any rules that were open previously and that still exist for (TreePath e : expandedNodes) { TreePath treePath = findTreePathByRuleName(e.getLastPathComponent().toString()); trRuleList.expandPath(treePath); } expandedNodes.clear(); // select the rule to leave the cursor in a logical place if (ruleToBeSelected != null) { TreePath treePath = findTreePathByRuleName(ruleToBeSelected); treeSelectionModel.setSelectionPath(treePath); trRuleList.expandPath(treePath); } }
From source file:org.sonar.scanner.protocol.viewer.ScannerReportViewerApp.java
private void loadChildren(Component parentComponent, DefaultMutableTreeNode parentNode) { for (int ref : parentComponent.getChildRefList()) { Component child = reader.readComponent(ref); DefaultMutableTreeNode childNode = createNode(child); parentNode.add(childNode); loadChildren(child, childNode);// www . jav a 2 s. co m } }
From source file:org.tellervo.desktop.tridasv2.ui.ComponentViewerOld.java
private void recurseAddElementsToList(ElementList elements, ElementList flat, DefaultMutableTreeNode parent, Sample parentSample, int depth) { for (Element e : elements) { if (e instanceof CachedElement) { CachedElement ce = (CachedElement) e; // need the basic... if (!ce.hasBasic()) { System.err.println("Cached, but not even basic loaded!"); continue; }/* w w w.ja v a 2 s. c om*/ // add to list flat.add(ce); // add to tree DefaultMutableTreeNode node = new DefaultMutableTreeNode(ce); parent.add(node); // can't go any deeper if there's no series... if (!ce.hasFull()) continue; try { Sample s = ce.load(); //Relaxer relaxer = vv.getModel().getRelaxer(); //relaxer.pause(); graph.addEdge(edgeFactory.create(), ComponentTreeCellRenderer.getFullTitle(s, false), ComponentTreeCellRenderer.getFullTitle(parentSample, false)); ElementList sampleElements = s.getElements(); //treeLayout.initialize(); //radialLayout.initialize(); //relaxer.resume(); if (sampleElements != null) recurseAddElementsToList(sampleElements, flat, node, s, depth + 1); } catch (IOException ioe) { // shouldn't happen } } else System.err.println("Non-cached element: " + e); } }
From source file:org.wings.STree.java
/** * Creates and returns a sample TreeModel. Used primarily for beanbuilders. * to show something interesting.//from w ww . ja v a2s . c o m * * @return the default TreeModel */ protected static TreeModel getDefaultTreeModel() { DefaultMutableTreeNode root = new DefaultMutableTreeNode("STree"); DefaultMutableTreeNode parent; parent = new DefaultMutableTreeNode("colors"); root.add(parent); parent.add(new DefaultMutableTreeNode("blue")); parent.add(new DefaultMutableTreeNode("violet")); parent.add(new DefaultMutableTreeNode("red")); parent.add(new DefaultMutableTreeNode("yellow")); parent = new DefaultMutableTreeNode("sports"); root.add(parent); parent.add(new DefaultMutableTreeNode("basketball")); parent.add(new DefaultMutableTreeNode("soccer")); parent.add(new DefaultMutableTreeNode("football")); parent.add(new DefaultMutableTreeNode("hockey")); parent = new DefaultMutableTreeNode("food"); root.add(parent); parent.add(new DefaultMutableTreeNode("hot dogs")); parent.add(new DefaultMutableTreeNode("pizza")); parent.add(new DefaultMutableTreeNode("ravioli")); parent.add(new DefaultMutableTreeNode("bananas")); return new DefaultTreeModel(root); }