Search in sources :

Example 61 with LabelStack

use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.

the class RowHeaderLayer method getConfigLabelsByPosition.

@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
    LabelStack labelStack = super.getConfigLabelsByPosition(columnPosition, rowPosition);
    if (this.selectionLayer.length > 0) {
        final int selectionLayerRowPosition = LayerUtil.convertRowPosition(this, rowPosition, this.selectionLayer[0]);
        boolean fullySelected = true;
        for (SelectionLayer sl : this.selectionLayer) {
            if (!sl.isRowPositionFullySelected(selectionLayerRowPosition)) {
                fullySelected = false;
                break;
            }
        }
        if (fullySelected) {
            labelStack.addLabel(SelectionStyleLabels.ROW_FULLY_SELECTED_STYLE);
        }
    }
    return labelStack;
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)

Example 62 with LabelStack

use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.

the class ColumnGroupHeaderLayer method getConfigLabelsByPosition.

@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
    int columnIndex = getColumnIndexByPosition(columnPosition);
    if (rowPosition == 0 && this.model.isPartOfAGroup(columnIndex)) {
        LabelStack stack = new LabelStack();
        if (getConfigLabelAccumulator() != null) {
            getConfigLabelAccumulator().accumulateConfigLabels(stack, columnPosition, rowPosition);
        }
        stack.addLabel(GridRegion.COLUMN_GROUP_HEADER);
        if (this.model.isPartOfACollapseableGroup(columnIndex)) {
            ColumnGroup group = this.model.getColumnGroupByIndex(columnIndex);
            if (group.isCollapsed()) {
                stack.addLabelOnTop(DefaultColumnGroupHeaderLayerConfiguration.GROUP_COLLAPSED_CONFIG_TYPE);
            } else {
                stack.addLabelOnTop(DefaultColumnGroupHeaderLayerConfiguration.GROUP_EXPANDED_CONFIG_TYPE);
            }
        }
        return stack;
    } else {
        return this.columnHeaderLayer.getConfigLabelsByPosition(columnPosition, rowPosition);
    }
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) ColumnGroup(org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup)

Example 63 with LabelStack

use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.

the class RowGroupHeaderLayer method getConfigLabelsByPosition.

@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
    int rowIndex = getRowIndexByPosition(rowPosition);
    if (columnPosition == 0 && RowGroupUtils.isPartOfAGroup(this.model, rowIndex)) {
        LabelStack stack = new LabelStack(GridRegion.ROW_GROUP_HEADER);
        IRowGroup<T> group = RowGroupUtils.getRowGroupForRowIndex(this.model, rowIndex);
        if (RowGroupUtils.isCollapsed(this.model, group)) {
            stack.addLabelOnTop(DefaultRowGroupHeaderLayerConfiguration.GROUP_COLLAPSED_CONFIG_TYPE);
        } else {
            stack.addLabelOnTop(DefaultRowGroupHeaderLayerConfiguration.GROUP_EXPANDED_CONFIG_TYPE);
        }
        List<Integer> selectedRowIndexes = convertToRowIndexes(this.selectionLayer.getFullySelectedRowPositions());
        if (selectedRowIndexes.contains(rowIndex)) {
            stack.addLabelOnTop(SelectionStyleLabels.ROW_FULLY_SELECTED_STYLE);
        }
        return stack;
    } else {
        return this.rowHeaderLayer.getConfigLabelsByPosition(columnPosition - 1, rowPosition);
    }
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack)

Example 64 with LabelStack

use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.

the class ColumnHeaderLayer method getConfigLabelsByPosition.

@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
    LabelStack labelStack = super.getConfigLabelsByPosition(columnPosition, rowPosition);
    if (this.selectionLayer.length > 0) {
        final int selectionLayerColumnPosition = LayerUtil.convertColumnPosition(this, columnPosition, this.selectionLayer[0]);
        boolean fullySelected = true;
        for (SelectionLayer sl : this.selectionLayer) {
            if (!sl.isColumnPositionFullySelected(selectionLayerColumnPosition)) {
                fullySelected = false;
                break;
            }
        }
        if (fullySelected) {
            labelStack.addLabel(SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE);
        }
    }
    return labelStack;
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)

Example 65 with LabelStack

use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.

the class HierarchicalTreeLayer method getConfigLabelsByPosition.

@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
    // for level header we do not need to call super
    if (isLevelHeaderColumn(columnPosition)) {
        return new LabelStack(LEVEL_HEADER_CELL);
    }
    LabelStack configLabels = super.getConfigLabelsByPosition(columnPosition, rowPosition);
    if (isTreeColumn(columnPosition)) {
        configLabels.addLabelOnTop(TreeLayer.TREE_COLUMN_CELL);
        ILayerCell cell = getCellByPosition(columnPosition, rowPosition);
        if (cell != null) {
            // always level 0 as we do not show all levels in one column and
            // therefore we do not need indentation
            configLabels.addLabelOnTop(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0);
            if (cell.getRowSpan() > 1) {
                configLabels.addLabelOnTop(DefaultTreeLayerConfiguration.TREE_EXPANDED_CONFIG_TYPE);
            } else if (isCollapsed(columnPosition, rowPosition)) {
                configLabels.addLabelOnTop(DefaultTreeLayerConfiguration.TREE_COLLAPSED_CONFIG_TYPE);
            } else {
                // we get here for example if handleCollapsedChildren is
                // false and the parent is collapsed
                // we can not show a handle to expand/collapse the child if
                // the parent is collapsed
                configLabels.addLabelOnTop(DefaultTreeLayerConfiguration.TREE_LEAF_CONFIG_TYPE);
            }
        }
    }
    if (this.handleCollapsedChildren) {
        boolean directLevelHeader = true;
        boolean headerCollapsed = false;
        for (int i = this.levelHeaderPositions.length - 1; i >= 0; i--) {
            int pos = this.levelHeaderPositions[i];
            if (pos < columnPosition) {
                int firstLevelColumnPosition = pos + (isShowTreeLevelHeader() ? 1 : 0);
                // the first header we find is the direct one
                if (directLevelHeader) {
                    directLevelHeader = false;
                } else if (isCollapsed(firstLevelColumnPosition, rowPosition)) {
                    headerCollapsed = true;
                }
            }
        }
        if (headerCollapsed) {
            configLabels.addLabelOnTop(COLLAPSED_CHILD);
            // remove tree labels to avoid specialized handling and
            // rendering
            configLabels.removeLabel(TreeLayer.TREE_COLUMN_CELL);
            configLabels.removeLabel(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + 0);
            configLabels.removeLabel(DefaultTreeLayerConfiguration.TREE_EXPANDED_CONFIG_TYPE);
            configLabels.removeLabel(DefaultTreeLayerConfiguration.TREE_COLLAPSED_CONFIG_TYPE);
            configLabels.removeLabel(DefaultTreeLayerConfiguration.TREE_LEAF_CONFIG_TYPE);
        }
    }
    return configLabels;
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)

Aggregations

LabelStack (org.eclipse.nebula.widgets.nattable.layer.LabelStack)80 Test (org.junit.Test)30 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)14 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)13 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)11 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)10 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)10 HashMap (java.util.HashMap)9 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)9 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)9 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 GridLayout (org.eclipse.swt.layout.GridLayout)9 Composite (org.eclipse.swt.widgets.Composite)9 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)8 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)8 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)8 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)8 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)8