Search in sources :

Example 86 with TreeSelectionListener

use of javax.swing.event.TreeSelectionListener in project vcell by virtualcell.

the class AnnotationsPanel method initialize.

private void initialize() {
    try {
        setLayout(new GridBagLayout());
        setBackground(Color.white);
        int gridy = 0;
        GridBagConstraints gbc = new java.awt.GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.insets = new Insets(4, 4, 4, 4);
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        gbc.anchor = GridBagConstraints.SOUTHWEST;
        add(getBottomPanel(), gbc);
        // used just to initialize emptyText once
        JTextPane tenpTextPane = new JTextPane();
        tenpTextPane.setContentType("text/html");
        tenpTextPane.setText(null);
        emptyHtmlText = tenpTextPane.getText();
        initializeComboBoxQualifier();
        getJTreeMIRIAM().addTreeSelectionListener(new TreeSelectionListener() {

            public void valueChanged(TreeSelectionEvent e) {
                TreePath tp = ((JTree) e.getSource()).getSelectionPath();
                if (tp == null) {
                    getJButtonDeleteRef().setEnabled(false);
                } else {
                    Object lastPathComponent = tp.getLastPathComponent();
                    getJButtonDeleteRef().setEnabled(tp != null && lastPathComponent instanceof LinkNode);
                }
            }
        });
    } catch (java.lang.Throwable ivjExc) {
        handleException(ivjExc);
    }
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) TreeSelectionListener(javax.swing.event.TreeSelectionListener) JTextPane(javax.swing.JTextPane) TreePath(javax.swing.tree.TreePath) LinkNode(cbit.vcell.xml.gui.MiriamTreeModel.LinkNode) BioPaxObject(org.vcell.pathway.BioPaxObject) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 87 with TreeSelectionListener

use of javax.swing.event.TreeSelectionListener in project vcell by virtualcell.

the class VCellConfigurationPanel method initialize.

private void initialize() {
    generalConfigurationPanel = new GeneralConfigurationPanel();
    generalConfigurationPanel.setName("generalConfigurationPanel");
    pythonConfigurationPanel = new PythonConfigurationPanel3();
    pythonConfigurationPanel.setName("pythonConfigurationPanel");
    comsolConfigurationPanel = new ComsolConfigurationPanel();
    comsolConfigurationPanel.setName("comsolConfigurationPanel");
    bioNetGenConfigurationPanel = new BioNetGenConfigurationPanel();
    bioNetGenConfigurationPanel.setName("bioNetGenConfigurationPanel");
    configurationOptionsTree = new javax.swing.JTree();
    configurationOptionsTreeModel = new ConfigurationOptionsTreeModel(configurationOptionsTree);
    configurationOptionsTree.setModel(configurationOptionsTreeModel);
    configurationOptionsTree.setEditable(false);
    configurationOptionsTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    configurationOptionsTree.setRootVisible(false);
    configurationOptionsTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            ConfigurationModelNode cmn = (ConfigurationModelNode) e.getNewLeadSelectionPath().getLastPathComponent();
            ConfigurationOptionsTreeFolderNode cotfn = (ConfigurationOptionsTreeFolderNode) cmn.getUserObject();
            switch(cotfn.getFolderClass()) {
                case GENERAL_NODE:
                    splitPane.setRightComponent(generalConfigurationPanel);
                    break;
                case PYTHON_NODE:
                    splitPane.setRightComponent(pythonConfigurationPanel);
                    break;
                case COMSOL_NODE:
                    splitPane.setRightComponent(comsolConfigurationPanel);
                    break;
                case BIONETGEN_NODE:
                    splitPane.setRightComponent(bioNetGenConfigurationPanel);
                    break;
            }
        }
    });
    JScrollPane treePanel = new javax.swing.JScrollPane(configurationOptionsTree);
    // Border margin = new EmptyBorder(5,3,1,1);
    // treePanel.setBorder(margin);
    Dimension dim = new Dimension(150, 300);
    // code that contributes to prevent resizing horizontally
    treePanel.setPreferredSize(dim);
    treePanel.setMinimumSize(dim);
    treePanel.setMaximumSize(dim);
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT) {

        // all code below to make it impossible to move the divider
        private final int location = 150;

        {
            // so that the left component cannot be resized
            setDividerLocation(location);
            // left component is fixed width
            setResizeWeight(0);
            // this also makes resizing impossible
            setDividerSize(0);
            // no UI widget on the divider to quickly expand / collapse
            setOneTouchExpandable(false);
        }

        @Override
        public int getDividerLocation() {
            return location;
        }

        @Override
        public int getLastDividerLocation() {
            return location;
        }
    };
    splitPane.setLeftComponent(treePanel);
    splitPane.setRightComponent(generalConfigurationPanel);
    // ---------------------------------------------------------------------------
    JPanel okCancelPanel = new JPanel();
    okCancelPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 1;
    // fake cell used for filling all the vertical empty space
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.WEST;
    okCancelPanel.add(new JLabel(""), gbc);
    // gbc = new GridBagConstraints();
    // gbc.gridx = 1;
    // gbc.gridy = 0;
    // gbc.insets = new Insets(0, 0, 4, 2);				//  top, left, bottom, right
    // okCancelPanel.add(getOkButton(), gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.insets = new Insets(0, 2, 4, 4);
    okCancelPanel.add(getCloseButton(), gbc);
    // --------------------------------------------------------------------------------
    setLayout(new GridBagLayout());
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = new Insets(1, 1, 1, 1);
    add(splitPane, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(1, 1, 1, 1);
    add(okCancelPanel, gbc);
    // configurationOptionsTree.addTreeSelectionListener(eventHandler);
    // configurationOptionsTree.addMouseListener(eventHandler);
    configurationOptionsTreeModel.populateTree();
}
Also used : PythonConfigurationPanel3(cbit.vcell.client.configuration.PythonConfigurationPanel3) JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) GeneralConfigurationPanel(cbit.vcell.client.configuration.GeneralConfigurationPanel) TreeSelectionListener(javax.swing.event.TreeSelectionListener) Dimension(java.awt.Dimension) JTree(javax.swing.JTree) ConfigurationOptionsTreeFolderNode(cbit.vcell.client.configuration.ConfigurationOptionsTreeModel.ConfigurationOptionsTreeFolderNode) ComsolConfigurationPanel(cbit.vcell.client.configuration.ComsolConfigurationPanel) ConfigurationOptionsTreeModel(cbit.vcell.client.configuration.ConfigurationOptionsTreeModel) ConfigurationModelNode(cbit.vcell.client.configuration.ConfigurationModelNode) BioNetGenConfigurationPanel(cbit.vcell.client.configuration.BioNetGenConfigurationPanel) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) JSplitPane(javax.swing.JSplitPane)

Aggregations

TreeSelectionListener (javax.swing.event.TreeSelectionListener)87 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)82 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)36 TreePath (javax.swing.tree.TreePath)33 JTree (javax.swing.JTree)27 JScrollPane (javax.swing.JScrollPane)25 ActionEvent (java.awt.event.ActionEvent)23 JPanel (javax.swing.JPanel)22 ActionListener (java.awt.event.ActionListener)20 MouseEvent (java.awt.event.MouseEvent)16 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)16 BorderLayout (java.awt.BorderLayout)14 Dimension (java.awt.Dimension)14 GridBagConstraints (java.awt.GridBagConstraints)12 GridBagLayout (java.awt.GridBagLayout)12 Insets (java.awt.Insets)12 JButton (javax.swing.JButton)11 Tree (com.intellij.ui.treeStructure.Tree)10 KeyAdapter (java.awt.event.KeyAdapter)9 KeyEvent (java.awt.event.KeyEvent)9