List of usage examples for javax.swing.tree DefaultMutableTreeNode getPath
public TreeNode[] getPath()
From source file:fr.jmmc.jmcs.logging.LogbackGui.java
private void jButtonCollapseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCollapseActionPerformed final DefaultMutableTreeNode currentNode = getTreeLoggers().findTreeNode(_currentLogger); getTreeLoggers().expandAll(new TreePath(currentNode.getPath()), false, (currentNode == getTreeLoggers().getRootNode()) ? false : true); }
From source file:de.erdesignerng.visual.common.OutlineComponent.java
/** * Set the currently selected item.//from w ww . j a va2 s . c om * * @param aSelection the selection */ public void setSelectedItem(ModelItem aSelection) { TreePath theSelected = tree.getSelectionPath(); if (theSelected != null) { DefaultMutableTreeNode theNode = (DefaultMutableTreeNode) theSelected.getLastPathComponent(); if (theNode.getUserObject().equals(aSelection)) { // The object is already selected, so keep the selection return; } } DefaultMutableTreeNode theNode = userObjectMap.get(aSelection); if (theNode != null) { TreePath thePath = new TreePath(theNode.getPath()); tree.setSelectionPath(thePath); tree.scrollPathToVisible(thePath); } else { tree.clearSelection(); } tree.invalidate(); tree.repaint(); }
From source file:de.erdesignerng.visual.common.OutlineComponent.java
/** * Create the PopupMenu actions correlating to a specific tree node. * * @param aNode - the node/*from w ww. j a va 2 s . c o m*/ * @param aMenu - the menu to add the actions to * @param aRecursive - recursive */ private void initializeActionsFor(final DefaultMutableTreeNode aNode, JPopupMenu aMenu, boolean aRecursive) { Object theUserObject = aNode.getUserObject(); if (!aRecursive) { JMenuItem theExpandAllItem = new JMenuItem(); theExpandAllItem.setText(getResourceHelper().getFormattedText(ERDesignerBundle.EXPANDALL)); theExpandAllItem .addActionListener(e -> expandOrCollapseAllChildrenOfNode(new TreePath(aNode.getPath()), true)); aMenu.add(theExpandAllItem); JMenuItem theCollapseAllItem = new JMenuItem(); theCollapseAllItem.setText(getResourceHelper().getFormattedText(ERDesignerBundle.COLLAPSEALL)); theCollapseAllItem.addActionListener( e -> expandOrCollapseAllChildrenOfNode(new TreePath(aNode.getPath()), false)); aMenu.add(theCollapseAllItem); aMenu.addSeparator(); } List<ModelItem> theItemList = new ArrayList<>(); if (theUserObject instanceof ModelItem) { theItemList.add((ModelItem) theUserObject); ContextMenuFactory.addActionsToMenu(ERDesignerComponent.getDefault().getEditor(), aMenu, theItemList); } if (aNode.getParent() != null) { initializeActionsFor((DefaultMutableTreeNode) aNode.getParent(), aMenu, true); } }
From source file:edu.harvard.i2b2.query.QueryConceptTreePanel.java
private void populateChildNodes(DefaultMutableTreeNode node) { QueryConceptTreeNodeData data = (QueryConceptTreeNodeData) node.getUserObject(); try {/*from w w w . j a v a 2s . c o m*/ GetChildrenType parentType = new GetChildrenType(); parentType.setMax(null);//Integer.parseInt(System.getProperty("OntMax"))); parentType.setHiddens(Boolean.parseBoolean(System.getProperty("OntHiddens"))); parentType.setSynonyms(Boolean.parseBoolean(System.getProperty("OntSynonyms"))); // log.info("sent : " + parentType.getMax() + System.getProperty("OntMax") + System.getProperty("OntHiddens") // + System.getProperty("OntSynonyms") ); parentType.setMax(parentPanel.max_child()); //System.out.println("Max children set to: "+parentPanel.max_child()); parentType.setBlob(true); // parentType.setType("all"); parentType.setParent(data.fullname()); //System.out.println(parentType.getParent()); //Long time = System.currentTimeMillis(); //log.info("making web service call " + time); GetChildrenResponseMessage msg = new GetChildrenResponseMessage(); StatusType procStatus = null; //while(procStatus == null || !procStatus.getType().equals("DONE")){ String response = OntServiceDriver.getChildren(parentType, ""); //System.out.println("Ontology service getchildren response: "+response); parentPanel.parentPanel.lastResponseMessage(response); // Long time2 = System.currentTimeMillis(); // log.info("returned from 1st web service call " + (time2 - time)); procStatus = msg.processResult(response); // log.info(procStatus.getType()); // log.info(procStatus.getValue()); int result; if (procStatus.getValue().equals("MAX_EXCEEDED")) { 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 = (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; } else { parentType.setMax(null); response = OntServiceDriver.getChildren(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; } ConceptsType allConcepts = msg.doReadConcepts(); List concepts = allConcepts.getConcept(); if (concepts != null) { addNodesFromOntXML(concepts, node); DefaultMutableTreeNode tmpnode = (DefaultMutableTreeNode) node.getChildAt(0); treeModel.removeNodeFromParent(tmpnode); jTree1.scrollPathToVisible(new TreePath(node.getPath())); } } 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; } }
From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java
/** This method is called from within the constructor to * initialize the form./*from w ww. j a v a 2 s . c o 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:edu.harvard.i2b2.query.QueryConceptTreePanel.java
public DefaultMutableTreeNode addNode(QueryConceptTreeNodeData node) { 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, top, top.getChildCount()); treeModel.insertNodeInto(tmpNode, childNode, childNode.getChildCount()); //Make sure the user can see the lovely new node. jTree1.scrollPathToVisible(new TreePath(childNode.getPath())); return childNode; }
From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.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 . ja va 2 s. c om*/ //Make sure the user can see the lovely new node. jTree1.scrollPathToVisible(new TreePath(childNode.getPath())); return childNode; }
From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.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()); }//w w w . j a v a 2 s. co m //Make sure the user can see the lovely new node. jTree1.scrollPathToVisible(new TreePath(childNode.getPath())); return childNode; }
From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java
public DefaultMutableTreeNode addNode(QueryResultData node, DefaultMutableTreeNode parent) { //QueryInstanceData rundata = (QueryInstanceData) parent.getUserObject(); DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(node); QueryInstanceData tmpData = new QueryInstanceData(); 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 . ja va2 s . co m //Make sure the user can see the lovely new node. jTree1.scrollPathToVisible(new TreePath(childNode.getPath())); DefaultMutableTreeNode tmpnode = (DefaultMutableTreeNode) parent.getChildAt(0); QueryData tmpdata = (QueryData) tmpnode.getUserObject(); if (tmpdata.name().equalsIgnoreCase("working ......")) { treeModel.removeNodeFromParent(tmpnode); } return childNode; }
From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java
public DefaultMutableTreeNode addNode(QueryInstanceData node, DefaultMutableTreeNode parent) { QueryMasterData logicdata = (QueryMasterData) parent.getUserObject(); logicdata.runs.add(node);/*from www . j av a 2 s .c o m*/ DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(node); QueryInstanceData tmpData = new QueryInstanceData(); 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()); } //Make sure the user can see the lovely new node. jTree1.scrollPathToVisible(new TreePath(childNode.getPath())); DefaultMutableTreeNode tmpnode = (DefaultMutableTreeNode) parent.getChildAt(0); QueryData tmpdata = (QueryData) tmpnode.getUserObject(); if (tmpdata.name().equalsIgnoreCase("working ......")) { treeModel.removeNodeFromParent(tmpnode); } return childNode; }