List of usage examples for javax.swing.tree DefaultMutableTreeNode getUserObject
public Object getUserObject()
From source file:edu.ku.brc.specify.tasks.subpane.security.NavigationTreeContextMenuMgr.java
/** * @param node/* w w w. j a v a 2s .c o m*/ * @return */ private DefaultMutableTreeNode getAdminTreeNode(final DefaultMutableTreeNode node) { for (int i = 0; i < node.getChildCount(); i++) { DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt(i); FormDataObjIFace dmObj = ((DataModelObjBaseWrapper) child.getUserObject()).getDataObj(); if (dmObj instanceof SpPrincipal) { String name = ((SpPrincipal) dmObj).getName(); if (name.equals("Administrator")) { return (DefaultMutableTreeNode) child; } } DefaultMutableTreeNode cNode = getAdminTreeNode(child); if (cNode != null) { return cNode; } } return null; }
From source file:be.ugent.maf.cellmissy.gui.controller.load.generic.DragAndDropController.java
/** * Taking the directory of the parent controller, and knowing the current * combination imaging type-algorithm, get the data file to parse. * * @param node//from w w w .ja v a2 s. c o m * @return */ private File getDataFile(DefaultMutableTreeNode node) { String directoryPath = genericImagedPlateController.getDirectory().getAbsolutePath(); String textFile = "" + node.getUserObject(); return new File(directoryPath + File.separator + currentAlgorithm + File.separator + currentImagingType + File.separator + textFile); }
From source file:com.pironet.tda.AbstractDumpParser.java
/** * check threads in given thread dump and add appropriate * custom categories (if any defined).//w w w . ja va 2 s . co m * * @param threadDump the thread dump info object. */ public void addCustomCategories(DefaultMutableTreeNode threadDump) { ThreadDumpInfo tdi = (ThreadDumpInfo) threadDump.getUserObject(); Category threads = tdi.getThreads(); ListModel cats = PrefManager.get().getCategories(); for (int i = 0; i < cats.getSize(); i++) { final Category cat = new TableCategory(((CustomCategory) cats.getElementAt(i)).getName(), IconFactory.CUSTOM_CATEGORY); for (int j = 0; j < threads.getNodeCount(); j++) { Iterator filterIter = ((CustomCategory) cats.getElementAt(i)).iterOfFilters(); boolean matches = true; ThreadInfo ti = (ThreadInfo) threads.getNodeAt(j).getUserObject(); while (matches && filterIter.hasNext()) { Filter filter = (Filter) filterIter.next(); matches = filter.matches(ti, true); } if (matches) { cat.addToCatNodes(new DefaultMutableTreeNode(ti)); } } if (cat.getNodeCount() > 0) { cat.setName(cat.getName() + " (" + cat.getNodeCount() + " Threads overall)"); threadDump.add(new DefaultMutableTreeNode(cat)); } } }
From source file:edu.mbl.jif.datasetconvert.CheckboxTreeDimensions.java
public void getSelectedIndices() { // channels = new int[]{0, 1, 2, 3, 4, 5, 6}; // slices = new int[]{0}; // frames = new int[]{0, 2}; // positions = new int[]{0}; List listChannels = new ArrayList(); List listSlices = new ArrayList(); List listFrames = new ArrayList(); List listPositions = new ArrayList(); // Check if root "All" selected, if so, not need to go further TreePath[] cr = CheckboxTreeDimensions.this.checkboxTree.getCheckingRoots(); for (TreePath path : cr) { System.out.println(path.getLastPathComponent()); }/*from w ww . j a v a2 s . c o m*/ System.out.println("\nPaths: "); TreePath[] cp = CheckboxTreeDimensions.this.checkboxTree.getCheckingPaths(); for (TreePath path : cp) { //Object[] pathObjs = path.getPath(); System.out.println(path.toString()); if (path.getPathCount() == 3) { DefaultMutableTreeNode nodeDim = (DefaultMutableTreeNode) path.getPathComponent(1); String dimension = (String) nodeDim.getUserObject(); DefaultMutableTreeNode nodeIndex = (DefaultMutableTreeNode) path.getPathComponent(2); Object uo = nodeIndex.getUserObject(); if (dimension.equalsIgnoreCase("Channel")) { String chan = (String) nodeIndex.getUserObject(); listChannels.add(chan); } if (dimension.equalsIgnoreCase("Z-Section")) { int index = (Integer) nodeIndex.getUserObject(); listSlices.add(index); } if (dimension.equalsIgnoreCase("TimePoint")) { int index = (Integer) nodeIndex.getUserObject(); listFrames.add(index); } if (dimension.equalsIgnoreCase("Position")) { int index = (Integer) nodeIndex.getUserObject(); listPositions.add(index); } } } // sort the list Collections.sort(listChannels); Collections.sort(listSlices); Collections.sort(listFrames); Collections.sort(listPositions); System.out.println("\nChannels: "); Iterator<Object> it = listChannels.iterator(); while (it.hasNext()) { Object obj = it.next(); System.out.print(" " + obj); } // Change list of channel names to an array of channel indices System.out.println("\nChannel Indices: "); Iterator<Object> itc = listChannels.iterator(); channels = new int[listChannels.size()]; int c = 0; while (itc.hasNext()) { Object obj = itc.next(); String channelName = (String) obj; int index = indexOfChannel(channelNamesOriginal, channelName, 0); channels[c] = index; c++; System.out.print(" " + channelName + " ::: " + index); } // String[] strArray = {"abcd", "abdc", "bcda"}; //for (String s : strArray) // if (s.startsWith(searchTerm)) // System.out.println(s); // Swap startsWith for contains you wish to simply look for containment. System.out.println("\nSlices: "); it = listSlices.iterator(); slices = new int[listSlices.size()]; c = 0; while (it.hasNext()) { Object obj = it.next(); int index = (Integer) obj; slices[c] = index; c++; System.out.print(" " + obj); } System.out.println("\nFrames: "); it = listFrames.iterator(); frames = new int[listFrames.size()]; c = 0; while (it.hasNext()) { Object obj = it.next(); int index = (Integer) obj; frames[c] = index; c++; System.out.print(" " + obj); } System.out.println("\nPositions: "); it = listPositions.iterator(); positions = new int[listPositions.size()]; c = 0; while (it.hasNext()) { Object obj = it.next(); int index = (Integer) obj; positions[c] = index; c++; System.out.print(" " + obj); } if (channels.length < 1) { promptForNoChoice("Channel"); } System.out.println(Arrays.toString(channels)); System.out.println(Arrays.toString(slices)); System.out.println(Arrays.toString(frames)); System.out.println(Arrays.toString(positions)); //CheckboxTreeExample_1.this.checkboxTree.; }
From source file:FileTree3.java
public boolean expand(DefaultMutableTreeNode parent) { DefaultMutableTreeNode flag = (DefaultMutableTreeNode) parent.getFirstChild(); if (flag == null) // No flag return false; Object obj = flag.getUserObject(); if (!(obj instanceof Boolean)) return false; // Already expanded parent.removeAllChildren(); // Remove Flag File[] files = listFiles();/*from w w w . jav a 2 s . co m*/ if (files == null) return true; Vector v = new Vector(); for (int k = 0; k < files.length; k++) { File f = files[k]; if (!(f.isDirectory())) continue; FileNode newNode = new FileNode(f); boolean isAdded = false; for (int i = 0; i < v.size(); i++) { FileNode nd = (FileNode) v.elementAt(i); if (newNode.compareTo(nd) < 0) { v.insertElementAt(newNode, i); isAdded = true; break; } } if (!isAdded) v.addElement(newNode); } for (int i = 0; i < v.size(); i++) { FileNode nd = (FileNode) v.elementAt(i); IconData idata = new IconData(FileTree3.ICON_FOLDER, FileTree3.ICON_EXPANDEDFOLDER, nd); DefaultMutableTreeNode node = new DefaultMutableTreeNode(idata); parent.add(node); if (nd.hasSubDirs()) node.add(new DefaultMutableTreeNode(new Boolean(true))); } return true; }
From source file:it.cnr.icar.eric.client.ui.swing.ConceptsTreeModel.java
/** * Implementation for expandTree. Option to fire no events. *//*from ww w . jav a 2 s. c o m*/ private void expandTree(final DefaultMutableTreeNode node, final int depth, boolean quiet) { // Warning: this method should be executed by a SwingWorker Object userObj = node.getUserObject(); if (!(userObj instanceof NodeInfo)) { return; } final NodeInfo nodeInfo = (NodeInfo) userObj; if (nodeInfo.loaded) { return; } nodeInfo.loaded = true; Collection<?> childConcepts = null; try { childConcepts = getChildConcepts(nodeInfo.obj); } catch (JAXRException e) { log.error(e); } if (childConcepts != null) { Iterator<?> iter = childConcepts.iterator(); int newDepth = depth - 1; while (iter.hasNext()) { // expandTree() NodeInfo newNodeInfo = new NodeInfo(); Concept childConcept = (Concept) iter.next(); newNodeInfo.obj = childConcept; newNodeInfo.loaded = false; ConceptsTreeNode newNode = new ConceptsTreeNode(newNodeInfo); // insertNodeInto(newNode, node, node.getChildCount()); node.add(newNode); if (newDepth != 0) { expandTree(newNode, newDepth, quiet); } } if (!quiet) { nodeStructureChanged(node); } } }
From source file:net.landora.animeinfo.notifications.NotificationViewer.java
private void addChildren(DefaultMutableTreeNode node, List<Object> items) { if (node.getAllowsChildren()) { for (int i = 0; i < node.getChildCount(); i++) { DefaultMutableTreeNode n = (DefaultMutableTreeNode) node.getChildAt(i); addChildren(n, items);/* w ww . ja v a 2s . c o m*/ } } else { items.add(node.getUserObject()); } }
From source file:wsattacker.plugin.intelligentdos.ui.dialog.Result_NB.java
private void resultTreeValueChanged(javax.swing.event.TreeSelectionEvent evt) {// GEN-FIRST:event_jTree1ValueChanged JTree tree = (JTree) evt.getSource(); DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (selectedNode != null && selectedNode.isLeaf()) { SuccessfulAttack sa = (SuccessfulAttack) selectedNode.getUserObject(); jLabel1.setText(FormatHelper.toHTML(sa)); StringBuilder builder = new StringBuilder(); builder.append("<html>"); String format = "-"; if (!Double.isNaN(sa.getRatio())) { format = df.format(sa.getRatio()); }//from w w w.j ava2 s .co m builder.append("Attack roundtrip time ratio: ").append(format); builder.append("<br />"); builder.append("the payload is ").append(sa.getEfficiency().name()); builder.append("<br />"); builder.append("<br />"); double reuqestsPerSecond = ((int) (sa.getParamItem().getReuqestsPerSecond() * 100.0)) / 100.0; builder.append(reuqestsPerSecond).append(" requests per second were sent"); builder.append("<br />"); if (sa.getTamperedContent() != null) { long l = (long) (sa.getTamperedContent().getBytes(Charset.forName("UTF-8")).length * sa.getParamItem().getReuqestsPerSecond()); builder.append("the traffic was (approx) ").append(FileUtils.byteCountToDisplaySize(l)) .append(" per second"); } builder.append("</html>"); successMetric.setText(builder.toString()); jTextArea1.setText(sa.getXmlWithPlaceholder()); JFreeChart createOverlaidChart = ChartHelper.createOverlaidChart(sa); JFreeChart createWhiskerChart = ChartHelper.createWhiskerChart(sa); ((ChartPanel) chartPanel1).setChart(createOverlaidChart); ((ChartPanel) chartPanel2).setChart(createWhiskerChart); } else { jLabel1.setText(""); successMetric.setText(""); } }
From source file:com.enderville.enderinstaller.ui.Installer.java
@Override public void valueChanged(TreeSelectionEvent e) { if (!e.isAddedPath()) { return;// w ww. j a v a 2s . c o m } TreePath path = e.getPath(); CheckBoxTree tree = getModTree(); if (e.getSource() == tree.getSelectionModel()) { DefaultMutableTreeNode last = (DefaultMutableTreeNode) path.getLastPathComponent(); loadModDescription(last.getUserObject().toString()); } else if (e.getSource() == tree.getCheckBoxTreeSelectionModel()) { getPresetDropdown().setSelectedItem(PRESET_CUSTOM); } }
From source file:gdt.jgui.entity.JEntityStructurePanel.java
private void addChildren(DefaultMutableTreeNode parentNode) { try {//from ww w . ja v a 2s . c o m String locator$ = (String) parentNode.getUserObject(); Properties locator = Locator.toProperties(locator$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); Entigrator entigrator = console.getEntigrator(entihome$); Sack parent = entigrator.getEntityAtKey(entityKey$); String[] sa = entigrator.ent_listComponents(parent); if (sa != null) { Sack child; String childLocator$; DefaultMutableTreeNode childNode; for (String aSa : sa) { child = entigrator.getEntityAtKey(aSa); childLocator$ = EntityHandler.getEntityLocator(entigrator, child); childNode = new DefaultMutableTreeNode(); childNode.setUserObject(childLocator$); parentNode.add(childNode); addChildren(childNode); } } } catch (Exception e) { Logger.getLogger(JEntityStructurePanel.class.getName()).severe(e.toString()); } }