List of usage examples for javax.swing.tree DefaultMutableTreeNode getUserObject
public Object getUserObject()
From source file:com.ibm.soatf.gui.SOATestingFrameworkGUI.java
private FlowExecutor buildFlowExecutor() throws FrameworkConfigurationException { String interfaceId = jlInterfaces.getSelectedValue().getWrappedObject().getName(); logger.info("Interface ID : " + interfaceId); String envName = cbEnvironment.getSelectedItem().toString(); //boolean ignoreFailures = chkBoxIgnoreFailures.isSelected(); FlowExecutor flowExecutor = new FlowExecutor(envName, interfaceId); TreePath selectionPath = jtInterfaceDetails.getSelectionPath(); if (selectionPath == null) { return flowExecutor; }/* ww w . j av a 2s . co m*/ DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath.getLastPathComponent(); while (node != null) { Object userObject = node.getUserObject(); if (userObject instanceof GUIObjects.Project) { boolean inboundOnly = "INBOUND" .equalsIgnoreCase(((GUIObjects.Project) userObject).getWrappedObject().getDirection()); flowExecutor = new FlowExecutor(inboundOnly, envName, interfaceId); break; } else if (userObject instanceof GUIObjects.Operation) { flowExecutor.setOperation(((GUIObjects.Operation) userObject).getWrappedObject()); } else if (userObject instanceof GUIObjects.InterfaceExecutionBlock) { flowExecutor.setIfaceExecutionBlock( ((GUIObjects.InterfaceExecutionBlock) userObject).getWrappedObject()); } else if (userObject instanceof GUIObjects.InterfaceTestScenario) { flowExecutor .setIfaceTestScenario(((GUIObjects.InterfaceTestScenario) userObject).getWrappedObject()); } else if (userObject instanceof GUIObjects.IfaceFlowPattern) { flowExecutor.setIfaceFlowPattern(((GUIObjects.IfaceFlowPattern) userObject).getWrappedObject()); } node = (DefaultMutableTreeNode) node.getParent(); } return flowExecutor; }
From source file:de.erdesignerng.visual.common.OutlineComponent.java
public void setModel(Model aModel) { userObjectMap.clear();/*ww w . j a va2 s . c o m*/ expandedUserObjects.clear(); DefaultMutableTreeNode theRoot = new DefaultMutableTreeNode(TreeGroupingElement.MODEL); Comparator<OwnedModelItem> theComparator = new BeanComparator("name"); // Add the user-defined datatypes if (aModel.getDialect() != null) { if (aModel.getDialect().isSupportsCustomTypes()) { List<CustomType> theCustomTypes = new ArrayList<>(); theCustomTypes.addAll(aModel.getCustomTypes()); Collections.sort(theCustomTypes, theComparator); buildCustomTypesChildren(aModel, theRoot, theCustomTypes); } // Add the domains List<Domain> theDomains = new ArrayList<>(); theDomains.addAll(aModel.getDomains()); Collections.sort(theDomains, theComparator); buildDomainsChildren(aModel, theRoot, theDomains); } // Add the Tables List<Table> theTables = new ArrayList<>(); theTables.addAll(aModel.getTables()); Collections.sort(theTables, theComparator); buildTablesChildren(aModel, theRoot, theTables); // Add the Views List<View> theViews = new ArrayList<>(); theViews.addAll(aModel.getViews()); Collections.sort(theTables, theComparator); buildViewsChildren(aModel, theRoot, theViews); // Add the Relations List<Relation> theRelations = new ArrayList<>(); theRelations.addAll(aModel.getRelations()); Collections.sort(theRelations, theComparator); buildRelationChildren(theRoot, theRelations); // Add the Indexes List<Index> theIndexes = new ArrayList<>(); for (Table theTable : aModel.getTables()) { theIndexes.addAll(theTable.getIndexes()); } Collections.sort(theIndexes, theComparator); buildIndexChildren(theRoot, theIndexes); // Add the subject areas List<SubjectArea> theSAList = new ArrayList<>(); theSAList.addAll(aModel.getSubjectAreas()); Collections.sort(theSAList, theComparator); buildSubjectAreasChildren(aModel, theRoot, theSAList); tree.setModel(new DefaultTreeModel(theRoot)); // if (aExpandAll) { for (int row = 0; row < tree.getRowCount(); row++) { TreePath thePath = tree.getPathForRow(row); DefaultMutableTreeNode theNode = (DefaultMutableTreeNode) thePath.getLastPathComponent(); Object theUserObject = theNode.getUserObject(); if (theUserObject instanceof TreeGroupingElement) { tree.expandRow(row); } } // } }
From source file:de.erdesignerng.visual.common.OutlineComponent.java
/** * Refresh the model tree as there were changes. * * @param aModel - model/*from ww w . j av a 2 s. c om*/ */ public void refresh(Model aModel) { if (aModel != null) { TreePath theSelected = tree.getSelectionPath(); DefaultMutableTreeNode theGroup = null; DefaultMutableTreeNode theSelectedNode = theSelected != null ? (DefaultMutableTreeNode) theSelected.getLastPathComponent() : null; if (theSelected != null && theSelected.getPathCount() > 1) { theGroup = (DefaultMutableTreeNode) theSelected.getPath()[1]; } Set<Object> theExpandedUserObjects = expandedUserObjects; setModel(aModel); List<TreePath> thePathsToExpand = new ArrayList<>(); TreePath theNewSelection = null; for (int theRow = 0; theRow < tree.getRowCount(); theRow++) { TreePath thePath = tree.getPathForRow(theRow); DefaultMutableTreeNode theLastNew = (DefaultMutableTreeNode) thePath.getLastPathComponent(); if (theExpandedUserObjects.contains(theLastNew.getUserObject())) { thePathsToExpand.add(thePath); } if (theSelectedNode != null) { DefaultMutableTreeNode theLastGroup = null; if (thePath.getPathCount() > 1) { theLastGroup = (DefaultMutableTreeNode) thePath.getPath()[1]; } if (theLastGroup != null && theGroup != null) { if (!theLastGroup.getUserObject().equals(theGroup.getUserObject())) { continue; } } if (theLastNew.getUserObject().equals(theSelectedNode.getUserObject())) { theNewSelection = thePath; } } } thePathsToExpand.forEach(tree::expandPath); if (theNewSelection != null) { tree.setSelectionPath(theNewSelection); tree.scrollPathToVisible(theNewSelection); } } }
From source file:edu.harvard.i2b2.query.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 va 2 s . co m for (int i = 0; i < list.size(); i++) { QueryConceptTreeNodeData node = new QueryConceptTreeNodeData(); ConceptType concept = list.get(i); node.name(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.lookupdb(data.lookupdb()); //node.lookuptable(data.lookuptable()); //node.selectservice(data.selectservice()); addNode(node, pnode); } }
From source file:fxts.stations.ui.help.ContentTree.java
/** * Returns path to node containing the specified url. * * @param aParentPath parent node/*from www . j av a 2s.c o m*/ * @param aUrl specified url * * @return path to node containing specified url */ public TreePath findPathByUrl(TreePath aParentPath, String aUrl) { DefaultMutableTreeNode parentNode; DefaultMutableTreeNode node; TreePath resultPath; NodeInfo info; parentNode = (DefaultMutableTreeNode) aParentPath.getLastPathComponent(); if (!parentNode.getAllowsChildren()) { return null; } for (Enumeration enumeration = parentNode.children(); enumeration.hasMoreElements();) { node = (DefaultMutableTreeNode) enumeration.nextElement(); info = (NodeInfo) node.getUserObject(); if (aUrl.equals(info.getUrl())) { return aParentPath.pathByAddingChild(node); } else { resultPath = findPathByUrl(aParentPath.pathByAddingChild(node), aUrl); if (resultPath != null) { return resultPath; } } } return null; }
From source file:edu.harvard.i2b2.query.QueryConceptTreePanel.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 . co m }
From source file:edu.harvard.i2b2.query.QueryConceptTreePanel.java
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException { DefaultMutableTreeNode node = (DefaultMutableTreeNode) event.getPath().getLastPathComponent(); QueryConceptTreeNodeData data = (QueryConceptTreeNodeData) node.getUserObject(); //System.out.println("Node will collapse: "+data.dimcode()); if (data.visualAttribute().equals("FAO")) { data.visualAttribute("FA"); } else if (data.visualAttribute().equals("CAO")) { data.visualAttribute("CA"); }//from w w w .j a v a 2s . c o m }
From source file:edu.harvard.i2b2.query.QueryConceptTreePanel.java
private void populateChildNodes(DefaultMutableTreeNode node) { QueryConceptTreeNodeData data = (QueryConceptTreeNodeData) node.getUserObject(); try {//from www .ja va 2 s . 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.query.QueryConceptTreePanel.java
private void addNodesFromXML(org.w3c.dom.Document resultDoc, DefaultMutableTreeNode pnode) { QueryConceptTreeNodeData data = (QueryConceptTreeNodeData) pnode.getUserObject(); String c_xml = ""; try {/*from w w w. j a va 2 s . 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.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.QueryConceptTreePanel.java
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { DefaultMutableTreeNode node = (DefaultMutableTreeNode) event.getPath().getLastPathComponent(); QueryConceptTreeNodeData data = (QueryConceptTreeNodeData) node.getUserObject(); //System.out.println("Node will expand: "+data.dimcode()); if (data.visualAttribute().equals("FA")) { data.visualAttribute("FAO"); } else if (data.visualAttribute().equals("CA")) { data.visualAttribute("CAO"); }/* w w w .j a v a 2 s.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 && !(node.getChildAt(0).toString().equalsIgnoreCase("Over 300 child nodes"))) { DefaultMutableTreeNode node1 = (DefaultMutableTreeNode) node.getChildAt(0); if (((QueryConceptTreeNodeData) node1.getUserObject()).visualAttribute().equals("LAO")) { populateChildNodes(node); } } 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"); } } } }