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;
}
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;
}
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;
}
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);
}
}
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;
}
Aggregations