Search in sources :

Example 11 with ListSelectionListener

use of javax.swing.event.ListSelectionListener in project gradle by gradle.

the class AbstractFilterEditorPanel method createListPanel.

private Component createListPanel() {
    model = new DefaultListModel();
    list = new JList(model);
    list.setCellRenderer(new FilterRenderer());
    list.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                enableAppropriately();
            }
        }
    });
    return new JScrollPane(list);
}
Also used : ListSelectionEvent(javax.swing.event.ListSelectionEvent) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 12 with ListSelectionListener

use of javax.swing.event.ListSelectionListener in project zaproxy by zaproxy.

the class ManageAddOnsDialog method getUninstalledAddOnsTable.

private JXTable getUninstalledAddOnsTable() {
    if (uninstalledAddOnsTable == null) {
        uninstalledAddOnsTable = new JXTable();
        uninstalledAddOnsModel.addTableModelListener(new TableModelListener() {

            @Override
            public void tableChanged(TableModelEvent e) {
                getInstallButton().setEnabled(uninstalledAddOnsModel.canIinstallSelected());
            }
        });
        uninstalledAddOnsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent e) {
                getAddOnInfoButton().setEnabled(false);
                if (DesktopUtils.canOpenUrlInBrowser() && getUninstalledAddOnsTable().getSelectedRowCount() == 1) {
                    //convertRowIndexToModel in-case they sorted
                    AddOnWrapper ao = uninstalledAddOnsModel.getAddOnWrapper(getUninstalledAddOnsTable().convertRowIndexToModel(getUninstalledAddOnsTable().getSelectedRow()));
                    if (ao != null && ao.getAddOn().getInfo() != null) {
                        getAddOnInfoButton().setEnabled(true);
                    }
                }
            }
        });
        uninstalledAddOnsTable.setModel(uninstalledAddOnsModel);
        //Icon
        uninstalledAddOnsTable.getColumnModel().getColumn(0).setMaxWidth(20);
        //Icon doesn't need sorting
        uninstalledAddOnsTable.getColumnExt(0).setSortable(false);
        //Status
        uninstalledAddOnsTable.getColumnModel().getColumn(1).setPreferredWidth(50);
        //Name
        uninstalledAddOnsTable.getColumnModel().getColumn(2).setPreferredWidth(150);
        //Description
        uninstalledAddOnsTable.getColumnModel().getColumn(3).setPreferredWidth(300);
        //Description doesn't need sorting
        uninstalledAddOnsTable.getColumnExt(3).setSortable(false);
        //Update (version number)
        uninstalledAddOnsTable.getColumnModel().getColumn(4).setPreferredWidth(60);
        //Update doesn't need sorting
        uninstalledAddOnsTable.getColumnExt(4).setSortable(false);
        //Checkbox
        uninstalledAddOnsTable.getColumnModel().getColumn(5).setPreferredWidth(40);
        //Checkbox doesn't need sorting
        uninstalledAddOnsTable.getColumnExt(5).setSortable(false);
        //Default sort by status (column 1) descending (Release, Beta, Alpha), and name (column 2) ascending 
        List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>(2);
        sortKeys.add(new RowSorter.SortKey(1, SortOrder.DESCENDING));
        sortKeys.add(new RowSorter.SortKey(2, SortOrder.ASCENDING));
        uninstalledAddOnsTable.getRowSorter().setSortKeys(sortKeys);
        DefaultAddOnToolTipHighlighter toolTipHighlighter = new DefaultAddOnToolTipHighlighter(UninstalledAddOnsTableModel.COLUMN_ADD_ON_WRAPPER);
        for (int i = 1; i < uninstalledAddOnsTable.getColumnCount(); i++) {
            uninstalledAddOnsTable.getColumnExt(i).addHighlighter(toolTipHighlighter);
        }
        uninstalledAddOnsTable.getColumnExt(0).setCellRenderer(new DefaultTableRenderer(new MappedValue(StringValues.EMPTY, IconValues.NONE), JLabel.CENTER));
        uninstalledAddOnsTable.getColumnExt(0).setHighlighters(new CompoundHighlighter(new WarningRunningIssuesHighlighter(AddOnsTableModel.COLUMN_ADD_ON_WRAPPER), new WarningRunningIssuesToolTipHighlighter(UninstalledAddOnsTableModel.COLUMN_ADD_ON_WRAPPER)));
        uninstalledAddOnsTable.getColumnExt(5).addHighlighter(new DisableSelectionHighlighter(UninstalledAddOnsTableModel.COLUMN_ADD_ON_WRAPPER));
    }
    return uninstalledAddOnsTable;
}
Also used : RowSorter(javax.swing.RowSorter) JXTable(org.jdesktop.swingx.JXTable) TableModelEvent(javax.swing.event.TableModelEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ArrayList(java.util.ArrayList) MappedValue(org.jdesktop.swingx.renderer.MappedValue) DefaultTableRenderer(org.jdesktop.swingx.renderer.DefaultTableRenderer) ListSelectionListener(javax.swing.event.ListSelectionListener) TableModelListener(javax.swing.event.TableModelListener) CompoundHighlighter(org.jdesktop.swingx.decorator.CompoundHighlighter)

Example 13 with ListSelectionListener

use of javax.swing.event.ListSelectionListener in project zaproxy by zaproxy.

the class PolicyManagerDialog method getParamsTable.

private JTable getParamsTable() {
    if (paramsTable == null) {
        paramsTable = new JTable();
        paramsTable.setModel(getParamsModel());
        paramsTable.addMouseListener(new MouseListener() {

            @Override
            public void mouseClicked(MouseEvent e) {
            }

            @Override
            public void mousePressed(MouseEvent e) {
                if (e.getClickCount() >= 2) {
                    int row = paramsTable.rowAtPoint(e.getPoint());
                    if (row >= 0) {
                        String name = (String) getParamsModel().getValueAt(row, 0);
                        if (name != null) {
                            try {
                                extension.showPolicyDialog(PolicyManagerDialog.this, name);
                            } catch (ConfigurationException e1) {
                                logger.error(e1.getMessage(), e1);
                            }
                        }
                    }
                }
            }

            @Override
            public void mouseReleased(MouseEvent e) {
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }
        });
        paramsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (getParamsTable().getSelectedRowCount() == 0) {
                    getModifyButton().setEnabled(false);
                    getRemoveButton().setEnabled(false);
                    getExportButton().setEnabled(false);
                } else if (getParamsTable().getSelectedRowCount() == 1) {
                    getModifyButton().setEnabled(true);
                    // Dont let the last policy be removed
                    getRemoveButton().setEnabled(getParamsModel().getRowCount() > 1);
                    getExportButton().setEnabled(true);
                } else {
                    getModifyButton().setEnabled(false);
                    getRemoveButton().setEnabled(false);
                    getExportButton().setEnabled(false);
                }
            }
        });
    }
    return paramsTable;
}
Also used : MouseListener(java.awt.event.MouseListener) MouseEvent(java.awt.event.MouseEvent) ConfigurationException(org.apache.commons.configuration.ConfigurationException) JTable(javax.swing.JTable) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 14 with ListSelectionListener

use of javax.swing.event.ListSelectionListener in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method createUIComponents.

private void createUIComponents() {
    DefaultTableModel tableModel = new DefaultTableModel() {

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    tableModel.addColumn("Name");
    tableModel.addColumn("JDK");
    tableModel.addColumn("Web container");
    tableModel.addColumn("Resource group");
    table = new JBTable(tableModel);
    table.setRowSelectionAllowed(true);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent event) {
            if (event.getValueIsAdjusting())
                return;
            //System.out.println("row : " + table.getValueAt(table.getSelectedRow(), 0).toString());
            fillAppServiceDetails();
        }
    });
    AnActionButton refreshAction = new AnActionButton("Refresh", AllIcons.Actions.Refresh) {

        @Override
        public void actionPerformed(AnActionEvent anActionEvent) {
            refreshAppServices();
        }
    };
    ToolbarDecorator tableToolbarDecorator = ToolbarDecorator.createDecorator(table).setAddAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            createAppService();
        }
    }).setRemoveAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            deleteAppService();
        }
    }).setRemoveActionUpdater(new AnActionButtonUpdater() {

        @Override
        public boolean isEnabled(AnActionEvent e) {
            return table.getSelectedRow() != -1;
        }
    }).disableUpDownActions().addExtraActions(refreshAction);
    panelTable = tableToolbarDecorator.createPanel();
}
Also used : AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) AnActionButtonUpdater(com.intellij.ui.AnActionButtonUpdater) DefaultTableModel(javax.swing.table.DefaultTableModel) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) JBTable(com.intellij.ui.table.JBTable) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnActionButton(com.intellij.ui.AnActionButton) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 15 with ListSelectionListener

use of javax.swing.event.ListSelectionListener in project pcgen by PCGen.

the class CampaignPanel method setupDisplay.

/**
	 * @see pcgen.gui2.converter.panel.ConvertSubPanel#setupDisplay(javax.swing.JPanel, pcgen.cdom.base.CDOMObject)
	 */
@Override
public void setupDisplay(JPanel panel, final CDOMObject pc) {
    panel.setLayout(new GridBagLayout());
    JLabel introLabel = new JLabel("Please select the Campaign(s) to Convert:");
    GridBagConstraints gbc = new GridBagConstraints();
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
    gbc.insets = new Insets(25, 25, 5, 25);
    panel.add(introLabel, gbc);
    final CampaignTableModel model = new CampaignTableModel(gameModeCampaigns, folderName);
    final JTable table = new JTable(model) {

        //Implement table cell tool tips.
        @Override
        public String getToolTipText(MouseEvent e) {
            java.awt.Point p = e.getPoint();
            int rowIndex = rowAtPoint(p);
            int colIndex = columnAtPoint(p);
            String tip = String.valueOf(getValueAt(rowIndex, colIndex));
            return tip;
        }
    };
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent event) {
            pc.removeListFor(ListKey.CAMPAIGN);
            int[] selRows = table.getSelectedRows();
            if (selRows.length == 0) {
                saveSourceSelection(pc);
                fireProgressEvent(ProgressEvent.NOT_ALLOWED);
            } else {
                for (int row : selRows) {
                    Campaign selCampaign = (Campaign) model.getValueAt(row, 0);
                    pc.addToListFor(ListKey.CAMPAIGN, selCampaign);
                }
                saveSourceSelection(pc);
                fireProgressEvent(ProgressEvent.ALLOWED);
            }
        }
    });
    JScrollPane listScroller = new JScrollPane(table);
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0);
    gbc.fill = GridBagConstraints.BOTH;
    panel.add(listScroller, gbc);
    initSourceSelection(model, table);
}
Also used : JScrollPane(javax.swing.JScrollPane) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) MouseEvent(java.awt.event.MouseEvent) GridBagLayout(java.awt.GridBagLayout) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JLabel(javax.swing.JLabel) ListSelectionListener(javax.swing.event.ListSelectionListener) Campaign(pcgen.core.Campaign) JTable(javax.swing.JTable)

Aggregations

ListSelectionListener (javax.swing.event.ListSelectionListener)106 ListSelectionEvent (javax.swing.event.ListSelectionEvent)102 ActionEvent (java.awt.event.ActionEvent)28 ActionListener (java.awt.event.ActionListener)22 MouseEvent (java.awt.event.MouseEvent)20 JScrollPane (javax.swing.JScrollPane)20 JPanel (javax.swing.JPanel)19 JBList (com.intellij.ui.components.JBList)17 JButton (javax.swing.JButton)17 BorderLayout (java.awt.BorderLayout)14 JLabel (javax.swing.JLabel)13 NotNull (org.jetbrains.annotations.NotNull)13 FlowLayout (java.awt.FlowLayout)10 MouseAdapter (java.awt.event.MouseAdapter)10 List (java.util.List)10 Insets (java.awt.Insets)9 KeyAdapter (java.awt.event.KeyAdapter)9 KeyEvent (java.awt.event.KeyEvent)9 ArrayList (java.util.ArrayList)8 JTextField (javax.swing.JTextField)8