use of org.eclipse.nebula.widgets.nattable.data.IDataProvider in project nebula.widgets.nattable by eclipse.
the class DefaultColumnHeaderDataProviderTest method shouldThrowExceptionOnSet.
@Test(expected = UnsupportedOperationException.class)
public void shouldThrowExceptionOnSet() {
IDataProvider dataProvider = new DefaultColumnHeaderDataProvider(new String[] { "One", "Two", "Three" });
dataProvider.setDataValue(0, 0, "Foo");
}
use of org.eclipse.nebula.widgets.nattable.data.IDataProvider in project nebula.widgets.nattable by eclipse.
the class DefaultColumnHeaderDataProviderTest method shouldReturnNullOnInvalidColumnIndex.
@Test
public void shouldReturnNullOnInvalidColumnIndex() {
String[] properties = { "firstname", "lastname", "gender", "birthday" };
Map<String, String> mapping = new HashMap<>();
mapping.put("firstname", "Vorname");
mapping.put("lastname", "Nachname");
mapping.put("gender", "Geschlecht");
mapping.put("birthday", "Geburtstag");
IDataProvider dataProvider = new DefaultColumnHeaderDataProvider(properties, mapping);
assertNull(dataProvider.getDataValue(-1, 0));
assertNull(dataProvider.getDataValue(4, 0));
}
use of org.eclipse.nebula.widgets.nattable.data.IDataProvider in project nebula.widgets.nattable by eclipse.
the class DefaultColumnHeaderDataProviderTest method shouldReturnColumnLabel.
@Test
public void shouldReturnColumnLabel() {
IDataProvider dataProvider = new DefaultColumnHeaderDataProvider(new String[] { "One", "Two", "Three" });
assertEquals(1, dataProvider.getRowCount());
assertEquals(3, dataProvider.getColumnCount());
assertEquals("One", dataProvider.getDataValue(0, 0));
assertEquals("Two", dataProvider.getDataValue(1, 0));
assertEquals("Three", dataProvider.getDataValue(2, 0));
// any other row will work too
assertEquals("One", dataProvider.getDataValue(0, 1));
}
use of org.eclipse.nebula.widgets.nattable.data.IDataProvider in project nebula.widgets.nattable by eclipse.
the class DefaultColumnHeaderDataProviderTest method shouldReturnPropertyLabel.
@Test
public void shouldReturnPropertyLabel() {
String[] properties = { "firstname", "lastname", "gender", "birthday" };
Map<String, String> mapping = new HashMap<>();
mapping.put("firstname", "Vorname");
mapping.put("lastname", "Nachname");
mapping.put("gender", "Geschlecht");
mapping.put("birthday", "Geburtstag");
IDataProvider dataProvider = new DefaultColumnHeaderDataProvider(properties, mapping);
assertEquals(1, dataProvider.getRowCount());
assertEquals(4, dataProvider.getColumnCount());
assertEquals("Vorname", dataProvider.getDataValue(0, 0));
assertEquals("Nachname", dataProvider.getDataValue(1, 0));
assertEquals("Geschlecht", dataProvider.getDataValue(2, 0));
assertEquals("Geburtstag", dataProvider.getDataValue(3, 0));
// any other row will work too
assertEquals("Vorname", dataProvider.getDataValue(0, 1));
}
use of org.eclipse.nebula.widgets.nattable.data.IDataProvider in project nebula.widgets.nattable by eclipse.
the class MaxCellBoundsHelperTest method getPreferedRowHeights.
@Test
public void getPreferedRowHeights() throws Exception {
DataLayerFixture dataLayer = new DataLayerFixture(3, 2, 10, 10);
IDataProvider dataProvider = dataLayer.getDataProvider();
// Row 0
dataProvider.setDataValue(0, 0, "..");
dataProvider.setDataValue(1, 0, "...");
dataProvider.setDataValue(2, 0, "...");
// Row 1
dataProvider.setDataValue(0, 1, "Elephant");
dataProvider.setDataValue(1, 1, "Cat");
dataProvider.setDataValue(2, 1, "Rat");
AutoResizeRowCommandFixture command = new AutoResizeRowCommandFixture();
GCFactory gcFactory = command.getGCFactory();
IConfigRegistry registry = command.getConfigRegistry();
GC gc = gcFactory.createGC();
int row0MaxTextHeight = new TextPainter().getPreferredHeight(new CellFixture(".."), gc, registry);
int row1MaxTextHeight = new TextPainter().getPreferredHeight(new CellFixture("Elephant"), gc, registry);
gc.dispose();
int[] maxRowHeights = MaxCellBoundsHelper.getPreferredRowHeights(registry, gcFactory, dataLayer, new int[] { 0, 1 });
// Adjust heights
int row0AdjustedMaxHeight = dataLayer.getLayerPainter().adjustCellBounds(0, 0, new Rectangle(0, 0, 10, maxRowHeights[0])).height;
int row1AdjustedMaxHeight = dataLayer.getLayerPainter().adjustCellBounds(0, 1, new Rectangle(0, 0, 10, maxRowHeights[1])).height;
Assert.assertEquals(row0MaxTextHeight, row0AdjustedMaxHeight);
Assert.assertEquals(row1MaxTextHeight, row1AdjustedMaxHeight);
}
Aggregations