Search in sources :

Example 1 with NatTable

use of org.eclipse.nebula.widgets.nattable.NatTable in project nebula.widgets.nattable by eclipse.

the class ColumnHideShowLayerTest2 method shouldFireTheCorrectEventOnColumnHide.

@Test
public void shouldFireTheCorrectEventOnColumnHide() throws Exception {
    NatTable natTable = new NatTableFixture();
    LayerListenerFixture listener = new LayerListenerFixture();
    natTable.addLayerListener(listener);
    // Grid coordinates
    natTable.doCommand(new ColumnHideCommand(natTable, 5));
    assertEquals(1, listener.getReceivedEvents().size());
    HideColumnPositionsEvent hideEvent = (HideColumnPositionsEvent) listener.getReceivedEvents().get(0);
    Range range = hideEvent.getColumnPositionRanges().iterator().next();
    assertEquals(5, range.start);
    assertEquals(6, range.end);
    // The range Before hide: 5 -> 6
    // The range After hide: 5 -> 5 (column is not there anymore)
    StructuralDiff columnDiff = hideEvent.getColumnDiffs().iterator().next();
    assertEquals(5, columnDiff.getBeforePositionRange().start);
    assertEquals(6, columnDiff.getBeforePositionRange().end);
    assertEquals(5, columnDiff.getAfterPositionRange().start);
    assertEquals(5, columnDiff.getAfterPositionRange().end);
}
Also used : ColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand) HideColumnPositionsEvent(org.eclipse.nebula.widgets.nattable.hideshow.event.HideColumnPositionsEvent) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) StructuralDiff(org.eclipse.nebula.widgets.nattable.layer.event.StructuralDiff) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) Test(org.junit.Test)

Example 2 with NatTable

use of org.eclipse.nebula.widgets.nattable.NatTable in project nebula.widgets.nattable by eclipse.

the class PersistenceHelperTest method testDeleteState.

@Test
public void testDeleteState() {
    Properties properties = new Properties();
    NatTable natTable = new NatTableFixture();
    natTable.saveState("", properties);
    natTable.saveState("Blubb", properties);
    natTable.saveState("Temp", properties);
    Collection<String> stateNames = PersistenceHelper.getAvailableStates(properties);
    assertTrue("Resulting state name collection does not contain the empty default state", stateNames.contains(""));
    assertTrue("Resulting state name collection does not contain the 'Blubb' state", stateNames.contains("Blubb"));
    assertTrue("Resulting state name collection does not contain the 'Temp' state", stateNames.contains("Temp"));
    PersistenceHelper.deleteState("Blubb", properties);
    stateNames = PersistenceHelper.getAvailableStates(properties);
    assertTrue("Resulting state name collection does not contain the empty default state", stateNames.contains(""));
    assertFalse("Resulting state name collection does not contain the 'Blubb' state", stateNames.contains("Blubb"));
    assertTrue("Resulting state name collection does not contain the 'Temp' state", stateNames.contains("Temp"));
}
Also used : NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) Properties(java.util.Properties) Test(org.junit.Test)

Example 3 with NatTable

use of org.eclipse.nebula.widgets.nattable.NatTable in project nebula.widgets.nattable by eclipse.

the class PersistenceHelperTest method testDeleteStateOnEmptyState.

@Test
public void testDeleteStateOnEmptyState() {
    Properties properties = new Properties();
    NatTable natTable = new NatTableFixture();
    natTable.saveState("", properties);
    natTable.saveState("Blubb", properties);
    natTable.saveState("Temp", properties);
    Collection<String> stateNames = PersistenceHelper.getAvailableStates(properties);
    assertTrue("Resulting state name collection does not contain the empty default state", stateNames.contains(""));
    assertTrue("Resulting state name collection does not contain the 'Blubb' state", stateNames.contains("Blubb"));
    assertTrue("Resulting state name collection does not contain the 'Temp' state", stateNames.contains("Temp"));
    PersistenceHelper.deleteState("", properties);
    // no impact
    stateNames = PersistenceHelper.getAvailableStates(properties);
    assertFalse("Resulting state name collection does not contain the empty default state", stateNames.contains(""));
    assertTrue("Resulting state name collection does not contain the 'Blubb' state", stateNames.contains("Blubb"));
    assertTrue("Resulting state name collection does not contain the 'Temp' state", stateNames.contains("Temp"));
}
Also used : NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) Properties(java.util.Properties) Test(org.junit.Test)

Example 4 with NatTable

use of org.eclipse.nebula.widgets.nattable.NatTable in project nebula.widgets.nattable by eclipse.

the class PersistenceHelperTest method testDeleteStateOnEmptyProperties.

@Test
public void testDeleteStateOnEmptyProperties() {
    Properties properties = new Properties();
    NatTable natTable = new NatTableFixture();
    natTable.saveState("", properties);
    natTable.saveState("Blubb", properties);
    natTable.saveState("Temp", properties);
    Collection<String> stateNames = PersistenceHelper.getAvailableStates(properties);
    assertTrue("Resulting state name collection does not contain the empty default state", stateNames.contains(""));
    assertTrue("Resulting state name collection does not contain the 'Blubb' state", stateNames.contains("Blubb"));
    assertTrue("Resulting state name collection does not contain the 'Temp' state", stateNames.contains("Temp"));
    PersistenceHelper.deleteState("Blubb", new Properties());
    // no impact
    stateNames = PersistenceHelper.getAvailableStates(properties);
    assertTrue("Resulting state name collection does not contain the empty default state", stateNames.contains(""));
    assertTrue("Resulting state name collection does not contain the 'Blubb' state", stateNames.contains("Blubb"));
    assertTrue("Resulting state name collection does not contain the 'Temp' state", stateNames.contains("Temp"));
}
Also used : NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) Properties(java.util.Properties) Test(org.junit.Test)

Example 5 with NatTable

use of org.eclipse.nebula.widgets.nattable.NatTable in project nebula.widgets.nattable by eclipse.

the class RowHideShowLayerTest2 method shouldFireTheCorrectEventOnRowHide.

@Test
public void shouldFireTheCorrectEventOnRowHide() throws Exception {
    NatTable natTable = new NatTableFixture(new Shell(), new DummyGridLayerStack() {

        @Override
        protected void init(IUniqueIndexLayer bodyDataLayer, IUniqueIndexLayer columnHeaderDataLayer, IUniqueIndexLayer rowHeaderDataLayer, IUniqueIndexLayer cornerDataLayer) {
            RowHideShowLayer rowHideShowLayer = new RowHideShowLayer(bodyDataLayer);
            super.init(rowHideShowLayer, columnHeaderDataLayer, rowHeaderDataLayer, cornerDataLayer);
        }
    });
    LayerListenerFixture listener = new LayerListenerFixture();
    natTable.addLayerListener(listener);
    // Grid coordinates
    natTable.doCommand(new RowHideCommand(natTable, 5));
    assertEquals(1, listener.getReceivedEvents().size());
    HideRowPositionsEvent hideEvent = (HideRowPositionsEvent) listener.getReceivedEvents().get(0);
    Range range = hideEvent.getRowPositionRanges().iterator().next();
    assertEquals(5, range.start);
    assertEquals(6, range.end);
    // The range Before hide: 5 -> 6
    // The range After hide: 5 -> 5 (row is not there anymore)
    StructuralDiff rowDiff = hideEvent.getRowDiffs().iterator().next();
    assertEquals(5, rowDiff.getBeforePositionRange().start);
    assertEquals(6, rowDiff.getBeforePositionRange().end);
    assertEquals(5, rowDiff.getAfterPositionRange().start);
    assertEquals(5, rowDiff.getAfterPositionRange().end);
}
Also used : Shell(org.eclipse.swt.widgets.Shell) HideRowPositionsEvent(org.eclipse.nebula.widgets.nattable.hideshow.event.HideRowPositionsEvent) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) StructuralDiff(org.eclipse.nebula.widgets.nattable.layer.event.StructuralDiff) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) IUniqueIndexLayer(org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) RowHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.RowHideCommand) Test(org.junit.Test)

Aggregations

NatTable (org.eclipse.nebula.widgets.nattable.NatTable)221 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)150 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)113 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)100 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)90 HashMap (java.util.HashMap)88 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)88 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)79 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)75 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)74 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)73 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)73 DefaultRowHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider)72 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)72 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)72 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)71 SelectionEvent (org.eclipse.swt.events.SelectionEvent)67 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)66 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)66 GridLayout (org.eclipse.swt.layout.GridLayout)64