use of com.revolsys.swing.table.BaseJTable in project com.revolsys.open by revolsys.
the class Log4jTableModel method newLogTable.
private static BaseJTable newLogTable() {
final Log4jTableModel model = new Log4jTableModel();
final BaseJTable table = new BaseJTable(model);
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
for (int i = 0; i < model.getColumnCount(); i++) {
final TableColumnExt column = table.getColumnExt(i);
if (i == 0) {
column.setMinWidth(180);
column.setPreferredWidth(180);
column.setMaxWidth(180);
} else if (i == 1) {
column.setMinWidth(80);
column.setPreferredWidth(80);
column.setMaxWidth(80);
} else if (i == 2) {
column.setMinWidth(200);
column.setPreferredWidth(400);
} else if (i == 3) {
column.setMinWidth(200);
column.setPreferredWidth(800);
}
}
table.setSortOrder(0, SortOrder.DESCENDING);
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(final MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) {
int row = table.rowAtPoint(e.getPoint());
row = table.convertRowIndexToModel(row);
if (row != -1) {
final LoggingEvent loggingEvent = model.getLoggingEvent(row);
LoggingEventPanel.showDialog(table, loggingEvent);
}
}
}
});
return table;
}
use of com.revolsys.swing.table.BaseJTable in project com.revolsys.open by revolsys.
the class RecordRowTable method getEventRecord.
public static <V extends Record> V getEventRecord() {
final BaseJTable eventTable = TablePanel.getEventTable();
if (eventTable instanceof RecordRowTable) {
final RecordRowTable table = (RecordRowTable) eventTable;
if (table != null) {
final int eventRow = TablePanel.getEventRow();
if (eventRow != -1) {
final RecordRowTableModel model = table.getTableModel();
final V record = model.getRecord(eventRow);
return record;
}
}
}
return null;
}
use of com.revolsys.swing.table.BaseJTable in project com.revolsys.open by revolsys.
the class SingleRecordTableModel method newTable.
public static BaseJTable newTable(final Record object, final boolean editable) {
final SingleRecordTableModel model = new SingleRecordTableModel(object, editable);
final BaseJTable table = newTable(model);
final JTableHeader tableHeader = table.getTableHeader();
tableHeader.setReorderingAllowed(false);
return table;
}
use of com.revolsys.swing.table.BaseJTable in project com.revolsys.open by revolsys.
the class LabelCountMapTableModel method newTable.
public BaseJTable newTable() {
final BaseJTable table = new BaseJTable(this);
setTable(table);
final TableColumnModel columnModel = table.getColumnModel();
for (int columnIndex = 0; columnIndex < getColumnCount(); columnIndex++) {
final int columnIndex1 = columnIndex;
final TableColumn column = columnModel.getColumn(columnIndex1);
setColumnWidth(columnIndex1, column);
}
table.setAutoCreateColumnsFromModel(false);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
final RowSorter<? extends TableModel> rowSorter = table.getRowSorter();
final SortKey sortKey = new SortKey(0, SortOrder.ASCENDING);
rowSorter.setSortKeys(Arrays.asList(sortKey));
table.addHighlighter(new ColorHighlighter((final Component renderer, final ComponentAdapter adapter) -> {
final int row = adapter.convertRowIndexToModel(adapter.row);
if (getValueAt(row, 0).equals(LabelCountMapTableModel.this.selectedLabel)) {
return true;
}
return false;
}, WebColors.ForestGreen, WebColors.Yellow, WebColors.DarkGreen, WebColors.Yellow));
table.addHighlighter(new ColorHighlighter((final Component renderer, final ComponentAdapter adapter) -> {
final int column = adapter.convertColumnIndexToModel(adapter.column);
final int row = adapter.convertRowIndexToModel(adapter.row);
if (getValueAt(row, 0).equals(LabelCountMapTableModel.this.selectedLabel)) {
if (getColumnName(column).equals(LabelCountMapTableModel.this.selectedCountName)) {
return true;
}
}
return false;
}, WebColors.Yellow, WebColors.DarkGreen, WebColors.Gold, WebColors.DarkGreen));
return table;
}
use of com.revolsys.swing.table.BaseJTable in project com.revolsys.open by revolsys.
the class LabelCountMapTableModel method addCountColumn.
private void addCountColumn(final CharSequence name) {
Invoke.later(() -> {
this.columnCount++;
final int columnIndex = 1 + this.countNames.indexOf(name);
fireTableStructureChanged();
final BaseJTable table = getTable();
if (table != null) {
final TableColumn column = new TableColumnExt(columnIndex);
setColumnWidth(columnIndex, column);
table.addColumn(column);
}
});
}
Aggregations