use of org.jdesktop.swingx.table.TableColumnExt in project com.revolsys.open by revolsys.
the class BaseJTable method resizeColumnsToContent.
public void resizeColumnsToContent() {
final TableModel model = getModel();
final int columnCount = getColumnCount();
for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) {
final TableColumnExt column = getColumnExt(columnIndex);
final TableCellRenderer headerRenderer = column.getHeaderRenderer();
final String columnName = model.getColumnName(columnIndex);
int maxPreferedWidth = getPreferedSize(headerRenderer, String.class, columnName);
for (int rowIndex = 0; rowIndex < model.getRowCount(); rowIndex++) {
final Object value = model.getValueAt(rowIndex, columnIndex);
if (value != null) {
final TableCellRenderer renderer = column.getCellRenderer();
final Class<?> columnClass = model.getColumnClass(columnIndex);
final int width = getPreferedSize(renderer, columnClass, value);
if (width > maxPreferedWidth) {
maxPreferedWidth = width;
}
}
}
column.setMinWidth(maxPreferedWidth + 25);
column.setPreferredWidth(maxPreferedWidth + 25);
}
}
use of org.jdesktop.swingx.table.TableColumnExt in project cuba by cuba-platform.
the class DesktopAbstractTable method setColumnCollapsed.
@Override
public void setColumnCollapsed(Column column, boolean collapsed) {
if (!getColumnControlVisible()) {
return;
}
checkNotNullArgument(column, "column must be non null");
if (column.isCollapsed() != collapsed) {
column.setCollapsed(collapsed);
}
TableColumn tableColumn = getColumn(column);
if (tableColumn instanceof TableColumnExt) {
((TableColumnExt) tableColumn).setVisible(!collapsed);
}
}
use of org.jdesktop.swingx.table.TableColumnExt in project com.revolsys.open by revolsys.
the class BaseJTable method setMinWidth.
public void setMinWidth(final int columnIndex, final int width) {
final TableColumnExt column = getColumnExt(columnIndex);
column.setMinWidth(width);
}
use of org.jdesktop.swingx.table.TableColumnExt 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);
}
});
}
use of org.jdesktop.swingx.table.TableColumnExt 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;
}
Aggregations