Search in sources :

Example 71 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project zaproxy by zaproxy.

the class PolicyAllCategoryPanel method getTableTest.

/**
 * This method initializes tableTest
 *
 * @return javax.swing.JTable
 */
private JTable getTableTest() {
    if (tableTest == null) {
        tableTest = new JTable();
        tableTest.setModel(getAllCategoryTableModel());
        tableTest.setRowHeight(DisplayUtils.getScaledSize(18));
        tableTest.setIntercellSpacing(new java.awt.Dimension(1, 1));
        tableTest.setAutoCreateRowSorter(true);
        // Default sort by name (column 0)
        List<RowSorter.SortKey> sortKeys = new ArrayList<>(1);
        sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
        tableTest.getRowSorter().setSortKeys(sortKeys);
        for (int i = 0; i < tableTest.getColumnCount() - 1; i++) {
            TableColumn column = tableTest.getColumnModel().getColumn(i);
            column.setPreferredWidth(width[i]);
        }
        JComboBox<String> jcb1 = new JComboBox<>();
        // Always show a blank one for where they are not all the same
        jcb1.addItem("");
        for (AlertThreshold level : AlertThreshold.values()) {
            jcb1.addItem(Constant.messages.getString("ascan.policy.level." + level.name().toLowerCase(Locale.ROOT)));
        }
        tableTest.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(jcb1));
        JComboBox<String> jcb2 = new JComboBox<>();
        // Always show a blank one for where they are not all the same
        jcb2.addItem("");
        for (AttackStrength level : AttackStrength.values()) {
            jcb2.addItem(Constant.messages.getString("ascan.policy.level." + level.name().toLowerCase(Locale.ROOT)));
        }
        tableTest.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(jcb2));
    }
    return tableTest;
}
Also used : RowSorter(javax.swing.RowSorter) JComboBox(javax.swing.JComboBox) ArrayList(java.util.ArrayList) TableColumn(javax.swing.table.TableColumn) AlertThreshold(org.parosproxy.paros.core.scanner.Plugin.AlertThreshold) DefaultCellEditor(javax.swing.DefaultCellEditor) JTable(javax.swing.JTable) AttackStrength(org.parosproxy.paros.core.scanner.Plugin.AttackStrength)

Example 72 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project zaproxy by zaproxy.

the class PolicyCategoryPanel method getTableTest.

/**
 * This method initializes tableTest
 *
 * @return javax.swing.JTable
 */
private JTable getTableTest() {
    if (tableTest == null) {
        tableTest = new JTable();
        tableTest.setModel(getCategoryTableModel());
        tableTest.setRowHeight(DisplayUtils.getScaledSize(18));
        tableTest.setIntercellSpacing(new java.awt.Dimension(1, 1));
        tableTest.setAutoCreateRowSorter(true);
        // Default sort by name (column 0)
        List<RowSorter.SortKey> sortKeys = new ArrayList<>(1);
        sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
        tableTest.getRowSorter().setSortKeys(sortKeys);
        for (int i = 0; i < tableTest.getColumnCount() - 1; i++) {
            TableColumn column = tableTest.getColumnModel().getColumn(i);
            column.setPreferredWidth(width[i]);
        }
        JComboBox<String> jcb1 = new JComboBox<>();
        for (AlertThreshold level : AlertThreshold.values()) {
            jcb1.addItem(Constant.messages.getString("ascan.policy.level." + level.name().toLowerCase(Locale.ROOT)));
        }
        tableTest.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(jcb1));
        JComboBox<String> jcb2 = new JComboBox<>();
        for (AttackStrength level : AttackStrength.values()) {
            jcb2.addItem(Constant.messages.getString("ascan.policy.level." + level.name().toLowerCase(Locale.ROOT)));
        }
        tableTest.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(jcb2));
    }
    return tableTest;
}
Also used : RowSorter(javax.swing.RowSorter) JComboBox(javax.swing.JComboBox) ArrayList(java.util.ArrayList) TableColumn(javax.swing.table.TableColumn) AlertThreshold(org.parosproxy.paros.core.scanner.Plugin.AlertThreshold) DefaultCellEditor(javax.swing.DefaultCellEditor) JTable(javax.swing.JTable) AttackStrength(org.parosproxy.paros.core.scanner.Plugin.AttackStrength)

Example 73 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project zaproxy by zaproxy.

the class PolicyPassiveScanPanel method getPassiveScanRulesTable.

private JXTable getPassiveScanRulesTable() {
    if (passiveScanRulesTable == null) {
        passiveScanRulesTable = new JXTable();
        passiveScanRulesTable.setModel(getPassiveScanTableModel());
        passiveScanRulesTable.setRowHeight(DisplayUtils.getScaledSize(18));
        passiveScanRulesTable.setIntercellSpacing(new java.awt.Dimension(1, 1));
        passiveScanRulesTable.setAutoCreateRowSorter(true);
        // Default sort by name (column 0)
        List<RowSorter.SortKey> sortKeys = new ArrayList<>(1);
        sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
        passiveScanRulesTable.getRowSorter().setSortKeys(sortKeys);
        for (int i = 0; i < passiveScanRulesTable.getColumnCount() - 1; i++) {
            TableColumn column = passiveScanRulesTable.getColumnModel().getColumn(i);
            column.setPreferredWidth(width[i]);
        }
        JComboBox<String> jcb1 = new JComboBox<>();
        for (AlertThreshold level : AlertThreshold.values()) {
            jcb1.addItem(Constant.messages.getString("ascan.policy.level." + level.name().toLowerCase(Locale.ROOT)));
        }
        passiveScanRulesTable.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(jcb1));
    }
    return passiveScanRulesTable;
}
Also used : RowSorter(javax.swing.RowSorter) JXTable(org.jdesktop.swingx.JXTable) JComboBox(javax.swing.JComboBox) ArrayList(java.util.ArrayList) TableColumn(javax.swing.table.TableColumn) AlertThreshold(org.parosproxy.paros.core.scanner.Plugin.AlertThreshold) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 74 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project Universal-G-Code-Sender by winder.

the class OptionTable method getCellEditor.

@Override
public TableCellEditor getCellEditor(int row, int column) {
    editingClass = null;
    int modelColumn = convertColumnIndexToModel(column);
    if (modelColumn == 1) {
        // TODO: When I have a color type check for that to create a custom
        // color picker. Also language combo box?
        editingClass = getModel().getValueAt(row, modelColumn).getClass();
        if (editingClass == java.awt.Color.class) {
            return new ColorEditor();
        } else if (editingClass == ComboRenderer.class) {
            ComboRenderer box = (ComboRenderer) getModel().getValueAt(row, modelColumn);
            return new DefaultCellEditor(box);
        }
        return getDefaultEditor(editingClass);
    } else {
        return super.getCellEditor(row, column);
    }
}
Also used : DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 75 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project freeplane by freeplane.

the class AttributeTable method getCellEditor.

@SuppressWarnings("serial")
public TableCellEditor getCellEditor(final int row, final int col, EventObject e) {
    if (dce != null) {
        dce.stopCellEditing();
    }
    if (col == 1) {
        final MTextController textController = (MTextController) TextController.getController();
        if (e instanceof KeyEvent) {
            final KeyEvent kev = (KeyEvent) e;
            textController.getEventQueue().setFirstEvent(kev);
        }
        final IAttributeTableModel model = (IAttributeTableModel) getModel();
        final String text = getValueForEdit(row, col);
        final DialogTableCellEditor dialogTableCellEditor = new DialogTableCellEditor();
        EditNodeBase base = textController.getEditNodeBase(model.getNode(), text, dialogTableCellEditor.getEditControl(), false);
        if (base != null) {
            dialogTableCellEditor.setEditBase(base);
            return dialogTableCellEditor;
        }
    }
    final JComboBox comboBox;
    if (dce == null) {
        comboBox = new JComboBox();
        comboBox.addFocusListener(AttributeTable.focusListener);
        comboBox.getEditor().getEditorComponent().addFocusListener(AttributeTable.focusListener);
        comboBox.setRenderer(new TypedListCellRenderer());
        dce = new DefaultCellEditor(comboBox) {

            public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col) {
                return super.getTableCellEditorComponent(table, ((AttributeTable) table).getValueForEdit(row, col), isSelected, row, col);
            }
        };
        dce.setClickCountToStart(CLICK_COUNT_TO_START);
    }
    return dce;
}
Also used : JComboBox(javax.swing.JComboBox) EditNodeBase(org.freeplane.features.text.mindmapmode.EditNodeBase) DefaultCellEditor(javax.swing.DefaultCellEditor) KeyEvent(java.awt.event.KeyEvent) TypedListCellRenderer(org.freeplane.core.ui.components.TypedListCellRenderer) JTable(javax.swing.JTable) IAttributeTableModel(org.freeplane.features.attribute.IAttributeTableModel) EventObject(java.util.EventObject) IFormattedObject(org.freeplane.features.format.IFormattedObject) MTextController(org.freeplane.features.text.mindmapmode.MTextController) EditedComponent(org.freeplane.features.text.mindmapmode.EditNodeBase.EditedComponent) Component(java.awt.Component) JComponent(javax.swing.JComponent)

Aggregations

DefaultCellEditor (javax.swing.DefaultCellEditor)79 JComboBox (javax.swing.JComboBox)44 TableColumn (javax.swing.table.TableColumn)30 JTable (javax.swing.JTable)28 JScrollPane (javax.swing.JScrollPane)18 Component (java.awt.Component)16 JPanel (javax.swing.JPanel)14 JButton (javax.swing.JButton)13 ActionEvent (java.awt.event.ActionEvent)12 JTextField (javax.swing.JTextField)12 JLabel (javax.swing.JLabel)11 ActionListener (java.awt.event.ActionListener)10 TableColumnModel (javax.swing.table.TableColumnModel)10 FlowLayout (java.awt.FlowLayout)9 BoxLayout (javax.swing.BoxLayout)9 PaddedComboBox (CCDD.CcddClassesComponent.PaddedComboBox)8 Point (java.awt.Point)8 TableCellEditor (javax.swing.table.TableCellEditor)8 ArrayList (java.util.ArrayList)7 JCheckBox (javax.swing.JCheckBox)7