Package javax.swing.tree

Examples of javax.swing.tree.DefaultTreeSelectionModel


    buttonBox.add(Box.createHorizontalStrut(5));
    buttonBox.add(cancelButton);
 
    add(buttonBox, BorderLayout.SOUTH);
 
    DefaultTreeSelectionModel treeSelectionModel =
      new DefaultTreeSelectionModel();
    treeSelectionModel.setSelectionMode(
      TreeSelectionModel.SINGLE_TREE_SELECTION);
    prefTree.setSelectionModel(treeSelectionModel);
    prefTree.addTreeSelectionListener(
      new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
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

    // 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

        assertNotNull(ui.getCellEditor());
    }

    public void testSetGetSelectionModel() {
        assertTrue(ui.getSelectionModel() instanceof DefaultTreeSelectionModel);
        DefaultTreeSelectionModel m = new DefaultTreeSelectionModel();
        ui.setSelectionModel(m);
        assertSame(m, ui.getSelectionModel());
        assertSame(m, ui.treeSelectionModel);
    }
View Full Code Here

        super.tearDown();
    }

    public void testTreeSelectionRedirector() throws Exception {
        assertNull(tree.selectionRedirector);
        DefaultTreeSelectionModel model = (DefaultTreeSelectionModel) tree.getSelectionModel();
        assertFalse(hasListener(model.getTreeSelectionListeners(),
                JTree.TreeSelectionRedirector.class));
        final Marker marker = new Marker();
        tree.addTreeSelectionListener(new TreeSelectionListener() {
            public void valueChanged(final TreeSelectionEvent e) {
                marker.setAuxiliary(e);
            }
        });
        assertNotNull(tree.selectionRedirector);
        assertTrue(hasListener(model.getTreeSelectionListeners(),
                JTree.TreeSelectionRedirector.class));
        TreePath path = new TreePath("root");
        TreePath oldLead = new TreePath("old_lead");
        TreePath newLead = new TreePath("new_lead");
        tree.selectionRedirector.valueChanged(new TreeSelectionEvent("any_source", path, true,
                oldLead, newLead));
        assertNotNull(marker.getAuxiliary());
        TreeSelectionEvent redirectedEvent = (TreeSelectionEvent) marker.getAuxiliary();
        assertSame(tree, redirectedEvent.getSource());
        assertSame(path, redirectedEvent.getPath());
        assertTrue(redirectedEvent.isAddedPath());
        assertSame(oldLead, redirectedEvent.getOldLeadSelectionPath());
        assertSame(newLead, redirectedEvent.getNewLeadSelectionPath());
        DefaultTreeSelectionModel newModel = new DefaultTreeSelectionModel();
        tree.setSelectionModel(newModel);
        assertTrue(hasListener(newModel.getTreeSelectionListeners(),
                JTree.TreeSelectionRedirector.class));
        tree.setSelectionModel(null);
        assertTrue(hasListener(((DefaultTreeSelectionModel) tree.getSelectionModel())
                .getTreeSelectionListeners(), JTree.TreeSelectionRedirector.class));
    }
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);
        assertSame(mapper, model1.getRowMapper());
        model1.setRowMapper(null);
        model2.setRowMapper(rowMapper2);
        tree.setSelectionModel(model2);
        assertSame(mapper, model2.getRowMapper());
        assertTrue(mapper instanceof VariableHeightLayoutCache);
    }
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

      MonitoredAttributesTreeTableModel model = (MonitoredAttributesTreeTableModel) m_ttTango
          .getTree().getModel();
      model.setAsksAllowsChildren(true);
      m_ttTango.getTree().setCellRenderer(new DeviceNodeCellRenderer());
      // allow only single selection
      DefaultTreeSelectionModel selectionModel = (DefaultTreeSelectionModel) m_ttTango
          .getTree().getSelectionModel();
      selectionModel
          .setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
      m_ttTango.getSelectionModel().setSelectionMode(
          ListSelectionModel.SINGLE_SELECTION);

      // add listener on tree's expansion (build nodes)
View Full Code Here

            m_ttTango = new TangoTreeTable(getTreeTableModel(),m_pnl);
            MonitoredAttributesTreeTableModel model =  (MonitoredAttributesTreeTableModel) m_ttTango.getTree().getModel();
            model.setAsksAllowsChildren(true);
            m_ttTango.getTree().setCellRenderer(new DeviceNodeCellRenderer());
            //allow only single selection
            DefaultTreeSelectionModel selectionModel =  (DefaultTreeSelectionModel) m_ttTango.getTree().getSelectionModel();
            selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
            m_ttTango.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

            //add listener on tree's expansion (build nodes)
            addListerner();
View Full Code Here

            m_ttTango = new TangoTreeTable(getTreeTableModel(),m_pnl);
            RecordingDevicesTreeTableModel model =  (RecordingDevicesTreeTableModel) m_ttTango.getTree().getModel();
            model.setAsksAllowsChildren(true);
            m_ttTango.getTree().setCellRenderer(new DeviceNodeCellRenderer());
            //allow only single selection
            DefaultTreeSelectionModel selectionModel =  (DefaultTreeSelectionModel) m_ttTango.getTree().getSelectionModel();
            selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
            m_ttTango.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

            //add listener on tree's expansion (build nodes)
            addListerner();
View Full Code Here

TOP

Related Classes of javax.swing.tree.DefaultTreeSelectionModel

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.