Search in sources :

Example 16 with ColumnGroup

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

the class ColumnGroupExpandCollapseLayer method getHiddenColumnIndexes.

@Override
public Collection<Integer> getHiddenColumnIndexes() {
    Collection<Integer> hiddenColumnIndexes = new HashSet<Integer>();
    IUniqueIndexLayer underlyingLayer = (IUniqueIndexLayer) getUnderlyingLayer();
    int underlyingColumnCount = underlyingLayer.getColumnCount();
    for (int i = 0; i < underlyingColumnCount; i++) {
        int columnIndex = underlyingLayer.getColumnIndexByPosition(i);
        for (ColumnGroupModel model : this.models) {
            ColumnGroup columnGroup = model.getColumnGroupByIndex(columnIndex);
            if (columnGroup != null && columnGroup.isCollapsed()) {
                if (!ColumnGroupUtils.isStaticOrFirstVisibleColumn(columnIndex, underlyingLayer, underlyingLayer, model)) {
                    hiddenColumnIndexes.add(Integer.valueOf(columnIndex));
                }
            }
        }
    }
    return hiddenColumnIndexes;
}
Also used : IUniqueIndexLayer(org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer) ColumnGroup(org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup) HashSet(java.util.HashSet)

Example 17 with ColumnGroup

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

the class ColumnGroupExpandCollapseLayer method isColumnIndexHidden.

// Expand/collapse
@Override
public boolean isColumnIndexHidden(int columnIndex) {
    IUniqueIndexLayer underlyingLayer = (IUniqueIndexLayer) getUnderlyingLayer();
    boolean isHiddeninUnderlyingLayer = ColumnGroupUtils.isColumnIndexHiddenInUnderLyingLayer(columnIndex, this, underlyingLayer);
    if (isHiddeninUnderlyingLayer)
        return true;
    for (ColumnGroupModel model : this.models) {
        ColumnGroup columnGroup = model.getColumnGroupByIndex(columnIndex);
        boolean isCollapsedAndStaticColumn = columnGroup != null && columnGroup.isCollapsed() && !ColumnGroupUtils.isStaticOrFirstVisibleColumn(columnIndex, underlyingLayer, underlyingLayer, model);
        if (isCollapsedAndStaticColumn)
            return true;
    }
    return false;
}
Also used : IUniqueIndexLayer(org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer) ColumnGroup(org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup)

Example 18 with ColumnGroup

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

the class ColumnGroupGroupHeaderLayer 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);
    if (columnGroup == null) {
        // part of a group in this level
        return this.columnGroupHeaderLayer.getStartPositionOfGroup(columnPosition);
    }
    int leastPossibleStartPositionOfGroup = columnPosition - columnGroup.getSize();
    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)

Example 19 with ColumnGroup

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

the class ColumnGroupGroupHeaderLayer 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);
    if (columnGroup == null) {
        // part of a group in this level
        return this.columnGroupHeaderLayer.getColumnSpan(columnPosition);
    }
    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 20 with ColumnGroup

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

the class ColumnGroupGroupHeaderLayer method getDataValueByPosition.

@Override
public Object getDataValueByPosition(int columnPosition, int rowPosition) {
    int columnIndex = getColumnIndexByPosition(columnPosition);
    ColumnGroup columnGroup = this.model.getColumnGroupByIndex(columnIndex);
    if (rowPosition == 0) {
        if (this.model.isPartOfAGroup(columnIndex)) {
            return columnGroup.getName();
        }
    } else {
        rowPosition--;
    }
    return this.columnGroupHeaderLayer.getDataValueByPosition(columnPosition, rowPosition);
}
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