List of usage examples for javax.swing.tree TreePath TreePath
public TreePath(Object lastPathComponent)
From source file:edu.brown.gui.CatalogViewer.java
protected void highlight(Collection<DefaultMutableTreeNode> nodes) { // Collapse everything and then show the paths to each node for (int ctr = this.catalogTree.getRowCount(); ctr >= 0; ctr--) { if (this.catalogTree.isExpanded(ctr)) { this.catalogTree.collapseRow(ctr); }//from w w w . j a va 2 s.c o m } // FOR this.catalogTree.getSelectionModel().clearSelection(); for (DefaultMutableTreeNode node : nodes) { TreePath path = new TreePath(node.getPath()); this.catalogTree.setSelectionPath(path); this.catalogTree.expandPath(path); } // FOR }
From source file:com.mindcognition.mindraider.ui.swing.trash.TrashJPanel.java
/** * Add an child object to a parent object. * * @param parent// w w w. ja v a 2 s .c om * the parent object. * @param child * the child object. * @param shouldBeVisible * if <code>true</code> the object should be visible. * @return Returns a <code>DefaultMutableTreeNode</code> */ public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent, Object child, boolean shouldBeVisible) { DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(child); if (parent == null) { parent = rootNode; } treeModel.insertNodeInto(childNode, parent, parent.getChildCount()); // Make sure the user can see the lovely new node. if (shouldBeVisible) { tree.scrollPathToVisible(new TreePath(childNode.getPath())); } return childNode; }
From source file:com.enderville.enderinstaller.ui.Installer.java
private void loadPreset(String presetName) { if (presetName.equals(PRESET_NONE)) { getModTree().getCheckBoxTreeSelectionModel().clearSelection(); } else if (presetName.equals(PRESET_ALL)) { CheckBoxTreeSelectionModel selectModel = getModTree().getCheckBoxTreeSelectionModel(); selectModel.setSelectionPath(new TreePath(modTreeRoot)); } else {// w ww. j ava2 s . c om loadPresetFromFile(presetName); } }
From source file:edu.harvard.i2b2.patientSet.ui.PatientSetJPanel.java
public DefaultMutableTreeNode addNode(QueryResultData node) { DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(node); QueryResultData tmpData = new QueryResultData(); tmpData.name("working ......"); tmpData.tooltip("A tmp node"); tmpData.visualAttribute("LAO"); tmpData.type("PATIENTSET"); 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()); }/*w w w .jav a2s .c om*/ jTree1.expandPath(new TreePath(top.getPath())); return childNode; }
From source file:com.enderville.enderinstaller.ui.Installer.java
private void loadPresetFromFile(String presetName) { List<String> mods = presetMap.get(presetName); CheckBoxTreeSelectionModel select = getModTree().getCheckBoxTreeSelectionModel(); select.clearSelection();// ww w .j av a2 s . c o m TreePath[] paths = new TreePath[mods.size()]; for (int i = 0; i < mods.size(); i++) { String mod = mods.get(i); DefaultMutableTreeNode modNode = treeNodeMap.get(mod); paths[i] = new TreePath(new Object[] { modTreeRoot, modNode }); } select.setSelectionPaths(paths); presetDropdown.setSelectedItem(presetName); }
From source file:com.mirth.connect.client.ui.DashboardTreeTableModel.java
private void updateChannelNodes(Map<String, DashboardStatus> statusMap, List<DashboardStatus> statuses, MutableTreeTableNode parent) {/*from w w w . j a va 2s .c o m*/ for (int i = 0; i < parent.getChildCount(); i++) { AbstractDashboardTableNode node = (AbstractDashboardTableNode) parent.getChildAt(i); if (statusMap.containsKey(node.getDashboardStatus().getKey())) { // Remove channels that do exist from the list of statuses so they will not be added again later. DashboardStatus status = statusMap.get(node.getDashboardStatus().getKey()); statuses.remove(status); // Update the channel status node.setDashboardStatus(status); modelSupport.firePathChanged(new TreePath(getPathToRoot(node))); // Update the connector level statuses updateConnector(statusMap, node); } } }
From source file:edu.harvard.i2b2.patientSet.ui.PatientSetJPanel.java
public DefaultMutableTreeNode insertNode(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); if (ascending) { treeModel.insertNodeInto(childNode, top, top.getChildCount()); } else {//from w w w . ja v a 2 s .c om treeModel.insertNodeInto(childNode, top, 0); } if (!(node.visualAttribute().startsWith("L") || node.visualAttribute().equalsIgnoreCase("MA"))) { treeModel.insertNodeInto(tmpNode, childNode, childNode.getChildCount()); } jTree1.expandPath(new TreePath(top.getPath())); previousQueries.add(node); return childNode; }
From source file:gdt.jgui.entity.JEntityDigestDisplay.java
private void expandTree(JTree tree, boolean expand) { TreeNode root = (TreeNode) tree.getModel().getRoot(); expandAll(tree, new TreePath(root), expand); }
From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java
/** This method is called from within the constructor to * initialize the form./*from w w w . ja va 2s . co m*/ */ private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); jTree1 = new javax.swing.JTree(); setLayout(new java.awt.BorderLayout()); QueryMasterData tmpData = new QueryMasterData(); tmpData.name("Queries by " + System.getProperty("user")); tmpData.tooltip("Previous query runs"); tmpData.visualAttribute("CA"); top = new DefaultMutableTreeNode(tmpData); //top = new DefaultMutableTreeNode("Root Node"); treeModel = new DefaultTreeModel(top); //treeModel.addTreeModelListener(new MyTreeModelListener()); jTree1 = new JTree(treeModel); jTree1.setEditable(false); //jTree1.getSelectionModel().setSelectionMode // (TreeSelectionModel.SINGLE_TREE_SELECTION); jTree1.setShowsRootHandles(true); //JScrollPane treeView = new JScrollPane(jTree1); jTree1.setRootVisible(false); jTree1.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); jTree1.setCellRenderer(new MyRenderer()); ToolTipManager.sharedInstance().registerComponent(jTree1); if (cellStatus.equalsIgnoreCase("CellDown")) { DefaultMutableTreeNode childNode = new DefaultMutableTreeNode("Data Repository Cell is unavailable"); treeModel.insertNodeInto(childNode, top, top.getChildCount()); // Make sure the user can see the lovely new node. jTree1.scrollPathToVisible(new TreePath(childNode.getPath())); } ArrayList<QueryMasterData> queries = previousQueries; if (queries != null) { for (int i = 0; i < queries.size(); i++) { addNode(queries.get(i)); } } jScrollPane1.setViewportView(jTree1); add(jScrollPane1, java.awt.BorderLayout.CENTER); jTree1.setTransferHandler(new NodeCopyTransferHandler()); jTree1.addTreeExpansionListener(this); }
From source file:com.mirth.connect.client.ui.DashboardTreeTableModel.java
private void updateConnector(Map<String, DashboardStatus> statusMap, AbstractDashboardTableNode channelNode) { Map<String, AbstractDashboardTableNode> nodeMap = new HashMap<String, AbstractDashboardTableNode>(); DashboardStatus channelStatus = statusMap.get(channelNode.getDashboardStatus().getKey()); // Remove connectors that no longer exist for (int i = 0; i < channelNode.getChildCount(); i++) { AbstractDashboardTableNode node = (AbstractDashboardTableNode) channelNode.getChildAt(i); if (!statusMap.containsKey(node.getDashboardStatus().getKey())) { removeNodeFromParent(node);//w ww. j av a 2 s . c o m i--; } else { nodeMap.put(node.getDashboardStatus().getKey(), node); } } // At this point, the only connectors remaining in the table should have an update. // Iterate across all the new statuses for (int i = 0; i < channelStatus.getChildStatuses().size(); i++) { // The new connector status at the current pointer DashboardStatus newConnectorStatus = channelStatus.getChildStatuses().get(i); // The node containing the old status AbstractDashboardTableNode oldConnectorNode = null; if (i < channelNode.getChildCount()) { oldConnectorNode = (AbstractDashboardTableNode) channelNode.getChildAt(i); } // If the new connector key is equal to the old one, then update the node's status if (oldConnectorNode != null && newConnectorStatus.getKey().equals(oldConnectorNode.getDashboardStatus().getKey())) { oldConnectorNode.setDashboardStatus(newConnectorStatus); modelSupport.firePathChanged(new TreePath(getPathToRoot(oldConnectorNode))); } else { AbstractDashboardTableNode node; if (nodeMap.containsKey(newConnectorStatus.getKey())) { // If the key is already in the table, remove it because it is out of order. node = nodeMap.get(newConnectorStatus.getKey()); removeNodeFromParent(node); // Update the node's status before it gets readded. node.setDashboardStatus(newConnectorStatus); } else { // If the key is not in the table yet, create a node for it. node = nodeFactory.createNode(newConnectorStatus.getChannelId(), newConnectorStatus); } // Insert the node insertNodeInto(node, channelNode, i); } } }