Example usage for javax.swing.tree DefaultMutableTreeNode getUserObject

List of usage examples for javax.swing.tree DefaultMutableTreeNode getUserObject

Introduction

In this page you can find the example usage for javax.swing.tree DefaultMutableTreeNode getUserObject.

Prototype

public Object getUserObject() 

Source Link

Document

Returns this node's user object.

Usage

From source file:com.pironet.tda.AbstractDumpParser.java

protected void diffDumps(String prefix, DefaultMutableTreeNode root, Map dumpStore, TreePath[] dumps,
        int minOccurence, String regex) {
    List<String> keys = new Vector<>(dumps.length);

    for (final TreePath dump : dumps) {
        String dumpName = getDumpStringFromTreePath(dump);
        if (dumpName.indexOf(" at") > 0) {
            dumpName = dumpName.substring(0, dumpName.indexOf(" at"));
        } else if (dumpName.indexOf(" around") > 0) {
            dumpName = dumpName.substring(0, dumpName.indexOf(" around"));
        }/*  w  ww . j av  a 2 s. c om*/
        keys.add(dumpName);
    }

    String info = prefix + " between " + keys.get(0) + " and " + keys.get(keys.size() - 1);
    DefaultMutableTreeNode catMerge = new DefaultMutableTreeNode(
            new TableCategory(info, IconFactory.DIFF_DUMPS));
    root.add(catMerge);
    int threadCount = 0;

    if (dumpStore.get(keys.get(0)) != null) {

        for (final Object o : ((Map) dumpStore.get(keys.get(0))).keySet()) {
            String threadKey = ((String) o).trim();

            if (Strings.isNullOrEmpty(regex) || threadKey.matches(regex)) {
                int occurence = 0;
                for (int i = 1; i < dumps.length; i++) {
                    Map threads = (Map) dumpStore.get(keys.get(i));
                    if (threads.containsKey(threadKey)) {
                        occurence++;
                    }
                }

                if (occurence >= (minOccurence - 1)) {
                    threadCount++;
                    StringBuilder content = new StringBuilder("<body bgcolor=\"ffffff\"><b><font size=")
                            .append(TDA.getFontSizeModifier(-1)).append('>').append(keys.get(0))
                            .append("</b></font><hr><pre><font size=").append(TDA.getFontSizeModifier(-1))
                            .append('>').append(fixMonitorLinks(
                                    (String) ((Map) dumpStore.get(keys.get(0))).get(threadKey), keys.get(0)));

                    int maxLines = 0;
                    for (int i = 1; i < dumps.length; i++) {
                        if (((Map) dumpStore.get(keys.get(i))).containsKey(threadKey)) {
                            content.append("\n\n</pre><b><font size=");
                            content.append(TDA.getFontSizeModifier(-1));
                            content.append('>');
                            content.append(keys.get(i));
                            content.append("</font></b><hr><pre><font size=");
                            content.append(TDA.getFontSizeModifier(-1));
                            content.append('>');
                            content.append(fixMonitorLinks(
                                    (String) ((Map) dumpStore.get(keys.get(i))).get(threadKey), keys.get(i)));
                            int countLines = countLines(
                                    ((String) ((Map) dumpStore.get(keys.get(i))).get(threadKey)));
                            maxLines = maxLines > countLines ? maxLines : countLines;
                        }
                    }
                    addToCategory(catMerge, threadKey, null, content.toString(), maxLines, true);
                }
            }
        }
    }

    ((Category) catMerge.getUserObject()).setInfo(getStatInfo(keys, prefix, minOccurence, threadCount));

}

From source file:edu.harvard.i2b2.query.ui.QueryConceptTreePanel.java

private List getConceptsFromTerm(QueryConceptTreeNodeData data, DefaultMutableTreeNode tmpnode) {

    //      QueryConceptTreeNodeData data = (QueryConceptTreeNodeData) node.getUserObject();
    try {/*from   w w  w .  ja va 2 s  . c  o  m*/
        GetTermInfoType parentType = new GetTermInfoType();

        parentType.setMax(null);//Integer.parseInt(System.getProperty("OntMax")));
        parentType.setHiddens(Boolean.parseBoolean(System.getProperty("OntHiddens")));
        parentType.setSynonyms(Boolean.parseBoolean(System.getProperty("OntSynonyms")));

        parentType.setMax(parentPanel.max_child());

        parentType.setBlob(true);

        parentType.setSelf(data.fullname());
        GetChildrenResponseMessage msg = new GetChildrenResponseMessage();
        StatusType procStatus = null;
        String response = OntServiceDriver.getTermInfo(parentType, "");
        procStatus = msg.processResult(response);
        int result;
        if (procStatus.getValue().equals("MAX_EXCEEDED") && tmpnode != null) {
            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 = data;//(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 null;
            } else {
                parentType.setMax(null);
                response = OntServiceDriver.getTermInfo(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 null;
        }

        ConceptsType allConcepts = msg.doReadConcepts();
        return allConcepts.getConcept();

    } 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 null;
    }
}

From source file:edu.harvard.i2b2.query.ui.QueryConceptTreePanel.java

private List getConceptsFromChildren(QueryConceptTreeNodeData data, DefaultMutableTreeNode tmpnode) {

    //      QueryConceptTreeNodeData data = (QueryConceptTreeNodeData) node.getUserObject();
    try {/*from   ww  w.  java  2  s.  com*/
        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")));

        parentType.setMax(parentPanel.max_child());

        parentType.setBlob(true);

        parentType.setParent(data.fullname());
        GetChildrenResponseMessage msg = new GetChildrenResponseMessage();
        StatusType procStatus = null;
        String response = OntServiceDriver.getChildren(parentType, "");
        procStatus = msg.processResult(response);
        int result;
        if (procStatus.getValue().equals("MAX_EXCEEDED") && tmpnode != null) {
            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 = data;//(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 null;
            } 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 null;
        }

        ConceptsType allConcepts = msg.doReadConcepts();
        return allConcepts.getConcept();

    } 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 null;
    }
}

From source file:edu.harvard.i2b2.query.ui.ConceptTreePanel.java

private List getConceptsFromTerm(QueryConceptTreeNodeData data, DefaultMutableTreeNode tmpnode) {

    // QueryConceptTreeNodeData data = (QueryConceptTreeNodeData)
    // node.getUserObject();
    try {//ww w. j ava  2 s. c  o  m
        GetTermInfoType parentType = new GetTermInfoType();

        parentType.setMax(null);// Integer.parseInt(System.getProperty(
        // "OntMax")));
        parentType.setHiddens(Boolean.parseBoolean(System.getProperty("OntHiddens")));
        parentType.setSynonyms(Boolean.parseBoolean(System.getProperty("OntSynonyms")));

        parentType.setMax(parentPanel.max_child());

        parentType.setBlob(true);

        parentType.setSelf(data.fullname());
        GetChildrenResponseMessage msg = new GetChildrenResponseMessage();
        StatusType procStatus = null;
        String response = OntServiceDriver.getTermInfo(parentType, "");
        procStatus = msg.processResult(response);
        int result;
        if (procStatus.getValue().equals("MAX_EXCEEDED") && tmpnode != null) {
            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 =
                // data;//(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 null;
            } else {
                parentType.setMax(null);
                response = OntServiceDriver.getTermInfo(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 null;
        }

        ConceptsType allConcepts = msg.doReadConcepts();
        return allConcepts.getConcept();

    } 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 null;
    }
}

From source file:edu.harvard.i2b2.query.ui.ConceptTreePanel.java

private List getConceptsFromChildren(QueryConceptTreeNodeData data, DefaultMutableTreeNode tmpnode) {

    // QueryConceptTreeNodeData data = (QueryConceptTreeNodeData)
    // node.getUserObject();
    try {/*from  w w w  . j  a  v  a2s.  com*/
        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")));

        parentType.setMax(parentPanel.max_child());

        parentType.setBlob(true);

        parentType.setParent(data.fullname());
        GetChildrenResponseMessage msg = new GetChildrenResponseMessage();
        StatusType procStatus = null;
        String response = OntServiceDriver.getChildren(parentType, "");
        procStatus = msg.processResult(response);
        int result;
        if (procStatus.getValue().equals("MAX_EXCEEDED") && tmpnode != null) {
            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 =
                // data;//(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 null;
            } 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 null;
        }

        ConceptsType allConcepts = msg.doReadConcepts();
        return allConcepts.getConcept();

    } 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 null;
    }
}

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);//from ww  w  .  j ava2  s .  c  om

    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 void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) event.getPath().getLastPathComponent();

    if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryResultData")) {
        //QueryResultData rdata = (QueryResultData) node.getUserObject();
        /*if (rdata.patientCount().equalsIgnoreCase("0")) {
                /*from   w w w.java2 s  .  c  om*/
           final JPanel parent = this;
           java.awt.EventQueue.invokeLater(new Runnable() {
              public void run() {
          JOptionPane.showMessageDialog(parent,
                "There are no patients in this set.",
                "Message", JOptionPane.INFORMATION_MESSAGE);
              }
           });
                
           return;
        }*/
    }
}

From source file:edu.harvard.i2b2.patientSet.ui.PatientSetJPanel.java

public void treeCollapsed(TreeExpansionEvent event) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) event.getPath().getLastPathComponent();
    QueryData data = (QueryData) node.getUserObject();

    System.out.println("Node collapsed: " + data.name());

    if (data.visualAttribute().equals("FAO")) {
        data.visualAttribute("FA");
    } else if (data.visualAttribute().equals("CAO")) {
        data.visualAttribute("CA");
    }/*  ww  w  . ja  va2s . co  m*/
}

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.  ja  v a 2  s  .  co  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   w w  w  . j  a v a 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");
            }
        }
    }
}