List of usage examples for javax.swing.tree TreePath TreePath
public TreePath(Object lastPathComponent)
From source file:com.mirth.connect.client.ui.DashboardPanel.java
private void selectChannelNodes(MutableTreeTableNode parent, TableState tableState, List<TreePath> selectionPaths) { DashboardTreeTableModel model = (DashboardTreeTableModel) dashboardTable.getTreeTableModel(); for (Enumeration<? extends MutableTreeTableNode> channelNodes = parent.children(); channelNodes .hasMoreElements();) {// www.j a v a2 s . com AbstractDashboardTableNode channelNode = (AbstractDashboardTableNode) channelNodes.nextElement(); if (tableState.getSelectedIds().contains(channelNode.getChannelId())) { selectionPaths.add(new TreePath(model.getPathToRoot(channelNode))); } for (Enumeration<? extends MutableTreeTableNode> connectorNodes = channelNode.children(); connectorNodes .hasMoreElements();) { AbstractDashboardTableNode connectorNode = (AbstractDashboardTableNode) connectorNodes .nextElement(); if (tableState.getSelectedConnectors().containsKey(connectorNode.getChannelId()) && tableState.getSelectedConnectors().get(connectorNode.getChannelId()) .contains(connectorNode.getDashboardStatus().getMetaDataId())) { selectionPaths.add(new TreePath(model.getPathToRoot(connectorNode))); } } } }
From source file:com.pironet.tda.TDA.java
/** * navigate to child of currently selected node with the given prefix in name * * @param startsWith node name prefix (e.g. "Threads waiting") *//* ww w .j a v a 2 s .co m*/ private void navigateToChild(String startsWith) { TreePath currentPath = tree.getSelectionPath(); DefaultMutableTreeNode dumpNode = (DefaultMutableTreeNode) currentPath.getLastPathComponent(); Enumeration childs = dumpNode.children(); TreePath searchPath = null; while ((searchPath == null) && childs.hasMoreElements()) { DefaultMutableTreeNode child = (DefaultMutableTreeNode) childs.nextElement(); String name = child.toString(); if (name != null && name.startsWith(startsWith)) { searchPath = new TreePath(child.getPath()); } } if (searchPath != null) { tree.makeVisible(searchPath); tree.setSelectionPath(searchPath); tree.scrollPathToVisible(searchPath); } }
From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java
private void addParameterToTree(final AvailableParameter[] parameters, final ParameterCombinationGUI pcGUI) { final DefaultListModel listModel = (DefaultListModel) parameterList.getModel(); final DefaultTreeModel treeModel = (DefaultTreeModel) pcGUI.tree.getModel(); final DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot(); for (final AvailableParameter parameter : parameters) { listModel.removeElement(parameter); final ParameterInfo selectedInfo = parameter.info; final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode( new ParameterInATree(selectedInfo, currentModelHandler.getModelClass())); treeModel.insertNodeInto(newNode, root, root.getChildCount()); if (selectedInfo instanceof SubmodelInfo) { final SubmodelInfo sInfo = (SubmodelInfo) selectedInfo; if (sInfo.getActualType() != null) { addSubParametersToTree(sInfo, pcGUI.tree, newNode); pcGUI.tree.expandPath(new TreePath(treeModel.getPathToRoot(newNode))); }/*from ww w. j a v a2s. co m*/ } } updateNumberOfRuns(); pcGUI.tree.expandPath(new TreePath(treeModel.getPathToRoot(root))); }
From source file:edu.harvard.i2b2.query.ui.QueryConceptTreePanel.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("FA")) { data.visualAttribute("FAO"); } else if (data.visualAttribute().equals("CA")) { data.visualAttribute("CAO"); }//from w w w.j av a 2 s . co m // 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.query.ui.ConceptTreePanel.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("FA")) { data.visualAttribute("FAO"); } else if (data.visualAttribute().equals("CA")) { data.visualAttribute("CAO"); }/* w w w . ja va 2 s . c o m*/ // 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:net.sf.jabref.groups.GroupSelector.java
public Enumeration<TreePath> getExpandedPaths() { return groupsTree.getExpandedDescendants(new TreePath(groupsRoot.getPath())); }
From source file:it.imtech.metadata.MetaUtility.java
/** * Metodo che setta il TreeMap oefos_path con i valori del nodo selezionato * e aggiorna il label che descrive il path dei nodi selezionati * * @param e L'albero sul quale ricercare il path selezionato *///from ww w.java 2 s .c o m private void setOEFOS(JTree e, String sequence, String panelname) throws Exception { try { DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getLastSelectedPathComponent(); String completePath = ""; //OefosPaths path = new OefosPaths(panelname, sequence); BookImporter.getInstance() .createComponentMap(BookImporter.getInstance().metadatapanels.get(panelname).getPanel()); Component controls = BookImporter.getInstance().getComponentByName("classification_path---" + sequence); //Se e' una foglia aggiorna il path nell'interfaccia e oefos_path if (node != null) { TreePath selpath = new TreePath(node.getPath()); e.setSelectionPath(selpath); Object[] nodes = selpath.getPath(); TreeMap<Integer, Integer> single_path = new TreeMap<Integer, Integer>(); for (int i = 1; i < nodes.length; i++) { Object nodeInfo = nodes[i]; DefaultMutableTreeNode nodeC = (DefaultMutableTreeNode) nodeInfo; ClassNode c = (ClassNode) nodeC.getUserObject(); single_path.put(i, Integer.parseInt(c.getKey().toString())); completePath += nodes[i].toString(); completePath += (i != nodes.length - 1) ? "/" : ""; } this.oefos_path.put(panelname + "----" + sequence, single_path); } else { this.oefos_path.put(panelname + "----" + sequence, null); } JLabel label = (JLabel) controls; if (completePath.length() > 120) { label.setText(completePath.substring(0, 120)); } else { label.setText(completePath); } label.revalidate(); } catch (Exception ex) { throw new Exception("Exception in setOEFOS: " + ex.getStackTrace() + "\n"); } }
From source file:com.lp.client.frame.component.PanelDokumentenablage.java
@Override public void treeExpanded(TreeExpansionEvent event) { if (treeInProgress) return;/*w ww . ja va2 s.co m*/ setBusy(true); DefaultMutableTreeNode node = (DefaultMutableTreeNode) event.getPath().getLastPathComponent(); DefaultMutableTreeNode firstChild = (DefaultMutableTreeNode) node.getFirstChild(); TreePath selectionPath = tree.getSelectionPath(); if (MUST_LOAD_CHILDREN.equals(firstChild.getUserObject())) { node.removeAllChildren(); DocPath expandPath = new DocPath(); for (Object obj : node.getUserObjectPath()) { try { expandPath.add((DocNodeBase) obj); } catch (ClassCastException ex) { expandPath.add(new DocNodeLiteral(obj.toString())); } } List<DocNodeBase> childList; try { childList = DelegateFactory.getInstance().getJCRDocDelegate() .getDocNodeChildrenFromNode(expandPath); setDocNodesOnTree(node, childList, expandPath); } catch (Throwable e) { treeModel.insertNodeInto(new DefaultMutableTreeNode(e), node, 0); } tree.expandPath(new TreePath(node.getPath())); tree.setSelectionPath(selectionPath); } setBusy(false); }
From source file:net.sf.jabref.groups.GroupSelector.java
/** * Highlight all groups that contain any/all of the specified entries. If entries is null or has zero length, * highlight is cleared.// w w w .ja v a2s .c o m */ public void showMatchingGroups(List<BibEntry> list, boolean requireAll) { if ((list == null) || (list.isEmpty())) { // nothing selected groupsTree.setHighlight3Cells(null); groupsTree.revalidate(); return; } List<GroupTreeNode> nodeList = new ArrayList<>(); for (Enumeration<GroupTreeNode> e = groupsRoot.preorderEnumeration(); e.hasMoreElements();) { GroupTreeNode node = e.nextElement(); AbstractGroup group = node.getGroup(); boolean breakFromLoop = false; for (BibEntry entry : list) { if (requireAll) { if (!group.contains(entry)) { breakFromLoop = true; break; } } else { if (group.contains(entry)) { nodeList.add(node); } } } if (requireAll && (!breakFromLoop)) // did not break from loop { nodeList.add(node); } } groupsTree.setHighlight3Cells(nodeList.toArray()); // ensure that all highlighted nodes are visible for (GroupTreeNode node : nodeList) { GroupTreeNode parentNode = (GroupTreeNode) node.getParent(); if (parentNode != null) { groupsTree.expandPath(new TreePath(parentNode.getPath())); } } groupsTree.revalidate(); }
From source file:edu.harvard.i2b2.query.ui.QueryConceptTreePanel.java
private List getConceptsFromTerm(QueryConceptTreeNodeData data, DefaultMutableTreeNode tmpnode) { // QueryConceptTreeNodeData data = (QueryConceptTreeNodeData) node.getUserObject(); try {// w w w.java 2s. c o m GetTermInfoType parentType = new GetTermInfoType(); parentType.setMax(null);//Integer.parseInt(System.getProperty("OntMax"))); parentType.setHiddens(Boolean.parseBoolean(System.getProperty("OntHiddens"))); parentType.setSynonyms(Boolean.parseBoolean(System.getProperty("OntSynonyms"))); parentType.setMax(parentPanel.max_child()); parentType.setBlob(true); parentType.setSelf(data.fullname()); GetChildrenResponseMessage msg = new GetChildrenResponseMessage(); StatusType procStatus = null; String response = OntServiceDriver.getTermInfo(parentType, ""); procStatus = msg.processResult(response); int result; if (procStatus.getValue().equals("MAX_EXCEEDED") && tmpnode != null) { result = JOptionPane.showConfirmDialog(parentPanel, "The node has exceeded maximum number of children.\n" + "Do you want to continue?", "Please note ...", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.NO_OPTION) { //DefaultMutableTreeNode tmpnode = data;//(DefaultMutableTreeNode) node.getChildAt(0); QueryConceptTreeNodeData tmpdata = (QueryConceptTreeNodeData) tmpnode.getUserObject(); tmpdata.name("Over maximum number of child nodes"); //procStatus.setType("DONE"); jTree1.repaint(); jTree1.scrollPathToVisible(new TreePath(tmpnode.getPath())); return null; } else { parentType.setMax(null); response = OntServiceDriver.getTermInfo(parentType, ""); procStatus = msg.processResult(response); } } if (!procStatus.getType().equals("DONE")) { JOptionPane.showMessageDialog(parentPanel, "Error message delivered from the remote server, " + "you may wish to retry your last action"); return null; } ConceptsType allConcepts = msg.doReadConcepts(); return allConcepts.getConcept(); } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(parentPanel, "Response delivered from the remote server could not be understood,\n" + "you may wish to retry your last action."); return null; } }