use of com.revolsys.swing.table.TablePanel 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;
}
use of com.revolsys.swing.table.TablePanel in project com.revolsys.open by revolsys.
the class BackgroundTaskTableModel method newPanel.
public static TablePanel newPanel() {
final BaseJTable table = newTaskTable();
final TablePanel panel = new TablePanel(table);
final BackgroundTaskTableModel model = table.getTableModel();
final JToolBar toolBar = panel.getToolBar();
addCountLabel(toolBar, model, "Pending", "pendingCount", WebColors.Pink, WebColors.DarkRed);
addCountLabel(toolBar, model, "Running", "runningCount", WebColors.Ivory, WebColors.DarkOrange);
addCountLabel(toolBar, model, "Done", "doneCount", WebColors.HoneyDew, WebColors.Green);
return panel;
}
use of com.revolsys.swing.table.TablePanel in project com.revolsys.open by revolsys.
the class RecordListTableModel method newPanel.
public static TablePanel newPanel(final RecordDefinition recordDefinition, final Collection<? extends Record> records, final Collection<String> fieldNames) {
final RecordListTableModel model = new RecordListTableModel(recordDefinition, records, fieldNames);
final BaseJTable table = new RecordRowTable(model);
return new TablePanel(table);
}
Aggregations