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());
}
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;
}
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;
}
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;
}
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;
}
Aggregations