use of org.eclipse.nebula.widgets.nattable.reorder.command.RowReorderCommand in project nebula.widgets.nattable by eclipse.
the class PersistenceIntegrationTest method saveStateToPropeties.
public void saveStateToPropeties() throws Exception {
// Resize column 2 to 200px
assertEquals(100, this.natTableFixture.getColumnWidthByPosition(2));
this.natTableFixture.doCommand(new ColumnResizeCommand(this.natTableFixture, 2, 200));
assertEquals(200, this.natTableFixture.getColumnWidthByPosition(2));
// Resize row 2 to 100px
assertEquals(20, this.natTableFixture.getRowHeightByPosition(2));
this.natTableFixture.doCommand(new RowResizeCommand(this.natTableFixture, 2, 100));
assertEquals(100, this.natTableFixture.getRowHeightByPosition(2));
// Reorder column 1 --> 5 (grid coordinates)
// 0, 1, 2, 3, 4, 5,.. --> 1, 2, 3, 0, 4, 5,..
assertEquals(0, this.natTableFixture.getColumnIndexByPosition(1));
this.natTableFixture.doCommand(new ColumnReorderCommand(this.natTableFixture, 1, 5));
assertEquals(1, this.natTableFixture.getColumnIndexByPosition(1));
// Reorder row 1 --> 5 (grid coordinates)
// 0, 1, 2, 3, 4, 5,.. --> 1, 2, 3, 0, 4, 5,..
assertEquals(0, this.natTableFixture.getRowIndexByPosition(1));
this.natTableFixture.doCommand(new RowReorderCommand(this.natTableFixture, 1, 5));
assertEquals(1, this.natTableFixture.getRowIndexByPosition(1));
// Hide column with index 3 (grid coordinates)
assertEquals(3, this.natTableFixture.getColumnIndexByPosition(3));
this.natTableFixture.doCommand(new ColumnHideCommand(this.natTableFixture, 3));
assertEquals(0, this.natTableFixture.getColumnIndexByPosition(3));
this.natTableFixture.saveState(TEST_PERSISTENCE_PREFIX, this.properties);
// Ensure that properties got persisted
assertEquals("true", this.properties.get("testPrefix.COLUMN_HEADER.columnWidth.resizableByDefault"));
assertEquals("100", this.properties.get("testPrefix.COLUMN_HEADER.columnWidth.defaultSize"));
assertEquals("true", this.properties.get("testPrefix.COLUMN_HEADER.rowHeight.resizableByDefault"));
assertEquals("40", this.properties.get("testPrefix.ROW_HEADER.columnWidth.defaultSize"));
assertEquals("true", this.properties.get("testPrefix.ROW_HEADER.rowHeight.resizableByDefault"));
assertEquals("true", this.properties.get("testPrefix.ROW_HEADER.columnWidth.resizableByDefault"));
assertEquals("40", this.properties.get("testPrefix.ROW_HEADER.rowHeight.defaultSize"));
assertEquals("20", this.properties.get("testPrefix.CORNER.rowHeight.defaultSize"));
assertEquals("true", this.properties.get("testPrefix.CORNER.columnWidth.resizableByDefault"));
assertEquals("true", this.properties.get("testPrefix.CORNER.rowHeight.resizableByDefault"));
assertEquals("20", this.properties.get("testPrefix.BODY.rowHeight.defaultSize"));
assertEquals("true", this.properties.get("testPrefix.BODY.rowHeight.resizableByDefault"));
assertEquals("true", this.properties.get("testPrefix.BODY.columnWidth.resizableByDefault"));
assertEquals("1,2,3,0,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,", this.properties.get("testPrefix.BODY.columnIndexOrder"));
assertEquals("1:100,", this.properties.get("testPrefix.BODY.rowHeight.sizes"));
assertEquals("1:200,", this.properties.get("testPrefix.BODY.columnWidth.sizes"));
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.RowReorderCommand in project nebula.widgets.nattable by eclipse.
the class RowStructuralChangeEventIntegrationTest method shouldUpdateOnInsertAndDelete.
@Test
public void shouldUpdateOnInsertAndDelete() {
this.contents.add("six");
this.underlyingLayer.fireLayerEvent(new RowInsertEvent(this.underlyingLayer, 5));
this.viewportLayer.doCommand(new RowReorderCommand(this.viewportLayer, 3, 6));
this.viewportLayer.doCommand(new RowReorderCommand(this.viewportLayer, 3, 5));
this.viewportLayer.doCommand(new MultiRowHideCommand(this.viewportLayer, new int[] { 2, 3, 5 }));
assertEquals("[0, 1, 2, 5, 4, 3]", this.rowReorderLayer.getRowIndexOrder().toString());
assertEquals("[2, 3, 5]", this.rowHideShowLayer.getHiddenRowIndexes().toString());
this.contents.add(3, "test");
this.underlyingLayer.fireLayerEvent(new RowInsertEvent(this.underlyingLayer, 3));
assertEquals("[0, 1, 2, 3, 6, 5, 4]", this.rowReorderLayer.getRowIndexOrder().toString());
assertEquals("[2, 4, 6]", this.rowHideShowLayer.getHiddenRowIndexes().toString());
this.contents.remove(3);
this.underlyingLayer.fireLayerEvent(new RowDeleteEvent(this.underlyingLayer, 3));
assertEquals("[0, 1, 2, 5, 4, 3]", this.rowReorderLayer.getRowIndexOrder().toString());
assertEquals("[2, 3, 5]", this.rowHideShowLayer.getHiddenRowIndexes().toString());
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.RowReorderCommand in project nebula.widgets.nattable by eclipse.
the class RowStructuralChangeEventIntegrationTest method testReorderHide.
@Test
public void testReorderHide() {
testInit();
// reorder to inverse order: 4 3 2 1 0
this.natTable.doCommand(new RowReorderCommand(this.viewportLayer, 4, 0));
this.natTable.doCommand(new RowReorderCommand(this.viewportLayer, 4, 1));
this.natTable.doCommand(new RowReorderCommand(this.viewportLayer, 4, 2));
this.natTable.doCommand(new RowReorderCommand(this.viewportLayer, 4, 3));
// hide row at position 2: 0 1 3 4
this.natTable.doCommand(new RowHideCommand(this.viewportLayer, 2));
assertEquals(4, this.viewportLayer.getRowCount());
assertEquals(4, this.viewportLayer.getRowIndexByPosition(0));
assertEquals(3, this.viewportLayer.getRowIndexByPosition(1));
assertEquals(1, this.viewportLayer.getRowIndexByPosition(2));
assertEquals(0, this.viewportLayer.getRowIndexByPosition(3));
assertEquals(-1, this.viewportLayer.getRowIndexByPosition(4));
assertEquals("five", this.viewportLayer.getDataValueByPosition(0, 0));
assertEquals("four", this.viewportLayer.getDataValueByPosition(0, 1));
assertEquals("two", this.viewportLayer.getDataValueByPosition(0, 2));
assertEquals("one", this.viewportLayer.getDataValueByPosition(0, 3));
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.RowReorderCommand in project nebula.widgets.nattable by eclipse.
the class RowStructuralChangeEventIntegrationTest method testReorder.
@Test
public void testReorder() {
testInit();
// reorder to inverse order: 4 3 2 1 0
this.natTable.doCommand(new RowReorderCommand(this.viewportLayer, 4, 0));
this.natTable.doCommand(new RowReorderCommand(this.viewportLayer, 4, 1));
this.natTable.doCommand(new RowReorderCommand(this.viewportLayer, 4, 2));
this.natTable.doCommand(new RowReorderCommand(this.viewportLayer, 4, 3));
assertEquals(4, this.viewportLayer.getRowIndexByPosition(0));
assertEquals(3, this.viewportLayer.getRowIndexByPosition(1));
assertEquals(2, this.viewportLayer.getRowIndexByPosition(2));
assertEquals(1, this.viewportLayer.getRowIndexByPosition(3));
assertEquals(0, this.viewportLayer.getRowIndexByPosition(4));
assertEquals("five", this.viewportLayer.getDataValueByPosition(0, 0));
assertEquals("four", this.viewportLayer.getDataValueByPosition(0, 1));
assertEquals("three", this.viewportLayer.getDataValueByPosition(0, 2));
assertEquals("two", this.viewportLayer.getDataValueByPosition(0, 3));
assertEquals("one", this.viewportLayer.getDataValueByPosition(0, 4));
}
use of org.eclipse.nebula.widgets.nattable.reorder.command.RowReorderCommand in project nebula.widgets.nattable by eclipse.
the class RowReorderLayerTest method canHandleRowReorderCommand.
@Test
public void canHandleRowReorderCommand() throws Exception {
RowReorderLayer reorderLayer = new RowReorderLayer(new DataLayerFixture());
RowReorderCommand reorderCommand = new RowReorderCommand(reorderLayer, 0, 2);
assertTrue(reorderLayer.doCommand(reorderCommand));
}
Aggregations