use of org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer in project nebula.widgets.nattable by eclipse.
the class _772_GridExcelExportExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
Composite panel = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
panel.setLayout(layout);
GridDataFactory.fillDefaults().grab(true, true).applyTo(panel);
Composite gridPanel = new Composite(panel, SWT.NONE);
gridPanel.setLayout(layout);
GridDataFactory.fillDefaults().grab(true, true).applyTo(gridPanel);
Composite buttonPanel = new Composite(panel, SWT.NONE);
buttonPanel.setLayout(new GridLayout());
GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonPanel);
// 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.
IDataProvider bodyDataProvider = new DefaultBodyDataProvider<>(PersonService.getPersons(10), propertyNames);
DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
SelectionLayer selectionLayer = new SelectionLayer(bodyDataLayer);
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);
final NatTable natTable = new NatTable(gridPanel, gridLayer);
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
Button addColumnButton = new Button(buttonPanel, SWT.PUSH);
addColumnButton.setText("Export");
addColumnButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
natTable.doCommand(new ExportCommand(natTable.getConfigRegistry(), natTable.getShell()));
}
});
return panel;
}
use of org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer 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);
}
use of org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer in project nebula.widgets.nattable by eclipse.
the class ElementalViewportLayerPerformanceTest method testCompositeViewportDataLayerPerformance.
@Test
public void testCompositeViewportDataLayerPerformance() {
CompositeLayer compositeLayer = new CompositeLayer(1, 1);
compositeLayer.setChildLayer(GridRegion.BODY, new ViewportLayer(new DataLayer(new DummyBodyDataProvider(1000000, 1000000))), 0, 0);
layer = compositeLayer;
}
use of org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer in project nebula.widgets.nattable by eclipse.
the class NatTableFixture method scrollToRow.
public void scrollToRow(int gridRowPosition) {
DummyGridLayerStack gridLayer = (DummyGridLayerStack) getUnderlyingLayerByPosition(1, 1);
ViewportLayer viewportLayer = gridLayer.getBodyLayer().getViewportLayer();
viewportLayer.invalidateVerticalStructure();
viewportLayer.setOriginY(viewportLayer.getStartYOfRowPosition(gridRowPosition));
}
use of org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer in project nebula.widgets.nattable by eclipse.
the class CompositeFreezeLayerTest method setup.
@Before
public void setup() {
TestLayer dataLayer = new TestLayer(4, 4, "0:0;100 | 1:1;100 | 2:2;100 | 3:3;100", "0:0;40 | 1:1;40 | 2:2;40 | 3:3;40", "A0 | B0 | C0 | D0 \n" + "A1 | B1 | C1 | D1 \n" + "A2 | B2 | C2 | D2 \n" + "A3 | B3 | C3 | D3 \n");
this.reorderLayer = new ColumnReorderLayer(dataLayer);
this.hideShowLayer = new ColumnHideShowLayer(this.reorderLayer);
this.selectionLayer = new SelectionLayer(this.hideShowLayer);
this.viewportLayer = new ViewportLayer(this.selectionLayer);
this.freezeLayer = new FreezeLayer(this.selectionLayer);
this.compositeFreezeLayer = new CompositeFreezeLayer(this.freezeLayer, this.viewportLayer, this.selectionLayer);
this.compositeFreezeLayer.setClientAreaProvider(new IClientAreaProvider() {
@Override
public Rectangle getClientArea() {
return new Rectangle(0, 0, 400, 160);
}
});
this.compositeFreezeLayer.doCommand(new InitializeClientAreaCommandFixture());
}
Aggregations