Search in sources :

Example 36 with TreeSelectionEvent

use of javax.swing.event.TreeSelectionEvent in project cayenne by apache.

the class ProjectTreeView method initTreeSelectionListener.

private void initTreeSelectionListener() {
    treeSelectionListener = new TreeSelectionListener() {

        public void valueChanged(TreeSelectionEvent e) {
            TreePath[] paths = getSelectionPaths();
            if (paths != null) {
                if (paths.length > 1) {
                    ConfigurationNode projectParentPath = null;
                    ConfigurationNode[] projectPaths = new ConfigurationNode[paths.length];
                    boolean commonParentPath = true;
                    for (int i = 0; i < paths.length; i++) {
                        projectPaths[i] = createProjectPath(paths[i]);
                        TreePath parentPath = paths[i].getParentPath();
                        if (i > 0 && parentPath != null && !parentPath.equals(paths[i - 1].getParentPath())) {
                            commonParentPath = false;
                        }
                    }
                    if (commonParentPath) {
                        TreePath parentPath = paths[0].getParentPath();
                        projectParentPath = createProjectPath(parentPath);
                    }
                    mediator.fireMultipleObjectsDisplayEvent(new MultipleObjectsDisplayEvent(this, projectPaths, projectParentPath));
                } else if (paths.length == 1) {
                    processSelection(paths[0]);
                }
            }
        }

        /**
         * Converts TreePath to Object
         */
        private ConfigurationNode createProjectPath(TreePath treePath) {
            Object[] path = treePath.getPath();
            DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) path[path.length - 1];
            return (ConfigurationNode) treeNode.getUserObject();
        }
    };
    addTreeSelectionListener(treeSelectionListener);
}
Also used : MultipleObjectsDisplayEvent(org.apache.cayenne.modeler.event.MultipleObjectsDisplayEvent) TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ConfigurationNode(org.apache.cayenne.configuration.ConfigurationNode) TreeSelectionListener(javax.swing.event.TreeSelectionListener) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 37 with TreeSelectionEvent

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

the class BioModelEditorSabioPanel method initialize.

private void initialize() {
    responseTree = new JTree();
    responseTreeModel = new ResponseTreeModel();
    responseTree.setModel(responseTreeModel);
    ToolTipManager.sharedInstance().registerComponent(responseTree);
    setLayout(new BorderLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    // ------- panel 1 ---------------
    JLabel categoryLabel1 = new JLabel("Role: ");
    panel1 = new JPanel();
    panel1.setBorder(BorderFactory.createTitledBorder(" Search "));
    panel1.setLayout(new GridBagLayout());
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel1.add(categoryLabel1, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel1.add(entityName1, gbc);
    gbc = new GridBagConstraints();
    searchSabioDatabaseButton = new JButton("Search");
    searchSabioDatabaseButton.addActionListener(eventHandler);
    searchSabioDatabaseButton.setEnabled(true);
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.insets = new Insets(2, 4, 4, 4);
    panel1.add(searchSabioDatabaseButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    p.add(panel1);
    // ------- panel 2 -----------------
    panel2 = new CollapsiblePanel(" Advanced Search ", false, BorderFactory.createLineBorder(new Color(213, 223, 229)));
    panel2.getContentPanel().setLayout(new GridBagLayout());
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.insets = new Insets(4, 4, 4, 1);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.LINE_START;
    JLabel categoryLabel2 = new JLabel("Category");
    categoryList2.setSelectedIndex(3);
    categoryList2.addActionListener(eventHandler);
    JLabel entityLabel2 = new JLabel("Entity");
    entityName2.addActionListener(eventHandler);
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(2, 2, 2, 0);
    panel2.getContentPanel().add(categoryLabel2, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(0, 2, 2, 0);
    panel2.getContentPanel().add(categoryList2, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(2, 2, 2, 0);
    panel2.getContentPanel().add(entityLabel2, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(0, 0, 2, 2);
    panel2.getContentPanel().add(entityName2, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    p.add(panel2, gbc);
    // ------- tree ------------------
    JPanel p1 = new JPanel(new BorderLayout());
    p1.add(new JScrollPane(responseTree));
    // ------- the panels -------------
    add(p, BorderLayout.NORTH);
    add(p1, BorderLayout.CENTER);
    ResponseTreeCellRenderer renderer = new ResponseTreeCellRenderer();
    // also available kineticLaw2Icon more colorful
    renderer.setLeafIcon(VCellIcons.kineticLawIcon);
    responseTree.setCellRenderer(renderer);
    responseTree.setRootVisible(false);
    responseTree.getSelectionModel().addTreeSelectionListener(eventHandler);
    // responseTree.addMouseListener( new MouseAdapter(){
    // public void mouseClicked(MouseEvent e){
    // if (e.getClickCount() <= 1) {
    // return;
    // }
    // treeSelectionChanged();	// for double click
    // }
    // });
    responseTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {

        public void valueChanged(TreeSelectionEvent e) {
            Object obj = responseTree.getLastSelectedPathComponent();
            if (obj == null || !(obj instanceof BioModelNode)) {
                return;
            }
            BioModelNode selectedNode = (BioModelNode) obj;
            Object userObject = selectedNode.getUserObject();
            setSelectedObjects(new Object[] { userObject });
        }
    });
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) BoxLayout(javax.swing.BoxLayout) Color(java.awt.Color) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) TreeSelectionListener(javax.swing.event.TreeSelectionListener) BioModelNode(cbit.vcell.desktop.BioModelNode) CollapsiblePanel(org.vcell.util.gui.CollapsiblePanel) JTree(javax.swing.JTree) BorderLayout(java.awt.BorderLayout) PathwayStringObject(cbit.vcell.client.desktop.biomodel.BioModelEditorPathwayCommonsPanel.PathwayStringObject) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 38 with TreeSelectionEvent

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

the class MIRIAMAnnotationEditor method initialize.

/**
 * This method initializes this
 */
private void initialize() {
    GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
    gridBagConstraints5.gridx = 0;
    gridBagConstraints5.fill = GridBagConstraints.NONE;
    gridBagConstraints5.insets = new Insets(4, 4, 4, 4);
    gridBagConstraints5.gridy = 2;
    GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
    gridBagConstraints1.fill = GridBagConstraints.BOTH;
    gridBagConstraints1.weighty = 1.0;
    gridBagConstraints1.gridx = 0;
    gridBagConstraints1.gridy = 0;
    gridBagConstraints1.weightx = 1.0;
    this.setLayout(new GridBagLayout());
    this.setSize(new Dimension(627, 333));
    this.add(getJScrollPane(), gridBagConstraints1);
    this.add(getJPanel(), gridBagConstraints5);
    getJButtonAdd().setEnabled(false);
    getJTreeMIRIAM().addTreeSelectionListener(new TreeSelectionListener() {

        public void valueChanged(TreeSelectionEvent e) {
            getJButtonAdd().setEnabled(((JTree) e.getSource()).getSelectionPath() != null && ((JTree) e.getSource()).getSelectionPath().getLastPathComponent() instanceof IdentifiableNode);
        // getJButtonAdd().setEnabled(e.getPath().getLastPathComponent() instanceof IdentifiableNode);
        }
    });
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) JTree(javax.swing.JTree) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) IdentifiableNode(cbit.vcell.xml.gui.MiriamTreeModel.IdentifiableNode) TreeSelectionListener(javax.swing.event.TreeSelectionListener) Dimension(java.awt.Dimension) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 39 with TreeSelectionEvent

use of javax.swing.event.TreeSelectionEvent in project sldeditor by robward-scisys.

the class FilterPanelv2 method createUI.

/**
 * Creates the ui.
 */
private void createUI() {
    JPanel treePanel = new JPanel();
    getContentPane().add(treePanel, BorderLayout.WEST);
    treePanel.setLayout(new BorderLayout(0, 0));
    JScrollPane scrollPane = new JScrollPane();
    treePanel.add(scrollPane);
    Dimension preferredSize = new Dimension(400, 350);
    scrollPane.setPreferredSize(preferredSize);
    model = new ExpressionTreeModel(rootNode);
    tree = new JTree(model);
    tree.addTreeSelectionListener(new TreeSelectionListener() {

        public void valueChanged(TreeSelectionEvent e) {
            treeSelected();
        }
    });
    scrollPane.setViewportView(tree);
    JPanel rightPanel = new JPanel(new BorderLayout());
    JPanel optionPanel = new JPanel(new BorderLayout());
    rightPanel.add(optionPanel, BorderLayout.NORTH);
    optionalCheckBox = new JCheckBox("Optional");
    optionalCheckBox.setVisible(false);
    optionalCheckBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            optionalCheckBoxSelected();
        }
    });
    optionPanel.add(optionalCheckBox, BorderLayout.NORTH);
    dataPanel = new JPanel(new CardLayout());
    dataPanel.add(emptyPanel, EMPTY_PANEL);
    expressionPanel = new ExpressionSubPanel(this);
    dataPanel.add(expressionPanel, ExpressionSubPanel.class.getName());
    filterPanel = new FilterSubPanel(this);
    dataPanel.add(filterPanel, FilterSubPanel.class.getName());
    literalPanel = new LiteralPanel(this);
    dataPanel.add(literalPanel, LiteralPanel.class.getName());
    propertyPanel = new PropertyPanel(this);
    dataPanel.add(propertyPanel, PropertyPanel.class.getName());
    envVarPanel = new EnvVarPanel(this);
    dataPanel.add(envVarPanel, EnvVarPanel.class.getName());
    rightPanel.add(dataPanel, BorderLayout.CENTER);
    getContentPane().add(rightPanel, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel();
    FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
    flowLayout.setAlignment(FlowLayout.TRAILING);
    getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    btnOk = new JButton(Localisation.getString(ExpressionPanelv2.class, "common.ok"));
    btnOk.setEnabled(false);
    btnOk.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            closeDialog(true);
        }
    });
    buttonPanel.add(btnOk);
    JButton btnCancel = new JButton(Localisation.getString(ExpressionPanelv2.class, "common.cancel"));
    btnCancel.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            closeDialog(false);
        }
    });
    buttonPanel.add(btnCancel);
    JPanel resultPanel = new JPanel();
    getContentPane().add(resultPanel, BorderLayout.NORTH);
    resultPanel.setLayout(new BorderLayout(0, 0));
    JScrollPane scrollPane1 = new JScrollPane();
    resultPanel.add(scrollPane1);
    textArea = new JTextArea();
    textArea.setRows(2);
    textArea.setEditable(false);
    scrollPane1.setViewportView(textArea);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) CardLayout(java.awt.CardLayout) FlowLayout(java.awt.FlowLayout) JTextArea(javax.swing.JTextArea) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) TreeSelectionListener(javax.swing.event.TreeSelectionListener) Dimension(java.awt.Dimension) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 40 with TreeSelectionEvent

use of javax.swing.event.TreeSelectionEvent in project sldeditor by robward-scisys.

the class ExpressionPanelv2 method createUI.

/**
 * Creates the ui.
 */
private void createUI() {
    JPanel treePanel = new JPanel();
    getContentPane().add(treePanel, BorderLayout.WEST);
    treePanel.setLayout(new BorderLayout(0, 0));
    JScrollPane scrollPane = new JScrollPane();
    treePanel.add(scrollPane);
    Dimension preferredSize = new Dimension(400, 350);
    scrollPane.setPreferredSize(preferredSize);
    model = new ExpressionTreeModel(rootNode);
    tree = new JTree(model);
    tree.addTreeSelectionListener(new TreeSelectionListener() {

        public void valueChanged(TreeSelectionEvent e) {
            selectedNode = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
            treeSelected(selectedNode);
        }
    });
    scrollPane.setViewportView(tree);
    dataPanel = new JPanel(new CardLayout());
    dataPanel.add(emptyPanel, EMPTY_PANEL);
    expressionPanel = new ExpressionSubPanel(this);
    dataPanel.add(expressionPanel, ExpressionSubPanel.class.getName());
    FilterSubPanel filterPanel = new FilterSubPanel(this);
    dataPanel.add(filterPanel, FilterSubPanel.class.getName());
    literalPanel = new LiteralPanel(this);
    dataPanel.add(literalPanel, LiteralPanel.class.getName());
    propertyPanel = new PropertyPanel(this);
    dataPanel.add(propertyPanel, PropertyPanel.class.getName());
    envVarPanel = new EnvVarPanel(this);
    dataPanel.add(envVarPanel, EnvVarPanel.class.getName());
    getContentPane().add(dataPanel, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel();
    FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
    flowLayout.setAlignment(FlowLayout.TRAILING);
    getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    btnOk = new JButton(Localisation.getString(ExpressionPanelv2.class, "common.ok"));
    btnOk.setEnabled(false);
    btnOk.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            okButtonPressed = true;
            setVisible(false);
        }
    });
    buttonPanel.add(btnOk);
    JButton btnCancel = new JButton(Localisation.getString(ExpressionPanelv2.class, "common.cancel"));
    btnCancel.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            okButtonPressed = false;
            setVisible(false);
        }
    });
    buttonPanel.add(btnCancel);
    JPanel resultPanel = new JPanel();
    getContentPane().add(resultPanel, BorderLayout.NORTH);
    resultPanel.setLayout(new BorderLayout(0, 0));
    JScrollPane scrollPane1 = new JScrollPane();
    scrollPane1.setPreferredSize(new Dimension(800, 30));
    resultPanel.add(scrollPane1);
    textArea = new JTextArea();
    textArea.setEditable(false);
    scrollPane1.setViewportView(textArea);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) CardLayout(java.awt.CardLayout) FlowLayout(java.awt.FlowLayout) JTextArea(javax.swing.JTextArea) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) TreeSelectionListener(javax.swing.event.TreeSelectionListener) Dimension(java.awt.Dimension) JTree(javax.swing.JTree) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Aggregations

TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)85 TreeSelectionListener (javax.swing.event.TreeSelectionListener)82 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)34 TreePath (javax.swing.tree.TreePath)32 JTree (javax.swing.JTree)27 ActionEvent (java.awt.event.ActionEvent)23 JScrollPane (javax.swing.JScrollPane)23 JPanel (javax.swing.JPanel)22 ActionListener (java.awt.event.ActionListener)20 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)18 MouseEvent (java.awt.event.MouseEvent)15 BorderLayout (java.awt.BorderLayout)14 Dimension (java.awt.Dimension)13 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)9 KeyAdapter (java.awt.event.KeyAdapter)9 KeyEvent (java.awt.event.KeyEvent)9