use of org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup in project nebula.widgets.nattable by eclipse.
the class ColumnGroupModelTest method shouldNotRemoveFromAnUnbreakableGroup.
@Test
public void shouldNotRemoveFromAnUnbreakableGroup() throws Exception {
ColumnGroup columnGroup = this.model.getColumnGroupByIndex(7);
columnGroup.setUnbreakable(true);
assertFalse(columnGroup.removeColumn(7));
}
use of org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup in project nebula.widgets.nattable by eclipse.
the class ColumnGroupModelTest method noColumnGroup.
@Test
public void noColumnGroup() throws Exception {
ColumnGroup columnGroup = this.model.getColumnGroupByIndex(100);
assertNull(columnGroup);
}
use of org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup in project nebula.widgets.nattable by eclipse.
the class ColumnGroupReorderLayerTest method shouldDragFirstCellRightAndAddColumnToGroup.
@Test
public void shouldDragFirstCellRightAndAddColumnToGroup() {
ColumnGroup columnGroup = this.modelFixture.getColumnGroupByIndex(0);
columnGroup.removeColumn(0);
assertEquals(1, getColumnIndexesInGroup(1).size());
this.modelFixture.insertColumnIndexes(ColumnGroupModelFixture.TEST_GROUP_1, 2);
assertEquals(2, getColumnIndexesInGroup(1).size());
// Drag right into group
ColumnReorderCommand command = new ColumnReorderCommand(this.layer, 0, 2);
this.layer.doCommand(command);
final int fromColumnIndex = 0;
final int toColumnIndex = 2;
assertEquals(ColumnGroupModelFixture.TEST_GROUP_1, this.modelFixture.getColumnGroupByIndex(fromColumnIndex).getName());
assertEquals(ColumnGroupModelFixture.TEST_GROUP_1, this.modelFixture.getColumnGroupByIndex(toColumnIndex).getName());
assertEquals(ColumnGroupModelFixture.TEST_GROUP_1, this.modelFixture.getColumnGroupByIndex(2).getName());
assertEquals(3, getColumnIndexesInGroup(fromColumnIndex).size());
}
use of org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup in project nebula.widgets.nattable by eclipse.
the class ColumnChooserDialog method moveSelectedDown.
/**
* Move columns <i>down</i> in the 'Selected' Tree (Right)
*/
@SuppressWarnings("boxing")
protected void moveSelectedDown() {
if (isAnyLeafSelected(this.selectedTree)) {
if (!isLastLeafSelected(this.selectedTree)) {
List<ColumnEntry> selectedColumnEntries = getSelectedColumnEntriesIncludingNested(this.selectedTree);
List<ColumnGroupEntry> selectedColumnGroupEntries = getSelectedColumnGroupEntries(this.selectedTree);
List<Integer> allSelectedPositions = merge(selectedColumnEntries, selectedColumnGroupEntries);
// Group continuous positions
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);
// Position of last element in list
int lastListIndex = groupedPositions.size() - 1;
int lastPositionInGroup = groupedPositions.get(lastListIndex);
// Column entry
ColumnEntry columnEntry = getNextColumnEntryForPosition(this.selectedTree, lastPositionInGroup);
int columnEntryIndex = columnEntry.getIndex();
// Next Column Entry
ColumnEntry nextColumnEntry = getNextColumnEntryForPosition(this.selectedTree, lastPositionInGroup + 1);
// is selected
if (nextColumnEntry == null) {
toPositions.add(lastPositionInGroup);
} else {
int nextColumnEntryIndex = nextColumnEntry.getIndex();
if (columnGroupMoved) {
// move past it.
if (this.columnGroupModel != null && this.columnGroupModel.isPartOfAGroup(nextColumnEntryIndex)) {
ColumnGroup nextColumnGroup = this.columnGroupModel.getColumnGroupByIndex(nextColumnEntryIndex);
toPositions.add(lastPositionInGroup + nextColumnGroup.getSize());
} else {
toPositions.add(lastPositionInGroup + 1);
}
} else {
// move down i.e. out of the group
if (this.columnGroupModel != null && this.columnGroupModel.isPartOfAnUnbreakableGroup(columnEntryIndex) && !ColumnGroupUtils.isInTheSameGroup(columnEntryIndex, nextColumnEntryIndex, this.columnGroupModel)) {
return;
}
// move past it
if (this.columnGroupModel != null && this.columnGroupModel.isPartOfAnUnbreakableGroup(nextColumnEntryIndex) && !this.columnGroupModel.isPartOfAGroup(columnEntryIndex) && !ColumnGroupUtils.isInTheSameGroup(columnEntryIndex, nextColumnEntryIndex, this.columnGroupModel)) {
ColumnGroup nextColumnGroup = this.columnGroupModel.getColumnGroupByIndex(nextColumnEntryIndex);
toPositions.add(lastPositionInGroup + nextColumnGroup.getSize());
} else {
toPositions.add(lastPositionInGroup + 1);
}
}
}
}
fireItemsMoved(MoveDirectionEnum.DOWN, selectedColumnGroupEntries, selectedColumnEntries, postionsGroupedByContiguous, toPositions);
}
}
}
use of org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup in project nebula.widgets.nattable by eclipse.
the class ColumnChooserDialog method populateModel.
/**
* Populates the tree. Looks for column group and adds an extra node for the
* group. The column leaves carry a {@link ColumnEntry} object as data. The
* column group leaves carry a {@link ColumnGroupEntry} object as data.
*/
private void populateModel(Tree tree, List<ColumnEntry> columnEntries, ColumnGroupModel columnGroupModel) {
this.columnGroupModel = columnGroupModel;
for (ColumnEntry columnEntry : columnEntries) {
TreeItem treeItem;
int columnEntryIndex = columnEntry.getIndex().intValue();
// Create a node for the column group - if needed
if (columnGroupModel != null && columnGroupModel.isPartOfAGroup(columnEntryIndex)) {
ColumnGroup columnGroup = columnGroupModel.getColumnGroupByIndex(columnEntryIndex);
String columnGroupName = columnGroup.getName();
TreeItem columnGroupTreeItem = getTreeItem(tree, columnGroupName);
if (columnGroupTreeItem == null) {
columnGroupTreeItem = new TreeItem(tree, SWT.NONE);
ColumnGroupEntry columnGroupEntry = new ColumnGroupEntry(columnGroupName, columnEntry.getPosition(), columnEntry.getIndex(), columnGroup.isCollapsed());
columnGroupTreeItem.setData(columnGroupEntry);
columnGroupTreeItem.setText(columnGroupEntry.getLabel());
}
treeItem = new TreeItem(columnGroupTreeItem, SWT.NONE);
} else {
treeItem = new TreeItem(tree, SWT.NONE);
}
treeItem.setText(columnEntry.getLabel());
treeItem.setData(columnEntry);
}
}
Aggregations