List of usage examples for javax.swing.tree DefaultMutableTreeNode getChildCount
public int getChildCount()
From source file:GUI.MainWindow.java
private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed System.out.println("Export to excel clicked"); DefaultTreeModel dtm = (DefaultTreeModel) this.VulnTree.getModel(); DefaultMutableTreeNode root = (DefaultMutableTreeNode) dtm.getRoot(); System.out.println("Child Count: " + root.getChildCount()); if (root.getChildCount() == 0) { System.out.println("No vulns in tree. Halting the export"); return;/*w w w .jav a2 s .co m*/ } // If we get here then there are some vulns. // Prompt for an export file. boolean proceed = true; int returnVal = this.fileChooser.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File save_file = fileChooser.getSelectedFile(); System.out.println(save_file); if (save_file.exists() == true) { int response = JOptionPane.showConfirmDialog(null, "Are you sure you want to replace existing file?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.NO_OPTION) { proceed = false; } } if (proceed == true) { ExportToExcel excelOut = new ExportToExcel(); try { excelOut.writeExcel(save_file, root); } catch (IOException ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, ex); } catch (WriteException ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, ex); } } } }
From source file:com.pironet.tda.TDA.java
/** * get the dump with the given name, starting from the provided node. *///from w w w.j a v a 2 s.c o m private DefaultMutableTreeNode getDumpRootNode(String dumpName, DefaultMutableTreeNode node) { DefaultMutableTreeNode lastNode = null; // search for starting node while (node != null && !(node.getUserObject() instanceof Logfile)) { lastNode = node; node = (DefaultMutableTreeNode) node.getParent(); } if (node == null) { node = lastNode; } DefaultMutableTreeNode dumpNode = null; if (node != null) { for (int i = 0; i < node.getChildCount(); i++) { Object userObject = ((DefaultMutableTreeNode) node.getChildAt(i)).getUserObject(); if ((userObject instanceof ThreadDumpInfo) && ((ThreadDumpInfo) userObject).getName().startsWith(dumpName)) { dumpNode = (DefaultMutableTreeNode) node.getChildAt(i); break; } } } return (dumpNode); }
From source file:edu.harvard.i2b2.previousquery.ui.PreviousQueryPanel.java
public DefaultMutableTreeNode addNode(QueryConceptTreeNodeData node, DefaultMutableTreeNode parent) { DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(node); QueryConceptTreeNodeData tmpData = new QueryConceptTreeNodeData(); tmpData.name("working ......"); tmpData.tooltip("A tmp node"); tmpData.visualAttribute("LAO"); DefaultMutableTreeNode tmpNode = new DefaultMutableTreeNode(tmpData); treeModel.insertNodeInto(childNode, parent, parent.getChildCount()); if (!(node.visualAttribute().startsWith("L") || node.visualAttribute().equalsIgnoreCase("MA"))) { treeModel.insertNodeInto(tmpNode, childNode, childNode.getChildCount()); }/*from ww w . j a v a2 s . com*/ return childNode; }
From source file:com.pironet.tda.SunJDKParser.java
/** * dump the monitor information/*from w w w .j a va 2 s.c om*/ */ private int[] dumpMonitors(DefaultMutableTreeNode catMonitors, DefaultMutableTreeNode catMonitorsLocks, MonitorMap mmap) { Iterator iter = mmap.iterOfKeys(); int monitorsWithoutLocksCount = 0; int overallThreadsWaiting = 0; while (iter.hasNext()) { String monitor = (String) iter.next(); Map<String, String>[] threads = mmap.getFromMonitorMap(monitor); ThreadInfo mi = new ThreadInfo(monitor, null, "", 0, null); DefaultMutableTreeNode monitorNode = new DefaultMutableTreeNode(mi); // first the locks Iterator<String> iterLocks = threads[MonitorMap.LOCK_THREAD_POS].keySet().iterator(); int locks = 0; int sleeps = 0; while (iterLocks.hasNext()) { String thread = iterLocks.next(); String stackTrace = threads[MonitorMap.LOCK_THREAD_POS].get(thread); if (threads[MonitorMap.SLEEP_THREAD_POS].containsKey(thread)) { createNode(monitorNode, "locks and sleeps on monitor: " + thread, null, stackTrace, 0); sleeps++; } else if (threads[MonitorMap.WAIT_THREAD_POS].containsKey(thread)) { createNode(monitorNode, "locks and waits on monitor: " + thread, null, stackTrace, 0); sleeps++; } else { createNode(monitorNode, "locked by " + thread, null, stackTrace, 0); } locks++; } Iterator iterWaits = threads[MonitorMap.WAIT_THREAD_POS].keySet().iterator(); int waits = 0; while (iterWaits.hasNext()) { String thread = (String) iterWaits.next(); if (!threads[MonitorMap.LOCK_THREAD_POS].containsKey(thread)) { createNode(monitorNode, "waits on monitor: " + thread, null, threads[MonitorMap.WAIT_THREAD_POS].get(thread), 0); waits++; } } mi.setContent(ThreadDumpInfo.getMonitorInfo(locks, waits, sleeps)); mi.setName(mi.getName() + ": " + (sleeps) + " Thread(s) sleeping, " + (waits) + " Thread(s) waiting, " + (locks) + " Thread(s) locking"); if (ThreadDumpInfo.areALotOfWaiting(waits)) { mi.setALotOfWaiting(true); } mi.setChildCount(monitorNode.getChildCount()); ((Category) catMonitors.getUserObject()).addToCatNodes(monitorNode); if (locks == 0) { monitorsWithoutLocksCount++; overallThreadsWaiting += waits; ((Category) catMonitorsLocks.getUserObject()).addToCatNodes(monitorNode); } } return new int[] { monitorsWithoutLocksCount, overallThreadsWaiting }; }
From source file:edu.harvard.i2b2.previousquery.ui.PreviousQueryPanel.java
public DefaultMutableTreeNode addNode(QueryMasterData node) { DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(node); QueryMasterData tmpData = new QueryMasterData(); tmpData.name("working ......"); tmpData.tooltip("A tmp node"); tmpData.visualAttribute("LAO"); DefaultMutableTreeNode tmpNode = new DefaultMutableTreeNode(tmpData); treeModel.insertNodeInto(childNode, top, top.getChildCount()); if (!(node.visualAttribute().startsWith("L") || node.visualAttribute().equalsIgnoreCase("MA"))) { treeModel.insertNodeInto(tmpNode, childNode, childNode.getChildCount()); }//from w ww. j a v a 2 s . c o m jTree1.expandPath(new TreePath(top.getPath())); return childNode; }
From source file:ai.aitia.meme.paramsweep.intellisweepPlugin.JgapGAPlugin.java
private void loadParameter(final NodeList parameterList, final List<ParameterInfo> params, final DefaultMutableTreeNode root) throws WizardLoadingException { if (parameterList != null) { for (int i = 0; i < parameterList.getLength(); ++i) { final Element parameterElement = (Element) parameterList.item(i); final String paramName = parameterElement.getAttribute(WizardSettingsManager.NAME); if (paramName == null || paramName.trim().isEmpty()) { throw new WizardLoadingException(true, "missing attribute '" + WizardSettingsManager.NAME + "' at node: " + PARAMETER); }//www . jav a 2 s . c o m final ParameterInfo info = findParameterInfo(params, paramName.trim()); if (info != null) { final NodeList content = parameterElement.getChildNodes(); if (content == null || content.getLength() == 0) { throw new WizardLoadingException(true, "missing content at node: " + PARAMETER); } final String parameterValue = ((Text) content.item(0)).getNodeValue().trim(); Object value; if (info.getType().equals("File") && parameterValue.isEmpty()) { value = new File(""); } else { value = ParameterInfo.getValue(parameterValue, info.getJavaType()); } info.setValue(value); final ParameterOrGene userObj = new ParameterOrGene(info); final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(userObj); getChromosomeTree().insertNodeInto(newNode, root, root.getChildCount()); } else { throw new WizardLoadingException(false, "Unrecognized gene: " + paramName + " (ignored)"); } } } }
From source file:edu.harvard.i2b2.query.ui.GroupPanel.java
public void treeExpanded(TreeExpansionEvent event) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) event.getPath().getLastPathComponent(); QueryConceptTreeNodeData data = (QueryConceptTreeNodeData) node.getUserObject(); jTree1.scrollPathToVisible(new TreePath(node)); // System.out.println("Node expanded: "+data.dimcode()); if (data.visualAttribute().equals("L")) { // return; }/* w w w . j av a 2 s. c o m*/ if (data.visualAttribute().equals("FA")) { data.visualAttribute("FAO"); } else if (data.visualAttribute().equals("CA")) { data.visualAttribute("CAO"); } // check to see if child is a placeholder ('working...') // if so, make Web Service call to update children of node if (node.getChildCount() == 1) { final DefaultMutableTreeNode node1 = (DefaultMutableTreeNode) node.getChildAt(0); if (((QueryConceptTreeNodeData) node1.getUserObject()).name().equalsIgnoreCase("working ......")) { final DefaultMutableTreeNode anode = node; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { populateChildNodes(anode); } }); } } else { for (int i = 0; i < node.getChildCount(); i++) { DefaultMutableTreeNode anode = (DefaultMutableTreeNode) node.getChildAt(0); QueryConceptTreeNodeData adata = (QueryConceptTreeNodeData) anode.getUserObject(); if (adata.visualAttribute().equals("FAO")) { // adata.visualAttribute("FA"); } else if (adata.visualAttribute().equals("CAO")) { // adata.visualAttribute("CA"); } } } }
From source file:edu.harvard.i2b2.patientSet.ui.PatientSetJPanel.java
public DefaultMutableTreeNode addNode(QueryMasterData node, DefaultMutableTreeNode parent) { DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(node); QueryMasterData tmpData = new QueryMasterData(); tmpData.name("working ......"); tmpData.tooltip("A tmp node"); tmpData.visualAttribute("LAO"); DefaultMutableTreeNode tmpNode = new DefaultMutableTreeNode(tmpData); treeModel.insertNodeInto(childNode, parent, parent.getChildCount()); if (!(node.visualAttribute().startsWith("L") || node.visualAttribute().equalsIgnoreCase("MA"))) { treeModel.insertNodeInto(tmpNode, childNode, childNode.getChildCount()); }// ww w . j ava 2s. c o m return childNode; }
From source file:edu.harvard.i2b2.patientSet.ui.PatientSetJPanel.java
public DefaultMutableTreeNode addNode(QueryConceptTreeNodeModel node, DefaultMutableTreeNode parent) { DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(node); QueryConceptTreeNodeModel tmpData = new QueryConceptTreeNodeModel(); tmpData.name("working ......"); tmpData.tooltip("A tmp node"); tmpData.visualAttribute("LAO"); DefaultMutableTreeNode tmpNode = new DefaultMutableTreeNode(tmpData); treeModel.insertNodeInto(childNode, parent, parent.getChildCount()); if (!(node.visualAttribute().startsWith("L") || node.visualAttribute().equalsIgnoreCase("MA"))) { treeModel.insertNodeInto(tmpNode, childNode, childNode.getChildCount()); }/*from w w w . j av a2 s.c o m*/ return childNode; }
From source file:GUI.MainWindow.java
private void doDelete() { DefaultTreeModel dtm = (DefaultTreeModel) VulnTree.getModel(); DefaultMutableTreeNode root = (DefaultMutableTreeNode) dtm.getRoot(); TreePath[] paths = VulnTree.getSelectionPaths(); if (paths == null) { return;/*w w w . j av a 2 s.c om*/ } for (int i = 0; i < paths.length; i++) { TreePath path = paths[i]; DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); if (i == 0) { // This is the first delete operation DefaultMutableTreeNode previous = (DefaultMutableTreeNode) node.getPreviousSibling(); // Consider saving deleted vulns into a scratchpad file TODO //System.out.println("previous:" + previous); // If it is null here we have no nodes above it, we get the next sibling below if (previous == null) { previous = (DefaultMutableTreeNode) node.getNextSibling(); } // If it is still null here there are no nodes in the tree. Point to the root. Avoids NullPointerException if (previous == null) { previous = root; } TreePath p = new TreePath(previous.getPath()); VulnTree.setSelectionPath(p); } if (node.getParent() != null) { dtm.removeNodeFromParent(node); } } if (root.getChildCount() == 0) { clearGUI(); } }