Search in sources :

Example 1 with ResizableHeader

use of org.ovirt.engine.ui.common.widget.table.header.ResizableHeader in project ovirt-engine by oVirt.

the class ColumnResizeCellTable method setColumnWidth.

public void setColumnWidth(Column<T, ?> column, String width, boolean overridePersist) {
    boolean columnVisible = isColumnVisible(column);
    if (columnVisible) {
        columnWidthMap.put(column, width);
    } else {
        width = HIDDEN_WIDTH;
    }
    // Update header cell visibility
    TableCellElement headerCell = getHeaderCell(getElement().cast(), getColumnIndex(column));
    if (headerCell != null) {
        headerCell.getStyle().setVisibility(columnVisible ? Visibility.VISIBLE : Visibility.HIDDEN);
    }
    // Prevent resizing of "hidden" (1px wide) columns
    if (columnResizingEnabled) {
        Header<?> header = getHeader(getColumnIndex(column));
        if (header instanceof ResizableHeader) {
            ((ResizableHeader<?>) header).setResizeEnabled(columnVisible);
        }
    }
    if (columnResizePersistenceEnabled && !overridePersist && columnVisible) {
        String persistedWidth = readColumnWidth(column);
        if (persistedWidth != null) {
            width = persistedWidth;
        }
    }
    super.setColumnWidth(column, width);
    column.setCellStyleNames(columnVisible ? GRID_VISIBLE : GRID_HIDDEN);
    int index = getColumnIndex(column);
    if (index >= 0) {
        removeColumnStyleName(index, columnVisible ? GRID_HIDDEN : GRID_VISIBLE);
        addColumnStyleName(index, columnVisible ? GRID_VISIBLE : GRID_HIDDEN);
    }
    redraw();
}
Also used : ResizableHeader(org.ovirt.engine.ui.common.widget.table.header.ResizableHeader) TableCellElement(com.google.gwt.dom.client.TableCellElement)

Aggregations

TableCellElement (com.google.gwt.dom.client.TableCellElement)1 ResizableHeader (org.ovirt.engine.ui.common.widget.table.header.ResizableHeader)1