Example usage for javax.swing.tree TreeSelectionModel SINGLE_TREE_SELECTION

List of usage examples for javax.swing.tree TreeSelectionModel SINGLE_TREE_SELECTION

Introduction

In this page you can find the example usage for javax.swing.tree TreeSelectionModel SINGLE_TREE_SELECTION.

Prototype

int SINGLE_TREE_SELECTION

To view the source code for javax.swing.tree TreeSelectionModel SINGLE_TREE_SELECTION.

Click Source Link

Document

Selection can only contain one path at a time.

Usage

From source file:DynamicTreeDemo.java

public DynamicTree() {
    super(new GridLayout(1, 0));

    rootNode = new DefaultMutableTreeNode("Root Node");
    treeModel = new DefaultTreeModel(rootNode);

    tree = new JTree(treeModel);
    tree.setEditable(true);//  ww w .  j  a  va 2s  .  c  om
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setShowsRootHandles(true);

    JScrollPane scrollPane = new JScrollPane(tree);
    add(scrollPane);
}

From source file:edu.clemson.cs.nestbed.client.gui.ConfigManagerFrame.java

public ConfigManagerFrame(Testbed testbed, Project project, ProjectDeploymentConfiguration config)
        throws RemoteException, NotBoundException, MalformedURLException, ClassNotFoundException {
    super(testbed.getName() + " Deployment Configuration Manager");

    this.testbed = testbed;
    this.project = project;
    this.config = config;

    lookupRemoteManagers();/*from   ww  w.  j a v a2 s . com*/
    // TODO:  We need to deregister listeners
    programCompileManager.addRemoteObserver(new ProgramCompileObserver());
    programManager.addRemoteObserver(new ProgramObserver());
    progProfManager.addRemoteObserver(new ProgramProfilingSymbolObserver());
    progProfMsgSymManager.addRemoteObserver(new ProgramProfilingMessageSymbolObserver());

    createComponents();
    programTree.addMouseListener(new ProgramTreeMouseListener());
    programTree.setCellRenderer(new ProgramTreeCellRenderer());
    programTree.setRootVisible(false);
    programTree.setShowsRootHandles(true);
    programTree.setDragEnabled(true);
    programTree.setTransferHandler(new ProgramTreeTransferHandler());
    programTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    profilingSymbolTable.addMouseListener(new ProfilingSymbolTableMouseListener());
    profilingSymbolTable.setModel(new ProfilingSymbolTableModel());
    profilingSymbolTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    new DropTarget(profilingSymbolTable, DnDConstants.ACTION_COPY_OR_MOVE, new ProgramSymbolDropTarget(), true);

    profilingMsgTable.addMouseListener(new ProfilingMessageTableMouseListener());
    profilingMsgTable.setModel(new ProfilingMessageSymbolTableModel());
    profilingMsgTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    new DropTarget(profilingMsgTable, DnDConstants.ACTION_COPY_OR_MOVE, new ProgramMessageSymbolDropTarget(),
            true);

    setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
    setJMenuBar(buildMenuBar());

    Container c = getContentPane();
    c.setLayout(new BorderLayout());

    JSplitPane top = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, buildLeftPanel(), buildMoteGridPanel());

    JSplitPane panel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, top, buildBottomPanel());

    c.add(panel, BorderLayout.CENTER);
}

From source file:dotaSoundEditor.Controls.ItemPanel.java

private void initTreeSelectionListener() {
    currentTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    currentTree.addTreeSelectionListener(new TreeSelectionListener() {
        @Override//from ww  w .  j a va 2 s .  c  o m
        public void valueChanged(TreeSelectionEvent evt) {
            currentTreeSelectionChanged(evt);
        }
    });
    attachDoubleClickListenerToTree();
}

From source file:gov.nij.er.ui.EntityResolutionDemo.java

private void setupWidgetModels() {

    rawDataTreeModel = new RecordTreeModel();
    resolvedDataTreeModel = new RecordTreeModel();
    resolvedDataTreeSelectionModel = rawDataTree.getSelectionModel();
    rawDataFilteredTreeModel = new RawDataFilteredTreeModel(rawDataTreeModel);
    parametersTableModel = new ERParametersTableModel(rawDataTreeModel, resolvedDataTreeModel);

    // rawDataTree.setModel(rawDataTreeModel);
    resolvedDataTree.setModel(resolvedDataTreeModel);
    rawDataTree.setModel(rawDataFilteredTreeModel);

    resolvedDataTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    resolvedDataTreeSelectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    parametersTable.setModel(parametersTableModel);

    for (Algorithm alg : Algorithm.SUPPORTED_ALGORITHMS) {
        algorithmComboBox.addItem(alg);/*  ww  w .  j  a  va  2 s .  c  o  m*/
    }
}

From source file:edu.brown.gui.CatalogViewer.java

/**
 * /* w w w.  j ava  2 s .co m*/
 */
protected void viewerInit() {
    // ----------------------------------------------
    // MENU
    // ----------------------------------------------
    JMenu menu;
    JMenuItem menuItem;

    // 
    // File Menu
    //
    menu = new JMenu("File");
    menu.getPopupMenu().setLightWeightPopupEnabled(false);
    menu.setMnemonic(KeyEvent.VK_F);
    menu.getAccessibleContext().setAccessibleDescription("File Menu");
    menuBar.add(menu);

    menuItem = new JMenuItem("Open Catalog From File");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Open Catalog From File");
    menuItem.addActionListener(this.menuHandler);
    menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.CATALOG_OPEN_FILE);
    menu.add(menuItem);

    menuItem = new JMenuItem("Open Catalog From Jar");
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Open Catalog From Project Jar");
    menuItem.addActionListener(this.menuHandler);
    menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.CATALOG_OPEN_JAR);
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem("Quit", KeyEvent.VK_Q);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Quit Program");
    menuItem.addActionListener(this.menuHandler);
    menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.QUIT);
    menu.add(menuItem);

    // ----------------------------------------------
    // CATALOG TREE PANEL
    // ----------------------------------------------
    this.catalogTree = new JTree();
    this.catalogTree.setEditable(false);
    this.catalogTree.setCellRenderer(new CatalogViewer.CatalogTreeRenderer());
    this.catalogTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    this.catalogTree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) CatalogViewer.this.catalogTree
                    .getLastSelectedPathComponent();
            if (node == null)
                return;

            Object user_obj = node.getUserObject();
            String new_text = ""; // <html>";
            boolean text_mode = true;
            if (user_obj instanceof WrapperNode) {
                CatalogType catalog_obj = ((WrapperNode) user_obj).getCatalogType();
                new_text += CatalogViewer.this.getAttributesText(catalog_obj);
            } else if (user_obj instanceof AttributesNode) {
                AttributesNode wrapper = (AttributesNode) user_obj;
                new_text += wrapper.getAttributes();

            } else if (user_obj instanceof PlanTreeCatalogNode) {
                final PlanTreeCatalogNode wrapper = (PlanTreeCatalogNode) user_obj;
                text_mode = false;

                CatalogViewer.this.mainPanel.remove(0);
                CatalogViewer.this.mainPanel.add(wrapper.getPanel(), BorderLayout.CENTER);
                CatalogViewer.this.mainPanel.validate();
                CatalogViewer.this.mainPanel.repaint();

                if (SwingUtilities.isEventDispatchThread() == false) {
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            wrapper.centerOnRoot();
                        }
                    });
                } else {
                    wrapper.centerOnRoot();
                }

            } else {
                new_text += CatalogViewer.this.getSummaryText();
            }

            // Text Mode
            if (text_mode) {
                if (CatalogViewer.this.text_mode == false) {
                    CatalogViewer.this.mainPanel.remove(0);
                    CatalogViewer.this.mainPanel.add(CatalogViewer.this.textInfoPanel);
                }
                CatalogViewer.this.textInfoTextArea.setText(new_text);

                // Scroll to top
                CatalogViewer.this.textInfoTextArea.grabFocus();
            }

            CatalogViewer.this.text_mode = text_mode;
        }
    });
    this.generateCatalogTree(this.catalog, this.catalog_file_path.getName());

    //
    // Text Information Panel
    //
    this.textInfoPanel = new JPanel();
    this.textInfoPanel.setLayout(new BorderLayout());
    this.textInfoTextArea = new JTextArea();
    this.textInfoTextArea.setEditable(false);
    this.textInfoTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
    this.textInfoTextArea.setText(this.getSummaryText());
    this.textInfoTextArea.addFocusListener(new FocusListener() {
        @Override
        public void focusLost(FocusEvent e) {
            // TODO Auto-generated method stub
        }

        @Override
        public void focusGained(FocusEvent e) {
            CatalogViewer.this.scrollTextInfoToTop();
        }
    });
    this.textInfoScroller = new JScrollPane(this.textInfoTextArea);
    this.textInfoPanel.add(this.textInfoScroller, BorderLayout.CENTER);
    this.mainPanel = new JPanel(new BorderLayout());
    this.mainPanel.add(textInfoPanel, BorderLayout.CENTER);

    //
    // Search Toolbar
    //
    JPanel searchPanel = new JPanel();
    searchPanel.setLayout(new BorderLayout());
    JPanel innerSearchPanel = new JPanel();
    innerSearchPanel.setLayout(new BoxLayout(innerSearchPanel, BoxLayout.X_AXIS));
    innerSearchPanel.add(new JLabel("Search: "));
    this.searchField = new JTextField(30);
    innerSearchPanel.add(this.searchField);
    searchPanel.add(innerSearchPanel, BorderLayout.EAST);

    this.searchField.addKeyListener(new KeyListener() {
        private String last = null;

        @Override
        public void keyReleased(KeyEvent e) {
            String value = CatalogViewer.this.searchField.getText().toLowerCase().trim();
            if (!value.isEmpty() && (this.last == null || !this.last.equals(value))) {
                CatalogViewer.this.search(value);
            }
            this.last = value;
        }

        @Override
        public void keyTyped(KeyEvent e) {
            // Do nothing...
        }

        @Override
        public void keyPressed(KeyEvent e) {
            // Do nothing...
        }
    });

    // Putting it all together
    JScrollPane scrollPane = new JScrollPane(this.catalogTree);
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());
    topPanel.add(searchPanel, BorderLayout.NORTH);
    topPanel.add(scrollPane, BorderLayout.CENTER);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, topPanel, this.mainPanel);
    splitPane.setDividerLocation(400);

    this.add(splitPane, BorderLayout.CENTER);
}

From source file:com.mirth.connect.client.ui.LibraryResourcesPanel.java

private void initComponents(Channel channel) {
    setBackground(UIConstants.BACKGROUND_COLOR);

    AbstractMutableTreeTableNode channelNode = new DefaultMutableTreeTableNode(
            new ConnectorEntry("Channel", -1, null));

    AbstractMutableTreeTableNode channelScriptsNode = new DefaultMutableTreeTableNode(
            new ConnectorEntry("Channel Scripts", null, null));
    channelScriptsNode//from   w w  w.java  2s  .c  om
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Deploy Script", null, null, false)));
    channelScriptsNode
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Undeploy Script", null, null, false)));
    channelScriptsNode
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Preprocessor Script", null, null, false)));
    channelScriptsNode.add(
            new DefaultMutableTreeTableNode(new ConnectorEntry("Postprocessor Script", null, null, false)));
    channelScriptsNode
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Attachment Script", null, null, false)));
    channelScriptsNode
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Batch Script", null, null, false)));
    channelNode.add(channelScriptsNode);

    AbstractMutableTreeTableNode sourceConnectorNode = new DefaultMutableTreeTableNode(
            new ConnectorEntry("Source Connector", 0, channel.getSourceConnector().getTransportName()));
    sourceConnectorNode.add(new DefaultMutableTreeTableNode(
            new ConnectorEntry("Receiver", channel.getSourceConnector().getMetaDataId(),
                    channel.getSourceConnector().getTransportName(), false)));
    sourceConnectorNode.add(new DefaultMutableTreeTableNode(
            new ConnectorEntry("Filter / Transformer Script", channel.getSourceConnector().getMetaDataId(),
                    channel.getSourceConnector().getTransportName(), false)));
    channelNode.add(sourceConnectorNode);

    for (Connector destinationConnector : channel.getDestinationConnectors()) {
        AbstractMutableTreeTableNode destinationConnectorNode = new DefaultMutableTreeTableNode(
                new ConnectorEntry(destinationConnector.getName(), destinationConnector.getMetaDataId(),
                        destinationConnector.getTransportName()));
        destinationConnectorNode
                .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Filter / Transformer Script",
                        destinationConnector.getMetaDataId(), destinationConnector.getTransportName(), false)));
        destinationConnectorNode.add(new DefaultMutableTreeTableNode(new ConnectorEntry("Dispatcher",
                destinationConnector.getMetaDataId(), destinationConnector.getTransportName(), false)));
        destinationConnectorNode
                .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Response Transformer Script",
                        destinationConnector.getMetaDataId(), destinationConnector.getTransportName(), false)));
        channelNode.add(destinationConnectorNode);
    }

    treeTable = new MirthTreeTable();

    DefaultTreeTableModel model = new SortableTreeTableModel(channelNode);
    model.setColumnIdentifiers(Arrays.asList(new String[] { "Library Context" }));
    treeTable.setTreeTableModel(model);

    treeTable.setRootVisible(true);
    treeTable.setDragEnabled(false);
    treeTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    treeTable.getTreeSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    treeTable.setRowHeight(UIConstants.ROW_HEIGHT);
    treeTable.setFocusable(true);
    treeTable.setOpaque(true);
    treeTable.getTableHeader().setReorderingAllowed(false);
    treeTable.setEditable(false);
    treeTable.setSortable(false);
    treeTable.addTreeSelectionListener(this);
    treeTable.getSelectionModel().addListSelectionListener(this);
    treeTable.putClientProperty("JTree.lineStyle", "Horizontal");
    treeTable.setShowGrid(true, true);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        treeTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR));
    }

    final String toolTipText = "<html>Select which context(s) to include library resources in.<br/>Libraries can be included everywhere (the Channel node),<br/>on channel-level scripts (the Channel Scripts node), and<br/>on specific source or destination connectors.</html>";

    treeTable.setTreeCellRenderer(new DefaultTreeCellRenderer() {
        @Override
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
                boolean expanded, boolean leaf, int row, boolean hasFocus) {
            super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
            setToolTipText(toolTipText);
            setEnabled(((ConnectorEntry) ((AbstractMutableTreeTableNode) value).getUserObject()).enabled);
            return this;
        }
    });

    treeTable.setOpenIcon(null);
    treeTable.setClosedIcon(null);
    treeTable.setLeafIcon(null);
    treeTable.getColumnExt(0).setToolTipText(toolTipText);

    treeTableScrollPane = new JScrollPane(treeTable);

    resourceTable = new MirthTable();
    resourceTable.setModel(new RefreshTableModel(new Object[] { "", "Name", "Type" }, 0) {
        @Override
        public boolean isCellEditable(int row, int column) {
            return column == SELECTED_COLUMN;
        }
    });
    resourceTable.setDragEnabled(false);
    resourceTable.setRowSelectionAllowed(false);
    resourceTable.setRowHeight(UIConstants.ROW_HEIGHT);
    resourceTable.setFocusable(false);
    resourceTable.setOpaque(true);
    resourceTable.getTableHeader().setReorderingAllowed(false);
    resourceTable.setEditable(true);
    resourceTable.setSortable(false);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        resourceTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR));
    }

    resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setMinWidth(20);
    resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setMaxWidth(20);
    resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setCellRenderer(new CheckBoxRenderer());
    resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setCellEditor(new CheckBoxEditor());

    resourceTable.getColumnModel().getColumn(TYPE_COLUMN).setMinWidth(75);
    resourceTable.getColumnModel().getColumn(TYPE_COLUMN).setMaxWidth(200);

    resourceTableScrollPane = new JScrollPane(resourceTable);
}

From source file:com.mirth.connect.client.ui.LibraryResourcesDialog.java

private void initComponents(Channel channel) {
    setLayout(new MigLayout("insets 12, novisualpadding, hidemode 3, fill", "", "[][]8[]8[]"));
    setBackground(UIConstants.BACKGROUND_COLOR);
    getContentPane().setBackground(getBackground());

    AbstractMutableTreeTableNode channelNode = new DefaultMutableTreeTableNode(
            new ConnectorEntry("Channel", -1, null));

    AbstractMutableTreeTableNode channelScriptsNode = new DefaultMutableTreeTableNode(
            new ConnectorEntry("Channel Scripts", null, null));
    channelScriptsNode// www.  ja  va 2  s  . c  o  m
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Deploy Script", null, null, false)));
    channelScriptsNode
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Undeploy Script", null, null, false)));
    channelScriptsNode
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Preprocessor Script", null, null, false)));
    channelScriptsNode.add(
            new DefaultMutableTreeTableNode(new ConnectorEntry("Postprocessor Script", null, null, false)));
    channelScriptsNode
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Attachment Script", null, null, false)));
    channelScriptsNode
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Batch Script", null, null, false)));
    channelNode.add(channelScriptsNode);

    AbstractMutableTreeTableNode sourceConnectorNode = new DefaultMutableTreeTableNode(
            new ConnectorEntry("Source Connector", 0, channel.getSourceConnector().getTransportName()));
    sourceConnectorNode.add(new DefaultMutableTreeTableNode(
            new ConnectorEntry("Receiver", channel.getSourceConnector().getMetaDataId(),
                    channel.getSourceConnector().getTransportName(), false)));
    sourceConnectorNode.add(new DefaultMutableTreeTableNode(
            new ConnectorEntry("Filter / Transformer Script", channel.getSourceConnector().getMetaDataId(),
                    channel.getSourceConnector().getTransportName(), false)));
    channelNode.add(sourceConnectorNode);

    for (Connector destinationConnector : channel.getDestinationConnectors()) {
        AbstractMutableTreeTableNode destinationConnectorNode = new DefaultMutableTreeTableNode(
                new ConnectorEntry(destinationConnector.getName(), destinationConnector.getMetaDataId(),
                        destinationConnector.getTransportName()));
        destinationConnectorNode
                .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Filter / Transformer Script",
                        destinationConnector.getMetaDataId(), destinationConnector.getTransportName(), false)));
        destinationConnectorNode.add(new DefaultMutableTreeTableNode(new ConnectorEntry("Dispatcher",
                destinationConnector.getMetaDataId(), destinationConnector.getTransportName(), false)));
        destinationConnectorNode
                .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Response Transformer Script",
                        destinationConnector.getMetaDataId(), destinationConnector.getTransportName(), false)));
        channelNode.add(destinationConnectorNode);
    }

    treeTable = new MirthTreeTable();

    DefaultTreeTableModel model = new SortableTreeTableModel(channelNode);
    model.setColumnIdentifiers(Arrays.asList(new String[] { "Library Context" }));
    treeTable.setTreeTableModel(model);

    treeTable.setRootVisible(true);
    treeTable.setDragEnabled(false);
    treeTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    treeTable.getTreeSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    treeTable.setRowHeight(UIConstants.ROW_HEIGHT);
    treeTable.setFocusable(true);
    treeTable.setOpaque(true);
    treeTable.getTableHeader().setReorderingAllowed(false);
    treeTable.setEditable(false);
    treeTable.setSortable(false);
    treeTable.addTreeSelectionListener(this);
    treeTable.getSelectionModel().addListSelectionListener(this);
    treeTable.putClientProperty("JTree.lineStyle", "Horizontal");
    treeTable.setShowGrid(true, true);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        treeTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR));
    }

    final String toolTipText = "<html>Select which context(s) to include library resources in.<br/>Libraries can be included everywhere (the Channel node),<br/>on channel-level scripts (the Channel Scripts node), and<br/>on specific source or destination connectors.</html>";

    treeTable.setTreeCellRenderer(new DefaultTreeCellRenderer() {
        @Override
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
                boolean expanded, boolean leaf, int row, boolean hasFocus) {
            super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
            setToolTipText(toolTipText);
            setEnabled(((ConnectorEntry) ((AbstractMutableTreeTableNode) value).getUserObject()).enabled);
            return this;
        }
    });

    treeTable.setOpenIcon(null);
    treeTable.setClosedIcon(null);
    treeTable.setLeafIcon(null);
    treeTable.getColumnExt(0).setToolTipText(toolTipText);

    add(new JScrollPane(treeTable), "grow, h 60%");

    resourceTable = new MirthTable();
    resourceTable.setModel(new RefreshTableModel(new Object[] { "", "Name", "Type" }, 0) {
        @Override
        public boolean isCellEditable(int row, int column) {
            return column == SELECTED_COLUMN;
        }
    });
    resourceTable.setDragEnabled(false);
    resourceTable.setRowSelectionAllowed(false);
    resourceTable.setRowHeight(UIConstants.ROW_HEIGHT);
    resourceTable.setFocusable(false);
    resourceTable.setOpaque(true);
    resourceTable.getTableHeader().setReorderingAllowed(false);
    resourceTable.setEditable(true);
    resourceTable.setSortable(false);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        resourceTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR));
    }

    resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setMinWidth(20);
    resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setMaxWidth(20);
    resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setCellRenderer(new CheckBoxRenderer());
    resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setCellEditor(new CheckBoxEditor());

    resourceTable.getColumnModel().getColumn(TYPE_COLUMN).setMinWidth(75);
    resourceTable.getColumnModel().getColumn(TYPE_COLUMN).setMaxWidth(200);

    add(new JScrollPane(resourceTable), "newline, grow, h 40%");

    add(new JSeparator(), "newline, grow");

    JPanel buttonPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3"));
    buttonPanel.setBackground(getBackground());

    okButton = new JButton("OK");
    okButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            okButtonActionPerformed();
        }
    });
    buttonPanel.add(okButton, "w 48!");

    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelButtonActionPerformed();
        }
    });
    buttonPanel.add(cancelButton, "w 48!");

    add(buttonPanel, "newline, right");
}

From source file:GenealogyExample.java

public GenealogyTree(Person graphNode) {
    super(new GenealogyModel(graphNode));
    getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
    Icon personIcon = null;// w w  w.  ja v  a 2s.c o m
    renderer.setLeafIcon(personIcon);
    renderer.setClosedIcon(personIcon);
    renderer.setOpenIcon(personIcon);
    setCellRenderer(renderer);
}

From source file:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java

/**
 * //from w  w  w .  j a va 2 s  . c om
 */
private void createUI() {
    CellConstraints cc = new CellConstraints();

    edaColObjPanel = new EditDeleteAddVertPanel(getEditColObjAL(), getDelColObjAL(), getAddColObjAL());
    edaContnrPanel = new EditDeleteAddVertPanel(getEditContainerAL(), getDelContainerAL(), getAddContainerAL());

    set(rootContainer, rootColObj);

    scrollPane = UIHelper.createScrollPane(tree, true);

    treeRenderer = new ContainerTreeRenderer(null, !isViewMode, isViewMode);
    treeRenderer.setEditable(true);
    treeRenderer.setLeafIcon(
            IconManager.getIcon(CollectionObject.class.getSimpleName(), IconManager.IconSize.Std32));
    treeRenderer.setVerticalTextPosition(SwingConstants.CENTER);
    tree.setCellRenderer(treeRenderer);

    tree.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(final MouseEvent e) {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    mousePressedOnTree(e);
                }
            });
        }
    });

    colObjAssocIcon = new JLabel(
            IconManager.getIcon(CollectionObject.class.getSimpleName(), IconManager.IconSize.Std20));
    containerAssocIcon = new JLabel(
            IconManager.getIcon(Container.class.getSimpleName(), IconManager.IconSize.Std20));

    colObjIcon = new JLabel(
            IconManager.getIcon(CollectionObject.class.getSimpleName(), IconManager.IconSize.Std20));
    containerIcon = new JLabel(
            IconManager.getIcon(Container.class.getSimpleName(), IconManager.IconSize.Std20));

    searchCOBtn = UIHelper.createIconBtn("Search", IconManager.IconSize.Std20, "", true, null);
    searchCNBtn = UIHelper.createIconBtn("Search", IconManager.IconSize.Std20, "", true, null);

    colObjIcon.setEnabled(false);
    containerIcon.setEnabled(false);

    containerPanel = new ViewBasedDisplayPanel(null, "ContainerBrief", Container.class.getName(), true,
            MultiView.NO_OPTIONS);

    // Right Vertical Control Panel
    PanelBuilder rpb = null;
    if (!isViewMode) {
        rpb = new PanelBuilder(new FormLayout("f:p:g", "p,2px,p,2px,p,10px,p, 20px,p,2px,p,10px,p,f:p:g"));

        PanelBuilder cnCOLblPB = new PanelBuilder(new FormLayout("p,1px,p", "p"));
        cnCOLblPB.add(containerAssocIcon, cc.xy(1, 1));
        cnCOLblPB.add(colObjAssocIcon, cc.xy(3, 1));
        containerAssocIcon.setEnabled(false);
        colObjAssocIcon.setEnabled(false);

        int y = 1;
        rpb.add(containerIcon, cc.xy(1, y));
        y += 2;
        rpb.add(edaContnrPanel, cc.xy(1, y));
        y += 2;
        rpb.add(searchCNBtn, cc.xy(1, y));
        y += 2;

        rpb.addSeparator("", cc.xy(1, y));
        y += 2;
        rpb.add(colObjIcon, cc.xy(1, y));
        y += 2;
        rpb.add(edaColObjPanel, cc.xy(1, y));
        y += 2;
        rpb.add(searchCOBtn, cc.xy(1, y));
        y += 2;
    }

    // Main Layout
    PanelBuilder pb = new PanelBuilder(new FormLayout("l:p,8px,f:p:g", "f:p:g,10px,p,2px,p"), this);

    if (rpb != null) {
        pb.add(rpb.getPanel(), cc.xy(1, 1));
    }
    pb.add(scrollPane, cc.xy(3, 1));

    //pb.addSeparator("Container", cc.xyw(1,3,3));
    //pb.add(containerPanel,       cc.xyw(1,5,3));
    //pb.setDefaultDialogBorder();

    tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            updateBtnUI();

            currContainer = null;
            currColObj = null;

            DefaultMutableTreeNode node = getSelectedTreeNode();
            if (node != null) {
                if (node.getUserObject() instanceof Container) {
                    currContainer = (Container) node.getUserObject();
                    if (containerPanel != null) {
                        containerPanel.getMultiView().setData(currContainer);
                    }
                } else if (node.getUserObject() instanceof CollectionObject) {
                    currColObj = (CollectionObject) node.getUserObject();
                }
            }
        }
    });

    GhostGlassPane glassPane = (GhostGlassPane) UIRegistry.get(UIRegistry.GLASSPANE);
    glassPane.add((GhostActionable) tree);

    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setShowsRootHandles(true);

    searchCOBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            addColObjToContainer(true, false);
        }
    });

    searchCNBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            addContainer(true);
        }
    });

    FormViewObj fvo = containerPanel.getMultiView().getCurrentViewAsFormViewObj();
    if (fvo != null) {
        Component comp = fvo.getCompById("nm");
        if (comp instanceof ValTextField) {
            final ValTextField nameTF = fvo.getCompById("nm");
            nameTF.getDocument().addDocumentListener(new DocumentAdaptor() {
                @Override
                protected void changed(DocumentEvent e) {
                    nameFieldChanged(nameTF.getText());
                    if (changeListener != null)
                        changeListener.stateChanged(null);
                }
            });

            final ValComboBox typeCBX = fvo.getCompById("typ");
            typeCBX.getComboBox().addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    PickListItemIFace pli = (PickListItemIFace) typeCBX.getComboBox().getSelectedItem();
                    typeChanged(pli == null ? -1 : Integer.parseInt(pli.getValue()));
                    if (changeListener != null)
                        changeListener.stateChanged(null);
                }
            });
        }
    }
}

From source file:kr.ac.kaist.swrc.jhannanum.demo.GUIDemo.java

/**
 * Setting of the plug-in tree view.//ww w .j a v  a 2 s.  c o m
 * @return the plug-in tree view
 */
private JComponent createPluginPool() {
    DefaultMutableTreeNode top = new DefaultMutableTreeNode("HanNanum Plug-in Pool");
    createPluginNodes(top);
    loadPluginInformation();

    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    tree.addTreeSelectionListener(new PluginTreeSelectionListener());

    tree.putClientProperty("JTree.lineStyle", "Horizontal");

    JScrollPane treeView = new JScrollPane(tree);

    return treeView;
}