Search in sources :

Example 6 with ColumnGroup

use of org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup in project nebula.widgets.nattable by eclipse.

the class ColumnGroupGroupHeaderLayer 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 {
        if (rowPosition != 0) {
            rowPosition--;
        }
        return this.columnGroupHeaderLayer.getConfigLabelsByPosition(columnPosition, rowPosition);
    }
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) ColumnGroup(org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup)

Example 7 with ColumnGroup

use of org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup in project nebula.widgets.nattable by eclipse.

the class ColumnGroupGroupHeaderLayer method setGroupUnbreakable.

/**
 * @see ColumnGroup#setUnbreakable(boolean)
 */
public void setGroupUnbreakable(int columnIndex) {
    ColumnGroup columnGroup = this.model.getColumnGroupByIndex(columnIndex);
    columnGroup.setUnbreakable(true);
}
Also used : ColumnGroup(org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup)

Example 8 with ColumnGroup

use of org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup in project nebula.widgets.nattable by eclipse.

the class ColumnGroupGroupHeaderLayer method setGroupAsCollapsed.

public void setGroupAsCollapsed(int columnIndex) {
    ColumnGroup columnGroup = this.model.getColumnGroupByIndex(columnIndex);
    columnGroup.setCollapsed(true);
}
Also used : ColumnGroup(org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup)

Example 9 with ColumnGroup

use of org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup in project nebula.widgets.nattable by eclipse.

the class ColumnGroupHeaderLayer method getColumnSpan.

/**
 * Calculates the span of a cell in a Column Group. Takes into account
 * collapsing and hidden columns in the group.
 *
 * @param columnPosition
 *            position of any column belonging to the group
 *
 * @since 1.6
 */
public int getColumnSpan(int columnPosition) {
    int columnIndex = getColumnIndexByPosition(columnPosition);
    ColumnGroup columnGroup = this.model.getColumnGroupByIndex(columnIndex);
    int sizeOfGroup = columnGroup.getSize();
    if (columnGroup.isCollapsed()) {
        int sizeOfStaticColumns = columnGroup.getStaticColumnIndexes().size();
        if (sizeOfStaticColumns == 0) {
            return 1;
        } else {
            sizeOfGroup = sizeOfStaticColumns;
        }
    }
    int startPositionOfGroup = getStartPositionOfGroup(columnPosition);
    int endPositionOfGroup = startPositionOfGroup + sizeOfGroup;
    List<Integer> columnIndexesInGroup = columnGroup.getMembers();
    for (int i = startPositionOfGroup; i < endPositionOfGroup; i++) {
        int index = getColumnIndexByPosition(i);
        if (!columnIndexesInGroup.contains(Integer.valueOf(index))) {
            sizeOfGroup--;
        }
    }
    return sizeOfGroup;
}
Also used : ColumnGroup(org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup)

Example 10 with ColumnGroup

use of org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup in project nebula.widgets.nattable by eclipse.

the class ColumnGroupHeaderLayer method getStartPositionOfGroup.

/**
 * Figures out the start position of the group.
 *
 * @param columnPosition
 *            of any column belonging to the group
 * @return first position of the column group
 *
 * @since 1.6
 */
public int getStartPositionOfGroup(int columnPosition) {
    int bodyColumnIndex = getColumnIndexByPosition(columnPosition);
    ColumnGroup columnGroup = this.model.getColumnGroupByIndex(bodyColumnIndex);
    int leastPossibleStartPositionOfGroup = columnPosition - (columnGroup.getSize() - 1);
    int i = 0;
    for (i = leastPossibleStartPositionOfGroup; i < columnPosition; i++) {
        if (ColumnGroupUtils.isInTheSameGroup(getColumnIndexByPosition(i), bodyColumnIndex, this.model)) {
            break;
        }
    }
    return i;
}
Also used : ColumnGroup(org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup)

Aggregations

ColumnGroup (org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup)27 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 ColumnEntry (org.eclipse.nebula.widgets.nattable.columnChooser.ColumnEntry)3 ColumnGroupEntry (org.eclipse.nebula.widgets.nattable.columnChooser.ColumnGroupEntry)3 List (java.util.List)2 IUniqueIndexLayer (org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer)2 LabelStack (org.eclipse.nebula.widgets.nattable.layer.LabelStack)2 Point (org.eclipse.swt.graphics.Point)2 HashSet (java.util.HashSet)1 ColumnRenameDialog (org.eclipse.nebula.widgets.nattable.columnRename.ColumnRenameDialog)1 ColumnGroupModel (org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel)1 HideColumnPositionsEvent (org.eclipse.nebula.widgets.nattable.hideshow.event.HideColumnPositionsEvent)1 ShowColumnPositionsEvent (org.eclipse.nebula.widgets.nattable.hideshow.event.ShowColumnPositionsEvent)1 ILayerEvent (org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent)1 ColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand)1 MultiColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand)1 MoveDirectionEnum (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.MoveDirectionEnum)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1