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);
}
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;
}
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;
}
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));
}
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);
}
}
}
Aggregations