use of org.eclipse.nebula.widgets.nattable.columnChooser.ColumnGroupEntry 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);
}
}
}
use of org.eclipse.nebula.widgets.nattable.columnChooser.ColumnGroupEntry in project nebula.widgets.nattable by eclipse.
the class ColumnChooserDialog method selectedTreeCollapsed.
private void selectedTreeCollapsed(TreeEvent event) {
TreeItem item = (TreeItem) event.item;
ColumnGroupEntry columnGroupEntry = (ColumnGroupEntry) item.getData();
fireGroupCollapsed(columnGroupEntry);
}
use of org.eclipse.nebula.widgets.nattable.columnChooser.ColumnGroupEntry in project nebula.widgets.nattable by eclipse.
the class ColumnChooserDialog method selectedTreeExpanded.
private void selectedTreeExpanded(TreeEvent event) {
TreeItem item = (TreeItem) event.item;
ColumnGroupEntry columnGroupEntry = (ColumnGroupEntry) item.getData();
fireGroupExpanded(columnGroupEntry);
}
use of org.eclipse.nebula.widgets.nattable.columnChooser.ColumnGroupEntry in project nebula.widgets.nattable by eclipse.
the class ColumnChooserDialog method expandAllLeaves.
public void expandAllLeaves() {
List<TreeItem> allLeaves = ArrayUtil.asList(this.selectedTree.getItems());
for (TreeItem leaf : allLeaves) {
if (isColumnGroupLeaf(leaf)) {
ColumnGroupEntry columnGroupEntry = (ColumnGroupEntry) leaf.getData();
leaf.setExpanded(!columnGroupEntry.isCollapsed());
}
}
}
Aggregations