Search in sources :

Example 16 with DummyColumnHeaderDataProvider

use of org.eclipse.nebula.widgets.nattable.grid.data.DummyColumnHeaderDataProvider in project nebula.widgets.nattable by eclipse.

the class InvertedLayerExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    DummyBodyDataProvider bodyDataProvider = new DummyBodyDataProvider(5, 10);
    DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
    bodyDataLayer.setDefaultRowHeight(100);
    SelectionLayer selectionLayer = new SelectionLayer(new ColumnHideShowLayer(new ColumnReorderLayer(bodyDataLayer)));
    InvertedLayer invertedLayer = new InvertedLayer(selectionLayer);
    ViewportLayer viewportLayer = new ViewportLayer(invertedLayer);
    DummyColumnHeaderDataProvider columnHeaderDataProvider = new DummyColumnHeaderDataProvider(bodyDataProvider);
    DataLayer columnHeaderDataLayer = new DataLayer(columnHeaderDataProvider);
    ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, viewportLayer, selectionLayer);
    DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
    DataLayer rowHeaderDataLayer = new DataLayer(rowHeaderDataProvider);
    rowHeaderDataLayer.setDefaultColumnWidth(40);
    ILayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, viewportLayer, selectionLayer);
    ILayer cornerLayer = new CornerLayer(new DataLayer(new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider)), rowHeaderLayer, columnHeaderLayer);
    GridLayer compositeLayer = new GridLayer(viewportLayer, columnHeaderLayer, rowHeaderLayer, cornerLayer);
    return new NatTable(parent, compositeLayer);
}
Also used : DummyBodyDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DummyBodyDataProvider) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) DummyColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DummyColumnHeaderDataProvider) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) InvertedLayer(org.eclipse.nebula.widgets.nattable.layer.InvertedLayer) 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) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)

Example 17 with DummyColumnHeaderDataProvider

use of org.eclipse.nebula.widgets.nattable.grid.data.DummyColumnHeaderDataProvider in project nebula.widgets.nattable by eclipse.

the class _781_DragAndDropExample method createTable.

private NatTable createTable(Composite parent, List<Person> data) {
    // property names of the Person class
    String[] propertyNames = { "firstName", "lastName" };
    // mapping from property to label, needed for column header labels
    Map<String, String> propertyToLabelMap = new HashMap<>();
    propertyToLabelMap.put("firstName", "Firstname");
    propertyToLabelMap.put("lastName", "Lastname");
    IColumnPropertyAccessor<Person> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
    IRowDataProvider<Person> bodyDataProvider = new ListDataProvider<>(data, columnPropertyAccessor);
    final DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
    ColumnReorderLayer reorderLayer = new ColumnReorderLayer(bodyDataLayer);
    final SelectionLayer selectionLayer = new SelectionLayer(reorderLayer);
    // set row selection model with single selection enabled
    selectionLayer.setSelectionModel(new RowSelectionModel<>(selectionLayer, bodyDataProvider, new IRowIdAccessor<Person>() {

        @Override
        public Serializable getRowId(Person rowObject) {
            return rowObject.getId();
        }
    }, false));
    ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
    ILayer columnHeaderLayer = new ColumnHeaderLayer(new DataLayer(new DummyColumnHeaderDataProvider(bodyDataProvider)), viewportLayer, selectionLayer);
    CompositeLayer compositeLayer = new CompositeLayer(1, 2);
    compositeLayer.setChildLayer(GridRegion.COLUMN_HEADER, columnHeaderLayer, 0, 0);
    compositeLayer.setChildLayer(GridRegion.BODY, viewportLayer, 0, 1);
    NatTable natTable = new NatTable(parent, compositeLayer);
    // add DnD support
    DragAndDropSupport dndSupport = new DragAndDropSupport(natTable, selectionLayer, data);
    Transfer[] transfer = { TextTransfer.getInstance() };
    natTable.addDragSupport(DND.DROP_COPY, transfer, dndSupport);
    natTable.addDropSupport(DND.DROP_COPY, transfer, dndSupport);
    // adding a full border
    natTable.addOverlayPainter(new NatTableBorderOverlayPainter(natTable.getConfigRegistry()));
    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) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) CompositeLayer(org.eclipse.nebula.widgets.nattable.layer.CompositeLayer) DummyColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DummyColumnHeaderDataProvider) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) IRowIdAccessor(org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Transfer(org.eclipse.swt.dnd.Transfer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) NatTableBorderOverlayPainter(org.eclipse.nebula.widgets.nattable.painter.NatTableBorderOverlayPainter) Person(org.eclipse.nebula.widgets.nattable.dataset.person.Person)

Aggregations

DummyColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DummyColumnHeaderDataProvider)17 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)16 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)16 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)16 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)16 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)13 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)11 CompositeLayer (org.eclipse.nebula.widgets.nattable.layer.CompositeLayer)10 DummyBodyDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DummyBodyDataProvider)8 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)7 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)6 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)6 DefaultRowHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider)6 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)6 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)6 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)6 ColumnReorderLayer (org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer)5 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)4 LineBorderDecorator (org.eclipse.nebula.widgets.nattable.painter.cell.decorator.LineBorderDecorator)3 ArrayList (java.util.ArrayList)2