Search in sources :

Example 41 with DataLayer

use of org.eclipse.nebula.widgets.nattable.layer.DataLayer in project nebula.widgets.nattable by eclipse.

the class ViewportLayerDisposalTest method testPostEventToDisposedLayer.

/**
 * Tests that an {@link IStructuralChangeEvent} will be safely handled by a
 * table's {@link ViewportLayer} after the table has been disposed (see: bug
 * <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=447942">Bug
 * 447942</a>).
 *
 * @throws InterruptedException
 *             on multi-threading issues
 */
@Test
public void testPostEventToDisposedLayer() throws InterruptedException {
    final DataLayer dataLayer = new TestDataLayer();
    final ViewportLayer viewportLayer = new ViewportLayer(dataLayer);
    final NatTable table = new NatTable(this.shell, viewportLayer);
    // Setting the table's size will cause the viewport layer to connect
    // itself to the table's scrollbars.
    table.setSize(500, 500);
    // Change a value in the data layer on a background thread.
    final Thread backgroundUpdater = new Thread(new Runnable() {

        @Override
        public void run() {
            // Calling "setDataValue" on a background thread will cause the
            // actual update to be executed asnchronously on the ui thread.
            dataLayer.setDataValue(4, 49, "VALUE");
        }
    }, "LayerDisposalTest.backgroundUpdater");
    backgroundUpdater.start();
    backgroundUpdater.join();
    // Disposing the table will also dispose all of its layers.
    table.dispose();
    // to the (disposed) viewport layer.
    while (this.shell.getDisplay().readAndDispatch()) {
    }
    // Test that the background thread has successfully updated the table's
    // data layer.
    Assert.assertEquals("The table's data layer should have been updated.", "VALUE", dataLayer.getDataValue(4, 49));
}
Also used : DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) Test(org.junit.Test)

Example 42 with DataLayer

use of org.eclipse.nebula.widgets.nattable.layer.DataLayer in project nebula.widgets.nattable by eclipse.

the class _509_SortHeaderLayerExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    // property names of the Person class
    String[] propertyNames = { "firstName", "lastName", "gender", "married", "birthday" };
    // mapping from property to label, needed for column header labels
    Map<String, String> propertyToLabelMap = new HashMap<>();
    propertyToLabelMap.put("firstName", "Firstname");
    propertyToLabelMap.put("lastName", "Lastname");
    propertyToLabelMap.put("gender", "Gender");
    propertyToLabelMap.put("married", "Married");
    propertyToLabelMap.put("birthday", "Birthday");
    // build the body layer stack
    // Usually you would create a new layer stack by extending
    // AbstractIndexLayerTransform and
    // setting the ViewportLayer as underlying layer. But in this case using
    // the ViewportLayer
    // directly as body layer is also working.
    List<PersonWithAddress> data = PersonService.getPersonsWithAddress(10);
    IColumnPropertyAccessor<PersonWithAddress> accessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
    IDataProvider bodyDataProvider = new ListDataProvider<>(data, accessor);
    DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
    ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(bodyDataLayer);
    ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
    SelectionLayer selectionLayer = new SelectionLayer(columnHideShowLayer);
    ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
    // build the column header layer
    IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
    DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
    ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, viewportLayer, selectionLayer);
    ConfigRegistry configRegistry = new ConfigRegistry();
    SortHeaderLayer<PersonWithAddress> sortHeaderLayer = new SortHeaderLayer<>(columnHeaderLayer, new PersonWithAddressSortModel(data));
    // build the row header layer
    IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
    DataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
    ILayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, viewportLayer, selectionLayer);
    // build the corner layer
    IDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
    DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
    ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, sortHeaderLayer);
    // build the grid layer
    GridLayer gridLayer = new GridLayer(viewportLayer, sortHeaderLayer, rowHeaderLayer, cornerLayer);
    // turn the auto configuration off as we want to add custom
    // configurations
    NatTable natTable = new NatTable(parent, gridLayer, false);
    natTable.setConfigRegistry(configRegistry);
    // as the autoconfiguration of the NatTable is turned off, we have to
    // add the DefaultNatTableStyleConfiguration manually
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
    // enable sorting on single click on the column header
    natTable.addConfiguration(new SingleClickSortConfiguration());
    natTable.configure();
    return natTable;
}
Also used : ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) HashMap(java.util.HashMap) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) PersonWithAddress(org.eclipse.nebula.widgets.nattable.dataset.person.PersonWithAddress) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) SortHeaderLayer(org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) CornerLayer(org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) SingleClickSortConfiguration(org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)

Example 43 with DataLayer

use of org.eclipse.nebula.widgets.nattable.layer.DataLayer in project nebula.widgets.nattable by eclipse.

the class _5112_TwoLevelColumnGroupingExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    // property names of the Person class
    String[] propertyNames = { "firstName", "lastName", "gender", "married", "address.street", "address.housenumber", "address.postalCode", "address.city", "age", "birthday", "money", "description", "favouriteFood", "favouriteDrinks" };
    // mapping from property to label, needed for column header labels
    Map<String, String> propertyToLabelMap = new HashMap<>();
    propertyToLabelMap.put("firstName", "Firstname");
    propertyToLabelMap.put("lastName", "Lastname");
    propertyToLabelMap.put("gender", "Gender");
    propertyToLabelMap.put("married", "Married");
    propertyToLabelMap.put("address.street", "Street");
    propertyToLabelMap.put("address.housenumber", "Housenumber");
    propertyToLabelMap.put("address.postalCode", "Postalcode");
    propertyToLabelMap.put("address.city", "City");
    propertyToLabelMap.put("age", "Age");
    propertyToLabelMap.put("birthday", "Birthday");
    propertyToLabelMap.put("money", "Money");
    propertyToLabelMap.put("description", "Description");
    propertyToLabelMap.put("favouriteFood", "Food");
    propertyToLabelMap.put("favouriteDrinks", "Drinks");
    IColumnPropertyAccessor<ExtendedPersonWithAddress> columnPropertyAccessor = new ExtendedReflectiveColumnPropertyAccessor<>(propertyNames);
    ColumnGroupModel columnGroupModel = new ColumnGroupModel();
    ColumnGroupModel sndColumnGroupModel = new ColumnGroupModel();
    // build the body layer stack
    // Usually you would create a new layer stack by extending
    // AbstractIndexLayerTransform and setting the ViewportLayer as
    // underlying layer. But in this case using the ViewportLayer directly
    // as body layer is also working.
    IDataProvider bodyDataProvider = new ListDataProvider<>(PersonService.getExtendedPersonsWithAddress(10), columnPropertyAccessor);
    DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
    ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(bodyDataLayer);
    ColumnGroupReorderLayer columnGroupReorderLayer = new ColumnGroupReorderLayer(columnReorderLayer, columnGroupModel);
    ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(columnGroupReorderLayer);
    ColumnGroupExpandCollapseLayer columnGroupExpandCollapseLayer = new ColumnGroupExpandCollapseLayer(columnHideShowLayer, sndColumnGroupModel, columnGroupModel);
    SelectionLayer selectionLayer = new SelectionLayer(columnGroupExpandCollapseLayer);
    ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
    // build the column header layer
    IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
    DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
    ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, viewportLayer, selectionLayer);
    ColumnGroupHeaderLayer columnGroupHeaderLayer = new ColumnGroupHeaderLayer(columnHeaderLayer, selectionLayer, columnGroupModel);
    // configure the column groups
    columnGroupHeaderLayer.addColumnsIndexesToGroup("Person", 0, 1, 2, 3);
    columnGroupHeaderLayer.addColumnsIndexesToGroup("Address", 4, 5, 6, 7);
    columnGroupHeaderLayer.addColumnsIndexesToGroup("Facts", 8, 9, 10);
    columnGroupHeaderLayer.addColumnsIndexesToGroup("Personal", 11, 12, 13);
    columnGroupHeaderLayer.setStaticColumnIndexesByGroup("Person", 0, 1);
    columnGroupHeaderLayer.setStaticColumnIndexesByGroup("Address", 4, 5, 6);
    columnGroupHeaderLayer.setGroupUnbreakable(1);
    ColumnGroupGroupHeaderLayer sndGroup = new ColumnGroupGroupHeaderLayer(columnGroupHeaderLayer, selectionLayer, sndColumnGroupModel);
    sndGroup.addColumnsIndexesToGroup("PersonWithAddress", 0, 1, 2, 3, 4, 5, 6, 7);
    sndGroup.addColumnsIndexesToGroup("Additional Information", 8, 9, 10, 11, 12, 13);
    sndGroup.setStaticColumnIndexesByGroup("PersonWithAddress", 0, 1);
    // build the row header layer
    IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
    DataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
    ILayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, viewportLayer, selectionLayer);
    // build the corner layer
    IDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
    DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
    ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, sndGroup);
    // build the grid layer
    GridLayer gridLayer = new GridLayer(viewportLayer, sndGroup, rowHeaderLayer, cornerLayer);
    // turn the auto configuration off as we want to add our header menu
    // configuration
    NatTable natTable = new NatTable(parent, gridLayer);
    return natTable;
}
Also used : ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) ExtendedPersonWithAddress(org.eclipse.nebula.widgets.nattable.dataset.person.ExtendedPersonWithAddress) HashMap(java.util.HashMap) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) ExtendedReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ExtendedReflectiveColumnPropertyAccessor) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) ColumnGroupGroupHeaderLayer(org.eclipse.nebula.widgets.nattable.group.ColumnGroupGroupHeaderLayer) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) ColumnGroupReorderLayer(org.eclipse.nebula.widgets.nattable.group.ColumnGroupReorderLayer) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) ColumnGroupModel(org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel) ColumnGroupHeaderLayer(org.eclipse.nebula.widgets.nattable.group.ColumnGroupHeaderLayer) RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) CornerLayer(org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) ColumnGroupExpandCollapseLayer(org.eclipse.nebula.widgets.nattable.group.ColumnGroupExpandCollapseLayer) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)

Example 44 with DataLayer

use of org.eclipse.nebula.widgets.nattable.layer.DataLayer in project nebula.widgets.nattable by eclipse.

the class _5113_RowGroupingExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    // Body
    // property names of the Person class
    String[] propertyNames = { "firstName", "lastName", "gender", "married", "birthday" };
    // mapping from property to label, needed for column header labels
    Map<String, String> propertyToLabelMap = new HashMap<>();
    propertyToLabelMap.put("firstName", "Firstname");
    propertyToLabelMap.put("lastName", "Lastname");
    propertyToLabelMap.put("gender", "Gender");
    propertyToLabelMap.put("married", "Married");
    propertyToLabelMap.put("birthday", "Birthday");
    // build the body layer stack
    // Usually you would create a new layer stack by extending
    // AbstractIndexLayerTransform and setting the ViewportLayer as
    // underlying layer. But in this case using the ViewportLayer directly
    // as body layer is also working.
    IRowDataProvider<Person> bodyDataProvider = new DefaultBodyDataProvider<>(getStaticPersonList(), propertyNames);
    DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
    ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(bodyDataLayer);
    ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
    RowHideShowLayer rowHideShowLayer = new RowHideShowLayer(columnHideShowLayer);
    RowGroupModel<Person> rowGroupModel = new RowGroupModel<>();
    rowGroupModel.setDataProvider(bodyDataProvider);
    RowGroupExpandCollapseLayer<Person> rowExpandCollapseLayer = new RowGroupExpandCollapseLayer<>(rowHideShowLayer, rowGroupModel);
    SelectionLayer selectionLayer = new SelectionLayer(rowExpandCollapseLayer);
    ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
    // Column header
    DefaultColumnHeaderDataProvider defaultColumnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
    DefaultColumnHeaderDataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(defaultColumnHeaderDataProvider);
    ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, viewportLayer, selectionLayer);
    // Row header
    DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
    DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
    RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, viewportLayer, selectionLayer, false);
    rowHeaderLayer.addConfiguration(new RowHeaderConfiguration());
    RowGroupHeaderLayer<Person> rowGroupHeaderLayer = new RowGroupHeaderLayer<>(rowHeaderLayer, selectionLayer, rowGroupModel);
    rowGroupHeaderLayer.setColumnWidth(20);
    // Create a group of rows for the model.
    RowGroup<Person> rowGroup = new RowGroup<>(rowGroupModel, "Simpson", false);
    rowGroup.addMemberRow(bodyDataProvider.getRowObject(0));
    rowGroup.addStaticMemberRow(bodyDataProvider.getRowObject(1));
    rowGroup.addMemberRow(bodyDataProvider.getRowObject(2));
    rowGroup.addMemberRow(bodyDataProvider.getRowObject(3));
    rowGroup.addMemberRow(bodyDataProvider.getRowObject(4));
    rowGroupModel.addRowGroup(rowGroup);
    rowGroup = new RowGroup<>(rowGroupModel, "Flanders", false);
    rowGroup.addMemberRow(bodyDataProvider.getRowObject(5));
    rowGroup.addStaticMemberRow(bodyDataProvider.getRowObject(6));
    rowGroup.addMemberRow(bodyDataProvider.getRowObject(7));
    rowGroup.addMemberRow(bodyDataProvider.getRowObject(8));
    rowGroupModel.addRowGroup(rowGroup);
    rowGroup = new RowGroup<>(rowGroupModel, "Lovejoy", true);
    rowGroup.addMemberRow(bodyDataProvider.getRowObject(9));
    rowGroup.addStaticMemberRow(bodyDataProvider.getRowObject(10));
    rowGroup.addMemberRow(bodyDataProvider.getRowObject(11));
    rowGroupModel.addRowGroup(rowGroup);
    // Corner
    final DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(defaultColumnHeaderDataProvider, rowHeaderDataProvider);
    DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
    ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowGroupHeaderLayer, columnHeaderLayer);
    // Grid
    GridLayer gridLayer = new GridLayer(viewportLayer, columnHeaderLayer, rowGroupHeaderLayer, cornerLayer);
    NatTable natTable = new NatTable(parent, gridLayer, false);
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
    natTable.addConfiguration(new HeaderMenuConfiguration(natTable));
    natTable.configure();
    natTable.setTheme(new ModernNatTableThemeConfiguration());
    return natTable;
}
Also used : HashMap(java.util.HashMap) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) RowGroup(org.eclipse.nebula.widgets.nattable.group.model.RowGroup) HeaderMenuConfiguration(org.eclipse.nebula.widgets.nattable.ui.menu.HeaderMenuConfiguration) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) RowGroupExpandCollapseLayer(org.eclipse.nebula.widgets.nattable.group.RowGroupExpandCollapseLayer) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) DefaultBodyDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultBodyDataProvider) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) RowGroupModel(org.eclipse.nebula.widgets.nattable.group.model.RowGroupModel) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) ModernNatTableThemeConfiguration(org.eclipse.nebula.widgets.nattable.style.theme.ModernNatTableThemeConfiguration) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) CornerLayer(org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider) RowGroupHeaderLayer(org.eclipse.nebula.widgets.nattable.group.RowGroupHeaderLayer) Person(org.eclipse.nebula.widgets.nattable.dataset.person.Person) RowHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.RowHideShowLayer)

Example 45 with DataLayer

use of org.eclipse.nebula.widgets.nattable.layer.DataLayer 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)

Aggregations

DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)227 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)150 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)99 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)96 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)93 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)91 HashMap (java.util.HashMap)83 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)82 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)78 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)77 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)77 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)76 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)75 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)75 DefaultRowHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider)74 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)74 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)70 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)64 Test (org.junit.Test)62 GridLayout (org.eclipse.swt.layout.GridLayout)56