use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class RenameColumnIntegrationTest method shouldRenameColumnHeaderForReorderedColumnProgrammatically.
@Test
public void shouldRenameColumnHeaderForReorderedColumnProgrammatically() {
String originalColumnHeader = this.natTableFixture.getDataValueByPosition(2, 0).toString();
assertEquals("Column 2", originalColumnHeader);
this.natTableFixture.doCommand(new ColumnReorderCommand(this.natTableFixture, 1, 5));
originalColumnHeader = this.natTableFixture.getDataValueByPosition(2, 0).toString();
assertEquals("Column 3", originalColumnHeader);
this.grid.getColumnHeaderLayer().renameColumnIndex(2, TEST_COLUMN_NAME);
String renamedColumnHeader = this.natTableFixture.getDataValueByPosition(2, 0).toString();
assertEquals(TEST_COLUMN_NAME, renamedColumnHeader);
assertEquals(2, this.listener.getEventsCount());
RenameColumnHeaderEvent event = (RenameColumnHeaderEvent) this.listener.getReceivedEvent(RenameColumnHeaderEvent.class);
assertEquals(new Range(2, 3), event.getColumnPositionRanges().iterator().next());
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateReorderOnInsert.
@Test
public void shouldUpdateReorderOnInsert() {
DefaultBodyLayerStack body = this.grid.getBodyLayer();
ColumnReorderLayer reorderLayer = body.getColumnReorderLayer();
body.doCommand(new ColumnReorderCommand(body, 3, 6));
body.doCommand(new ColumnReorderCommand(body, 3, 5));
assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString());
this.provider.setColumnCount(7);
this.grid.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3));
assertEquals("[0, 1, 2, 3, 6, 5, 4]", reorderLayer.getColumnIndexOrder().toString());
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateOnInsertAndDelete.
@Test
public void shouldUpdateOnInsertAndDelete() {
DefaultBodyLayerStack body = this.grid.getBodyLayer();
ColumnReorderLayer reorderLayer = body.getColumnReorderLayer();
ColumnHideShowLayer hideShowLayer = body.getColumnHideShowLayer();
body.doCommand(new ColumnReorderCommand(body, 3, 6));
body.doCommand(new ColumnReorderCommand(body, 3, 5));
body.doCommand(new MultiColumnHideCommand(body, new int[] { 2, 3, 5 }));
assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString());
assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
this.provider.setColumnCount(7);
this.grid.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3));
assertEquals("[0, 1, 2, 3, 6, 5, 4]", reorderLayer.getColumnIndexOrder().toString());
assertEquals("[2, 4, 6]", hideShowLayer.getHiddenColumnIndexes().toString());
this.provider.setColumnCount(6);
this.grid.getBodyDataLayer().fireLayerEvent(new ColumnDeleteEvent(this.grid.getBodyDataLayer(), 3));
assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString());
assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand in project nebula.widgets.nattable by eclipse.
the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateOnInsert.
@Test
public void shouldUpdateOnInsert() {
DefaultBodyLayerStack body = this.grid.getBodyLayer();
ColumnReorderLayer reorderLayer = body.getColumnReorderLayer();
ColumnHideShowLayer hideShowLayer = body.getColumnHideShowLayer();
body.doCommand(new ColumnReorderCommand(body, 3, 6));
body.doCommand(new ColumnReorderCommand(body, 3, 5));
body.doCommand(new MultiColumnHideCommand(body, new int[] { 2, 3, 5 }));
assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString());
assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
this.provider.setColumnCount(7);
this.grid.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3));
assertEquals("[0, 1, 2, 3, 6, 5, 4]", reorderLayer.getColumnIndexOrder().toString());
assertEquals("[2, 4, 6]", hideShowLayer.getHiddenColumnIndexes().toString());
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand 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