use of com.revolsys.swing.table.AbstractTableModel in project com.revolsys.open by revolsys.
the class BaseTableCellEditor method getTableCellEditorComponent.
@SuppressWarnings("rawtypes")
@Override
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, int rowIndex, int columnIndex) {
if (table instanceof JXTable) {
final JXTable jxTable = (JXTable) table;
rowIndex = jxTable.convertRowIndexToModel(rowIndex);
columnIndex = jxTable.convertColumnIndexToModel(columnIndex);
}
final AbstractTableModel model = (AbstractTableModel) table.getModel();
this.editorComponent = model.getEditorField(rowIndex, columnIndex, value);
if (this.editorComponent instanceof JTextField) {
final JTextField textField = (JTextField) this.editorComponent;
textField.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(WebColors.LightSteelBlue), BorderFactory.createEmptyBorder(1, 2, 1, 2)));
}
this.editorComponent.setOpaque(false);
SwingUtil.setFieldValue(this.editorComponent, value);
this.rowIndex = rowIndex;
this.columnIndex = columnIndex;
this.editorComponent.addKeyListener(this);
this.editorComponent.addMouseListener(this.mouseListeners);
if (this.editorComponent instanceof JComboBox) {
final JComboBox comboBox = (JComboBox) this.editorComponent;
final ComboBoxEditor editor = comboBox.getEditor();
final Component comboEditorComponent = editor.getEditorComponent();
comboEditorComponent.addKeyListener(this);
comboEditorComponent.addMouseListener(this.mouseListeners);
}
return this.editorComponent;
}
use of com.revolsys.swing.table.AbstractTableModel in project com.revolsys.open by revolsys.
the class ColorTableCellEditor method getTableCellEditorComponent.
@Override
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) {
final AbstractTableModel tableModel = (AbstractTableModel) table.getModel();
this.colorChooser.setColor((Color) value);
this.colorChooser.setVisible(true);
final JDialog dialog = JColorChooser.createDialog(table, "Select Color", true, this.colorChooser, e -> tableModel.setValueUndo(this.colorChooser.getColor(), row, column), null);
dialog.setVisible(true);
return null;
}
Aggregations