Search in sources :

Example 6 with TableColumnExt

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);
    }
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) TableColumnExt(org.jdesktop.swingx.table.TableColumnExt) TableModel(javax.swing.table.TableModel)

Example 7 with TableColumnExt

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);
    }
}
Also used : TableColumnExt(org.jdesktop.swingx.table.TableColumnExt) TableColumn(javax.swing.table.TableColumn)

Example 8 with TableColumnExt

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);
}
Also used : TableColumnExt(org.jdesktop.swingx.table.TableColumnExt)

Example 9 with TableColumnExt

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);
        }
    });
}
Also used : TableColumnExt(org.jdesktop.swingx.table.TableColumnExt) BaseJTable(com.revolsys.swing.table.BaseJTable) TableColumn(javax.swing.table.TableColumn)

Example 10 with TableColumnExt

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;
}
Also used : TableColumnExt(org.jdesktop.swingx.table.TableColumnExt) BaseJTable(com.revolsys.swing.table.BaseJTable)

Aggregations

TableColumnExt (org.jdesktop.swingx.table.TableColumnExt)11 TableColumn (javax.swing.table.TableColumn)5 BaseJTable (com.revolsys.swing.table.BaseJTable)4 Element (org.dom4j.Element)3 JXTable (org.jdesktop.swingx.JXTable)3 Table (com.haulmont.cuba.gui.components.Table)2 MetaClass (com.haulmont.chile.core.model.MetaClass)1 MetaProperty (com.haulmont.chile.core.model.MetaProperty)1 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)1 RowSorterImpl (com.haulmont.cuba.desktop.gui.data.RowSorterImpl)1 FocusableTable (com.haulmont.cuba.desktop.sys.vcl.FocusableTable)1 Action (com.haulmont.cuba.gui.components.Action)1 CollectionDsActionsNotifier (com.haulmont.cuba.gui.data.impl.CollectionDsActionsNotifier)1 WeakCollectionChangeListener (com.haulmont.cuba.gui.data.impl.WeakCollectionChangeListener)1 WeakItemPropertyChangeListener (com.haulmont.cuba.gui.data.impl.WeakItemPropertyChangeListener)1 NumericComparator (com.revolsys.comparator.NumericComparator)1 RecordDefinition (com.revolsys.record.schema.RecordDefinition)1 RecordTableCellEditor (com.revolsys.swing.table.record.editor.RecordTableCellEditor)1 SingleRecordTableCellRenderer (com.revolsys.swing.table.record.renderer.SingleRecordTableCellRenderer)1 MouseAdapter (java.awt.event.MouseAdapter)1