Search in sources :

Example 1 with MultiColumnReorderCommand

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();
}
Also used : MultiColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand) Test(org.junit.Test)

Example 2 with MultiColumnReorderCommand

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());
}
Also used : MultiColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand) Test(org.junit.Test)

Example 3 with MultiColumnReorderCommand

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)));
}
Also used : MultiColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand) Test(org.junit.Test)

Example 4 with MultiColumnReorderCommand

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));
}
Also used : MultiColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Example 5 with MultiColumnReorderCommand

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();
}
Also used : MultiColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand) ArrayList(java.util.ArrayList) List(java.util.List) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) MultiColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand) ILayerCommand(org.eclipse.nebula.widgets.nattable.command.ILayerCommand)

Aggregations

MultiColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand)14 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)3 List (java.util.List)2 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)2 DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)2 ColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand)2 NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)2 EventList (ca.odell.glazedlists.EventList)1 FilterList (ca.odell.glazedlists.FilterList)1 SortedList (ca.odell.glazedlists.SortedList)1 TransformedList (ca.odell.glazedlists.TransformedList)1 HashMap (java.util.HashMap)1 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)1 ILayerCommand (org.eclipse.nebula.widgets.nattable.command.ILayerCommand)1 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)1 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)1 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)1 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)1 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)1