Search in sources :

Example 1 with MappedValue

use of org.jdesktop.swingx.renderer.MappedValue in project zaproxy by zaproxy.

the class SpiderPanel method getUrlsTable.

/**
 * Gets the scan results table.
 *
 * @return the scan results table
 */
private JXTable getUrlsTable() {
    if (urlsTable == null) {
        // Create the table with a default, empty TableModel and the proper settings
        urlsTable = new ZapTable(EMPTY_URLS_TABLE_MODEL);
        urlsTable.setColumnSelectionAllowed(false);
        urlsTable.setCellSelectionEnabled(false);
        urlsTable.setRowSelectionAllowed(true);
        urlsTable.setAutoCreateRowSorter(true);
        urlsTable.setAutoCreateColumnsFromModel(false);
        urlsTable.getColumnExt(0).setCellRenderer(new DefaultTableRenderer(new MappedValue(StringValues.EMPTY, IconValues.NONE), JLabel.CENTER));
        urlsTable.getColumnExt(0).setHighlighters(new ProcessedCellItemIconHighlighter(0));
        urlsTable.getColumnModel().getColumn(0).setMinWidth(80);
        // processed
        urlsTable.getColumnModel().getColumn(0).setPreferredWidth(90);
        urlsTable.getColumnModel().getColumn(1).setMinWidth(60);
        // method
        urlsTable.getColumnModel().getColumn(1).setPreferredWidth(70);
        // name
        urlsTable.getColumnModel().getColumn(2).setMinWidth(300);
        urlsTable.getColumnModel().getColumn(3).setMinWidth(50);
        // flags
        urlsTable.getColumnModel().getColumn(3).setPreferredWidth(250);
        urlsTable.setName(PANEL_NAME);
        urlsTable.setDoubleBuffered(true);
        urlsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        urlsTable.setComponentPopupMenu(new JPopupMenu() {

            private static final long serialVersionUID = 6608291059686282641L;

            @Override
            public void show(Component invoker, int x, int y) {
                View.getSingleton().getPopupMenu().show(invoker, x, y);
            }
        });
    }
    return urlsTable;
}
Also used : ZapTable(org.zaproxy.zap.view.ZapTable) MappedValue(org.jdesktop.swingx.renderer.MappedValue) Component(java.awt.Component) DefaultTableRenderer(org.jdesktop.swingx.renderer.DefaultTableRenderer) JPopupMenu(javax.swing.JPopupMenu)

Example 2 with MappedValue

use of org.jdesktop.swingx.renderer.MappedValue in project zaproxy by zaproxy.

the class ManageAddOnsDialog method getInstalledAddOnsTable.

private ZapTable getInstalledAddOnsTable() {
    if (installedAddOnsTable == null) {
        installedAddOnsTable = createCustomZapTable();
        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);
        installedAddOnsTable.getColumnExt(0).setSortable(// icon doesn't need to be sortable
        false);
        // name
        installedAddOnsTable.getColumnModel().getColumn(1).setPreferredWidth(200);
        // version
        installedAddOnsTable.getColumnModel().getColumn(2).setPreferredWidth(60);
        installedAddOnsTable.getColumnExt(2).setSortable(// version doesn't need to be sortable
        false);
        installedAddOnsTable.getColumnModel().getColumn(3).setPreferredWidth(// description
        400);
        installedAddOnsTable.getColumnExt(3).setSortable(// description doesn't need to be sortable
        false);
        // update
        installedAddOnsTable.getColumnModel().getColumn(4).setPreferredWidth(60);
        installedAddOnsTable.getColumnExt(4).setSortable(// update doesn't need to be sortable
        false);
        installedAddOnsTable.getColumnModel().getColumn(5).setPreferredWidth(40);
        installedAddOnsTable.getColumnExt(5).setSortable(// checkbox doesn't need to be sortable
        false);
        // Default sort by name (column 1)
        List<RowSorter.SortKey> sortKeys = new ArrayList<>(1);
        sortKeys.add(new RowSorter.SortKey(1, SortOrder.ASCENDING));
        installedAddOnsTable.getRowSorter().setSortKeys(sortKeys);
        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) 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 3 with MappedValue

use of org.jdesktop.swingx.renderer.MappedValue in project zaproxy by zaproxy.

the class ManageAddOnsDialog method getUninstalledAddOnsTable.

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

            @Override
            public void tableChanged(TableModelEvent e) {
                getInstallButton().setEnabled(uninstalledAddOnsModel.canIinstallSelected());
                getInstallAllButton().setEnabled(uninstalledAddOnsModel.hasAvailableAddOns());
            }
        });
        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);
        uninstalledAddOnsTable.getColumnModel().getColumn(3).setPreferredWidth(// Description
        300);
        uninstalledAddOnsTable.getColumnExt(3).setSortable(// Description doesn't need sorting
        false);
        uninstalledAddOnsTable.getColumnModel().getColumn(4).setPreferredWidth(// Update (version number)
        60);
        uninstalledAddOnsTable.getColumnExt(4).setSortable(// Update doesn't need sorting
        false);
        // Checkbox
        uninstalledAddOnsTable.getColumnModel().getColumn(5).setPreferredWidth(40);
        uninstalledAddOnsTable.getColumnExt(5).setSortable(// Checkbox doesn't need sorting
        false);
        // Default sort by status (column 1) descending (Release, Beta, Alpha), and name (column
        // 2) ascending
        List<RowSorter.SortKey> sortKeys = new ArrayList<>(2);
        sortKeys.add(new RowSorter.SortKey(1, SortOrder.DESCENDING));
        sortKeys.add(new RowSorter.SortKey(2, SortOrder.ASCENDING));
        uninstalledAddOnsTable.getRowSorter().setSortKeys(sortKeys);
        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) 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 4 with MappedValue

use of org.jdesktop.swingx.renderer.MappedValue in project zaproxy by zaproxy.

the class HttpSessionsPanel method getHttpSessionsTable.

/**
 * Gets the http sessions table.
 *
 * @return the http sessions table
 */
private JXTable getHttpSessionsTable() {
    if (sessionsTable == null) {
        sessionsTable = new JXTable(sessionsModel);
        sessionsTable.setColumnSelectionAllowed(false);
        sessionsTable.setCellSelectionEnabled(false);
        sessionsTable.setRowSelectionAllowed(true);
        sessionsTable.setAutoCreateRowSorter(true);
        sessionsTable.setColumnControlVisible(true);
        sessionsTable.setAutoCreateColumnsFromModel(false);
        sessionsTable.getColumnExt(0).setCellRenderer(new DefaultTableRenderer(new MappedValue(StringValues.EMPTY, IconValues.NONE), JLabel.CENTER));
        sessionsTable.getColumnExt(0).setHighlighters(new ActiveSessionIconHighlighter(0));
        this.setSessionsTableColumnSizes();
        sessionsTable.setName(PANEL_NAME);
        sessionsTable.setDoubleBuffered(true);
        sessionsTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        sessionsTable.addMouseListener(new java.awt.event.MouseAdapter() {

            @Override
            public void mousePressed(java.awt.event.MouseEvent e) {
                showPopupMenuIfTriggered(e);
            }

            @Override
            public void mouseReleased(java.awt.event.MouseEvent e) {
                showPopupMenuIfTriggered(e);
            }

            private void showPopupMenuIfTriggered(java.awt.event.MouseEvent e) {
                if (e.isPopupTrigger()) {
                    // Select table item
                    int row = sessionsTable.rowAtPoint(e.getPoint());
                    if (row < 0 || !sessionsTable.getSelectionModel().isSelectedIndex(row)) {
                        sessionsTable.getSelectionModel().clearSelection();
                        if (row >= 0) {
                            sessionsTable.getSelectionModel().setSelectionInterval(row, row);
                        }
                    }
                    View.getSingleton().getPopupMenu().show(e.getComponent(), e.getX(), e.getY());
                }
            }
        });
    }
    return sessionsTable;
}
Also used : JXTable(org.jdesktop.swingx.JXTable) MappedValue(org.jdesktop.swingx.renderer.MappedValue) DefaultTableRenderer(org.jdesktop.swingx.renderer.DefaultTableRenderer)

Example 5 with MappedValue

use of org.jdesktop.swingx.renderer.MappedValue in project zaproxy by zaproxy.

the class SpiderPanel method getAddedNodesTable.

private JXTable getAddedNodesTable() {
    if (addedNodesTable == null) {
        // Create the table with a default, empty TableModel and the proper settings
        addedNodesTable = new ZapTable(EMPTY_URLS_NO_FLAGS_TABLE_MODEL);
        addedNodesTable.setColumnSelectionAllowed(false);
        addedNodesTable.setCellSelectionEnabled(false);
        addedNodesTable.setRowSelectionAllowed(true);
        addedNodesTable.setAutoCreateRowSorter(true);
        addedNodesTable.setAutoCreateColumnsFromModel(false);
        addedNodesTable.getColumnExt(0).setCellRenderer(new DefaultTableRenderer(new MappedValue(StringValues.EMPTY, IconValues.NONE), JLabel.CENTER));
        addedNodesTable.getColumnExt(0).setHighlighters(new ProcessedCellItemIconHighlighter(0));
        addedNodesTable.getColumnModel().getColumn(0).setMinWidth(80);
        // processed
        addedNodesTable.getColumnModel().getColumn(0).setPreferredWidth(90);
        addedNodesTable.getColumnModel().getColumn(1).setMinWidth(60);
        // method
        addedNodesTable.getColumnModel().getColumn(1).setPreferredWidth(70);
        // name
        addedNodesTable.getColumnModel().getColumn(2).setMinWidth(400);
        addedNodesTable.getColumnModel().getColumn(2).setPreferredWidth(1000);
        addedNodesTable.setName(ADDED_NODES_CONTAINER_NAME);
        addedNodesTable.setDoubleBuffered(true);
        addedNodesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        addedNodesTable.setComponentPopupMenu(new JPopupMenu() {

            private static final long serialVersionUID = 6608291059686282641L;

            @Override
            public void show(Component invoker, int x, int y) {
                View.getSingleton().getPopupMenu().show(invoker, x, y);
            }
        });
    }
    return addedNodesTable;
}
Also used : ZapTable(org.zaproxy.zap.view.ZapTable) MappedValue(org.jdesktop.swingx.renderer.MappedValue) Component(java.awt.Component) DefaultTableRenderer(org.jdesktop.swingx.renderer.DefaultTableRenderer) JPopupMenu(javax.swing.JPopupMenu)

Aggregations

DefaultTableRenderer (org.jdesktop.swingx.renderer.DefaultTableRenderer)5 MappedValue (org.jdesktop.swingx.renderer.MappedValue)5 Component (java.awt.Component)2 ArrayList (java.util.ArrayList)2 JPopupMenu (javax.swing.JPopupMenu)2 RowSorter (javax.swing.RowSorter)2 TableModelEvent (javax.swing.event.TableModelEvent)2 TableModelListener (javax.swing.event.TableModelListener)2 CompoundHighlighter (org.jdesktop.swingx.decorator.CompoundHighlighter)2 ZapTable (org.zaproxy.zap.view.ZapTable)2 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1 ListSelectionListener (javax.swing.event.ListSelectionListener)1 JXTable (org.jdesktop.swingx.JXTable)1