Search in sources :

Example 11 with ColumnGroup

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

the class ColumnGroupHeaderLayer 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 12 with ColumnGroup

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

the class ColumnGroupUtils method getVisibleIndexesToTheRight.

/**
 * Inclusive of the columnIndex passed as the parameter.
 */
public static List<Integer> getVisibleIndexesToTheRight(int columnIndex, ILayer layer, IUniqueIndexLayer underlyingLayer, ColumnGroupModel model) {
    ColumnGroup columnGroup = model.getColumnGroupByIndex(columnIndex);
    if (columnGroup.isCollapsed()) {
        return Collections.emptyList();
    }
    List<Integer> columnIndexesInGroup = columnGroup.getMembers();
    int columnPosition = underlyingLayer.getColumnPositionByIndex(columnIndex);
    List<Integer> visibleColumnIndexesOnRight = new ArrayList<Integer>();
    for (Integer currentIndex : columnIndexesInGroup) {
        int currentPosition = underlyingLayer.getColumnPositionByIndex(currentIndex.intValue());
        if (!isColumnIndexHiddenInUnderLyingLayer(currentIndex.intValue(), layer, underlyingLayer) && currentPosition >= columnPosition) {
            visibleColumnIndexesOnRight.add(currentIndex);
        }
    }
    return visibleColumnIndexesOnRight;
}
Also used : ArrayList(java.util.ArrayList) ColumnGroup(org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup)

Example 13 with ColumnGroup

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

the class ColumnGroupUtils method isInTheSameGroup.

public static boolean isInTheSameGroup(int fromColumnIndex, int toColumnIndex, ColumnGroupModel model) {
    ColumnGroup fromColumnGroup = model.getColumnGroupByIndex(fromColumnIndex);
    ColumnGroup toColumnGroup = model.getColumnGroupByIndex(toColumnIndex);
    return fromColumnGroup != null && toColumnGroup != null && fromColumnGroup == toColumnGroup;
}
Also used : ColumnGroup(org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup)

Example 14 with ColumnGroup

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

the class ColumnGroupModelTest method removeColumnFromGroup.

@Test
public void removeColumnFromGroup() {
    ColumnGroup columnGroup = this.model.getColumnGroupByIndex(12);
    List<Integer> columnIndexesInGroup = columnGroup.getMembers();
    assertTrue(columnIndexesInGroup.contains(12));
    assertTrue(columnGroup.removeColumn(12));
    columnGroup = this.model.getColumnGroupByIndex(13);
    columnIndexesInGroup = columnGroup.getMembers();
    assertEquals(1, columnIndexesInGroup.size());
    assertTrue(columnGroup.removeColumn(13));
    assertFalse(this.model.isPartOfAGroup(12));
}
Also used : ColumnGroup(org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup) Test(org.junit.Test)

Example 15 with ColumnGroup

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

the class ColumnChooserDialog method moveSelectedUp.

/**
 * Move columns <i>up</i> in the 'Selected' Tree (Right)
 */
@SuppressWarnings("boxing")
protected void moveSelectedUp() {
    if (isAnyLeafSelected(this.selectedTree)) {
        if (!isFirstLeafSelected(this.selectedTree)) {
            List<ColumnEntry> selectedColumnEntries = getSelectedColumnEntriesIncludingNested(this.selectedTree);
            List<ColumnGroupEntry> selectedColumnGroupEntries = getSelectedColumnGroupEntries(this.selectedTree);
            List<Integer> allSelectedPositions = merge(selectedColumnEntries, selectedColumnGroupEntries);
            // Group continuous positions. If a column group moves, a bunch
            // of 'from' positions move to a single 'to' position
            List<List<Integer>> postionsGroupedByContiguous = PositionUtil.getGroupedByContiguous(allSelectedPositions);
            List<Integer> toPositions = new ArrayList<Integer>();
            // Set destination positions
            for (List<Integer> groupedPositions : postionsGroupedByContiguous) {
                // Do these contiguous positions contain a column group ?
                boolean columnGroupMoved = columnGroupMoved(groupedPositions, selectedColumnGroupEntries);
                // If already at first position do not move
                int firstPositionInGroup = groupedPositions.get(0);
                // Column entry
                ColumnEntry columnEntry = getPreviousColumnEntryForPosition(this.selectedTree, firstPositionInGroup);
                int columnEntryIndex = columnEntry.getIndex();
                // Previous column entry
                ColumnEntry previousColumnEntry = getPreviousColumnEntryForPosition(this.selectedTree, firstPositionInGroup - 1);
                // tree is selected
                if (previousColumnEntry == null) {
                    toPositions.add(firstPositionInGroup);
                } else {
                    int previousColumnEntryIndex = previousColumnEntry.getIndex();
                    if (columnGroupMoved) {
                        // move above it.
                        if (this.columnGroupModel != null && this.columnGroupModel.isPartOfAGroup(previousColumnEntryIndex)) {
                            ColumnGroup previousColumnGroup = this.columnGroupModel.getColumnGroupByIndex(previousColumnEntryIndex);
                            toPositions.add(firstPositionInGroup - previousColumnGroup.getSize());
                        } else {
                            toPositions.add(firstPositionInGroup - 1);
                        }
                    } else {
                        // can't move up i.e. out of the group
                        if (this.columnGroupModel != null && this.columnGroupModel.isPartOfAnUnbreakableGroup(columnEntryIndex) && !ColumnGroupUtils.isInTheSameGroup(columnEntryIndex, previousColumnEntryIndex, this.columnGroupModel)) {
                            return;
                        }
                        // move above it
                        if (this.columnGroupModel != null && this.columnGroupModel.isPartOfAnUnbreakableGroup(previousColumnEntryIndex) && !this.columnGroupModel.isPartOfAGroup(columnEntryIndex) && !ColumnGroupUtils.isInTheSameGroup(columnEntryIndex, previousColumnEntryIndex, this.columnGroupModel)) {
                            ColumnGroup previousColumnGroup = this.columnGroupModel.getColumnGroupByIndex(previousColumnEntryIndex);
                            toPositions.add(firstPositionInGroup - previousColumnGroup.getSize());
                        } else {
                            toPositions.add(firstPositionInGroup - 1);
                        }
                    }
                }
            }
            fireItemsMoved(MoveDirectionEnum.UP, selectedColumnGroupEntries, selectedColumnEntries, postionsGroupedByContiguous, toPositions);
        }
    }
}
Also used : ColumnGroupEntry(org.eclipse.nebula.widgets.nattable.columnChooser.ColumnGroupEntry) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ColumnEntry(org.eclipse.nebula.widgets.nattable.columnChooser.ColumnEntry) 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