Search in sources :

Example 11 with RecordRowTableModel

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));
}
Also used : ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) Color(java.awt.Color) RecordRowTableModel(com.revolsys.swing.table.record.model.RecordRowTableModel)

Example 12 with RecordRowTableModel

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);
            }
        }
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) RecordRowTableModel(com.revolsys.swing.table.record.model.RecordRowTableModel)

Example 13 with RecordRowTableModel

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();
        }
    });
}
Also used : RecordRowTableModel(com.revolsys.swing.table.record.model.RecordRowTableModel) TableColumnModel(javax.swing.table.TableColumnModel) TableColumn(javax.swing.table.TableColumn)

Example 14 with RecordRowTableModel

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);
                }
            }
        }
    }
}
Also used : RecordRowTableModel(com.revolsys.swing.table.record.model.RecordRowTableModel) SortOrder(javax.swing.SortOrder)

Aggregations

RecordRowTableModel (com.revolsys.swing.table.record.model.RecordRowTableModel)14 RecordTableCellEditor (com.revolsys.swing.table.record.editor.RecordTableCellEditor)3 JComponent (javax.swing.JComponent)3 Geometry (com.revolsys.geometry.model.Geometry)2 Record (com.revolsys.record.Record)2 EventObject (java.util.EventObject)2 FieldDefinition (com.revolsys.record.schema.FieldDefinition)1 RecordLayerTable (com.revolsys.swing.map.layer.record.table.RecordLayerTable)1 RecordLayerTableModel (com.revolsys.swing.map.layer.record.table.model.RecordLayerTableModel)1 BaseJTable (com.revolsys.swing.table.BaseJTable)1 ColorHighlighter (com.revolsys.swing.table.highlighter.ColorHighlighter)1 Color (java.awt.Color)1 StringSelection (java.awt.datatransfer.StringSelection)1 Transferable (java.awt.datatransfer.Transferable)1 ListSelectionModel (javax.swing.ListSelectionModel)1 SortOrder (javax.swing.SortOrder)1 TableColumn (javax.swing.table.TableColumn)1 TableColumnModel (javax.swing.table.TableColumnModel)1 ColorHighlighter (org.jdesktop.swingx.decorator.ColorHighlighter)1 Highlighter (org.jdesktop.swingx.decorator.Highlighter)1