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:edu.harvard.i2b2.query.ui.ConceptTreePanel.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 2 s . com*/
}

From source file:com.lp.client.frame.component.PanelDokumentenablage.java

public void valueChanged(TreeSelectionEvent arg0) {

    DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();

    if (tree.getPathBounds(arg0.getPath()) != null)
        tree.scrollRectToVisible(tree.getPathBounds(arg0.getPath()));

    jcrDocDto = null;/*w  ww.  j  av a  2 s. co m*/
    file = null;
    clearComponents();
    enableAllComponents(this, false);
    wcbVersteckteAnzeigen.setEnabled(true);
    wtfSuche.setEditable(true);
    wbuSuche.setEnabled(true);
    wmcMedia.setMimeType(null);
    if (node != null) {
        enableToolsPanelButtons(false, PanelBasis.ACTION_SAVE, PanelBasis.ACTION_DISCARD);
        if (node.getUserObject() instanceof DocNodeBase) {
            Object[] objectPath = node.getUserObjectPath();
            DocPath selectionDocPath = new DocPath();
            for (Object object : objectPath) {
                if (object instanceof DocNodeBase) {
                    selectionDocPath.add((DocNodeBase) object);
                } else if (object instanceof String) {
                    selectionDocPath.add(new DocNodeLiteral(object.toString() + "_string"));
                }
            }
            DocNodeBase selectedDocNode = (DocNodeBase) node.getUserObject();

            if (selectedDocNode.getNodeType() == DocNodeBase.FILE && node.isLeaf()) {
                jcrDocDto = ((DocNodeFile) selectedDocNode).getJcrDocDto();
            } else if (selectedDocNode.getNodeType() == DocNodeBase.VERSION) {
                jcrDocDto = ((DocNodeVersion) selectedDocNode).getJCRDocDto();
            } else {
                jcrDocDto = null;
            }
            if (jcrDocDto != null) {
                if (!jcrDocDto.getbVersteckt() || bVersteckteAnzeigen) {
                    dto2Components();
                    dropArea.setVisible(false);
                    enableToolsPanelButtons(false, PanelBasis.ACTION_NEW, BUTTON_SCAN);
                    enableToolsPanelButtons(
                            selectedDocNode.getNodeType() == DocNodeBase.FILE
                                    || selectedDocNode.getNodeType() == DocNodeBase.VERSION
                                            && bHatMindestensEineSicherheitsStufe() && bHatDokumentenablage,
                            PanelBasis.ACTION_UPDATE);

                    wbuShowDoc.setEnabled(true);
                    wbuSaveDoc.setEnabled(true);
                }
            } else {
                enableToolsPanelButtons(false, PanelBasis.ACTION_UPDATE);
                boolean b = fullDocPath.asDocNodeList().size() > 0 && selectedDocNode instanceof DocNodeJCR
                        && bHatMindestensEineSicherheitsStufe() && bHatDokumentenablage;
                enableToolsPanelButtons(b, PanelBasis.ACTION_NEW, BUTTON_SCAN);
                dropArea.setVisible(b);
            }
        }
    } else {
        enableToolsPanelButtons(false, ACTION_UPDATE, PanelBasis.ACTION_NEW, BUTTON_SCAN);
        dropArea.setVisible(false);
    }
}

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

public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equalsIgnoreCase("Constrain Item ...")) {
        //JOptionPane.showMessageDialog(this, "Constrain Item ...");
        //DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        //QueryConceptTreeNodeData ndata = (QueryConceptTreeNodeData) node.getUserObject();
        //final QueryConstrainFrame cframe = new QueryConstrainFrame(ndata);
        //cframe.setTitle("Constrain Item: "+ndata.name());
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                //cframe.setVisible(true);
            }/*from  w  w  w . jav  a2  s .c o m*/
        });
    } else if (e.getActionCommand().equalsIgnoreCase("Delete Item")) {
        //JOptionPane.showMessageDialog(this, "Delete Item");
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        treeModel.removeNodeFromParent(node);
        data().getItems().remove(node.getUserObject());
    } else if (e.getActionCommand().equalsIgnoreCase("Set Value ...")) {
        final DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath()
                .getLastPathComponent();
        final QueryConceptTreeNodeData ndata = (QueryConceptTreeNodeData) node.getUserObject();
        final QueryConceptTreePanel parent = this;

        int index = data().getItems().indexOf(node.getUserObject());
        currentData = data().getItems().get(index);

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                if (ndata.valuePropertyData().hasEnumValue()) {
                    EnumValueConstrainFrame vDialog = new EnumValueConstrainFrame(parent);
                    vDialog.setSize(410, 330);
                    vDialog.setLocation(300, 300);
                    vDialog.setTitle("Choose value of " + ndata.titleName());
                    vDialog.setVisible(true);
                } else {
                    NumericValueConstrainFrame vDialog = new NumericValueConstrainFrame(parent);
                    vDialog.setSize(410, 215);
                    vDialog.setLocation(300, 300);
                    vDialog.setTitle("Choose value of " + ndata.titleName());
                    vDialog.setVisible(true);
                }
            }
        });
    }
}

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

private void addNodesFromXML(org.w3c.dom.Document resultDoc, DefaultMutableTreeNode pnode) {
    QueryConceptTreeNodeData data = (QueryConceptTreeNodeData) pnode.getUserObject();
    String c_xml = "";
    try {//from w  w  w . ja v a  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.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.ConceptTreePanel.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");
    }/*from www  .j  a va 2  s.c o  m*/

    // 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");
            }
        }
    }
}

From source file:edu.harvard.i2b2.query.ui.ConceptTreePanel.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 .  j av a  2 s .c  o m*/

    // 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 actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equalsIgnoreCase("Constrain Item ...")) {
        // JOptionPane.showMessageDialog(this, "Constrain Item ...");
        // DefaultMutableTreeNode node = (DefaultMutableTreeNode)
        // jTree1.getSelectionPath().getLastPathComponent();
        // QueryConceptTreeNodeData ndata = (QueryConceptTreeNodeData)
        // node.getUserObject();
        // final QueryConstrainFrame cframe = new
        // QueryConstrainFrame(ndata);
        // cframe.setTitle("Constrain Item: "+ndata.name());
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                // cframe.setVisible(true);
            }//from w w  w .j  a v a  2s .com
        });
    } else if (e.getActionCommand().equalsIgnoreCase("Delete Item")) {
        // JOptionPane.showMessageDialog(this, "Delete Item");
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        treeModel.removeNodeFromParent(node);
        data().getItems().remove(node.getUserObject());
    } else if (e.getActionCommand().equalsIgnoreCase("Set Value ...")) {
        final DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath()
                .getLastPathComponent();
        final QueryConceptTreeNodeData ndata = (QueryConceptTreeNodeData) node.getUserObject();
        final ConceptTreePanel parent = this;

        int index = data().getItems().indexOf(node.getUserObject());
        currentData = data().getItems().get(index);

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                if (ndata.valuePropertyData().hasEnumValue()) {
                    EnumValueConstrainFrame vDialog = new EnumValueConstrainFrame(parent);
                    vDialog.setSize(410, 330);
                    vDialog.setLocation(300, 300);
                    vDialog.setTitle("Choose value of " + ndata.titleName());
                    vDialog.setVisible(true);
                } else {
                    NumericValueConstrainFrame vDialog = new NumericValueConstrainFrame(parent);
                    vDialog.setSize(410, 215);
                    vDialog.setLocation(300, 300);
                    vDialog.setTitle("Choose value of " + ndata.titleName());
                    vDialog.setVisible(true);
                }
            }
        });
    }
}

From source file:edu.ku.brc.af.tasks.subpane.formeditor.ViewSetSelectorPanel.java

/**
 * //w  w w. j  a  va2  s  .  c  om
 */
@SuppressWarnings("unchecked") //$NON-NLS-1$
public ViewSetSelectorPanel(final BasicFormPreviewPanel previewPanel) {
    this.previewPanel = previewPanel;

    Vector<String> levelsVec = new Vector<String>();
    SpecifyUser user = AppContextMgr.getInstance().getClassObject(SpecifyUser.class);
    @SuppressWarnings("unused")
    Hashtable<Discipline, Boolean> usedColTypes = new Hashtable<Discipline, Boolean>();

    levelsVec.add(user.getUserType());

    //        for (Agent agent : user.getAgents())
    //        {
    //            // XXX Commented Out
    //            /*Discipline ct = agent.getDiscipline();
    //            if (usedColTypes.get(ct) == null)
    //            {
    //                levelsVec.add(ct.getName());
    //                usedColTypes.put(ct, true);
    //            }*/
    //        }
    levelsVec.add("BackStop"); //$NON-NLS-1$

    addBtn = UIHelper.createIconBtn("PlusSign", "", new ActionListener() { //$NON-NLS-1$ //$NON-NLS-2$
        public void actionPerformed(ActionEvent arg0) {
            addControl();
        }
    });

    delBtn = UIHelper.createIconBtn("MinusSign", "", new ActionListener() { //$NON-NLS-1$ //$NON-NLS-2$
        public void actionPerformed(ActionEvent arg0) {
            delControl(TYPE.SelectedObj);
        }
    });

    ActionListener addViewAL = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            addView();
        }
    };

    ActionListener delViewAL = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            delView();
        }
    };

    viewControlPanel = new EditDeleteAddPanel(null, delViewAL, addViewAL);

    ActionListener addAltViewAL = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            addAltView();
        }
    };

    ActionListener delAltViewAL = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            delAltView();
        }
    };

    altViewControlPanel = new EditDeleteAddPanel(null, delAltViewAL, addAltViewAL);

    ActionListener addDefViewAL = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            addViewDef();
        }
    };

    ActionListener delDefViewAL = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            delViewDef();
        }
    };

    viewDefControlPanel = new EditDeleteAddPanel(null, delDefViewAL, addDefViewAL);

    ActionListener saveAL = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            save();
        }
    };
    EditDeleteAddPanel saveControlPanel = new EditDeleteAddPanel(null, null, saveAL);
    saveControlPanel.getAddBtn().setIcon(IconManager.getIcon("Save", IconManager.IconSize.Std16)); //$NON-NLS-1$
    saveControlPanel.getAddBtn().setEnabled(true);

    setLayout(new BorderLayout());

    levelsList = new JList(levelsVec);
    panel = new EditorPropPanel(controlHash, subcontrolHash, null, true, this);
    //panel.setFormViewDef(null);

    PanelBuilder pb = new PanelBuilder(new FormLayout("p,4px,p, 6px,10px,6px, p,6px,p, 6px,10px,6px, p,f:p:g", //$NON-NLS-1$
            "p,2px,f:p:g,2px,p,10px,p,4px")); //$NON-NLS-1$
    CellConstraints cc = new CellConstraints();

    String[] labels = new String[] { "User Level", "ViewSets", " ", "Views", "AltViews", " ", "View Defs" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
    int x = 1;
    for (String label : labels) {
        pb.add(createLabel(label, SwingConstants.CENTER), cc.xy(x, 1));
        x += 2;
    }

    Color vsFGColor = new Color(224, 224, 224);
    Color vsBGColor = new Color(124, 124, 124);

    Dimension ps = new Dimension(200, 150);

    x = 1;
    JScrollPane sp = createScrollPane(levelsList);
    pb.add(sp, cc.xy(x, 3));
    x += 2;

    viewSetsList = new JList(new DefaultListModel());
    sp = createScrollPane(viewSetsList);
    sp.setPreferredSize(ps);
    pb.add(sp, cc.xy(x, 3));
    x += 2;

    pb.add(new VerticalSeparator(vsFGColor, vsBGColor), cc.xy(x, 3));
    x += 2;

    viewsList = new JList(new DefaultListModel());
    sp = new JScrollPane(viewsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    sp.setPreferredSize(ps);
    pb.add(sp, cc.xy(x, 3));
    x += 2;

    altViewsList = new JList(new DefaultListModel());
    sp = createScrollPane(altViewsList);
    sp.setPreferredSize(ps);
    pb.add(sp, cc.xy(x, 3));
    x += 2;

    pb.add(new VerticalSeparator(vsFGColor, vsBGColor), cc.xy(x, 3));
    x += 2;

    viewDefsList = new JList(new DefaultListModel());
    sp = createScrollPane(viewDefsList);
    sp.setPreferredSize(ps);
    pb.add(sp, cc.xy(x, 3));
    x += 2;

    pb.add(saveControlPanel, cc.xy(1, 5));
    //pb.add(createLabel(" "),     cc.xy(3, 5));
    //pb.add(createLabel(" "),     cc.xy(5, 5));
    pb.add(viewControlPanel, cc.xy(7, 5));
    pb.add(altViewControlPanel, cc.xy(9, 5));
    //pb.add(createLabel(" "),     cc.xy(11, 5));
    pb.add(viewDefControlPanel, cc.xy(13, 5));

    pb.addSeparator("View Def Editor", cc.xywh(1, 7, 13, 1)); //$NON-NLS-1$

    add(pb.getPanel(), BorderLayout.NORTH);

    pb = new PanelBuilder(new FormLayout("max(250px;p),4px,f:p:g", "t:p")); //$NON-NLS-1$ //$NON-NLS-2$

    PanelBuilder inner = new PanelBuilder(new FormLayout("max(250px;p)", "t:p,2px,t:p")); //$NON-NLS-1$ //$NON-NLS-2$
    tree = new JTree();
    ((DefaultTreeModel) tree.getModel()).setRoot(null);
    sp = createScrollPane(tree);
    inner.add(sp, cc.xy(1, 1));

    PanelBuilder btnPb = new PanelBuilder(new FormLayout("f:p:g,p,2px,p", "p")); //$NON-NLS-1$ //$NON-NLS-2$
    btnPb.add(delBtn, cc.xy(2, 1));
    btnPb.add(addBtn, cc.xy(4, 1));
    inner.add(btnPb.getPanel(), cc.xy(1, 3));

    pb.add(inner.getPanel(), cc.xy(1, 1));
    pb.add(panel, cc.xy(3, 1));

    add(pb.getPanel(), BorderLayout.CENTER);

    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            treeSelected();
        }
    });

    levelsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                levelSelected();
            }
        }
    });

    viewSetsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                viewSetSelected();
            }
        }
    });

    viewsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                viewSelected();
            }
        }
    });

    altViewsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                altViewSelected();
            }
        }
    });

    viewDefsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                viewDefSelected();
            }
        }
    });

    tree.addMouseListener(new MouseAdapter() {

        protected void doPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
                int xc = e.getX();
                int yc = e.getY();
                TreePath path = tree.getPathForLocation(xc, yc);
                if (path != null) {
                    tree.setSelectionPath(path);
                }

                treeSelected();

                DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) tree.getSelectionModel()
                        .getSelectionPath().getLastPathComponent();

                if (selectedCell != null || selectedRow != null) {
                    new TreePopupMenu((Component) e.getSource(), e, selectedCell);

                } else if (selectedNode.getUserObject() instanceof FormViewDef) {
                    new TreePopupMenu((Component) e.getSource(), e);
                }
            }
        }

        public void mouseReleased(MouseEvent e) {
            doPopup(e);
        }

        public void mousePressed(MouseEvent e) {
            doPopup(e);
        }
    });

    XStream xstream = new XStream();
    xstream.alias("control", Control.class); //$NON-NLS-1$
    xstream.useAttributeFor(Control.class, "type"); //$NON-NLS-1$
    xstream.useAttributeFor(Attr.class, "type"); //$NON-NLS-1$
    xstream.useAttributeFor(Attr.class, "name"); //$NON-NLS-1$
    xstream.useAttributeFor(Attr.class, "required"); //$NON-NLS-1$
    xstream.useAttributeFor(Attr.class, "defaultValue"); //$NON-NLS-1$
    xstream.aliasAttribute("default", "defaultValue"); //$NON-NLS-1$ //$NON-NLS-2$

    xstream.alias("uicontrols", Vector.class); //$NON-NLS-1$
    xstream.alias("attr", Attr.class); //$NON-NLS-1$
    xstream.alias("param", Param.class); //$NON-NLS-1$
    xstream.alias("subcontrol", SubControl.class); //$NON-NLS-1$
    xstream.aliasAttribute("desc", "desc"); //$NON-NLS-1$ //$NON-NLS-2$
    xstream.aliasAttribute(Attr.class, "values", "values"); //$NON-NLS-1$ //$NON-NLS-2$
    xstream.useAttributeFor(SubControl.class, "type"); //$NON-NLS-1$

    try {
        controls = (Vector<Control>) xstream.fromXML(FileUtils.readFileToString(new File("UIControls.xml"))); //$NON-NLS-1$
        for (Control control : controls) {
            controlHash.put(control.getType(), control);
            if (control.getSubcontrols() != null) {
                for (SubControl sc : control.getSubcontrols()) {
                    //System.out.println(" ["+sc.getType()+"]  ");
                    subcontrolHash.put(sc.getType(), sc);
                }
            }
        }

    } catch (IOException ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ViewSetSelectorPanel.class, ex);
        ex.printStackTrace();
    }
}

From source file:it.imtech.metadata.MetaUtility.java

/**
 * Metodo che setta il TreeMap oefos_path con i valori del nodo selezionato
 * e aggiorna il label che descrive il path dei nodi selezionati
 *
 * @param e L'albero sul quale ricercare il path selezionato
 *//*from  w w  w  .  j a  v  a 2s.  co m*/
private void setOEFOS(JTree e, String sequence, String panelname) throws Exception {
    try {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getLastSelectedPathComponent();
        String completePath = "";
        //OefosPaths path = new OefosPaths(panelname, sequence);

        BookImporter.getInstance()
                .createComponentMap(BookImporter.getInstance().metadatapanels.get(panelname).getPanel());
        Component controls = BookImporter.getInstance().getComponentByName("classification_path---" + sequence);

        //Se e' una foglia aggiorna il path nell'interfaccia e oefos_path
        if (node != null) {
            TreePath selpath = new TreePath(node.getPath());
            e.setSelectionPath(selpath);

            Object[] nodes = selpath.getPath();

            TreeMap<Integer, Integer> single_path = new TreeMap<Integer, Integer>();

            for (int i = 1; i < nodes.length; i++) {
                Object nodeInfo = nodes[i];
                DefaultMutableTreeNode nodeC = (DefaultMutableTreeNode) nodeInfo;
                ClassNode c = (ClassNode) nodeC.getUserObject();
                single_path.put(i, Integer.parseInt(c.getKey().toString()));

                completePath += nodes[i].toString();
                completePath += (i != nodes.length - 1) ? "/" : "";
            }

            this.oefos_path.put(panelname + "----" + sequence, single_path);
        } else {
            this.oefos_path.put(panelname + "----" + sequence, null);
        }

        JLabel label = (JLabel) controls;
        if (completePath.length() > 120) {
            label.setText(completePath.substring(0, 120));
        } else {
            label.setText(completePath);
        }

        label.revalidate();
    } catch (Exception ex) {
        throw new Exception("Exception in setOEFOS: " + ex.getStackTrace() + "\n");
    }
}

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

private int[] dumpBlockingMonitors(DefaultMutableTreeNode catLockingTree, MonitorMap mmap) {
    final Map<String, DefaultMutableTreeNode> directChildMap = new HashMap<>(); // Top level of our display model

    //******************************************************************
    // Figure out what threads are blocking and what threads are blocked
    //******************************************************************
    int blockedThreads = fillBlockingThreadMaps(mmap, directChildMap);
    int contendedLocks = directChildMap.size();

    //********************************************************************
    // Renormalize this from a flat tree (depth==1) into a structured tree
    //********************************************************************
    reNormalizeBlockingThreadTree(mmap, directChildMap);

    //********************************************************************
    // Recalculate the number of blocked threads and add remaining top-level threads to our display model
    //********************************************************************
    for (final Object o : directChildMap.entrySet()) {
        DefaultMutableTreeNode threadNode = (DefaultMutableTreeNode) ((Map.Entry) o).getValue();
        updateChildCount(threadNode, true);
        ((Category) catLockingTree.getUserObject()).addToCatNodes(threadNode);
    }//from ww  w.  j  ava2  s  .c om

    directChildMap.clear();
    return new int[] { contendedLocks, blockedThreads };
}