use of org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack in project nebula.widgets.nattable by eclipse.
the class FreezeHandlerTest method setUp.
@Before
public void setUp() {
final DataLayer bodyDataLayer = new DataLayer(new DummyBodyDataProvider(10, 10));
final DefaultBodyLayerStack bodyLayer = new DefaultBodyLayerStack(bodyDataLayer);
this.selectionLayer = bodyLayer.getSelectionLayer();
this.freezeLayer = new FreezeLayer(this.selectionLayer);
this.compositeFreezeLayer = new CompositeFreezeLayer(this.freezeLayer, bodyLayer.getViewportLayer(), bodyLayer.getSelectionLayer());
this.viewportLayer = bodyLayer.getViewportLayer();
this.commandHandler = new FreezeCommandHandler(this.freezeLayer, this.viewportLayer, this.selectionLayer);
this.compositeFreezeLayer.registerCommandHandler(this.commandHandler);
this.compositeFreezeLayer.setClientAreaProvider(new IClientAreaProvider() {
@Override
public Rectangle getClientArea() {
return new Rectangle(0, 0, 600, 400);
}
});
// Shoot this command so that the viewport can be initialized
this.compositeFreezeLayer.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.H_SCROLL | SWT.V_SCROLL)));
}
use of org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack in project nebula.widgets.nattable by eclipse.
the class SelectionModelStructuralChangeEventHandlerTest method setup.
@Before
public void setup() {
this.dataLayer = new DataLayerFixture(10, 10);
DefaultBodyLayerStack bodyLayer = new DefaultBodyLayerStack(this.dataLayer);
this.selectionLayer = bodyLayer.getSelectionLayer();
this.selectionModel = this.selectionLayer.getSelectionModel();
}
use of org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack 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.layer.stack.DefaultBodyLayerStack in project nebula.widgets.nattable by eclipse.
the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateHiddenOnInsert.
@Test
public void shouldUpdateHiddenOnInsert() {
DefaultBodyLayerStack body = this.grid.getBodyLayer();
ColumnHideShowLayer hideShowLayer = body.getColumnHideShowLayer();
body.doCommand(new MultiColumnHideCommand(body, new int[] { 2, 3, 5 }));
assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
this.provider.setColumnCount(7);
this.grid.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3));
assertEquals("[2, 4, 6]", hideShowLayer.getHiddenColumnIndexes().toString());
}
use of org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack in project nebula.widgets.nattable by eclipse.
the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateHiddenOnInsertAndDelete.
@Test
public void shouldUpdateHiddenOnInsertAndDelete() {
DefaultBodyLayerStack body = this.grid.getBodyLayer();
ColumnHideShowLayer hideShowLayer = body.getColumnHideShowLayer();
body.doCommand(new MultiColumnHideCommand(body, new int[] { 2, 3, 5 }));
assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
this.provider.setColumnCount(7);
this.grid.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3));
assertEquals("[2, 4, 6]", hideShowLayer.getHiddenColumnIndexes().toString());
this.provider.setColumnCount(6);
this.grid.getBodyDataLayer().fireLayerEvent(new ColumnDeleteEvent(this.grid.getBodyDataLayer(), 3));
assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
}
Aggregations