Search in sources :

Example 1 with ConfigurationOptionsTreeFolderNode

use of cbit.vcell.client.configuration.ConfigurationOptionsTreeModel.ConfigurationOptionsTreeFolderNode 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");
    visItConfigurationPanel = new VisItConfigurationPanel();
    visItConfigurationPanel.setName("visItConfigurationPanel");
    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 VISIT_NODE:
                    splitPane.setRightComponent(visItConfigurationPanel);
                    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(200, 400);
    // 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 = 200;

        {
            // 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) VisItConfigurationPanel(cbit.vcell.client.configuration.VisItConfigurationPanel) ConfigurationModelNode(cbit.vcell.client.configuration.ConfigurationModelNode) BioNetGenConfigurationPanel(cbit.vcell.client.configuration.BioNetGenConfigurationPanel) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) JSplitPane(javax.swing.JSplitPane)

Aggregations

BioNetGenConfigurationPanel (cbit.vcell.client.configuration.BioNetGenConfigurationPanel)1 ComsolConfigurationPanel (cbit.vcell.client.configuration.ComsolConfigurationPanel)1 ConfigurationModelNode (cbit.vcell.client.configuration.ConfigurationModelNode)1 ConfigurationOptionsTreeModel (cbit.vcell.client.configuration.ConfigurationOptionsTreeModel)1 ConfigurationOptionsTreeFolderNode (cbit.vcell.client.configuration.ConfigurationOptionsTreeModel.ConfigurationOptionsTreeFolderNode)1 GeneralConfigurationPanel (cbit.vcell.client.configuration.GeneralConfigurationPanel)1 PythonConfigurationPanel3 (cbit.vcell.client.configuration.PythonConfigurationPanel3)1 VisItConfigurationPanel (cbit.vcell.client.configuration.VisItConfigurationPanel)1 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 JSplitPane (javax.swing.JSplitPane)1 JTree (javax.swing.JTree)1 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)1 TreeSelectionListener (javax.swing.event.TreeSelectionListener)1