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);
}
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"));
}
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"));
}
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"));
}
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);
}
Aggregations