use of com.revolsys.swing.table.record.model.RecordRowTableModel in project com.revolsys.open by revolsys.
the class ModifiedFieldPredicate method add.
public static void add(final RecordRowTable table) {
final RecordRowTableModel model = table.getModel();
final ModifiedFieldPredicate predicate = new ModifiedFieldPredicate(model);
final Color lime50 = WebColors.newAlpha(WebColors.Lime, 127);
table.addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.EVEN), lime50, WebColors.Black, lime50, WebColors.Black));
table.addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.ODD), WebColors.Lime, WebColors.Black, WebColors.Lime, WebColors.Black));
}
use of com.revolsys.swing.table.record.model.RecordRowTableModel in project com.revolsys.open by revolsys.
the class RecordRowTable method mouseClicked.
@Override
public void mouseClicked(final MouseEvent e) {
final Object source = e.getSource();
if (source == getTableHeader()) {
final RecordRowTableModel model = getModel();
final int columnIndex = columnAtPoint(e.getPoint());
if (columnIndex > -1 && SwingUtilities.isLeftMouseButton(e)) {
final Class<?> fieldClass = model.getColumnClass(columnIndex);
if (!Geometry.class.isAssignableFrom(fieldClass)) {
model.setSortOrder(columnIndex);
}
}
}
}
use of com.revolsys.swing.table.record.model.RecordRowTableModel in project com.revolsys.open by revolsys.
the class RecordRowTable method tableChanged.
@Override
public void tableChanged(final TableModelEvent event) {
Invoke.later(() -> {
final RecordRowTableModel model = getModel();
final int fieldsOffset = model.getColumnFieldsOffset();
tableChangedDo(event);
final int type = event.getType();
final int eventColumn = event.getColumn();
final int row = event.getFirstRow();
if (type == TableModelEvent.UPDATE && eventColumn == TableModelEvent.ALL_COLUMNS && row == TableModelEvent.HEADER_ROW) {
createDefaultColumnsFromModel();
final TableColumnModel columnModel = getColumnModel();
for (int columnIndex = 0; columnIndex < model.getColumnCount(); columnIndex++) {
final TableColumn column = columnModel.getColumn(columnIndex);
if (columnIndex >= fieldsOffset) {
column.setCellEditor(this.tableCellEditor);
}
column.setCellRenderer(this.cellRenderer);
}
initializeColumnWidths();
}
if (this.tableHeader != null) {
this.tableHeader.resizeAndRepaint();
}
});
}
use of com.revolsys.swing.table.record.model.RecordRowTableModel in project com.revolsys.open by revolsys.
the class RecordRowTable method setRowSorter.
@Override
public void setRowSorter(final RowSorter<? extends TableModel> sorter) {
super.setRowSorter(sorter);
if (sorter != null) {
final SortController<?> sortController = getSortController();
if (sortController != null) {
final RecordRowTableModel model = getTableModel();
sortController.resetSortOrders();
for (final Entry<Integer, SortOrder> entry : model.getSortedColumns().entrySet()) {
final int index = entry.getKey();
if (index < model.getColumnCount()) {
final SortOrder sortOrder = entry.getValue();
sortController.setSortOrder(index, sortOrder);
}
}
}
}
}
Aggregations