use of org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer in project nebula.widgets.nattable by eclipse.
the class _762_MultiPrintExample method createGrid.
private NatTable createGrid(Composite parent) {
// property names of the Person class
String[] propertyNames = { "firstName", "lastName", "gender", "married", "birthday", "address.street", "address.housenumber", "address.postalCode", "address.city" };
// 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");
propertyToLabelMap.put("address.street", "Street");
propertyToLabelMap.put("address.housenumber", "Housenumber");
propertyToLabelMap.put("address.postalCode", "Postal Code");
propertyToLabelMap.put("address.city", "City");
// 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(100);
IColumnPropertyAccessor<PersonWithAddress> accessor = new ExtendedReflectiveColumnPropertyAccessor<>(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);
// 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, columnHeaderLayer);
// build the grid layer
GridLayer gridLayer = new GridLayer(viewportLayer, columnHeaderLayer, rowHeaderLayer, cornerLayer);
NatTable natTable = new NatTable(parent, gridLayer);
natTable.addOverlayPainter(new NatTableBorderOverlayPainter());
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
return natTable;
}
use of org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer in project nebula.widgets.nattable by eclipse.
the class _002_Lateral_layer_composition method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
DummyBodyDataProvider bodyDataProvider = new DummyBodyDataProvider(200, 1000000);
SelectionLayer selectionLayer = new SelectionLayer(new ColumnReorderLayer(new DataLayer(bodyDataProvider)));
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, false);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new DebugMenuConfiguration(natTable));
natTable.configure();
return natTable;
}
use of org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer in project nebula.widgets.nattable by eclipse.
the class CompositeGridLayerExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
DummyBodyDataProvider bodyDataProvider = new DummyBodyDataProvider(500, 1000000);
SelectionLayer selectionLayer = new SelectionLayer(new ColumnHideShowLayer(new ColumnReorderLayer(new DataLayer(bodyDataProvider))));
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
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.reorder.ColumnReorderLayer in project nebula.widgets.nattable by eclipse.
the class ColumnHeaderViewportSelectionReorderDataLayerExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
DummyBodyDataProvider bodyDataProvider = new DummyBodyDataProvider(200, 1000000);
SelectionLayer selectionLayer = new SelectionLayer(new ColumnReorderLayer(new DataLayer(bodyDataProvider)));
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);
return new NatTable(parent, compositeLayer);
}
use of org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer in project nebula.widgets.nattable by eclipse.
the class ElementalViewportLayerPerformanceTest method testViewportReorderDataLayerPerformance.
@Test
public void testViewportReorderDataLayerPerformance() {
ColumnReorderLayer reorderLayer = new ColumnReorderLayer(new DataLayer(new DummyBodyDataProvider(1000000, 1000000)));
reorderLayer.reorderColumnPosition(1, 2);
layer = new ViewportLayer(reorderLayer);
}
Aggregations