Search in sources :

Example 1 with ColorHighlighter

use of com.revolsys.swing.table.highlighter.ColorHighlighter in project com.revolsys.open by revolsys.

the class RecordLayerTable method addModifiedRecordHighlighter.

@Override
protected void addModifiedRecordHighlighter() {
    final RecordLayerTableModel model = getModel();
    final HighlightPredicate predicate = (renderer, adapter) -> {
        try {
            final int rowIndex = adapter.convertRowIndexToModel(adapter.row);
            final LayerRecord record = model.getRecord(rowIndex);
            final AbstractRecordLayer layer = model.getLayer();
            return layer.isModified(record);
        } catch (final Throwable e) {
            return false;
        }
    };
    addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.EVEN), WebColors.newAlpha(WebColors.LimeGreen, 127), WebColors.Black, WebColors.newAlpha(WebColors.DarkGreen, 191), Color.WHITE));
    addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.ODD), WebColors.LimeGreen, WebColors.Black, WebColors.DarkGreen, Color.WHITE));
}
Also used : RecordLayerTableModel(com.revolsys.swing.map.layer.record.table.model.RecordLayerTableModel) Color(java.awt.Color) ListSelectionModel(javax.swing.ListSelectionModel) DataFlavor(java.awt.datatransfer.DataFlavor) TextAttribute(java.awt.font.TextAttribute) SwingUtil(com.revolsys.swing.SwingUtil) Transferable(java.awt.datatransfer.Transferable) LayerRecordMenu(com.revolsys.swing.map.layer.record.LayerRecordMenu) RowFilter(javax.swing.RowFilter) JTableHeader(javax.swing.table.JTableHeader) TableColumnExt(org.jdesktop.swingx.table.TableColumnExt) EventObject(java.util.EventObject) RecordLayerTableModel(com.revolsys.swing.map.layer.record.table.model.RecordLayerTableModel) WebColors(com.revolsys.awt.WebColors) ClipboardUtil(com.revolsys.swing.dnd.ClipboardUtil) Map(java.util.Map) StringSelection(java.awt.datatransfer.StringSelection) TableColumnModelEvent(javax.swing.event.TableColumnModelEvent) RowSorter(javax.swing.RowSorter) ListSelectionEvent(javax.swing.event.ListSelectionEvent) RecordRowTableModel(com.revolsys.swing.table.record.model.RecordRowTableModel) PropertyChangeEvent(java.beans.PropertyChangeEvent) TableModel(javax.swing.table.TableModel) JComponent(javax.swing.JComponent) ChangeEvent(javax.swing.event.ChangeEvent) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) TableColumnModelExtListener(org.jdesktop.swingx.event.TableColumnModelExtListener) TableModelEvent(javax.swing.event.TableModelEvent) HighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate) FontHighlighter(org.jdesktop.swingx.decorator.FontHighlighter) TablePanel(com.revolsys.swing.table.TablePanel) Font(java.awt.Font) TableColumn(javax.swing.table.TableColumn) TableColumnModelExt(org.jdesktop.swingx.table.TableColumnModelExt) RecordRowTable(com.revolsys.swing.table.record.RecordRowTable) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) Geometry(com.revolsys.geometry.model.Geometry) RecordTableCellEditor(com.revolsys.swing.table.record.editor.RecordTableCellEditor) ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) HighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate)

Example 2 with ColorHighlighter

use of com.revolsys.swing.table.highlighter.ColorHighlighter in project com.revolsys.open by revolsys.

the class RecordLayerTable method addDeletedRecordHighlighter.

@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void addDeletedRecordHighlighter() {
    final RecordLayerTableModel model = getModel();
    final HighlightPredicate predicate = (renderer, adapter) -> {
        try {
            final int rowIndex = adapter.convertRowIndexToModel(adapter.row);
            return model.isDeleted(rowIndex);
        } catch (final Throwable e) {
        }
        return false;
    };
    addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.EVEN), WebColors.newAlpha(WebColors.Pink, 127), WebColors.FireBrick, WebColors.LightCoral, WebColors.FireBrick));
    addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.ODD), WebColors.Pink, WebColors.FireBrick, WebColors.Crimson, WebColors.White));
    final Font tableFont = getFont();
    final Map<TextAttribute, Object> fontAttributes = (Map) tableFont.getAttributes();
    fontAttributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
    final Font font = new Font(fontAttributes);
    final FontHighlighter fontHighlighter = new FontHighlighter(predicate, font);
    addHighlighter(fontHighlighter);
}
Also used : RecordLayerTableModel(com.revolsys.swing.map.layer.record.table.model.RecordLayerTableModel) Color(java.awt.Color) ListSelectionModel(javax.swing.ListSelectionModel) DataFlavor(java.awt.datatransfer.DataFlavor) TextAttribute(java.awt.font.TextAttribute) SwingUtil(com.revolsys.swing.SwingUtil) Transferable(java.awt.datatransfer.Transferable) LayerRecordMenu(com.revolsys.swing.map.layer.record.LayerRecordMenu) RowFilter(javax.swing.RowFilter) JTableHeader(javax.swing.table.JTableHeader) TableColumnExt(org.jdesktop.swingx.table.TableColumnExt) EventObject(java.util.EventObject) RecordLayerTableModel(com.revolsys.swing.map.layer.record.table.model.RecordLayerTableModel) WebColors(com.revolsys.awt.WebColors) ClipboardUtil(com.revolsys.swing.dnd.ClipboardUtil) Map(java.util.Map) StringSelection(java.awt.datatransfer.StringSelection) TableColumnModelEvent(javax.swing.event.TableColumnModelEvent) RowSorter(javax.swing.RowSorter) ListSelectionEvent(javax.swing.event.ListSelectionEvent) RecordRowTableModel(com.revolsys.swing.table.record.model.RecordRowTableModel) PropertyChangeEvent(java.beans.PropertyChangeEvent) TableModel(javax.swing.table.TableModel) JComponent(javax.swing.JComponent) ChangeEvent(javax.swing.event.ChangeEvent) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) TableColumnModelExtListener(org.jdesktop.swingx.event.TableColumnModelExtListener) TableModelEvent(javax.swing.event.TableModelEvent) HighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate) FontHighlighter(org.jdesktop.swingx.decorator.FontHighlighter) TablePanel(com.revolsys.swing.table.TablePanel) Font(java.awt.Font) TableColumn(javax.swing.table.TableColumn) TableColumnModelExt(org.jdesktop.swingx.table.TableColumnModelExt) RecordRowTable(com.revolsys.swing.table.record.RecordRowTable) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) Geometry(com.revolsys.geometry.model.Geometry) RecordTableCellEditor(com.revolsys.swing.table.record.editor.RecordTableCellEditor) ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) TextAttribute(java.awt.font.TextAttribute) FontHighlighter(org.jdesktop.swingx.decorator.FontHighlighter) EventObject(java.util.EventObject) HighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) Map(java.util.Map) Font(java.awt.Font)

Example 3 with ColorHighlighter

use of com.revolsys.swing.table.highlighter.ColorHighlighter in project com.revolsys.open by revolsys.

the class RecordLayerTable method addNewRecordHighlighter.

@Override
protected void addNewRecordHighlighter() {
    final RecordLayerTableModel model = getModel();
    final HighlightPredicate predicate = (renderer, adapter) -> {
        try {
            final int rowIndex = adapter.convertRowIndexToModel(adapter.row);
            final LayerRecord record = model.getRecord(rowIndex);
            final AbstractRecordLayer layer = model.getLayer();
            return layer.isNew(record);
        } catch (final Throwable e) {
            return false;
        }
    };
    addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.EVEN), WebColors.newAlpha(WebColors.LightSkyBlue, 127), WebColors.Black, WebColors.newAlpha(WebColors.RoyalBlue, 191), Color.WHITE));
    addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.ODD), WebColors.LightSkyBlue, WebColors.Black, WebColors.RoyalBlue, Color.WHITE));
}
Also used : RecordLayerTableModel(com.revolsys.swing.map.layer.record.table.model.RecordLayerTableModel) Color(java.awt.Color) ListSelectionModel(javax.swing.ListSelectionModel) DataFlavor(java.awt.datatransfer.DataFlavor) TextAttribute(java.awt.font.TextAttribute) SwingUtil(com.revolsys.swing.SwingUtil) Transferable(java.awt.datatransfer.Transferable) LayerRecordMenu(com.revolsys.swing.map.layer.record.LayerRecordMenu) RowFilter(javax.swing.RowFilter) JTableHeader(javax.swing.table.JTableHeader) TableColumnExt(org.jdesktop.swingx.table.TableColumnExt) EventObject(java.util.EventObject) RecordLayerTableModel(com.revolsys.swing.map.layer.record.table.model.RecordLayerTableModel) WebColors(com.revolsys.awt.WebColors) ClipboardUtil(com.revolsys.swing.dnd.ClipboardUtil) Map(java.util.Map) StringSelection(java.awt.datatransfer.StringSelection) TableColumnModelEvent(javax.swing.event.TableColumnModelEvent) RowSorter(javax.swing.RowSorter) ListSelectionEvent(javax.swing.event.ListSelectionEvent) RecordRowTableModel(com.revolsys.swing.table.record.model.RecordRowTableModel) PropertyChangeEvent(java.beans.PropertyChangeEvent) TableModel(javax.swing.table.TableModel) JComponent(javax.swing.JComponent) ChangeEvent(javax.swing.event.ChangeEvent) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) TableColumnModelExtListener(org.jdesktop.swingx.event.TableColumnModelExtListener) TableModelEvent(javax.swing.event.TableModelEvent) HighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate) FontHighlighter(org.jdesktop.swingx.decorator.FontHighlighter) TablePanel(com.revolsys.swing.table.TablePanel) Font(java.awt.Font) TableColumn(javax.swing.table.TableColumn) TableColumnModelExt(org.jdesktop.swingx.table.TableColumnModelExt) RecordRowTable(com.revolsys.swing.table.record.RecordRowTable) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) Geometry(com.revolsys.geometry.model.Geometry) RecordTableCellEditor(com.revolsys.swing.table.record.editor.RecordTableCellEditor) ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) HighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate)

Example 4 with ColorHighlighter

use of com.revolsys.swing.table.highlighter.ColorHighlighter in project com.revolsys.open by revolsys.

the class RecordLayerErrorsTableModel method newPanel.

public TablePanel newPanel() {
    final RecordRowTable table = new RecordRowTable(this);
    table.setVisibleRowCount(this.getRowCount() + 1);
    table.setSortable(true);
    table.getSelectionModel().addListSelectionListener(this);
    table.resizeColumnsToContent();
    final HighlightPredicate predicate = (renderer, adapter) -> {
        final int columnIndex = adapter.convertColumnIndexToModel(adapter.column);
        return columnIndex == 0;
    };
    table.addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.EVEN), WebColors.newAlpha(WebColors.Pink, 127), WebColors.FireBrick, WebColors.LightCoral, WebColors.FireBrick));
    table.addHighlighter(new ColorHighlighter(new AndHighlightPredicate(predicate, HighlightPredicate.ODD), WebColors.Pink, WebColors.FireBrick, WebColors.Crimson, WebColors.White));
    return new TablePanel(table);
}
Also used : ListSelectionModel(javax.swing.ListSelectionModel) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) RecordListTableModel(com.revolsys.swing.table.record.model.RecordListTableModel) HighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate) TablePanel(com.revolsys.swing.table.TablePanel) Collection(java.util.Collection) RecordRowTable(com.revolsys.swing.table.record.RecordRowTable) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) Record(com.revolsys.record.Record) WebColors(com.revolsys.awt.WebColors) List(java.util.List) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ListSelectionListener(javax.swing.event.ListSelectionListener) ObjectPropertyException(com.revolsys.beans.ObjectPropertyException) SortableTableModel(com.revolsys.swing.table.SortableTableModel) ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) HighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) RecordRowTable(com.revolsys.swing.table.record.RecordRowTable) TablePanel(com.revolsys.swing.table.TablePanel)

Example 5 with ColorHighlighter

use of com.revolsys.swing.table.highlighter.ColorHighlighter in project com.revolsys.open by revolsys.

the class RecordValidationDialog method newInvalidRecordsTablePanel.

private TablePanel newInvalidRecordsTablePanel() {
    final RecordDefinition recordDefinition = this.layer.getRecordDefinition();
    final List<String> fieldNames = this.layer.getFieldNames();
    final RecordListTableModel model = new RecordListTableModel(recordDefinition, this.invalidRecords, fieldNames);
    model.setReadOnlyFieldNames(this.layer.getUserReadOnlyFieldNames());
    final RecordRowTable table = new RecordRowTable(model);
    table.setVisibleRowCount(Math.min(10, model.getRowCount() + 1));
    table.setSortable(true);
    table.resizeColumnsToContent();
    final HighlightPredicate invalidFieldPredicate = (final Component renderer, final ComponentAdapter adapter) -> {
        try {
            final int rowIndex = adapter.convertRowIndexToModel(adapter.row);
            final int columnIndex = adapter.convertColumnIndexToModel(adapter.column);
            final Map<String, String> fieldErrors = this.invalidRecordErrors.get(rowIndex);
            if (!fieldErrors.isEmpty()) {
                final String fieldName = this.layer.getFieldName(columnIndex);
                final String errorMessage = fieldErrors.get(fieldName);
                if (Property.hasValue(errorMessage)) {
                    final JComponent jcomponent = (JComponent) renderer;
                    jcomponent.setToolTipText(errorMessage);
                    return true;
                }
            }
        } catch (final Throwable e) {
        }
        return false;
    };
    final Highlighter invalidFieldHighlighter = new ColorHighlighter(invalidFieldPredicate, WebColors.newAlpha(Color.RED, 64), Color.RED, Color.RED, Color.YELLOW);
    table.addHighlighter(invalidFieldHighlighter);
    final HighlightPredicate validRecordPredicate = (final Component renderer, final ComponentAdapter adapter) -> {
        try {
            final int rowIndex = adapter.convertRowIndexToModel(adapter.row);
            final Map<String, String> fieldErrors = this.invalidRecordErrors.get(rowIndex);
            if (fieldErrors.isEmpty()) {
                return true;
            }
        } catch (final Throwable e) {
        }
        return false;
    };
    table.addHighlighter(new ColorHighlighter(new AndHighlightPredicate(validRecordPredicate, HighlightPredicate.EVEN), WebColors.newAlpha(WebColors.LimeGreen, 127), WebColors.Black, WebColors.newAlpha(WebColors.DarkGreen, 191), Color.WHITE));
    table.addHighlighter(new ColorHighlighter(new AndHighlightPredicate(validRecordPredicate, HighlightPredicate.ODD), WebColors.LimeGreen, WebColors.Black, WebColors.DarkGreen, Color.WHITE));
    final TablePanel tablePanel = new TablePanel(table);
    tablePanel.setBorder(BorderFactory.createTitledBorder(table.getRowCount() + " invalid records"));
    return tablePanel;
}
Also used : JComponent(javax.swing.JComponent) RecordDefinition(com.revolsys.record.schema.RecordDefinition) ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) HighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) JComponent(javax.swing.JComponent) Component(java.awt.Component) AndHighlightPredicate(org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate) HashMap(java.util.HashMap) Map(java.util.Map) RecordListTableModel(com.revolsys.swing.table.record.model.RecordListTableModel) ComponentAdapter(org.jdesktop.swingx.decorator.ComponentAdapter) RecordRowTable(com.revolsys.swing.table.record.RecordRowTable) Highlighter(org.jdesktop.swingx.decorator.Highlighter) ColorHighlighter(com.revolsys.swing.table.highlighter.ColorHighlighter) TablePanel(com.revolsys.swing.table.TablePanel)

Aggregations

ColorHighlighter (com.revolsys.swing.table.highlighter.ColorHighlighter)7 TablePanel (com.revolsys.swing.table.TablePanel)6 HighlightPredicate (org.jdesktop.swingx.decorator.HighlightPredicate)6 WebColors (com.revolsys.awt.WebColors)5 RecordRowTable (com.revolsys.swing.table.record.RecordRowTable)5 Color (java.awt.Color)5 Map (java.util.Map)5 AndHighlightPredicate (org.jdesktop.swingx.decorator.HighlightPredicate.AndHighlightPredicate)5 SwingUtil (com.revolsys.swing.SwingUtil)4 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)4 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)4 RecordRowTableModel (com.revolsys.swing.table.record.model.RecordRowTableModel)4 PropertyChangeEvent (java.beans.PropertyChangeEvent)4 JComponent (javax.swing.JComponent)4 ListSelectionModel (javax.swing.ListSelectionModel)4 ListSelectionEvent (javax.swing.event.ListSelectionEvent)4 TableColumnExt (org.jdesktop.swingx.table.TableColumnExt)4 Geometry (com.revolsys.geometry.model.Geometry)3 ClipboardUtil (com.revolsys.swing.dnd.ClipboardUtil)3 LayerRecordMenu (com.revolsys.swing.map.layer.record.LayerRecordMenu)3