Search in sources :

Example 71 with ViewportLayer

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);
}
Also used : DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) Before(org.junit.Before)

Example 72 with ViewportLayer

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));
}
Also used : DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)

Example 73 with ViewportLayer

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));
}
Also used : DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)

Example 74 with ViewportLayer

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());
}
Also used : ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) HashMap(java.util.HashMap) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) GridLayout(org.eclipse.swt.layout.GridLayout) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) E4SelectionListener(org.eclipse.nebula.widgets.nattable.extension.e4.selection.E4SelectionListener) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) Text(org.eclipse.swt.widgets.Text) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) 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) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider) Person(org.eclipse.nebula.widgets.nattable.dataset.person.Person) PostConstruct(javax.annotation.PostConstruct)

Example 75 with ViewportLayer

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;
}
Also used : DefaultEditConfiguration(org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditConfiguration) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) AbstractRegistryConfiguration(org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) SpanningDataLayer(org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer) DefaultEditBindings(org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditBindings)

Aggregations

ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)96 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)77 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)71 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)71 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)56 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)53 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)48 DefaultRowHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider)41 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)41 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)40 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)39 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)39 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)39 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)39 HashMap (java.util.HashMap)38 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)34 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)34 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)31 CompositeLayer (org.eclipse.nebula.widgets.nattable.layer.CompositeLayer)25 ColumnReorderLayer (org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer)25