Search in sources :

Example 6 with ColumnReorderLayer

use of org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer in project nebula.widgets.nattable by eclipse.

the class ColumnReorderLayerVisibleChangeTest method returnsCorrectPositionRectangleForMultiColumnReorderLeftCase.

@SuppressWarnings("boxing")
@Test
public /**
 * 	Index		10	11	12	13 ... 20
 *          --------------------
 *  Position 	0 	1	2	3 ... 20
 */
void returnsCorrectPositionRectangleForMultiColumnReorderLeftCase() {
    ColumnReorderLayer reorderLayer = new ColumnReorderLayer(new BaseDataLayerFixture(20, 20));
    // Build expected cell positions to redraw
    final Set<Rectangle> expectedPositions = new HashSet<Rectangle>();
    expectedPositions.add(new Rectangle(0, 0, 20, 20));
    reorderLayer.addLayerListener(new ILayerListener() {

        @Override
        public void handleLayerEvent(ILayerEvent event) {
            ColumnReorderEvent multiReorder = (ColumnReorderEvent) event;
            assertTrue(multiReorder.getChangedPositionRectangles().containsAll(expectedPositions));
        }
    });
    // Reorder to beginning of grid
    List<Integer> fromColumnPositions = Arrays.asList(new Integer[] { 10, 11, 12, 13 });
    reorderLayer.reorderMultipleColumnPositions(fromColumnPositions, 0);
    // Reorder to middle of grid
    expectedPositions.clear();
    expectedPositions.add(new Rectangle(10, 0, 10, 20));
    fromColumnPositions = Arrays.asList(new Integer[] { 19, 18, 17, 16 });
    reorderLayer.reorderMultipleColumnPositions(fromColumnPositions, 10);
    // Reorder to end of grid
    expectedPositions.clear();
    expectedPositions.add(new Rectangle(5, 0, 15, 20));
    fromColumnPositions = Arrays.asList(new Integer[] { 5, 6, 7, 8 });
    reorderLayer.reorderMultipleColumnPositions(fromColumnPositions, 10);
}
Also used : ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) BaseDataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture) Rectangle(org.eclipse.swt.graphics.Rectangle) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) ColumnReorderEvent(org.eclipse.nebula.widgets.nattable.reorder.event.ColumnReorderEvent) ILayerListener(org.eclipse.nebula.widgets.nattable.layer.ILayerListener) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with ColumnReorderLayer

use of org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer in project nebula.widgets.nattable by eclipse.

the class ColumnReorderLayerVisibleChangeTest method returnsCorrectPositionRectangleForMultiColumnReorderRightCase.

@SuppressWarnings("boxing")
@Test
public /**
 * 	Index		2	3	0	1 ... 20
 *          --------------------
 *  Position 	0 	1	2	3 ... 20
 */
void returnsCorrectPositionRectangleForMultiColumnReorderRightCase() {
    ColumnReorderLayer reorderLayer = new ColumnReorderLayer(new BaseDataLayerFixture(20, 20));
    // Build expected cell positions to redraw
    final Set<Rectangle> expectedPositions = new HashSet<Rectangle>();
    expectedPositions.add(new Rectangle(0, 0, 20, 20));
    reorderLayer.addLayerListener(new ILayerListener() {

        @Override
        public void handleLayerEvent(ILayerEvent event) {
            ColumnReorderEvent multiReorder = (ColumnReorderEvent) event;
            assertTrue(multiReorder.getChangedPositionRectangles().containsAll(expectedPositions));
        }
    });
    // Reorder from beginning of grid
    List<Integer> fromColumnPositions = Arrays.asList(new Integer[] { 0, 1 });
    reorderLayer.reorderMultipleColumnPositions(fromColumnPositions, 2);
    // Reorder to middle of grid
    expectedPositions.clear();
    expectedPositions.add(new Rectangle(5, 0, 15, 20));
    fromColumnPositions = Arrays.asList(new Integer[] { 5, 6, 7, 8 });
    reorderLayer.reorderMultipleColumnPositions(fromColumnPositions, 10);
    // Reorder to end of grid
    expectedPositions.clear();
    expectedPositions.add(new Rectangle(10, 0, 10, 20));
    fromColumnPositions = Arrays.asList(new Integer[] { 10, 11, 12, 13 });
    reorderLayer.reorderMultipleColumnPositions(fromColumnPositions, 19);
}
Also used : ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) BaseDataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture) Rectangle(org.eclipse.swt.graphics.Rectangle) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) ColumnReorderEvent(org.eclipse.nebula.widgets.nattable.reorder.event.ColumnReorderEvent) ILayerListener(org.eclipse.nebula.widgets.nattable.layer.ILayerListener) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 8 with ColumnReorderLayer

use of org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer in project nebula.widgets.nattable by eclipse.

the class SummaryRowIntegrationTest method initLayerStackWithSummaryRow.

@Before
public void initLayerStackWithSummaryRow() {
    this.dataList = RowDataListFixture.getList().subList(0, 4);
    // Rows 0, 1, 2, 3; Summary row would be position 4
    assertEquals(4, this.dataList.size());
    this.dataProvider = new ListDataProvider<RowDataFixture>(this.dataList, new ReflectiveColumnPropertyAccessor<RowDataFixture>(RowDataListFixture.getPropertyNames()));
    IConfigRegistry configRegistry = new ConfigRegistry();
    this.dataLayer = new DataLayer(this.dataProvider);
    this.summaryRowLayer = new SummaryRowLayer(this.dataLayer, configRegistry);
    IUniqueIndexLayer columnReorderLayer = new ColumnReorderLayer(this.summaryRowLayer);
    IUniqueIndexLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
    IUniqueIndexLayer selectionLayer = new SelectionLayer(columnHideShowLayer);
    this.layerStackWithSummary = new ViewportLayer(selectionLayer);
    // NatTableFixture initializes the client area
    this.natTable = new NatTableFixture(this.layerStackWithSummary, false);
    this.natTable.setConfigRegistry(configRegistry);
    this.natTable.addConfiguration(new TestSummaryRowConfiguration());
    this.natTable.configure();
}
Also used : NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) IUniqueIndexLayer(org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer) Before(org.junit.Before)

Example 9 with ColumnReorderLayer

use of org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer 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());
}
Also used : ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) ColumnInsertEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) Test(org.junit.Test)

Example 10 with ColumnReorderLayer

use of org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer 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());
}
Also used : ColumnDeleteEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) ColumnInsertEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Aggregations

ColumnReorderLayer (org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer)36 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)25 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)25 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)24 ColumnHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer)22 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)21 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)21 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)18 DefaultRowHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider)18 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)18 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)18 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)18 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)18 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)16 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)14 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)14 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)14 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)14 HashMap (java.util.HashMap)13 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)11