use of org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer in project nebula.widgets.nattable by eclipse.
the class CellSelectionTraversalTest method setUp.
@Before
public void setUp() {
this.selectionLayer = new SelectionLayer(new DataLayerFixture(10, 10, 100, 20));
this.viewportLayer = new ViewportLayer(this.selectionLayer);
}
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 NatTableFixture method scrollToColumn.
public void scrollToColumn(int gridColumnPosition) {
DummyGridLayerStack gridLayer = (DummyGridLayerStack) getUnderlyingLayerByPosition(1, 1);
ViewportLayer viewportLayer = gridLayer.getBodyLayer().getViewportLayer();
viewportLayer.invalidateHorizontalStructure();
viewportLayer.setOriginX(viewportLayer.getStartXOfColumnPosition(gridColumnPosition));
}
use of org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer in project nebula.widgets.nattable by eclipse.
the class SelectionListenerExample method postConstruct.
@PostConstruct
public void postConstruct(Composite parent) {
// 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");
IColumnPropertyAccessor<Person> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
final List<Person> data = PersonService.getPersons(10);
// create the body layer stack
final IRowDataProvider<Person> bodyDataProvider = new ListDataProvider<>(data, columnPropertyAccessor);
final DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
final SelectionLayer selectionLayer = new SelectionLayer(bodyDataLayer);
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
// create a E4SelectionListener and configure it for providing selection
// on cell selection
E4SelectionListener<Person> esl = new E4SelectionListener<>(service, selectionLayer, bodyDataProvider);
esl.setFullySelectedRowsOnly(false);
esl.setHandleSameRowSelection(false);
selectionLayer.addLayerListener(esl);
// create the column header layer stack
IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
ILayer columnHeaderLayer = new ColumnHeaderLayer(new DataLayer(columnHeaderDataProvider), viewportLayer, selectionLayer);
// create the row header layer stack
IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
ILayer rowHeaderLayer = new RowHeaderLayer(new DefaultRowHeaderDataLayer(new DefaultRowHeaderDataProvider(bodyDataProvider)), viewportLayer, selectionLayer);
// create the corner layer stack
ILayer cornerLayer = new CornerLayer(new DataLayer(new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider)), rowHeaderLayer, columnHeaderLayer);
// create the grid layer composed with the prior created layer stacks
GridLayer gridLayer = new GridLayer(viewportLayer, columnHeaderLayer, rowHeaderLayer, cornerLayer);
final NatTable natTable = new NatTable(parent, gridLayer);
natTable.setData("org.eclipse.e4.ui.css.CssClassName", "modern");
parent.setLayout(new GridLayout());
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
outputArea = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
outputArea.setEditable(false);
GridDataFactory.fillDefaults().grab(true, false).hint(0, 100).align(SWT.FILL, SWT.BEGINNING).applyTo(outputArea);
showSourceLinks(parent, getClass().getName());
}
use of org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer in project nebula.widgets.nattable by eclipse.
the class _5014_SpanningDataLayerExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
// To make the default edit and selection configurations work correctly,
// the region label
// GridRegion.BODY is necessary, which is directly set to the
// ViewportLayer instance here.
ViewportLayer layer = new ViewportLayer(new SelectionLayer(new SpanningDataLayer(new DummySpanningBodyDataProvider(100, 100))));
layer.setRegionName(GridRegion.BODY);
NatTable natTable = new NatTable(parent, layer, false);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
// add configurations to enable editing
// this is to verify that spanned cells are also editable and update the
// data model correctly
// @see Bug 414754
layer.addConfiguration(new DefaultEditBindings());
layer.addConfiguration(new DefaultEditConfiguration());
layer.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE);
}
});
natTable.configure();
return natTable;
}
Aggregations