use of com.revolsys.swing.table.BaseJTable in project com.revolsys.open by revolsys.
the class BackgroundTaskTableModel method newTaskTable.
private static BaseJTable newTaskTable() {
final BackgroundTaskTableModel model = new BackgroundTaskTableModel();
final BaseJTable table = new BaseJTable(model);
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
table.setAutoCreateColumnsFromModel(false);
for (int i = 0; i < model.getColumnCount(); i++) {
final TableColumnExt column = table.getColumnExt(i);
if (i == 1 || i == 2) {
column.setMinWidth(200);
column.setPreferredWidth(300);
} else {
column.setMinWidth(70);
column.setPreferredWidth(70);
column.setMaxWidth(70);
}
}
addHighlighter(table, model, StateValue.PENDING, WebColors.Pink, WebColors.DarkRed);
addHighlighter(table, model, StateValue.STARTED, WebColors.Ivory, WebColors.DarkOrange);
addHighlighter(table, model, StateValue.DONE, WebColors.HoneyDew, WebColors.Green);
return table;
}
use of com.revolsys.swing.table.BaseJTable in project com.revolsys.open by revolsys.
the class BackgroundTaskTableModel method addHighlighter.
private static void addHighlighter(final BaseJTable table, final BackgroundTaskTableModel model, final StateValue state, final Color background, final Color foreground) {
final HighlightPredicate predicate = (renderer, adapter) -> {
final int rowIndex = adapter.convertRowIndexToModel(adapter.row);
final BackgroundTask task = model.tasks.get(rowIndex);
return task.getTaskStatus() == state;
};
final ColorHighlighter highlighter = new ColorHighlighter(predicate, background, foreground, foreground, background);
table.addHighlighter(highlighter);
}
use of com.revolsys.swing.table.BaseJTable 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.BaseJTable in project com.revolsys.open by revolsys.
the class AbstractSingleRecordTableModel method newTable.
public static BaseJTable newTable(final AbstractSingleRecordTableModel model) {
final BaseJTable table = new BaseJTable(model);
table.setModel(model);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setAutoCreateColumnsFromModel(false);
table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
final SingleRecordTableCellRenderer cellRenderer = new SingleRecordTableCellRenderer();
final RecordTableCellEditor cellEditor = new RecordTableCellEditor(table);
cellEditor.setPopupMenu(model.getMenu()::newJPopupMenu);
final RecordDefinition recordDefinition = model.getRecordDefinition();
final List<String> allFieldNames = recordDefinition.getFieldNames();
int maxTitleWidth = 100;
for (final String fieldName : allFieldNames) {
final String title = model.getFieldTitle(fieldName);
final int titleWidth = Math.max(title.length(), fieldName.length()) * 8;
if (titleWidth > maxTitleWidth) {
maxTitleWidth = titleWidth;
}
}
final int columnCount = model.getColumnCount();
int columnWidth;
if (columnCount > 3) {
columnWidth = (740 - maxTitleWidth) / 2;
} else {
columnWidth = (740 - maxTitleWidth) / 2;
}
for (int i = 0; i < columnCount; i++) {
final TableColumnExt column = table.getColumnExt(i);
column.setCellRenderer(cellRenderer);
if (i == 0) {
column.setMinWidth(40);
column.setPreferredWidth(40);
column.setMaxWidth(40);
column.setComparator(new NumericComparator());
} else if (i == 1) {
column.setMinWidth(maxTitleWidth);
column.setPreferredWidth(maxTitleWidth);
column.setMaxWidth(maxTitleWidth);
} else {
column.setPreferredWidth(columnWidth);
if (i == 2) {
column.setCellEditor(cellEditor);
}
}
}
return table;
}
use of com.revolsys.swing.table.BaseJTable 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