use of org.eclipse.nebula.widgets.nattable.config.ConfigRegistry in project nebula.widgets.nattable by eclipse.
the class FilterRowHeaderCompositeTest method setup.
@Before
public void setup() {
this.columnHeaderLayer = new DataLayerFixture(10, 2, 100, 50);
this.configRegistry = new ConfigRegistry();
new DefaultNatTableStyleConfiguration().configureRegistry(this.configRegistry);
new DefaultFilterRowConfiguration().configureRegistry(this.configRegistry);
this.filterList = new FilterList<RowDataFixture>(GlazedLists.eventList(RowDataListFixture.getList()));
this.layerUnderTest = new FilterRowHeaderComposite<RowDataFixture>(new DefaultGlazedListsFilterStrategy<RowDataFixture>(this.filterList, new ReflectiveColumnPropertyAccessor<RowDataFixture>(RowDataListFixture.getPropertyNames()), this.configRegistry), this.columnHeaderLayer, this.columnHeaderLayer.getDataProvider(), this.configRegistry);
this.listener = new LayerListenerFixture();
this.layerUnderTest.addLayerListener(this.listener);
}
use of org.eclipse.nebula.widgets.nattable.config.ConfigRegistry in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerGlazedListsTest method setup.
@Before
public void setup() {
// de-normalize the object graph without parent structure objects
List<HierarchicalWrapper> data = HierarchicalHelper.deNormalize(CarService.getInput(), false, CarService.PROPERTY_NAMES_COMPACT);
EventList<HierarchicalWrapper> eventList = GlazedLists.eventList(data);
TransformedList<HierarchicalWrapper, HierarchicalWrapper> rowObjectsGlazedList = GlazedLists.threadSafeList(eventList);
this.columnPropertyAccessor = new HierarchicalReflectiveColumnPropertyAccessor(CarService.PROPERTY_NAMES_COMPACT);
this.sortedList = new SortedList<>(rowObjectsGlazedList, new HierarchicalWrapperComparator(this.columnPropertyAccessor, HierarchicalHelper.getLevelIndexMapping(CarService.PROPERTY_NAMES_COMPACT)));
this.filterList = new FilterList<>(this.sortedList);
this.bodyDataProvider = new ListDataProvider<>(this.filterList, this.columnPropertyAccessor);
HierarchicalSpanningDataProvider spanningDataProvider = new HierarchicalSpanningDataProvider(this.bodyDataProvider, CarService.PROPERTY_NAMES_COMPACT);
this.bodyDataLayer = new SpanningDataLayer(spanningDataProvider);
// simply apply labels for every column by index
this.bodyDataLayer.setConfigLabelAccumulator(new ColumnLabelAccumulator());
// layer for event handling of GlazedLists and PropertyChanges
GlazedListsEventLayer<HierarchicalWrapper> glazedListsEventLayer = new GlazedListsEventLayer<>(this.bodyDataLayer, this.filterList);
glazedListsEventLayer.setTestMode(true);
this.selectionLayer = new SelectionLayer(glazedListsEventLayer);
this.treeLayer = new HierarchicalTreeLayer(this.selectionLayer, this.filterList, CarService.PROPERTY_NAMES_COMPACT);
// create a dummy config registry
this.configRegistry = new ConfigRegistry();
this.configRegistry.registerConfigAttribute(SortConfigAttributes.SORT_COMPARATOR, DefaultComparator.getInstance());
this.columnHeaderDataLayer = new DataLayer(new DefaultColumnHeaderDataProvider(CarService.PROPERTY_NAMES_COMPACT));
}
use of org.eclipse.nebula.widgets.nattable.config.ConfigRegistry in project nebula.widgets.nattable by eclipse.
the class RowSelectionIntegrationTest method setup.
@Before
public void setup() {
IConfigRegistry configRegistry = new ConfigRegistry();
// 10 rows in fixture
this.eventListFixture = GlazedLists.eventList(RowDataListFixture.getList(10));
GlazedListsGridLayer<RowDataFixture> gridLayer = new GlazedListsGridLayer<>(this.eventListFixture, RowDataListFixture.getPropertyNames(), RowDataListFixture.getPropertyToLabelMap(), configRegistry);
this.nattable = new NatTableFixture(gridLayer, false);
this.nattable.setConfigRegistry(configRegistry);
this.selectionLayer = gridLayer.getBodyLayerStack().getSelectionLayer();
this.bodyDataProvider = gridLayer.getBodyDataProvider();
this.selectionProvider = new RowSelectionProvider<>(this.selectionLayer, this.bodyDataProvider);
this.nattable.addConfiguration(new DefaultSortConfiguration());
// Enable preserve selection on data update
this.selectionLayer.setSelectionModel(new RowSelectionModel<>(this.selectionLayer, this.bodyDataProvider, new IRowIdAccessor<RowDataFixture>() {
@Override
public Serializable getRowId(RowDataFixture rowObject) {
return rowObject.getSecurity_id();
}
}));
// Enable test mode - events can be fired outside the Display thread
gridLayer.getGlazedListsEventLayer().setTestMode(true);
this.nattable.configure();
}
use of org.eclipse.nebula.widgets.nattable.config.ConfigRegistry in project nebula.widgets.nattable by eclipse.
the class MultiCellEditDialogRunner method shouldOpenDefaultDialogWithoutIncrementDecrementBox.
public void shouldOpenDefaultDialogWithoutIncrementDecrementBox() {
CellFixture cell = new CellFixture();
cell.setBounds(new Rectangle(100, 100, 100, 20));
cell.setConfigLabels(new LabelStack("Cell_Edit"));
cell.setDataValue("123");
cell.setDisplayMode(DisplayMode.NORMAL);
TextCellEditor cellEditor = new TextCellEditor();
IDisplayConverter dataTypeConverter = new DisplayConverter() {
@Override
public Object canonicalToDisplayValue(Object canonicalValue) {
return canonicalValue;
}
@Override
public Object displayToCanonicalValue(Object displayValue) {
return displayValue;
}
};
final Character newValue = Character.valueOf('4');
IDataValidator dataValidator = new DataValidator() {
@Override
public boolean validate(int columnIndex, int rowIndex, Object newValue) {
Assert.assertEquals(newValue, newValue);
return false;
}
};
Shell shell = new Shell(Display.getDefault(), SWT.H_SCROLL | SWT.V_SCROLL | SWT.RESIZE);
ConfigRegistry configRegistry = new ConfigRegistry();
configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, dataTypeConverter);
configRegistry.registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, dataValidator);
final CellEditDialog dialog = new CellEditDialog(shell, newValue, cell, cellEditor, configRegistry);
if (!this.interactive) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
dialog.close();
}
}
});
}
dialog.open();
}
use of org.eclipse.nebula.widgets.nattable.config.ConfigRegistry in project nebula.widgets.nattable by eclipse.
the class FormulaDisplayConverterTest method shouldConvertToNativeFormulaResult.
@Test
public void shouldConvertToNativeFormulaResult() {
this.formulaDataProvider.getFormulaParser().setDecimalFormat((DecimalFormat) DecimalFormat.getInstance(Locale.ENGLISH));
this.dataProvider.setDataValue(0, 0, "5.3");
this.dataProvider.setDataValue(1, 0, "3.2");
this.dataProvider.setDataValue(2, 0, "=A1+B1");
DataLayer dataLayer = new DataLayer(this.formulaDataProvider);
ConfigRegistry configRegistry = new ConfigRegistry();
assertEquals("=A1+B1", this.editConverter.canonicalToDisplayValue(dataLayer.getCellByPosition(2, 0), configRegistry, this.formulaDataProvider.getDataValue(2, 0)));
this.dataProvider.setDataValue(0, 0, "5.3");
this.dataProvider.setDataValue(1, 0, "2");
this.dataProvider.setDataValue(2, 0, "=A1*B1");
assertEquals("=A1*B1", this.editConverter.canonicalToDisplayValue(dataLayer.getCellByPosition(2, 0), configRegistry, this.formulaDataProvider.getDataValue(2, 0)));
}
Aggregations