use of org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer in project nebula.widgets.nattable by eclipse.
the class ConfigLabelProviderTest method testSummaryRowLabels.
@Test
public void testSummaryRowLabels() {
SummaryRowLayer summaryRowLayer = new SummaryRowLayer(this.bodyDataLayer, new ConfigRegistry(), false);
SelectionLayer selectionLayer = new SelectionLayer(summaryRowLayer);
Collection<String> labels = selectionLayer.getProvidedLabels();
assertEquals(13, labels.size());
assertTrue(labels.contains(SelectionStyleLabels.SELECTION_ANCHOR_STYLE));
assertTrue(labels.contains(SelectionStyleLabels.SELECTION_ANCHOR_GRID_LINE_STYLE));
assertTrue(labels.contains(SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE));
assertTrue(labels.contains(SelectionStyleLabels.ROW_FULLY_SELECTED_STYLE));
assertTrue(labels.contains(SelectionStyleLabels.FILL_HANDLE_CELL));
assertTrue(labels.contains(SelectionStyleLabels.FILL_HANDLE_REGION));
assertTrue(labels.contains(SelectionStyleLabels.COPY_BORDER_STYLE));
assertTrue(labels.contains(SummaryRowLayer.DEFAULT_SUMMARY_ROW_CONFIG_LABEL));
assertTrue(labels.contains(SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX + "0"));
assertTrue(labels.contains(SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX + "1"));
assertTrue(labels.contains(SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX + "2"));
assertTrue(labels.contains(SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX + "3"));
assertTrue(labels.contains(SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX + "4"));
}
use of org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer in project nebula.widgets.nattable by eclipse.
the class _5121_SummaryRowExample method createExampleControl.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.nebula.widgets.nattable.examples.INatExample#createExampleControl
* (org.eclipse.swt.widgets.Composite)
*/
@Override
public Control createExampleControl(Composite parent) {
// property names of the NumberValues class
String[] propertyNames = { "columnOneNumber", "columnTwoNumber", "columnThreeNumber", "columnFourNumber", "columnFiveNumber" };
IColumnPropertyAccessor<NumberValues> cpa = new ReflectiveColumnPropertyAccessor<>(propertyNames);
IDataProvider dataProvider = new ListDataProvider<>(createNumberValueList(), cpa);
ConfigRegistry configRegistry = new ConfigRegistry();
DataLayer dataLayer = new DataLayer(dataProvider);
// Plug in the SummaryRowLayer
SummaryRowLayer summaryRowLayer = new SummaryRowLayer(dataLayer, configRegistry, false);
ViewportLayer viewportLayer = new ViewportLayer(summaryRowLayer);
NatTable natTable = new NatTable(parent, viewportLayer, false);
// Configure custom summary formula for a column
natTable.addConfiguration(new ExampleSummaryRowConfiguration(dataProvider));
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.setConfigRegistry(configRegistry);
natTable.configure();
return natTable;
}
use of org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer in project nebula.widgets.nattable by eclipse.
the class Creating_a_summary_row method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
this.myDataProvider = new IDataProvider() {
@Override
public int getColumnCount() {
return 4;
}
@Override
public int getRowCount() {
return 10;
}
@Override
public Object getDataValue(int columnIndex, int rowIndex) {
if (columnIndex >= getColumnCount() || rowIndex >= getRowCount()) {
throw new RuntimeException("Data value requested is out of bounds");
}
return (columnIndex % 2 == 0) ? 10 : "Apple";
}
@Override
public void setDataValue(int columnIndex, int rowIndex, Object newValue) {
}
};
IConfigRegistry configRegistry = new ConfigRegistry();
IUniqueIndexLayer dataLayer = new DataLayer(this.myDataProvider);
// Plug in the SummaryRowLayer
IUniqueIndexLayer summaryRowLayer = new SummaryRowLayer(dataLayer, configRegistry, false);
ViewportLayer viewportLayer = new ViewportLayer(summaryRowLayer);
NatTable natTable = new NatTable(parent, viewportLayer, false);
// Configure custom summary formula for a column
natTable.addConfiguration(new MySummaryRowConfig(this.myDataProvider));
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.setConfigRegistry(configRegistry);
natTable.configure();
return natTable;
}
Aggregations