Package javax.swing.tree

Examples of javax.swing.tree.TreeSelectionModel


        tree.setItsNatTreeCellRenderer(new MainTreeRenderer(tree.getItsNatTreeCellRenderer()));

        tree.setItsNatTreeCellEditor(null); // to avoid edition

        TreeSelectionModel selModel = tree.getTreeSelectionModel();
        selModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        selModel.addTreeSelectionListener(this);

        FeatureTreeBuilder treeBuilder = new FeatureTreeBuilder(this);
        FeatureTreeNode rootNode = treeBuilder.buildFeatureTreeModel();
        treeBuilder.buildSwingTree(rootNode);
    }
View Full Code Here


        TreeModel dataModel = comp.getTreeModel();
        dataModel.addTreeModelListener(this); // Added before to call setTreeModel again because it must be called last (the last registered is the first called, the component register a listener to add/remove DOM elements)
        comp.setTreeModel(dataModel);// Resets the internal listeners, the internal TreeModelListener listener is called first
        comp.addTreeExpansionListener(this);

        TreeSelectionModel selModel = comp.getTreeSelectionModel();
        selModel.addTreeSelectionListener(this);
    }
View Full Code Here

        FeatureShowcaseDocument featShowDoc = feature.getFeatureShowcaseDocument();
        ItsNatFreeTree tree = featShowDoc.getItsNatFreeTree();

        feature.setOnloadTargetPanel(panel);

        TreeSelectionModel selModel = tree.getTreeSelectionModel();
        selModel.setSelectionPath(path);
    }
View Full Code Here

        TreeModel dataModel = comp.getTreeModel();
        dataModel.addTreeModelListener(this); // Added before to call setTreeModel again because it must be called last (the last registered is the first called, the component register a listener to add/remove DOM elements)
        comp.setTreeModel(dataModel)// resets the internal listeners, the internal TreeModelListener listener is called first
        comp.addTreeExpansionListener(this);

        TreeSelectionModel selModel = comp.getTreeSelectionModel();
        selModel.addTreeSelectionListener(this);
    }
View Full Code Here

                addNode(new TreeTableItem("Shonda Rhimes","Creator"),parentNode);
                addNode(new TreeTableItem("USA","Country"),parentNode);
                addNode(new TreeTableItem("English","Language"),parentNode);

        TreeSelectionModel selModel = treeComp.getTreeSelectionModel();
        selModel.setSelectionMode(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);

        selModel.addSelectionPath(new TreePath(parentNode.getPath())); // Other

        treeComp.addEventListener("click",this);
        dataModel.addTreeModelListener(this);
        selModel.addTreeSelectionListener(this);

        this.removeButton = (ItsNatHTMLInputButton)compMgr.createItsNatComponentById("removeId");
        removeButton.addEventListener("click",this);

        DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)selModel.getSelectionPath().getLastPathComponent();
        TreeTableItem selectedItem = (TreeTableItem)selectedNode.getUserObject();
        this.itemPrincipalComp = (ItsNatHTMLInputText)compMgr.createItsNatComponentById("itemPrincipalId");
        itemPrincipalComp.setText(selectedItem.getPrincipal());
        this.itemSecondaryComp = (ItsNatHTMLInputText)compMgr.createItsNatComponentById("itemSecondaryId");
        itemSecondaryComp.setText(selectedItem.getSecondary());

        this.posComp = (ItsNatHTMLInputText)compMgr.createItsNatComponentById("posId");
        posComp.setText(Integer.toString(selModel.getMinSelectionRow()));

        this.updateButton = (ItsNatHTMLInputButton)compMgr.createItsNatComponentById("updateId");
        updateButton.addEventListener("click",this);

        this.insertBeforeButton = (ItsNatHTMLInputButton)compMgr.createItsNatComponentById("insertBeforeId");
View Full Code Here

        EventTarget currentTarget = evt.getCurrentTarget();
        if (currentTarget == removeButton.getHTMLInputElement())
        {
            DefaultTreeModel dataModel = (DefaultTreeModel)treeComp.getTreeModel();
            TreeSelectionModel selModel = treeComp.getTreeSelectionModel();
            if (!selModel.isSelectionEmpty())
            {
                // Selection Model is in CONTIGUOUS_TREE_SELECTION mode
                TreePath[] paths = selModel.getSelectionPaths();
                for(int i = 0; i < paths.length; i++)
                {
                    MutableTreeNode node = (MutableTreeNode)paths[i].getLastPathComponent();
                    if (node == dataModel.getRoot())
                        dataModel.setRoot(null);
View Full Code Here

        log(e.toString());
    }

    public void valueChanged(TreeSelectionEvent e)
    {
        TreeSelectionModel selModel = treeComp.getTreeSelectionModel();

        TreePath[] paths = e.getPaths();
        String fact = "";
        for(int i = 0; i < paths.length; i++)
        {
            TreePath path = paths[i];
            boolean selected = selModel.isPathSelected(path);
            if (selected)
                fact += ", selected ";
            else
                fact += ", deselected ";
            fact += path.getLastPathComponent();
        }

        log(e.getClass().toString() + " " + fact);

        int row = selModel.getMinSelectionRow(); // First selected
        if (row != -1)
        {
            TreePath path = treeComp.getTreePathForRow(row);
            DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
            TreeTableItem value = (TreeTableItem)node.getUserObject();
View Full Code Here

                addNode("Ellen Pompeo",parentNode,dataModel);
                addNode("Sandra Oh",parentNode,dataModel);
                addNode("Justin Chambers",parentNode,dataModel);
                addNode("T.R. Knight",parentNode,dataModel);

        TreeSelectionModel selModel = treeComp.getTreeSelectionModel();
        selModel.setSelectionMode(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);

        selModel.addSelectionPath(new TreePath(parentNode.getPath())); // Actors

        treeComp.addEventListener("click",this);
        dataModel.addTreeModelListener(this);
        selModel.addTreeSelectionListener(this);

        treeComp.addTreeWillExpandListener(this);

        this.removeButton = (ItsNatHTMLInputButton)compMgr.createItsNatComponentById("removeId");
        removeButton.addEventListener("click",this);

        this.itemComp = (ItsNatHTMLInputText)compMgr.createItsNatComponentById("itemId");
        itemComp.setText(selModel.getSelectionPath().getLastPathComponent().toString());

        this.posComp = (ItsNatHTMLInputText)compMgr.createItsNatComponentById("posId");
        posComp.setText(Integer.toString(selModel.getMinSelectionRow()));

        this.updateButton = (ItsNatHTMLInputButton)compMgr.createItsNatComponentById("updateId");
        updateButton.addEventListener("click",this);

        this.insertBeforeButton = (ItsNatHTMLInputButton)compMgr.createItsNatComponentById("insertBeforeId");
View Full Code Here

        EventTarget currentTarget = evt.getCurrentTarget();
        if (currentTarget == removeButton.getHTMLInputElement())
        {
            DefaultTreeModel dataModel = (DefaultTreeModel)treeComp.getTreeModel();
            TreeSelectionModel selModel = treeComp.getTreeSelectionModel();
            if (!selModel.isSelectionEmpty())
            {
                // Selection Model is in CONTIGUOUS_TREE_SELECTION mode
                TreePath[] paths = selModel.getSelectionPaths();
                for(int i = 0; i < paths.length; i++)
                {
                    MutableTreeNode node = (MutableTreeNode)paths[i].getLastPathComponent();
                    if (node == dataModel.getRoot())
                        dataModel.setRoot(null);
View Full Code Here

        log(e.toString());
    }

    public void valueChanged(TreeSelectionEvent e)
    {
        TreeSelectionModel selModel = (TreeSelectionModel)e.getSource();

        TreePath[] paths = e.getPaths();
        String fact = "";
        for(int i = 0; i < paths.length; i++)
        {
            TreePath path = paths[i];
            boolean selected = selModel.isPathSelected(path);
            if (selected)
                fact += ", selected ";
            else
                fact += ", deselected ";
            fact += path.getLastPathComponent();
        }

        log(e.getClass().toString() + " " + fact);

        int row = selModel.getMinSelectionRow(); // First selected
        if (row != -1)
        {
            TreePath path = treeComp.getTreePathForRow(row);
            Object value = path.getLastPathComponent();
            itemComp.setText(value.toString());
View Full Code Here

TOP

Related Classes of javax.swing.tree.TreeSelectionModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.