Search in sources :

Example 1 with NatGridLayerPainter

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

the class _4221_NatGridLayerPainterExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    parent.setLayout(new GridLayout());
    // property names of the Person class
    String[] propertyNames = { "firstName", "lastName", "gender", "married", "birthday" };
    IColumnPropertyAccessor<Person> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
    IDataProvider bodyDataProvider = new ListDataProvider<>(PersonService.getPersons(10), columnPropertyAccessor);
    final DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
    // use different style bits to avoid rendering of inactive scrollbars
    // for small table
    // Note: The enabling/disabling and showing of the scrollbars is handled
    // by the ViewportLayer.
    // Without the ViewportLayer the scrollbars will always be visible with
    // the default style bits of NatTable.
    final NatTable natTable = new NatTable(parent, SWT.NO_REDRAW_RESIZE | SWT.DOUBLE_BUFFERED | SWT.BORDER, bodyDataLayer);
    natTable.setBackground(GUIHelper.COLOR_WHITE);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
    natTable.setLayerPainter(new NatGridLayerPainter(natTable, DataLayer.DEFAULT_ROW_HEIGHT));
    return natTable;
}
Also used : ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) GridLayout(org.eclipse.swt.layout.GridLayout) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) Person(org.eclipse.nebula.widgets.nattable.dataset.person.Person) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) NatGridLayerPainter(org.eclipse.nebula.widgets.nattable.painter.layer.NatGridLayerPainter)

Example 2 with NatGridLayerPainter

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

the class _010_NatTable_with_grid_painting_of_remainder_space method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    NatTable natTable = new NatTable(parent);
    NatGridLayerPainter layerPainter = new NatGridLayerPainter(natTable);
    natTable.setLayerPainter(layerPainter);
    return natTable;
}
Also used : NatTable(org.eclipse.nebula.widgets.nattable.NatTable) NatGridLayerPainter(org.eclipse.nebula.widgets.nattable.painter.layer.NatGridLayerPainter)

Aggregations

NatTable (org.eclipse.nebula.widgets.nattable.NatTable)2 NatGridLayerPainter (org.eclipse.nebula.widgets.nattable.painter.layer.NatGridLayerPainter)2 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)1 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)1 ReflectiveColumnPropertyAccessor (org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor)1 Person (org.eclipse.nebula.widgets.nattable.dataset.person.Person)1 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)1 GridLayout (org.eclipse.swt.layout.GridLayout)1