Search in sources :

Example 1 with NumberValues

use of org.eclipse.nebula.widgets.nattable.dataset.NumberValues in project nebula.widgets.nattable by eclipse.

the class ColumnGroupHeaderLayerSelectionTest method shouldMoveAnchorOnDeselectWithCtrlWithPreserve.

@Test
public void shouldMoveAnchorOnDeselectWithCtrlWithPreserve() {
    this.gridLayer.getBodyLayer().getSelectionLayer().setSelectionModel(new PreserveSelectionModel<>(this.gridLayer.getBodyLayer().getSelectionLayer(), this.dataProvider, new IRowIdAccessor<NumberValues>() {

        @Override
        public Serializable getRowId(NumberValues rowObject) {
            return rowObject.getColumnOneNumber();
        }
    }));
    this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 2, 0, false, false));
    this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 6, 0, false, true));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(0));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(1));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(2));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(5));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(6));
    PositionCoordinate selectionAnchor = this.gridLayer.getBodyLayer().getSelectionLayer().getSelectionAnchor();
    assertEquals(0, selectionAnchor.getRowPosition());
    assertEquals(5, selectionAnchor.getColumnPosition());
    this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 6, 0, false, true));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(0));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(1));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(2));
    assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(5));
    assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(6));
    selectionAnchor = this.gridLayer.getBodyLayer().getSelectionLayer().getSelectionAnchor();
    assertEquals(0, selectionAnchor.getRowPosition());
    assertEquals(0, selectionAnchor.getColumnPosition());
}
Also used : IRowIdAccessor(org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor) ViewportSelectColumnGroupCommand(org.eclipse.nebula.widgets.nattable.group.command.ViewportSelectColumnGroupCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) NumberValues(org.eclipse.nebula.widgets.nattable.dataset.NumberValues) Test(org.junit.Test)

Example 2 with NumberValues

use of org.eclipse.nebula.widgets.nattable.dataset.NumberValues in project nebula.widgets.nattable by eclipse.

the class ColumnGroupHeaderLayerSelectionTest method getNumberValues.

private List<NumberValues> getNumberValues() {
    List<NumberValues> result = new ArrayList<>();
    for (int i = 0; i < 50; i++) {
        NumberValues value = new NumberValues();
        value.setColumnOneNumber(i * 10);
        value.setColumnTwoNumber(i * 10 + 1);
        value.setColumnThreeNumber(i * 10 + 2);
        value.setColumnFourNumber(i * 10 + 3);
        value.setColumnFiveNumber(i * 10 + 4);
        value.setColumnSixNumber(i * 10 + 5);
        value.setColumnSevenNumber(i * 10 + 6);
        value.setColumnEightNumber(i * 10 + 7);
        value.setColumnNineNumber(i * 10 + 8);
        value.setColumnTenNumber(i * 10 + 9);
        result.add(value);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) NumberValues(org.eclipse.nebula.widgets.nattable.dataset.NumberValues)

Example 3 with NumberValues

use of org.eclipse.nebula.widgets.nattable.dataset.NumberValues in project nebula.widgets.nattable by eclipse.

the class _5121_SummaryRowExample method createExampleControl.

/*
     * (non-Javadoc)
     *
     * @see
     * org.eclipse.nebula.widgets.nattable.examples.INatExample#createExampleControl
     * (org.eclipse.swt.widgets.Composite)
     */
@Override
public Control createExampleControl(Composite parent) {
    // property names of the NumberValues class
    String[] propertyNames = { "columnOneNumber", "columnTwoNumber", "columnThreeNumber", "columnFourNumber", "columnFiveNumber" };
    IColumnPropertyAccessor<NumberValues> cpa = new ReflectiveColumnPropertyAccessor<>(propertyNames);
    IDataProvider dataProvider = new ListDataProvider<>(createNumberValueList(), cpa);
    ConfigRegistry configRegistry = new ConfigRegistry();
    DataLayer dataLayer = new DataLayer(dataProvider);
    // Plug in the SummaryRowLayer
    SummaryRowLayer summaryRowLayer = new SummaryRowLayer(dataLayer, configRegistry, false);
    ViewportLayer viewportLayer = new ViewportLayer(summaryRowLayer);
    NatTable natTable = new NatTable(parent, viewportLayer, false);
    // Configure custom summary formula for a column
    natTable.addConfiguration(new ExampleSummaryRowConfiguration(dataProvider));
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
    natTable.setConfigRegistry(configRegistry);
    natTable.configure();
    return natTable;
}
Also used : ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) NumberValues(org.eclipse.nebula.widgets.nattable.dataset.NumberValues) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) SummaryRowLayer(org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable)

Example 4 with NumberValues

use of org.eclipse.nebula.widgets.nattable.dataset.NumberValues in project nebula.widgets.nattable by eclipse.

the class ExampleSummaryRowGridConfiguration method createExampleControl.

/*
     * (non-Javadoc)
     *
     * @see
     * org.eclipse.nebula.widgets.nattable.examples.INatExample#createExampleControl
     * (org.eclipse.swt.widgets.Composite)
     */
@Override
public Control createExampleControl(Composite parent) {
    // property names of the NumberValues class
    String[] propertyNames = { "columnOneNumber", "columnTwoNumber", "columnThreeNumber", "columnFourNumber", "columnFiveNumber" };
    // mapping from property to label, needed for column header labels
    Map<String, String> propertyToLabelMap = new HashMap<>();
    propertyToLabelMap.put("columnOneNumber", "Column 1");
    propertyToLabelMap.put("columnTwoNumber", "Column 2");
    propertyToLabelMap.put("columnThreeNumber", "Column 3");
    propertyToLabelMap.put("columnFourNumber", "Column 4");
    propertyToLabelMap.put("columnFiveNumber", "Column 5");
    IColumnPropertyAccessor<NumberValues> cpa = new ReflectiveColumnPropertyAccessor<>(propertyNames);
    IDataProvider dataProvider = new ListDataProvider<>(createNumberValueList(), cpa);
    ConfigRegistry configRegistry = new ConfigRegistry();
    SummaryRowGridLayer gridLayer = new SummaryRowGridLayer(dataProvider, configRegistry, propertyNames, propertyToLabelMap);
    NatTable natTable = new NatTable(parent, gridLayer, false);
    natTable.setConfigRegistry(configRegistry);
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
    natTable.configure();
    return natTable;
}
Also used : ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) HashMap(java.util.HashMap) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) NumberValues(org.eclipse.nebula.widgets.nattable.dataset.NumberValues) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) NatTable(org.eclipse.nebula.widgets.nattable.NatTable)

Example 5 with NumberValues

use of org.eclipse.nebula.widgets.nattable.dataset.NumberValues in project nebula.widgets.nattable by eclipse.

the class ExampleSummaryRowGridConfiguration method createNumberValueList.

private List<NumberValues> createNumberValueList() {
    List<NumberValues> result = new ArrayList<>();
    for (int i = 0; i < 25; i++) {
        NumberValues nv = new NumberValues();
        nv.setColumnOneNumber(5);
        nv.setColumnTwoNumber(4);
        nv.setColumnThreeNumber(3);
        nv.setColumnFourNumber(1);
        nv.setColumnFiveNumber(1);
        result.add(nv);
        nv = new NumberValues();
        nv.setColumnOneNumber(1);
        nv.setColumnTwoNumber(1);
        nv.setColumnThreeNumber(2);
        nv.setColumnFourNumber(2);
        nv.setColumnFiveNumber(3);
        result.add(nv);
        nv = new NumberValues();
        nv.setColumnOneNumber(1);
        nv.setColumnTwoNumber(2);
        nv.setColumnThreeNumber(2);
        nv.setColumnFourNumber(3);
        nv.setColumnFiveNumber(3);
        result.add(nv);
        nv = new NumberValues();
        nv.setColumnOneNumber(1);
        nv.setColumnTwoNumber(2);
        nv.setColumnThreeNumber(4);
        nv.setColumnFourNumber(4);
        nv.setColumnFiveNumber(3);
        result.add(nv);
        nv = new NumberValues();
        nv.setColumnOneNumber(5);
        nv.setColumnTwoNumber(4);
        nv.setColumnThreeNumber(4);
        nv.setColumnFourNumber(4);
        nv.setColumnFiveNumber(7);
        result.add(nv);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) NumberValues(org.eclipse.nebula.widgets.nattable.dataset.NumberValues)

Aggregations

NumberValues (org.eclipse.nebula.widgets.nattable.dataset.NumberValues)22 ArrayList (java.util.ArrayList)10 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)6 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)6 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)5 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)5 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)5 ReflectiveColumnPropertyAccessor (org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor)5 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)4 HashMap (java.util.HashMap)3 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 CompositeLayer (org.eclipse.nebula.widgets.nattable.layer.CompositeLayer)2 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)2 FixedSummaryRowLayer (org.eclipse.nebula.widgets.nattable.summaryrow.FixedSummaryRowLayer)2 Map (java.util.Map)1 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)1 PositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate)1 AutomaticSpanningDataProvider (org.eclipse.nebula.widgets.nattable.data.AutomaticSpanningDataProvider)1