Package javax.swing.tree

Examples of javax.swing.tree.TreeSelectionModel


    public TreePath getEditingPath() {
        return getUI().getEditingPath(this);
    }

    public void setSelectionModel(final TreeSelectionModel model) {
        TreeSelectionModel oldValue = selectionModel;
        selectionModel.removeTreeSelectionListener(selectionRedirector);

        selectionModel = model != null ? model : EmptySelectionModel.sharedInstance();
        if (selectionRedirector != null) {
            selectionModel.addTreeSelectionListener(selectionRedirector);
View Full Code Here


    }

    private static List<Object> getSelectedElements(JTree tree) {
        assert tree != null;

        TreeSelectionModel selectionModel = tree.getSelectionModel();
        int min = selectionModel.getMinSelectionRow();
        int max = selectionModel.getMaxSelectionRow();

        if (min < 0 || max < 0) {
            return new ArrayList<Object>(0);
        }

        ArrayList<Object> elements = new ArrayList<Object>(max - min + 1);

        for (int i = min; i <= max; i++) {
            if (selectionModel.isRowSelected(i)) {
                elements.add(getElement(tree, i));
            }
        }

        return elements;
View Full Code Here

        final DefaultTreeModel tm = new DefaultTreeModel(rootNode);
        setModel(tm);
        linkedPanel.setTestCaseTree(this);
        mLinkedpanel= linkedPanel;
        TreeSelectionModel selModel = this.getSelectionModel();
        selModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

        TestBedConfiguration.registerConfigurationChangeHandler(new TestBedConfiguration.ConfigurationChangeHandler() {

            public void onConfigurationChange() {
                TestAPIDocsTree.this.buildTree(rootNode, TestAPIDocsTree.this);
View Full Code Here

        generateScriptsTree(rootFileNode);
        TCTreeListener listener = new TCTreeListener();
        this.addMouseListener(listener);
        addTreeWillExpandListener(listener);
        addTreeSelectionListener(listener);
        TreeSelectionModel selModel = this.getSelectionModel();
        selModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

        // drag drop initialization
        ds = new DragSource();
        dt = new DropTarget();
View Full Code Here

        generateScriptsTree(rootFileNode);
        TCTreeListener listener = new TCTreeListener();
        this.addMouseListener(listener);
        addTreeWillExpandListener(listener);
        addTreeSelectionListener(listener);
        TreeSelectionModel selModel = this.getSelectionModel();
        selModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    }
View Full Code Here

      });

    logTree.setEditable(false);

    //  TODO decide if Multi-selection is useful, and how it would work 
    TreeSelectionModel selectionModel = new DefaultTreeSelectionModel();
    selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    logTree.setSelectionModel(selectionModel);

    logTree.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    scrollTree = new JScrollPane(logTree);
    toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.X_AXIS));
View Full Code Here

    tree.setDragEnabled(true); // To allow drag to stylemap table.
    tree.setRootVisible(false);
    tree.setShowsRootHandles(true); // Displays node expansion glyphs.

    TreeSelectionModel selectionModel = tree.getSelectionModel();
    selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
    cellRenderer.setLeafIcon(null);
    cellRenderer.setClosedIcon(null);
    cellRenderer.setOpenIcon(null);
View Full Code Here

    tree.setDragEnabled(true); // To allow drag to stylemap table.
    tree.setRootVisible(false);
    tree.setShowsRootHandles(true); // Displays node expansion glyphs.

    TreeSelectionModel selectionModel = tree.getSelectionModel();
    selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
    cellRenderer.setLeafIcon(null);
    cellRenderer.setClosedIcon(null);
    cellRenderer.setOpenIcon(null);
View Full Code Here

    // Set up the type tree. Use simple DefaultTreeModel.
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("<html><b>No CAS!</b></html>");
    DefaultTreeModel treeModel = new DefaultTreeModel(root);
    this.typeTree = new JTree(treeModel);
    this.typeTree.addTreeSelectionListener(new TypeTreeSelectionListener());
    TreeSelectionModel treeSelectionModel = new DefaultTreeSelectionModel();
    treeSelectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    this.typeTree.setSelectionModel(treeSelectionModel);
    JScrollPane treePane = new JScrollPane(this.typeTree);
    contentPane.setLeftComponent(treePane);
    DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
    cellRenderer.setLeafIcon(null);
View Full Code Here

        RowMapper rowMapper2 = new RowMapper() {
            public int[] getRowsForPaths(TreePath[] path) {
                return null;
            }
        };
        TreeSelectionModel model1 = new DefaultTreeSelectionModel();
        TreeSelectionModel model2 = new DefaultTreeSelectionModel();
        RowMapper mapper = tree.getSelectionModel().getRowMapper();
        tree.setSelectionModel(model1);
        assertTrue(propertyChangeController.isChanged("selectionModel"));
        assertEquals(model1, tree.getSelectionModel());
        assertSame(mapper, tree.getSelectionModel().getRowMapper());
        tree.setSelectionModel(model2);
        assertEquals(model2, tree.getSelectionModel());
        assertSame(mapper, tree.getSelectionModel().getRowMapper());
        propertyChangeController.reset();
        TreeSelectionModel oldModel = tree.getSelectionModel();
        tree.setSelectionModel(null);
        assertNotNull(tree.getSelectionModel());
        assertTrue(tree.getSelectionModel() instanceof JTree.EmptySelectionModel);
        assertSame(mapper, tree.getSelectionModel().getRowMapper());
        assertTrue(propertyChangeController.isChanged("selectionModel"));
        propertyChangeController.checkPropertyFired(tree, "selectionModel", oldModel, tree
                .getSelectionModel());
        TreeSelectionModel emptyModel = tree.getSelectionModel();
        tree.setSelectionModel(model2);
        tree.setSelectionModel(null);
        assertSame(emptyModel, tree.getSelectionModel());
        model1.setRowMapper(rowMapper1);
        tree.setSelectionModel(model1);
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.