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);
}
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;
}
Aggregations