use of org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupReorderLayerTest method shouldNotAllowMultiReorderIntoAnUnbreakableGroup.
@Test
public void shouldNotAllowMultiReorderIntoAnUnbreakableGroup() {
setGroupUnBreakable(11);
MultiColumnReorderCommand reorderCommand = new MultiColumnReorderCommand(this.layer, Arrays.asList(5, 6), 11);
this.layer.doCommand(reorderCommand);
this.modelFixture.assertUnchanged();
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupReorderLayerTest method reorderMultipleColums.
@Test
public void reorderMultipleColums() {
// One of the 'from' column is already in the destination group
MultiColumnReorderCommand reorderCommand = new MultiColumnReorderCommand(this.layer, Arrays.asList(9, 10), 11);
this.layer.doCommand(reorderCommand);
assertEquals(4, getColumnIndexesInGroup(12).size());
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupReorderLayerTest method shouldRemoveFromAGroupWhileReorderingMultipleColumns.
@Test
public void shouldRemoveFromAGroupWhileReorderingMultipleColumns() {
MultiColumnReorderCommand reorderCommand = new MultiColumnReorderCommand(this.layer, Arrays.asList(10, 11), 5);
this.layer.doCommand(reorderCommand);
assertEquals(1, getColumnIndexesInGroup(12).size());
assertTrue(getColumnIndexesInGroup(12).contains(Integer.valueOf(12)));
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class ReorderColumnEventTest method reorderMultipleNotConsecutiveColumnsInHiddenState.
@Test
public void reorderMultipleNotConsecutiveColumnsInHiddenState() {
DefaultBodyLayerStack underlyingLayer = new DefaultBodyLayerStack(new DataLayerFixture(10, 10, 100, 20));
NatTableFixture natTableFixture = new NatTableFixture(underlyingLayer, 1000, 400, true);
// Add listener
LayerListenerFixture listenerFixture = new LayerListenerFixture();
natTableFixture.addLayerListener(listenerFixture);
assertEquals(10, natTableFixture.getColumnCount());
// hide some columns
natTableFixture.doCommand(new MultiColumnHideCommand(natTableFixture, new int[] { 2, 5, 8 }));
assertEquals(7, natTableFixture.getColumnCount());
List<Integer> columnToMove = Arrays.asList(3, 4, 6, 7);
int destinationPosition = 0;
natTableFixture.doCommand(new MultiColumnReorderCommand(underlyingLayer.getColumnReorderLayer(), columnToMove, destinationPosition));
// verify the event
ColumnReorderEvent event = (ColumnReorderEvent) listenerFixture.getReceivedEvent(ColumnReorderEvent.class);
assertNotNull(event);
assertTrue(StructuralChangeEventHelper.isReorder(event.getColumnDiffs()));
assertEquals(7, natTableFixture.getColumnCount());
assertEquals(0, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(3));
assertEquals(1, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(4));
assertEquals(2, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(6));
assertEquals(3, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(7));
assertEquals(4, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(0));
assertEquals(5, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(1));
assertEquals(6, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(2));
assertEquals(7, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(5));
assertEquals(8, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(8));
assertEquals(9, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(9));
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class ChooseColumnsFromCategoriesCommandHandler method itemsMoved.
/**
* Moves the columns up or down by firing commands on the dialog.
*
* Individual columns are moved using the {@link ColumnReorderCommand}
* Contiguously selected columns are moved using the
* {@link MultiColumnReorderCommand}
*
* @param direction
* the direction to move
* @param selectedPositions
* the column positions to move
*/
@Override
public void itemsMoved(MoveDirectionEnum direction, List<Integer> selectedPositions) {
List<List<Integer>> fromPositions = PositionUtil.getGroupedByContiguous(selectedPositions);
List<Integer> toPositions = getDestinationPositions(direction, fromPositions);
for (int i = 0; i < fromPositions.size(); i++) {
boolean multipleColumnsMoved = fromPositions.get(i).size() > 1;
ILayerCommand command = null;
if (!multipleColumnsMoved) {
int fromPosition = fromPositions.get(i).get(0).intValue();
int toPosition = toPositions.get(i);
command = new ColumnReorderCommand(this.columnHideShowLayer, fromPosition, toPosition);
} else if (multipleColumnsMoved) {
command = new MultiColumnReorderCommand(this.columnHideShowLayer, fromPositions.get(i), toPositions.get(i));
}
this.columnHideShowLayer.doCommand(command);
}
refreshDialog();
}
Aggregations