List of usage examples for javax.swing.tree DefaultMutableTreeNode getChildAt
public TreeNode getChildAt(int index)
From source file:edu.harvard.i2b2.patientSet.ui.PatientSetJPanel.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") || node.patientCount().equalsIgnoreCase("0"))) { treeModel.insertNodeInto(tmpNode, childNode, childNode.getChildCount()); }/* w ww.ja va2 s .c om*/ 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.patientSet.ui.PatientSetJPanel.java
public DefaultMutableTreeNode addNode(QueryInstanceData node, DefaultMutableTreeNode parent) { QueryMasterData logicdata = (QueryMasterData) parent.getUserObject(); logicdata.runs.add(node);/*ww w . ja v a2s.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. 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.patientSet.ui.PatientSetJPanel.java
public DefaultMutableTreeNode addNode(PatientData 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 w w w .j av a 2 s . c o m*/ // Make sure the user can see the lovely new node. 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.patientSet.ui.PatientSetJPanel.java
public void treeExpanded(TreeExpansionEvent event) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) event.getPath().getLastPathComponent(); QueryData data = (QueryData) node.getUserObject(); /*if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase( "QueryResultData")) {/*from ww w . j a va 2s. c o m*/ QueryResultData rdata = (QueryResultData) node.getUserObject(); if (rdata.patientCount().equalsIgnoreCase("0")) { return; /* * final JPanel parent = this; * java.awt.EventQueue.invokeLater(new Runnable() { public void * run() { JOptionPane.showMessageDialog(parent, "There's no * patient in this set.", "Message", * JOptionPane.INFORMATION_MESSAGE); } }); */ //} //}*/ jTree1.scrollPathToVisible(new TreePath(node)); System.out.println("Node expanded: " + data.name()); if (data.visualAttribute().equals("FA")) { data.visualAttribute("FAO"); } else if (data.visualAttribute().equals("CA")) { data.visualAttribute("CAO"); } // 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 (((QueryData) node1.getUserObject()).visualAttribute().equals("LAO") && ((QueryData) node1.getUserObject()).name().equals("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); QueryData adata = (QueryData) 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.previousquery.ui.QueryPreviousRunsPanel.java
private void populateChildNodes(DefaultMutableTreeNode node) { if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryMasterData")) { QueryMasterData data = (QueryMasterData) node.getUserObject(); try {/*from w ww. ja v a 2s .co m*/ String xmlRequest = data.writeContentQueryXML(); String xmlResponse = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { xmlResponse = QueryListNamesClient.sendQueryRequestSOAP(xmlRequest); } else { xmlResponse = QueryListNamesClient.sendQueryRequestREST(xmlRequest); } if (xmlResponse.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); return; } try { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(xmlResponse); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bt = messageType.getMessageBody(); InstanceResponseType instanceResponseType = (InstanceResponseType) new JAXBUnWrapHelper() .getObjectByClass(bt.getAny(), InstanceResponseType.class); for (QueryInstanceType queryInstanceType : instanceResponseType.getQueryInstance()) { // change later for working with new xml schema // RunQuery runQuery = //queryInstanceType.getResult().get(i).getRunQuery().get // (0); QueryInstanceData runData = new QueryInstanceData(); runData.visualAttribute("FA"); runData.tooltip("The results of the query run"); runData.id(queryInstanceType.getQueryInstanceId()); // runData.patientRefId(new // Integer(queryInstanceType.getRefId()).toString()); // runData.patientCount(new // Long(queryInstanceType.getCount()).toString()); // XMLGregorianCalendar cldr = // queryInstanceType.getStartDate(); /* * runData.name("Results of "+ * "["+addZero(cldr.getMonth( * ))+"-"+addZero(cldr.getDay())+"-" * +addZero(cldr.getYear())+" * "+addZero(cldr.getHour())+":" * +addZero(cldr.getMinute()) * +":"+addZero(cldr.getSecond())+"]"); */ runData.name("Results of " + data.name().substring(0, data.name().indexOf("["))); runData.queryName(data.name()); data.runs.add(runData); addNode(runData, node); } } catch (Exception e) { e.printStackTrace(); } // jTree1.scrollPathToVisible(new TreePath(node.getPath())); } catch (Exception e) { e.printStackTrace(); } } else if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryInstanceData")) { QueryInstanceData data = (QueryInstanceData) node.getUserObject(); try { String xmlRequest = data.writeContentQueryXML(); String xmlResponse = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { xmlResponse = QueryListNamesClient.sendQueryRequestSOAP(xmlRequest); } else { xmlResponse = QueryListNamesClient.sendQueryRequestREST(xmlRequest); } if (xmlResponse.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); return; } JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(xmlResponse); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bt = messageType.getMessageBody(); ResultResponseType resultResponseType = (ResultResponseType) new JAXBUnWrapHelper() .getObjectByClass(bt.getAny(), ResultResponseType.class); for (QueryResultInstanceType queryResultInstanceType : resultResponseType .getQueryResultInstance()) { String status = queryResultInstanceType.getQueryStatusType().getName(); QueryResultData resultData = new QueryResultData(); if (queryResultInstanceType.getQueryResultType().getName().equalsIgnoreCase("PATIENTSET")) { resultData.visualAttribute("FA"); } else { resultData.visualAttribute("LAO"); } // resultData.queryId(data.queryId()); resultData.patientRefId(queryResultInstanceType.getResultInstanceId());// data.patientRefId()); resultData.patientCount(new Integer(queryResultInstanceType.getSetSize()).toString());// data.patientCount()); String resultname = ""; // if ((resultname = queryResultInstanceType // .getQueryResultType().getDescription()) == null) { resultname = queryResultInstanceType.getQueryResultType().getDescription();// getName(); // } if (status.equalsIgnoreCase("FINISHED")) { if (queryResultInstanceType.getQueryResultType().getName().equals("PATIENTSET")) resultname += " - " + resultData.patientCount() + " Patients"; resultData.name(resultname);// + " - " // + resultData.patientCount() + " Patients"); resultData.tooltip(resultData.patientCount() + " Patients"); } else { resultData.name(resultname);// + " - " + status); resultData.tooltip(status); } resultData.xmlContent(xmlResponse); resultData.queryName(data.queryName()); resultData.type(queryResultInstanceType.getQueryResultType().getName()); addNode(resultData, node); } // jTree1.scrollPathToVisible(new TreePath(node.getPath())); } catch (Exception e) { e.printStackTrace(); } } else if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryResultData")) { QueryResultData data = (QueryResultData) node.getUserObject(); if (data.patientCount().equalsIgnoreCase("0")) { return; } int maxNumPatientsToDisplay = Integer.valueOf(System.getProperty("PQMaxPatientsNumber")); if (Integer.valueOf(data.patientCount()) > maxNumPatientsToDisplay) { final JPanel parent = this; result = JOptionPane.showConfirmDialog(parent, "The patient count is greater than maximum configured to be displayed.\n" + "Populating the patient list may affect performance. \n" + "Do you want to continue?", "Please Note ...", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.NO_OPTION) { DefaultMutableTreeNode tmpnode = (DefaultMutableTreeNode) node.getChildAt(0); QueryData tmpdata = (QueryData) tmpnode.getUserObject(); if (tmpdata.name().equalsIgnoreCase("working ......")) { tmpdata.name("Over maximum number of patient nodes"); treeModel.reload(tmpnode); } return; } } try { String xmlRequest = data.writeContentQueryXML(); String xmlResponse = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { xmlResponse = QueryListNamesClient.sendPDORequestSOAP(xmlRequest, showName()); } else { xmlResponse = QueryListNamesClient.sendPdoRequestREST(xmlRequest); } if (xmlResponse.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); return; } // check response status here ...... // System.out.println("Response: "+xmlResponse); PatientSet patientSet = new PDOResponseMessageFactory().getPatientSetFromResponseXML(xmlResponse); List<PatientType> patients = patientSet.getPatient(); System.out.println("Patient set size: " + patients.size()); for (int i = 0; i < patients.size(); i++) { PatientType patient = patients.get(i); PatientData pData = new PatientData(); pData.patientID(patient.getPatientId().getValue()); pData.setParamData(patient.getParam()); pData.visualAttribute("LAO"); pData.tooltip("Patient"); pData.patientSetID(data.patientRefId()); if (showName()) { pData.name(pData.patientID() + " [" + pData.lastName().substring(0, 1).toUpperCase() + pData.lastName().substring(1, pData.lastName().length()).toLowerCase() + ", " + pData.firstName().substring(0, 1).toUpperCase() + pData.firstName().substring(1, pData.firstName().length()).toLowerCase() + "]");//["+pData.age()+" // y/o // "+pData.gender()+" // "+pData.race()+"]"); } else { pData.name(pData.patientID() + " [" + pData.age() + " y/o " + pData.gender() + " " + pData.race() + "]"); } pData.queryName(data.queryName()); addNode(pData, node); } } catch (Exception e) { e.printStackTrace(); } } // implement for other type of nodes later!!! }
From source file:edu.harvard.i2b2.previousquery.ui.PreviousQueryPanel.java
private void populateChildNodes(DefaultMutableTreeNode node) { if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryMasterData")) { QueryMasterData data = (QueryMasterData) node.getUserObject(); try {//from w ww.j a v a 2s.c o m String xmlRequest = data.writeContentQueryXML(); String xmlResponse = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { xmlResponse = QueryListNamesClient.sendQueryRequestSOAP(xmlRequest); } else { xmlResponse = QueryListNamesClient.sendQueryRequestREST(xmlRequest); } if (xmlResponse.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); return; } try { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(xmlResponse); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bt = messageType.getMessageBody(); InstanceResponseType instanceResponseType = (InstanceResponseType) new JAXBUnWrapHelper() .getObjectByClass(bt.getAny(), InstanceResponseType.class); for (QueryInstanceType queryInstanceType : instanceResponseType.getQueryInstance()) { // change later for working with new xml schema // RunQuery runQuery = QueryInstanceData runData = new QueryInstanceData(); runData.visualAttribute("FA"); if (queryInstanceType.getQueryStatusType().getName().equalsIgnoreCase("completed")) { XMLGregorianCalendar sCldr = queryInstanceType.getStartDate(); XMLGregorianCalendar eCldr = queryInstanceType.getEndDate(); long diff = eCldr.toGregorianCalendar().getTimeInMillis() - sCldr.toGregorianCalendar().getTimeInMillis(); runData.tooltip("All results are available, run " + (diff / 1000) + " seconds"); } runData.id(queryInstanceType.getQueryInstanceId()); // runData.patientRefId(new // Integer(queryInstanceType.getRefId()).toString()); // runData.patientCount(new // Long(queryInstanceType.getCount()).toString()); // XMLGregorianCalendar cldr = // queryInstanceType.getStartDate(); /* * runData.name("Results of "+ * "["+addZero(cldr.getMonth( * ))+"-"+addZero(cldr.getDay())+"-" * +addZero(cldr.getYear())+" * "+addZero(cldr.getHour())+":" * +addZero(cldr.getMinute()) * +":"+addZero(cldr.getSecond())+"]"); */ runData.name("Results of " + data.name().substring(0, data.name().indexOf("["))); runData.queryName(data.name()); data.runs.add(runData); if (!queryInstanceType.getQueryStatusType().getName().equalsIgnoreCase("completed")) { runData.name( runData.name() + " --- " + queryInstanceType.getQueryStatusType().getName()); runData.tooltip("The results of the query run"); } addNode(runData, node); } } catch (Exception e) { e.printStackTrace(); } // jTree1.scrollPathToVisible(new TreePath(node.getPath())); } catch (Exception e) { e.printStackTrace(); } } else if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryInstanceData")) { QueryInstanceData data = (QueryInstanceData) node.getUserObject(); try { String xmlRequest = data.writeContentQueryXML(); String xmlResponse = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { xmlResponse = QueryListNamesClient.sendQueryRequestSOAP(xmlRequest); } else { xmlResponse = QueryListNamesClient.sendQueryRequestREST(xmlRequest); } if (xmlResponse.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); return; } JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(xmlResponse); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bt = messageType.getMessageBody(); ResultResponseType resultResponseType = (ResultResponseType) new JAXBUnWrapHelper() .getObjectByClass(bt.getAny(), ResultResponseType.class); for (QueryResultInstanceType queryResultInstanceType : resultResponseType .getQueryResultInstance()) { String status = queryResultInstanceType.getQueryStatusType().getName(); QueryResultData resultData = new QueryResultData(); if (queryResultInstanceType.getQueryResultType().getName().equalsIgnoreCase("PATIENTSET") && UserInfoBean.getInstance().isRoleInProject("DATA_LDS")) { resultData.visualAttribute("FA"); } else { resultData.visualAttribute("LAO"); } // resultData.queryId(data.queryId()); resultData.patientRefId(queryResultInstanceType.getResultInstanceId());// data.patientRefId()); resultData.patientCount(new Integer(queryResultInstanceType.getSetSize()).toString());// data.patientCount()); String resultname = ""; if ((resultname = queryResultInstanceType.getQueryResultType().getDescription()) == null) { resultname = queryResultInstanceType.getQueryResultType().getName(); } // if (status.equalsIgnoreCase("FINISHED")) { if (queryResultInstanceType.getQueryResultType().getName().equals("PATIENTSET") /*|| queryResultInstanceType.getQueryResultType().getName() .equals("PATIENT_COUNT_XML")*/) { // if (UserInfoBean.getInstance().isRoleInProject( // "DATA_OBFSC")) { // resultData.name(resultname + " - " // + resultData.patientCount() + " Patients"); // resultData.tooltip(resultData.patientCount() // + " Patients"); // } else { if (queryResultInstanceType.getDescription() != null) { resultname = queryResultInstanceType.getDescription(); resultData.name(queryResultInstanceType.getDescription()); } else { resultData.name(resultname + " - " + resultData.patientCount() + " Patients"); } resultData.tooltip(resultData.patientCount() + " Patients"); // } } else { if (queryResultInstanceType.getDescription() != null) { resultname = queryResultInstanceType.getDescription(); resultData.name(queryResultInstanceType.getDescription()); } else { resultData.name(resultname);// + " - " + status); resultData.tooltip(status); } } resultData.xmlContent(xmlResponse); resultData.queryName(data.queryName()); resultData.type(queryResultInstanceType.getQueryResultType().getName()); if (!status.equalsIgnoreCase("FINISHED")) { resultData.name(resultData.name() + " --- " + status); } addNode(resultData, node); } // } // jTree1.scrollPathToVisible(new TreePath(node.getPath())); } catch (Exception e) { e.printStackTrace(); } } else if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryResultData")) { QueryResultData data = (QueryResultData) node.getUserObject(); if (data.patientCount().equalsIgnoreCase("0")) { return; } int maxNumPatientsToDisplay = Integer.valueOf(System.getProperty("PQMaxPatientsNumber")); if (Integer.valueOf(data.patientCount()) > maxNumPatientsToDisplay) { final JPanel parent = this; result = JOptionPane.showConfirmDialog(parent, "The patient count is greater than maximum configured to be displayed.\n" + "Populating the patient list may affect performance. \n" + "Do you want to continue?", "Please Note ...", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.NO_OPTION) { DefaultMutableTreeNode tmpnode = (DefaultMutableTreeNode) node.getChildAt(0); QueryData tmpdata = (QueryData) tmpnode.getUserObject(); if (tmpdata.name().equalsIgnoreCase("working ......")) { tmpdata.name("Over maximum number of patient nodes"); treeModel.reload(tmpnode); } return; } } try { String xmlRequest = data.writeContentQueryXML(); String xmlResponse = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { xmlResponse = QueryListNamesClient.sendPDORequestSOAP(xmlRequest, showName()); } else { xmlResponse = QueryListNamesClient.sendPdoRequestREST(xmlRequest); } if (xmlResponse.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); return; } // check response status here ...... // System.out.println("Response: "+xmlResponse); PatientSet patientSet = new PDOResponseMessageFactory().getPatientSetFromResponseXML(xmlResponse); List<PatientType> patients = patientSet.getPatient(); System.out.println("Patient set size: " + patients.size()); for (int i = 0; i < patients.size(); i++) { PatientType patient = patients.get(i); PatientData pData = new PatientData(); pData.patientID(patient.getPatientId().getValue()); pData.setParamData(patient.getParam()); pData.visualAttribute("LAO"); pData.tooltip("Patient"); pData.patientSetID(data.patientRefId()); if (showName() && pData.lastName() != null && pData.firstName() != null) { pData.name(pData.patientID() + " [" + pData.lastName().substring(0, 1).toUpperCase() + pData.lastName().substring(1, pData.lastName().length()).toLowerCase() + ", " + pData.firstName().substring(0, 1).toUpperCase() + pData.firstName().substring(1, pData.firstName().length()).toLowerCase() + "]");// ["+pData.age()+" // y/o // "+pData.gender()+" // "+pData.race()+"]"); } else { pData.name(pData.patientID() + " [" + pData.age() + " y/o " + pData.gender() + " " + pData.race() + "]"); } pData.queryName(data.queryName()); addNode(pData, node); } } catch (Exception e) { e.printStackTrace(); } } // implement for other type of nodes later!!! }
From source file:edu.harvard.i2b2.patientSet.ui.PatientSetJPanel.java
@SuppressWarnings("rawtypes") private void populateChildNodes(DefaultMutableTreeNode node) { if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryMasterData")) { QueryMasterData data = (QueryMasterData) node.getUserObject(); try {/* ww w .ja v a 2 s .c o m*/ String xmlRequest = data.writeContentQueryXML(); String xmlResponse = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { xmlResponse = QueryListNamesClient.sendQueryRequestSOAP(xmlRequest); } else { xmlResponse = QueryListNamesClient.sendQueryRequestREST(xmlRequest, true); } if (xmlResponse.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); return; } try { JAXBUtil jaxbUtil = PatientSetJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(xmlResponse); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bt = messageType.getMessageBody(); InstanceResponseType instanceResponseType = (InstanceResponseType) new JAXBUnWrapHelper() .getObjectByClass(bt.getAny(), InstanceResponseType.class); for (QueryInstanceType queryInstanceType : instanceResponseType.getQueryInstance()) { // change later for working with new xml schema // RunQuery runQuery = QueryInstanceData runData = new QueryInstanceData(); runData.visualAttribute("FA"); if (queryInstanceType.getQueryStatusType().getName().equalsIgnoreCase("completed")) { XMLGregorianCalendar sCldr = queryInstanceType.getStartDate(); XMLGregorianCalendar eCldr = queryInstanceType.getEndDate(); long diff = eCldr.toGregorianCalendar().getTimeInMillis() - sCldr.toGregorianCalendar().getTimeInMillis(); runData.tooltip("All results are available, run " + (diff / 1000) + " seconds"); } runData.id(queryInstanceType.getQueryInstanceId()); // runData.patientRefId(new // Integer(queryInstanceType.getRefId()).toString()); // runData.patientCount(new // Long(queryInstanceType.getCount()).toString()); // XMLGregorianCalendar cldr = // queryInstanceType.getStartDate(); /* * runData.name("Results of "+ * "["+addZero(cldr.getMonth( * ))+"-"+addZero(cldr.getDay())+"-" * +addZero(cldr.getYear())+" * "+addZero(cldr.getHour())+":" * +addZero(cldr.getMinute()) * +":"+addZero(cldr.getSecond())+"]"); */ runData.name("Results of " + data.name().substring(0, data.name().indexOf("["))); runData.queryName(data.name()); data.runs.add(runData); if (!queryInstanceType.getQueryStatusType().getName().equalsIgnoreCase("completed")) { runData.name( runData.name() + " --- " + queryInstanceType.getQueryStatusType().getName()); runData.tooltip("The results of the query run"); } addNode(runData, node); } } catch (Exception e) { e.printStackTrace(); } // jTree1.scrollPathToVisible(new TreePath(node.getPath())); } catch (Exception e) { e.printStackTrace(); } } else if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryInstanceData")) { QueryInstanceData data = (QueryInstanceData) node.getUserObject(); try { String xmlRequest = data.writeContentQueryXML(); String xmlResponse = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { xmlResponse = QueryListNamesClient.sendQueryRequestSOAP(xmlRequest); } else { xmlResponse = QueryListNamesClient.sendQueryRequestREST(xmlRequest, true); } if (xmlResponse.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); return; } JAXBUtil jaxbUtil = PatientSetJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(xmlResponse); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bt = messageType.getMessageBody(); ResultResponseType resultResponseType = (ResultResponseType) new JAXBUnWrapHelper() .getObjectByClass(bt.getAny(), ResultResponseType.class); for (QueryResultInstanceType queryResultInstanceType : resultResponseType .getQueryResultInstance()) { String status = queryResultInstanceType.getQueryStatusType().getName(); QueryResultData resultData = new QueryResultData(); if (queryResultInstanceType.getQueryResultType().getName().equalsIgnoreCase("PATIENTSET") && UserInfoBean.getInstance().isRoleInProject("DATA_LDS")) { resultData.visualAttribute("FA"); } else { resultData.visualAttribute("LAO"); } // resultData.queryId(data.queryId()); resultData.patientRefId(queryResultInstanceType.getResultInstanceId());// data.patientRefId()); resultData.patientCount(new Integer(queryResultInstanceType.getSetSize()).toString());// data.patientCount()); String resultname = ""; if ((resultname = queryResultInstanceType.getQueryResultType().getDescription()) == null) { resultname = queryResultInstanceType.getQueryResultType().getName(); } // if (status.equalsIgnoreCase("FINISHED")) { if (queryResultInstanceType.getQueryResultType().getName().equals("PATIENTSET") /*|| queryResultInstanceType.getQueryResultType().getName() .equals("PATIENT_COUNT_XML")*/) { // if (UserInfoBean.getInstance().isRoleInProject( // "DATA_OBFSC")) { // resultData.name(resultname + " - " // + resultData.patientCount() + " Patients"); // resultData.tooltip(resultData.patientCount() // + " Patients"); // } else { if (queryResultInstanceType.getDescription() != null) { resultname = queryResultInstanceType.getDescription(); resultData.name(queryResultInstanceType.getDescription()); } else { resultData.name(resultname + " - " + resultData.patientCount() + " Patients"); } resultData.tooltip(resultData.patientCount() + " Patients"); // } } else { if (queryResultInstanceType.getDescription() != null) { resultname = queryResultInstanceType.getDescription(); resultData.name(queryResultInstanceType.getDescription()); } else { resultData.name(resultname);// + " - " + status); resultData.tooltip(status); } } resultData.xmlContent(xmlResponse); resultData.queryName(data.queryName()); resultData.type(queryResultInstanceType.getQueryResultType().getName()); if (!status.equalsIgnoreCase("FINISHED")) { resultData.name(resultData.name() + " --- " + status); } addNode(resultData, node); } // } // jTree1.scrollPathToVisible(new TreePath(node.getPath())); } catch (Exception e) { e.printStackTrace(); } } else if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryResultData")) { QueryResultData data = (QueryResultData) node.getUserObject(); if (data.patientCount().equalsIgnoreCase("0")) { return; } int maxNumPatientsToDisplay = Integer.valueOf(System.getProperty("PQMaxPatientsNumber")); if (Integer.valueOf(data.patientCount()) > maxNumPatientsToDisplay) { final JPanel parent = this; result = JOptionPane.showConfirmDialog(parent, "The patient count is greater than maximum configured to be displayed.\n" + "Populating the patient list may affect performance. \n" + "Do you want to continue?", "Please Note ...", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.NO_OPTION) { DefaultMutableTreeNode tmpnode = (DefaultMutableTreeNode) node.getChildAt(0); QueryData tmpdata = (QueryData) tmpnode.getUserObject(); if (tmpdata.name().equalsIgnoreCase("working ......")) { tmpdata.name("Over maximum number of patient nodes"); treeModel.reload(tmpnode); } return; } } try { String xmlRequest = data.writeContentQueryXML(); String xmlResponse = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { xmlResponse = QueryListNamesClient.sendPDORequestSOAP(xmlRequest, showName()); } else { xmlResponse = QueryListNamesClient.sendPdoRequestREST(xmlRequest); } if (xmlResponse.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); return; } // check response status here ...... // System.out.println("Response: "+xmlResponse); PatientSet patientSet = new PDOResponseMessageFactory().getPatientSetFromResponseXML(xmlResponse); List<PatientType> patients = patientSet.getPatient(); System.out.println("Patient set size: " + patients.size()); for (int i = 0; i < patients.size(); i++) { PatientType patient = patients.get(i); PatientData pData = new PatientData(); pData.patientID(patient.getPatientId().getValue()); pData.setParamData(patient.getParam()); pData.visualAttribute("LAO"); pData.tooltip("Patient"); pData.patientSetID(data.patientRefId()); if (showName() && pData.lastName() != null && pData.firstName() != null) { pData.name(pData.patientID() + " [" + pData.lastName().substring(0, 1).toUpperCase() + pData.lastName().substring(1, pData.lastName().length()).toLowerCase() + ", " + pData.firstName().substring(0, 1).toUpperCase() + pData.firstName().substring(1, pData.firstName().length()).toLowerCase() + "]");// ["+pData.age()+" // y/o // "+pData.gender()+" // "+pData.race()+"]"); } else { pData.name(pData.patientID() + " [" + pData.age() + " y/o " + pData.gender() + " " + pData.race() + "]"); } pData.queryName(data.queryName()); addNode(pData, node); } } catch (Exception e) { e.printStackTrace(); } } // implement for other type of nodes later!!! }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
private DefaultMutableTreeNode findNode(DefaultMutableTreeNode node, Object userObject) { DefaultMutableTreeNode retVal = null; if (node.getUserObject().equals(userObject)) { retVal = node;/*from ww w . j av a 2s . c o m*/ } if (retVal == null) { for (int i = 0; i < node.getChildCount(); i++) { DefaultMutableTreeNode nodeChild = (DefaultMutableTreeNode) node.getChildAt(i); retVal = findNode(nodeChild, userObject); if (retVal != null) { break; } } } return retVal; }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
private void getMatchingFiles(String baseFileName, DefaultMutableTreeNode rootNode, FSOCollection files) { if (rootNode.getUserObject() instanceof FileSystemObject) { FileSystemObject fso = (FileSystemObject) rootNode.getUserObject(); if (fso.getFileNameWithoutRepTypeOrSuffix().equals(baseFileName)) { files.add(fso);//from w w w .j av a 2 s .c o m } } for (int i = 0; i < rootNode.getChildCount(); i++) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) rootNode.getChildAt(i); getMatchingFiles(baseFileName, node, files); } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
public void expandNode(JTree whichTree, DefaultMutableTreeNode node, boolean recurse) { whichTree.expandPath(new TreePath(node.getPath())); if (recurse && node.getChildCount() > 0) { for (int i = 0; i < node.getChildCount(); i++) { DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt(i); expandNode(whichTree, child, recurse); }/*from w w w .j a v a 2s . c o m*/ } }