Search in sources :

Example 6 with TableModelEvent

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

the class ManageAddOnsDialog method getInstalledAddOnsTable.

private JXTable getInstalledAddOnsTable() {
    if (installedAddOnsTable == null) {
        installedAddOnsTable = new JXTable();
        installedAddOnsModel.addTableModelListener(new TableModelListener() {

            @Override
            public void tableChanged(TableModelEvent e) {
                getUpdateButton().setEnabled(installedAddOnsModel.canUpdateSelected());
                getUpdateAllButton().setEnabled(installedAddOnsModel.getAllUpdates().size() > 0);
                getUninstallButton().setEnabled(installedAddOnsModel.canUninstallSelected());
            }
        });
        installedAddOnsTable.setModel(installedAddOnsModel);
        //icon
        installedAddOnsTable.getColumnModel().getColumn(0).setMaxWidth(20);
        //icon doesn't need to be sortable
        installedAddOnsTable.getColumnExt(0).setSortable(false);
        //name
        installedAddOnsTable.getColumnModel().getColumn(1).setPreferredWidth(200);
        //description
        installedAddOnsTable.getColumnModel().getColumn(2).setPreferredWidth(400);
        //description doesn't need to be sortable
        installedAddOnsTable.getColumnExt(2).setSortable(false);
        //update
        installedAddOnsTable.getColumnModel().getColumn(3).setPreferredWidth(60);
        //update doesn't need to be sortable
        installedAddOnsTable.getColumnExt(3).setSortable(false);
        installedAddOnsTable.getColumnModel().getColumn(4).setPreferredWidth(40);
        //checkbox doesn't need to be sortable
        installedAddOnsTable.getColumnExt(4).setSortable(false);
        //Default sort by name (column 1)
        List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>(1);
        sortKeys.add(new RowSorter.SortKey(1, SortOrder.ASCENDING));
        installedAddOnsTable.getRowSorter().setSortKeys(sortKeys);
        DefaultAddOnToolTipHighlighter toolTipHighlighter = new DefaultAddOnToolTipHighlighter(AddOnsTableModel.COLUMN_ADD_ON_WRAPPER);
        for (int i = 1; i < installedAddOnsTable.getColumnCount(); i++) {
            installedAddOnsTable.getColumnExt(i).addHighlighter(toolTipHighlighter);
        }
        installedAddOnsTable.getColumnExt(0).setCellRenderer(new DefaultTableRenderer(new MappedValue(StringValues.EMPTY, IconValues.NONE), JLabel.CENTER));
        installedAddOnsTable.getColumnExt(0).setHighlighters(new CompoundHighlighter(new WarningRunningIssuesHighlighter(AddOnsTableModel.COLUMN_ADD_ON_WRAPPER), new WarningRunningIssuesToolTipHighlighter(AddOnsTableModel.COLUMN_ADD_ON_WRAPPER)));
        installedAddOnsTable.getColumnExt(3).setHighlighters(new CompoundHighlighter(new WarningUpdateIssuesHighlighter(AddOnsTableModel.COLUMN_ADD_ON_WRAPPER), new WarningUpdateIssuesToolTipHighlighter(AddOnsTableModel.COLUMN_ADD_ON_WRAPPER)));
        installedAddOnsTable.getColumnExt(4).addHighlighter(new DisableSelectionHighlighter(AddOnsTableModel.COLUMN_ADD_ON_WRAPPER));
    }
    return installedAddOnsTable;
}
Also used : RowSorter(javax.swing.RowSorter) JXTable(org.jdesktop.swingx.JXTable) TableModelEvent(javax.swing.event.TableModelEvent) ArrayList(java.util.ArrayList) MappedValue(org.jdesktop.swingx.renderer.MappedValue) DefaultTableRenderer(org.jdesktop.swingx.renderer.DefaultTableRenderer) TableModelListener(javax.swing.event.TableModelListener) CompoundHighlighter(org.jdesktop.swingx.decorator.CompoundHighlighter)

Example 7 with TableModelEvent

use of javax.swing.event.TableModelEvent 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 8 with TableModelEvent

use of javax.swing.event.TableModelEvent in project intellij-community by JetBrains.

the class AbstractTableView method initializeTable.

protected final void initializeTable() {
    myTable.setModelAndUpdateColumns(myTableModel);
    if (getEmptyPaneText() != null) {
        final CardLayout cardLayout = ((CardLayout) myInnerPanel.getLayout());
        myTable.getModel().addTableModelListener(new TableModelListener() {

            @Override
            public void tableChanged(TableModelEvent e) {
                cardLayout.show(myInnerPanel, myTable.getRowCount() == 0 ? EMPTY_PANE : TREE);
            }
        });
    }
    tuneTable(myTable);
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener)

Example 9 with TableModelEvent

use of javax.swing.event.TableModelEvent in project ACS by ACS-Community.

the class LogLevelSelectorPanel method initLogLevelsPanel.

/**
	 * Initialize the log level panel (i.e. the table)
	 * 
	 * @return The panel with the table of log levels
	 * 
	 * @throws LogLvlSelNotSupportedException If the configurable does not support selection
	 */
private JComponent initLogLevelsPanel() throws AcsJCORBAProblemEx {
    LogLevelHelper[] levels = loggersLbl();
    model = new LogLevelModel(levels);
    model.addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            applyBtn.setEnabled(userChangedLogLevels());
        }
    });
    table = new LogLevelTable(model);
    JScrollPane scrollPane = new JScrollPane(table);
    return scrollPane;
}
Also used : JScrollPane(javax.swing.JScrollPane) TableModelEvent(javax.swing.event.TableModelEvent) TableModelListener(javax.swing.event.TableModelListener)

Example 10 with TableModelEvent

use of javax.swing.event.TableModelEvent in project adempiere by adempiere.

the class ResultTableModel method setValueAt.

//  getValueAt
/**
	 *  Set Value At
	 *  @param aValue
	 *  @param row
	 *  @param col
	 */
public void setValueAt(Object aValue, int row, int col) {
    m_model.setValueAt(aValue, row, col);
    fireTableChanged(new TableModelEvent(this, row, row, col, TableModelEvent.UPDATE));
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent)

Aggregations

TableModelEvent (javax.swing.event.TableModelEvent)35 TableModelListener (javax.swing.event.TableModelListener)15 DefaultTableModel (javax.swing.table.DefaultTableModel)6 ActionEvent (java.awt.event.ActionEvent)4 ActionListener (java.awt.event.ActionListener)4 ArrayList (java.util.ArrayList)4 JScrollPane (javax.swing.JScrollPane)4 TableColumn (javax.swing.table.TableColumn)4 JBTable (com.intellij.ui.table.JBTable)3 Dimension (java.awt.Dimension)3 GridBagConstraints (java.awt.GridBagConstraints)3 Insets (java.awt.Insets)3 JButton (javax.swing.JButton)3 JTable (javax.swing.JTable)3 ListSelectionEvent (javax.swing.event.ListSelectionEvent)3 ListSelectionListener (javax.swing.event.ListSelectionListener)3 GridBagLayout (java.awt.GridBagLayout)2 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)2 JComboBox (javax.swing.JComboBox)2 JPanel (javax.swing.JPanel)2