Search in sources :

Example 1 with SummaryRowLayer

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"));
}
Also used : ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) SummaryRowLayer(org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer) Test(org.junit.Test)

Example 2 with SummaryRowLayer

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;
}
Also used : ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) NumberValues(org.eclipse.nebula.widgets.nattable.dataset.NumberValues) 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) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) SummaryRowLayer(org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable)

Example 3 with SummaryRowLayer

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;
}
Also used : IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) SummaryRowLayer(org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) IUniqueIndexLayer(org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer)

Aggregations

ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)3 SummaryRowLayer (org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer)3 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)2 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)2 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)2 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)2 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)2 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)2 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)1 ReflectiveColumnPropertyAccessor (org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor)1 NumberValues (org.eclipse.nebula.widgets.nattable.dataset.NumberValues)1 IUniqueIndexLayer (org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer)1 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)1 Test (org.junit.Test)1