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:edu.ucla.stat.SOCR.chart.ChartTree.java
private TreeModel createTreeModel() { DefaultMutableTreeNode root = new DefaultMutableTreeNode("SOCRCharts"); root.add(createPieChartsNode()); root.add(createBarChartsNode());//from w w w . j a va 2 s. c o m root.add(createLineChartsNode()); root.add(createAreaChartsNode()); // root.add(createTimeSeriesChartsNode()); // root.add(createFinancialChartsNode()); // root.add(createXYChartsNode()); // root.add(createMeterChartsNode()); // root.add(createMultipleAxisChartsNode()); // root.add(createCombinedAxisChartsNode()); // root.add(createGanttChartsNode()); root.add(createMiscellaneousChartsNode()); return new DefaultTreeModel(root); }
From source file:it.unibas.spicygui.controllo.window.operator.ProjectTreeGenerator.java
private void analizzaScenario(DefaultMutableTreeNode treeNode, Scenario scenario) { DefaultMutableTreeNode nodeScenario = null; if (scenario.isSelected()) { nodeScenario = new DefaultMutableTreeNode(new TreeTopComponentAdapter(scenario, true, false, false)); } else {/*from w ww. jav a 2s . c om*/ nodeScenario = new DefaultMutableTreeNode(new TreeTopComponentAdapter(scenario, false, false, false)); } treeNode.add(nodeScenario); if (scenario.getMappingTaskTopComponent() != null) { DefaultMutableTreeNode nodeTopComponent = new DefaultMutableTreeNode( new TreeTopComponentAdapter(scenario.getMappingTaskTopComponent(), false, false, false)); nodeScenario.add(nodeTopComponent); createMappingTaskChild(nodeTopComponent, scenario.getMappingTask().getSourceProxy(), "Source"); createMappingTaskChild(nodeTopComponent, scenario.getMappingTask().getTargetProxy(), "Target"); } if (scenario.getTransformationTopComponent() != null) { DefaultMutableTreeNode nodeTopComponent = new DefaultMutableTreeNode( new TreeTopComponentAdapter(scenario.getTransformationTopComponent(), false, false, false)); nodeScenario.add(nodeTopComponent); } if (scenario.getInstancesTopComponent() != null) { DefaultMutableTreeNode nodeTopComponent = new DefaultMutableTreeNode( new TreeTopComponentAdapter(scenario.getInstancesTopComponent(), false, false, false)); nodeScenario.add(nodeTopComponent); createInstanceChild(nodeTopComponent, scenario.getMappingTask().getSourceProxy(), "Source"); createInstanceChild(nodeTopComponent, scenario.getMappingTask().getTargetProxy(), "Taget"); } if (scenario.getXQueryTopComponent() != null) { DefaultMutableTreeNode nodeTopComponent = new DefaultMutableTreeNode( new TreeTopComponentAdapter(scenario.getXQueryTopComponent(), false, false, false)); nodeScenario.add(nodeTopComponent); } if (scenario.getSqlTopComponent() != null) { DefaultMutableTreeNode nodeTopComponent = new DefaultMutableTreeNode( new TreeTopComponentAdapter(scenario.getSqlTopComponent(), false, false, false)); nodeScenario.add(nodeTopComponent); } if (scenario.getTGDListTopComponent() != null) { DefaultMutableTreeNode nodeTopComponent = new DefaultMutableTreeNode( new TreeTopComponentAdapter(scenario.getTGDListTopComponent(), false, false, false)); nodeScenario.add(nodeTopComponent); } if (scenario.getTGDCorrespondencesTopComponent() != null) { DefaultMutableTreeNode nodeTopComponent = new DefaultMutableTreeNode( new TreeTopComponentAdapter(scenario.getTGDCorrespondencesTopComponent(), false, false, false)); nodeScenario.add(nodeTopComponent); } }
From source file:gov.nih.nci.ncicb.cadsr.contexttree.CDEBrowserTree.java
public DefaultMutableTreeNode buildTree(Hashtable treeParams) throws Exception { DefaultMutableTreeNode tree = null; BaseTreeNode baseNode = null;//from ww w. ja v a 2 s . c om //TimeUtils.recordStartTime("Tree"); try { log.info("Tree Start " + TimeUtils.getEasternTime()); baseNode = new BaseTreeNode(treeParams); CDEBrowserTreeCache cache = CDEBrowserTreeCache.getAnInstance(); cache.init(baseNode, treeParams); WebNode contexts = new WebNode(cache.getIdGen().getNewId(), "caDSR Contexts", "javascript:" + baseNode.getJsFunctionName() + "('P_PARAM_TYPE=P_PARAM_TYPE&P_IDSEQ=P_IDSEQ&" + baseNode.getExtraURLParameters() + "')"); tree = new DefaultMutableTreeNode(contexts); List allContexts = cache.getAllContextHolders(); if (allContexts == null) return tree; ListIterator contextIt = allContexts.listIterator(); while (contextIt.hasNext()) { ContextHolder currContextHolder = (ContextHolder) contextIt.next(); Context currContext = currContextHolder.getContext(); DefaultMutableTreeNode contextNode = currContextHolder.getNode(); //Adding data template nodes DefaultMutableTreeNode tmpLabelNode; DefaultMutableTreeNode otherTempNodes; if (Context.CTEP.equals(currContext.getName())) { cache.initCtepInfo(baseNode, currContext); tmpLabelNode = new DefaultMutableTreeNode( new WebNode(cache.getIdGen().getNewId(), "Protocol Form Templates")); List ctepNodes = cache.getAllTemplatesForCtep(); tmpLabelNode.add((DefaultMutableTreeNode) ctepNodes.get(0)); tmpLabelNode.add((DefaultMutableTreeNode) ctepNodes.get(1)); contextNode.add(tmpLabelNode); log.info("CTEP Templates End " + TimeUtils.getEasternTime()); } else { log.info("Other Templates Start " + TimeUtils.getEasternTime()); otherTempNodes = cache.getTemplateNodes(currContext.getConteIdseq()); if (otherTempNodes != null) { contextNode.add(otherTempNodes); } log.info("Other Templates End " + TimeUtils.getEasternTime()); } //Adding classification nodes long startingTime = System.currentTimeMillis(); log.info("Classification Start " + TimeUtils.getEasternTime()); DefaultMutableTreeNode csNode = cache.getClassificationNodes(currContext.getConteIdseq()); if (csNode != null) contextNode.add(csNode); long timeElsp = System.currentTimeMillis() - startingTime; log.info("Classification Took " + timeElsp); //End Adding Classification Node //Adding protocols nodes //Filtering CTEP context in data element search tree log.info("Proto forms Start " + TimeUtils.getEasternTime()); /** Remove to TT 1892 if ((!currContext.getName().equals(Context.CTEP) && treeType.equals(TreeConstants.DE_SEARCH_TREE)) //Publish Change order || (baseNode.isCTEPUser().equals("Yes") && treeType.equals(TreeConstants.DE_SEARCH_TREE)) || (treeType.equals(TreeConstants.FORM_SEARCH_TREE))) { if ((currContext.getName().equals( Context.CTEP) && baseNode.isCTEPUser().equals("Yes")) || (!currContext.getName().equals(Context.CTEP))) { **/ List protoNodes = cache.getProtocolNodes(currContext.getConteIdseq()); /** for release 3.0.1, forms without protocol is not displayed, uncomment this * code to display them DefaultMutableTreeNode noProtocolFormNode = cache.getProtocolFormNodeWithNoProtocol(currContext.getConteIdseq()); */ DefaultMutableTreeNode protocolFormsLabelNode = null; /** for release 3.0.1, forms without protocol is not displayed, uncomment this * code to display them if ((protoNodes != null && !protoNodes.isEmpty()) || noProtocolFormNode != null ) { */ if ((protoNodes != null && !protoNodes.isEmpty())) { protocolFormsLabelNode = new DefaultMutableTreeNode( new WebNode(cache.getIdGen().getNewId(), "Protocol Forms")); /** for release 3.0.1, forms without protocol is not displayed, uncomment this * code to display them // Add form with no protocol if (noProtocolFormNode != null ) { protocolFormsLabelNode.add(noProtocolFormNode); } */ // Add form with protocol if (protoNodes != null && !protoNodes.isEmpty()) { Iterator tmpIter = protoNodes.iterator(); while (tmpIter.hasNext()) { protocolFormsLabelNode.add((DefaultMutableTreeNode) tmpIter.next()); } } contextNode.add(protocolFormsLabelNode); } /** } TT 1892 }**/ log.info("Proto forms End " + TimeUtils.getEasternTime()); //End Add Protocol Nodes //Display Catalog //Get Publishing Node info log.info("Publish strat " + TimeUtils.getEasternTime()); DefaultMutableTreeNode publishNode = cache.getPublishNode(currContext); if (publishNode != null) contextNode.add(publishNode); log.info("Publish end " + TimeUtils.getEasternTime()); //End Catalog tree.add(contextNode); } log.info("Tree End " + TimeUtils.getEasternTime()); } catch (Exception ex) { ex.printStackTrace(); throw ex; } return tree; }
From source file:dotaSoundEditor.Controls.EditorPanel.java
protected TreeModel buildSoundListTree(TreeModel scriptTree) { TreeNode rootNode = (TreeNode) scriptTree.getRoot(); int childCount = rootNode.getChildCount(); TreeModel soundListTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode("root")); ArrayList<String> wavePathsList = new ArrayList<>(); for (int i = 0; i < childCount; i++) { String nodeValue = scriptTree.getChild(rootNode, i).toString(); if (nodeValue.trim().startsWith("//")) { continue; }//from w ww. java2s.co m wavePathsList = getWavePathsAsList((TreeNode) scriptTree.getChild(rootNode, i)); DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(nodeValue); for (String s : wavePathsList) { DefaultMutableTreeNode tempNode = new DefaultMutableTreeNode(s); newNode.add(tempNode); } ((DefaultMutableTreeNode) soundListTreeModel.getRoot()).add(newNode); } return soundListTreeModel; }
From source file:Importers.ImportReportCompiler.java
@Override public DefaultMutableTreeNode readFile(File importFile) { System.out.println("==ImportReportCompiler=readFile"); DefaultMutableTreeNode root = new DefaultMutableTreeNode("vulns"); try {/*w w w . j a va2s. co m*/ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(importFile); doc.normalize(); NodeList vulns_list = doc.getElementsByTagName("vuln"); for (int i = 0; i < vulns_list.getLength(); i++) { Node vuln_node = vulns_list.item(i); Vulnerability vuln = getVuln(vuln_node); root.add(new DefaultMutableTreeNode(vuln)); } } catch (ParserConfigurationException ex) { Logger.getLogger(NessusV2XMLImporter.class.getName()).log(Level.SEVERE, null, ex); } catch (SAXException ex) { Logger.getLogger(NessusV2XMLImporter.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(NessusV2XMLImporter.class.getName()).log(Level.SEVERE, null, ex); } return root; }
From source file:net.sf.taverna.t2.workbench.views.results.workflow.RenderedResultComponent.java
public void buildErrorDocumentTree(DefaultMutableTreeNode node, ErrorDocument errorDocument) throws IOException { DefaultMutableTreeNode child = new DefaultMutableTreeNode(errorDocument); String trace = errorDocument.getTrace(); if (trace != null && !trace.isEmpty()) for (String line : trace.split("\n")) child.add(new DefaultMutableTreeNode(line)); node.add(child);//from w w w . j av a 2s.com List<Path> causes = errorDocument.getCausedBy(); for (Path cause : causes) if (DataBundles.isError(cause)) { ErrorDocument causeErrorDocument = DataBundles.getError(cause); if (causes.size() == 1) buildErrorDocumentTree(node, causeErrorDocument); else buildErrorDocumentTree(child, causeErrorDocument); } else if (DataBundles.isList(cause)) { List<ErrorDocument> errorDocuments = getErrorDocuments(cause); if (errorDocuments.size() == 1) buildErrorDocumentTree(node, errorDocuments.get(0)); else for (ErrorDocument errorDocument2 : errorDocuments) buildErrorDocumentTree(child, errorDocument2); } }
From source file:br.upe.ecomp.dosa.view.mainwindow.MainWindowActions.java
private void addMeasurement(DefaultMutableTreeNode meassurementNode, Algorithm algorithm) { DefaultMutableTreeNode measurementChild; for (Measurement measurement : algorithm.getMeasurements()) { measurementChild = new ExtendedTreeNode(measurement, TreeNodeTypeEnum.MEASSUREMENT_CHILD); meassurementNode.add(measurementChild); }//w w w . j a v a2 s . co m }
From source file:com.compomics.cell_coord.gui.controller.load.LoadTracksController.java
/** * Load the data files into the tree.// w w w. java 2s. c o m * * @throws LoadDirectoryException - when the directory is empty! */ private void loadDataIntoTree() throws LoadDirectoryException { DefaultTreeModel model = (DefaultTreeModel) loadTracksPanel.getDirectoryTree().getModel(); DefaultMutableTreeNode rootNote = (DefaultMutableTreeNode) model.getRoot(); // change name (user object) of root node rootNote.setUserObject(directory.getName()); File[] listFiles = directory.listFiles(); if (listFiles.length != 0) { for (File file : listFiles) { if (!file.isDirectory()) { DefaultMutableTreeNode fileNode = new DefaultMutableTreeNode(file.getName(), Boolean.FALSE); rootNote.add(fileNode); } else { // reset the directory to null directory = null; throw new LoadDirectoryException("This directory has a wrong structure!"); } } } else { // reset the directory to null directory = null; throw new LoadDirectoryException("This directory seems to be empty!"); } model.reload(); loadTracksPanel.getChosenDirectoryTextArea().setText(directory.getAbsolutePath()); cellCoordController.showMessage("Directory successful loaded!\nYou can now select the files to import!", "", JOptionPane.INFORMATION_MESSAGE); loadTracksPanel.getImportFilesButton().setEnabled(true); }
From source file:br.upe.ecomp.dosa.view.mainwindow.MainWindowActions.java
private void addStopCondition(DefaultMutableTreeNode stopConditionNode, Algorithm algorithm) { DefaultMutableTreeNode stopConditionChild; for (StopCondition stopCondition : algorithm.getStopConditions()) { stopConditionChild = new ExtendedTreeNode(stopCondition, TreeNodeTypeEnum.STOP_CONDITION_CHILD); stopConditionNode.add(stopConditionChild); }/* w w w. j ava 2 s . com*/ }
From source file:io.bibleget.BibleGetHelp.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor./*from w w w.j a v a 2s .c om*/ */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jSplitPane1 = new javax.swing.JSplitPane(); jScrollPane2 = new javax.swing.JScrollPane(); jTree1 = new javax.swing.JTree(); jScrollPane3 = new javax.swing.JScrollPane(); jTextPane2 = new javax.swing.JTextPane(); jTextPane2.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, true); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle(__("Instructions")); setBounds(frameLeft, frameTop, frameWidth, frameHeight); setIconImages(setIconImages()); renderer = new LocalCellRenderer(jTree1); javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode(__("Help")); javax.swing.tree.DefaultMutableTreeNode treeNode2 = new javax.swing.tree.DefaultMutableTreeNode( __("Usage of the Plugin")); javax.swing.tree.DefaultMutableTreeNode treeNode3; treeNode1.add(treeNode2); treeNode2 = new javax.swing.tree.DefaultMutableTreeNode(__("Formulation of the Queries")); treeNode1.add(treeNode2); treeNode2 = new javax.swing.tree.DefaultMutableTreeNode(__("Biblical Books and Abbreviations")); treeNode1.add(treeNode2); for (JsonValue jsonValue : bibleVersionsObj) { treeNode3 = new javax.swing.tree.DefaultMutableTreeNode( BibleGetI18N.localizeLanguage(jsonValue.toString())); treeNode2.add(treeNode3); } jTree1.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1)); jTree1.setCellRenderer(renderer); jTree1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jTree1MouseClicked(evt); } }); jScrollPane2.setViewportView(jTree1); jSplitPane1.setLeftComponent(jScrollPane2); jTextPane2.setContentType("text/html;charset=UTF-8"); // NOI18N jTextPane2.setDocument(doc); jTextPane2.setEditorKit(kit); jTextPane2.setText(HTMLStr0); jScrollPane3.setViewportView(jTextPane2); jSplitPane1.setRightComponent(jScrollPane3); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1250, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 600, Short.MAX_VALUE)); pack(); }