List of usage examples for javax.swing.tree DefaultMutableTreeNode getUserObject
public Object getUserObject()
From source file:eu.crisis_economics.abm.dashboard.GASearchHandler.java
private void saveParameterOrGene(final DefaultMutableTreeNode node, final ObjectFactory factory, final Object parent) { final ParameterOrGene userObj = (ParameterOrGene) node.getUserObject(); final ParameterInfo info = userObj.getInfo(); if (userObj.isGene()) { final GeneInfo geneInfo = userObj.getGeneInfo(); final eu.crisis_economics.abm.dashboard.generated.Gene gene = factory.createGene(); gene.setName(info.getName());/*from ww w . ja v a 2s .c om*/ gene.setGeneType(geneInfo.getValueType()); if (GeneInfo.INTERVAL.equals(geneInfo.getValueType())) { gene.setInteger(geneInfo.isIntegerVals()); gene.setMin(geneInfo.isIntegerVals() ? new BigDecimal(geneInfo.getMinValue().longValue()) : new BigDecimal(geneInfo.getMinValue().doubleValue())); gene.setMax(geneInfo.isIntegerVals() ? new BigDecimal(geneInfo.getMaxValue().longValue()) : new BigDecimal(geneInfo.getMaxValue().doubleValue())); } else { final List<String> geneValues = gene.getGeneValueList(); for (final Object value : geneInfo.getValueRange()) geneValues.add(String.valueOf(value)); } if (parent instanceof eu.crisis_economics.abm.dashboard.generated.Chromosome) { final eu.crisis_economics.abm.dashboard.generated.Chromosome chromosome = (eu.crisis_economics.abm.dashboard.generated.Chromosome) parent; chromosome.getGeneList().add(gene); } else if (parent instanceof SubmodelParameter) { final SubmodelParameter submodelParameter = (SubmodelParameter) parent; submodelParameter.getGeneList().add(gene); } } else if (info instanceof SubmodelInfo) { final SubmodelInfo sInfo = (SubmodelInfo) info; final SubmodelParameter parameter = factory.createSubmodelParameter(); parameter.setName(info.getName()); parameter.setType(sInfo.getActualType() == null ? "null" : sInfo.getActualType().getName()); if (parent instanceof eu.crisis_economics.abm.dashboard.generated.Chromosome) { final eu.crisis_economics.abm.dashboard.generated.Chromosome chromosome = (eu.crisis_economics.abm.dashboard.generated.Chromosome) parent; chromosome.getSubmodelParameterList().add(parameter); } else if (parent instanceof SubmodelParameter) { final SubmodelParameter submodelParameter = (SubmodelParameter) parent; submodelParameter.getSubmodelParameterList().add(parameter); } if (node.getChildCount() > 0) { @SuppressWarnings("rawtypes") final Enumeration childNodes = node.children(); while (childNodes.hasMoreElements()) { final DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) childNodes.nextElement(); saveParameterOrGene(childNode, factory, parameter); } } } else { final Parameter parameter = factory.createParameter(); parameter.setName(info.getName()); parameter.setParameterType(ParameterType.CONSTANT); parameter.getContent().add(info.getValue().toString()); if (parent instanceof eu.crisis_economics.abm.dashboard.generated.Chromosome) { final eu.crisis_economics.abm.dashboard.generated.Chromosome chromosome = (eu.crisis_economics.abm.dashboard.generated.Chromosome) parent; chromosome.getParameterList().add(parameter); } else if (parent instanceof SubmodelParameter) { final SubmodelParameter submodelParameter = (SubmodelParameter) parent; submodelParameter.getParameterList().add(parameter); } } }
From source file:gdt.jgui.entity.index.JIndexPanel.java
private void select(String selectedNodeKey$) { try {/*from w w w. ja v a2s .c om*/ DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel().getRoot(); Enumeration en = root.preorderEnumeration(); DefaultMutableTreeNode node; // System.out.println("EntityDigestDisplay:select:selection node="+selectedNodeKey$); String nodeLocator$; Properties locator; while (en.hasMoreElements()) { node = (DefaultMutableTreeNode) en.nextElement(); nodeLocator$ = (String) node.getUserObject(); locator = Locator.toProperties(nodeLocator$); //System.out.println("EntityDigestDisplay:select:node number="+nodeNumber$); if (selectedNodeKey$.equals(locator.getProperty(NODE_KEY))) { TreeNode[] nodes = ((DefaultTreeModel) tree.getModel()).getPathToRoot(node); TreePath tpath = new TreePath(nodes); tree.scrollPathToVisible(tpath); tree.setSelectionPath(tpath); break; } } } catch (Exception e) { Logger.getLogger(getClass().getName()).severe(e.toString()); } }
From source file:gdt.jgui.entity.index.JIndexPanel.java
/** * Get the context menu./*from w w w . j a va2 s .co m*/ * @return the context menu. */ @Override public JMenu getContextMenu() { menu = new JMenu("Context"); menu.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { //System.out.println("IndexPanel:getConextMenu:menu selected"); menu.removeAll(); JMenuItem expandItem = new JMenuItem("Expand"); expandItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { expandAll(tree, new TreePath(rootNode), true); } }); menu.add(expandItem); JMenuItem collapseItem = new JMenuItem("Collapse"); collapseItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { expandAll(tree, new TreePath(rootNode), false); } }); menu.add(collapseItem); final TreePath[] tpa = tree.getSelectionPaths(); if (tpa != null && tpa.length > 0) { menu.addSeparator(); JMenuItem copyItem = new JMenuItem("Copy"); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cut = false; console.clipboard.clear(); DefaultMutableTreeNode node; String locator$; for (TreePath tp : tpa) { node = (DefaultMutableTreeNode) tp.getLastPathComponent(); locator$ = (String) node.getUserObject(); if (locator$ != null) console.clipboard.putString(locator$); } } }); menu.add(copyItem); JMenuItem cutItem = new JMenuItem("Cut"); cutItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cut = true; console.clipboard.clear(); DefaultMutableTreeNode node; String locator$; for (TreePath tp : tpa) { node = (DefaultMutableTreeNode) tp.getLastPathComponent(); locator$ = (String) node.getUserObject(); if (locator$ != null) console.clipboard.putString(locator$); } } }); menu.add(cutItem); JMenuItem deleteItem = new JMenuItem("Delete"); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { try { DefaultMutableTreeNode node; String locator$; String nodeKey$; for (TreePath tp : tpa) { node = (DefaultMutableTreeNode) tp.getLastPathComponent(); locator$ = (String) node.getUserObject(); nodeKey$ = Locator.getProperty(locator$, NODE_KEY); index.removeElementItem("index.title", nodeKey$); index.removeElementItem("index.jlocator", nodeKey$); } Entigrator entigrator = console.getEntigrator(entihome$); entigrator.save(index); JConsoleHandler.execute(console, getLocator()); } catch (Exception ee) { LOGGER.info(ee.toString()); } } } }); menu.add(deleteItem); } } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); return menu; }
From source file:com.mindcognition.mindraider.ui.swing.explorer.LabelsTree.java
public void treeNodesChanged(TreeModelEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) (e.getTreePath().getLastPathComponent()); /*/*from w ww . j ava 2 s .c o m*/ * If the event lists children, then the changed node is the child * of the node we've already gotten. Otherwise, the changed node and * the specified node are the same. */ // TODO try { int index = e.getChildIndices()[0]; node = (DefaultMutableTreeNode) (node.getChildAt(index)); // TODO RENAME NOT IMPLEMENTED investigate how is the node stored into the user object /* if (node.getLevel() == LEVEL_LABELS) { MindRaider.folderCustodian.rename( (String) getTreeNodeToResourceUriMap().get(node), (String) node.getUserObject()); } else { if (node.getLevel() == LEVEL_NOTEBOOKS) { MindRaider.notebookCustodian.rename( (String) getTreeNodeToResourceUriMap() .get(node), (String) node .getUserObject()); MindRaider.profile.setActiveNotebookUri(null); MindRaider.notebookCustodian.loadNotebook(new URI( (String) getTreeNodeToResourceUriMap() .get(node))); NotebookJPanel.getInstance().refresh(); } } */ } catch (Exception ex) { logger.debug("Unable to found node!", ex); } logger.debug("New value: " + node.getUserObject()); }
From source file:edu.harvard.i2b2.query.ui.QueryConceptTreePanel.java
private void addNodesFromOntXML(List<ConceptType> list, DefaultMutableTreeNode pnode) { QueryConceptTreeNodeData data = (QueryConceptTreeNodeData) pnode.getUserObject(); String c_xml = ""; if (list.size() > 0) { ((QueryConceptTreeNodeData) pnode.getUserObject()).visualAttribute("FAO"); }/*from w ww . j a v a 2 s . c o m*/ for (int i = 0; i < list.size(); i++) { QueryConceptTreeNodeData node = new QueryConceptTreeNodeData(); ConceptType concept = list.get(i); node.name(concept.getName()); node.titleName(concept.getName()); node.visualAttribute(concept.getVisualattributes().trim()); node.tooltip(concept.getTooltip()); node.hlevel(new Integer(concept.getLevel()).toString()); node.fullname(concept.getKey()); node.dimcode(concept.getDimcode()); node.columnName(concept.getColumnname()); node.factTableColumn(concept.getFacttablecolumn()); node.tableName(concept.getTablename()); node.columnDataType(concept.getColumndatatype()); node.operator(concept.getOperator()); // node.lookupdb(data.lookupdb()); //node.lookuptable(data.lookuptable()); //node.selectservice(data.selectservice()); //int size = concept.getMetadataxml().getAny().size(); // System.out.println("Value xml tag item size: "+size); addNode(node, pnode); } }
From source file:edu.harvard.i2b2.query.ui.ConceptTreePanel.java
private void populateChildNodes(DefaultMutableTreeNode node) { List concepts = getConceptsFromChildren((QueryConceptTreeNodeData) node.getUserObject(), (DefaultMutableTreeNode) node.getChildAt(0)); if (concepts != null) { addNodesFromOntXML(concepts, node); DefaultMutableTreeNode tmpnode = (DefaultMutableTreeNode) node.getChildAt(0); treeModel.removeNodeFromParent(tmpnode); jTree1.scrollPathToVisible(new TreePath(node.getPath())); }/* w w w .jav a 2s . c o m*/ }
From source file:edu.harvard.i2b2.query.ui.ConceptTreePanel.java
private void addNodesFromOntXML(List<ConceptType> list, DefaultMutableTreeNode pnode) { QueryConceptTreeNodeData data = (QueryConceptTreeNodeData) pnode.getUserObject(); String c_xml = ""; if (list.size() > 0) { ((QueryConceptTreeNodeData) pnode.getUserObject()).visualAttribute("FAO"); }//from ww w .j ava 2 s . c o m for (int i = 0; i < list.size(); i++) { QueryConceptTreeNodeData node = new QueryConceptTreeNodeData(); ConceptType concept = list.get(i); node.name(concept.getName()); node.titleName(concept.getName()); node.visualAttribute(concept.getVisualattributes().trim()); node.tooltip(concept.getTooltip()); node.hlevel(new Integer(concept.getLevel()).toString()); node.fullname(concept.getKey()); node.dimcode(concept.getDimcode()); node.columnName(concept.getColumnname()); node.factTableColumn(concept.getFacttablecolumn()); node.tableName(concept.getTablename()); node.columnDataType(concept.getColumndatatype()); node.operator(concept.getOperator()); // node.lookupdb(data.lookupdb()); // node.lookuptable(data.lookuptable()); // node.selectservice(data.selectservice()); // int size = concept.getMetadataxml().getAny().size(); // System.out.println("Value xml tag item size: "+size); addNode(node, pnode); } }
From source file:edu.harvard.i2b2.query.ui.QueryConceptTreePanel.java
private void addNodesFromXML(org.w3c.dom.Document resultDoc, DefaultMutableTreeNode pnode) { QueryConceptTreeNodeData data = (QueryConceptTreeNodeData) pnode.getUserObject(); String c_xml = ""; try {/*from www . j av a2s. c o m*/ org.jdom.input.DOMBuilder builder = new org.jdom.input.DOMBuilder(); org.jdom.Document jresultDoc = builder.build(resultDoc); org.jdom.Namespace ns = jresultDoc.getRootElement().getNamespace(); //System.out.println((new XMLOutputter()).outputString(jresultDoc)); Iterator iterator = jresultDoc.getRootElement().getChildren("patientData", ns).iterator(); while (iterator.hasNext()) { org.jdom.Element patientData = (org.jdom.Element) iterator.next(); org.jdom.Element lookup = (org.jdom.Element) patientData .getChild(data.lookuptable().toLowerCase(), ns).clone(); //modification of c_metadataxml tag to make it part of the xml document try { org.jdom.Element metaDataXml = (org.jdom.Element) lookup.getChild("c_metadataxml"); c_xml = metaDataXml.getText(); if ((c_xml != null) && (c_xml.trim().length() > 0) && (!c_xml.equals("(null)"))) { SAXBuilder parser = new SAXBuilder(); String xmlContent = c_xml; java.io.StringReader xmlStringReader = new java.io.StringReader(xmlContent); org.jdom.Document tableDoc = parser.build(xmlStringReader); org.jdom.Element rootElement = (org.jdom.Element) tableDoc.getRootElement().clone(); metaDataXml.setText(""); metaDataXml.getChildren().add(rootElement); } } catch (Exception e) { System.out.println("getNodesFromXML: parsing XML:" + e.getMessage()); } org.jdom.Element nameXml = lookup.getChild("c_name"); String c_name = nameXml.getText().trim(); nameXml = lookup.getChild("c_dimcode"); String c_dimcode = nameXml.getText().trim(); nameXml = lookup.getChild("c_operator"); String c_operator = nameXml.getText().trim(); nameXml = lookup.getChild("c_columndatatype"); String c_columndatatype = nameXml.getText().trim(); nameXml = lookup.getChild("c_columnname"); String c_columnname = nameXml.getText().trim(); nameXml = lookup.getChild("c_tablename"); String c_table = nameXml.getText().trim(); nameXml = lookup.getChild("c_tooltip"); String c_tooltip = nameXml.getText().trim(); nameXml = lookup.getChild("c_visualattributes"); String c_visual = nameXml.getText().trim(); nameXml = lookup.getChild("c_hlevel"); String hlevel = nameXml.getText().trim(); nameXml = lookup.getChild("c_fullname"); String fullname = nameXml.getText().trim(); nameXml = lookup.getChild("c_synonym_cd"); String synonym = nameXml.getText().trim(); if (nameXml == null) nameXml = lookup.getChild("c_facttablecolumn"); String sFactDimColumn = nameXml.getText(); if (c_operator.toUpperCase().equals("LIKE")) { c_dimcode = "'" + c_dimcode + "\\%'"; } else if (c_operator.toUpperCase().equals("IN")) { c_dimcode = "(" + c_dimcode + ")"; } else if (c_operator.toUpperCase().equals("=")) { if (c_columndatatype.equals("T")) { c_dimcode = "'" + c_dimcode + "'"; } } if (!(c_visual.substring(1, 2).equals("H")) && !(synonym.equals("Y"))) { QueryConceptTreeNodeData node = new QueryConceptTreeNodeData(); node.name(c_name); node.titleName(c_name); node.visualAttribute(c_visual); node.tooltip(c_tooltip); node.hlevel(hlevel); node.fullname(fullname); node.dimcode(c_dimcode); node.lookupdb(data.lookupdb()); node.lookuptable(data.lookuptable()); node.selectservice(data.selectservice()); addNode(node, pnode); } } org.jdom.Element result = (org.jdom.Element) jresultDoc.getRootElement().getChild("result"); String resultString = result.getChildTextTrim("resultString", ns); //System.out.println(resultString); } catch (Exception e) { e.printStackTrace(); //System.out.println(e.getMessage()); } }
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 . ja v a 2s.com // 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 treeCollapsed(TreeExpansionEvent event) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) event.getPath().getLastPathComponent(); QueryConceptTreeNodeData data = (QueryConceptTreeNodeData) node.getUserObject(); // System.out.println("Node collapsed: "+data.dimcode()); if (data.visualAttribute().equals("FAO")) { data.visualAttribute("FA"); } else if (data.visualAttribute().equals("CAO")) { data.visualAttribute("CA"); }//from w w w .j av a 2 s . c om }