Search in sources :

Example 51 with ConfigRegistry

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);
}
Also used : ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) DataLayerFixture(org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.DataLayerFixture) DefaultFilterRowConfiguration(org.eclipse.nebula.widgets.nattable.filterrow.config.DefaultFilterRowConfiguration) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.LayerListenerFixture) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) Before(org.junit.Before)

Example 52 with ConfigRegistry

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));
}
Also used : HierarchicalWrapper(org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalWrapper) SpanningDataLayer(org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer) GlazedListsEventLayer(org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) SpanningDataLayer(org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) HierarchicalWrapperComparator(org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalWrapperComparator) ColumnLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.ColumnLabelAccumulator) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider) HierarchicalReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalReflectiveColumnPropertyAccessor) HierarchicalSpanningDataProvider(org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalSpanningDataProvider) HierarchicalTreeLayer(org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalTreeLayer) Before(org.junit.Before)

Example 53 with ConfigRegistry

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();
}
Also used : IRowIdAccessor(org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) DefaultSortConfiguration(org.eclipse.nebula.widgets.nattable.sort.config.DefaultSortConfiguration) NatTableFixture(org.eclipse.nebula.widgets.nattable.extension.glazedlists.fixture.NatTableFixture) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) Before(org.junit.Before)

Example 54 with ConfigRegistry

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();
}
Also used : CellFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.CellFixture) LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) IDataValidator(org.eclipse.nebula.widgets.nattable.data.validate.IDataValidator) DisplayConverter(org.eclipse.nebula.widgets.nattable.data.convert.DisplayConverter) IDisplayConverter(org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter) Rectangle(org.eclipse.swt.graphics.Rectangle) IDisplayConverter(org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) Shell(org.eclipse.swt.widgets.Shell) IDataValidator(org.eclipse.nebula.widgets.nattable.data.validate.IDataValidator) DataValidator(org.eclipse.nebula.widgets.nattable.data.validate.DataValidator) TextCellEditor(org.eclipse.nebula.widgets.nattable.edit.editor.TextCellEditor)

Example 55 with ConfigRegistry

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)));
}
Also used : ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) Test(org.junit.Test)

Aggregations

ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)92 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)72 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)61 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)54 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)54 HashMap (java.util.HashMap)40 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)38 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)38 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)34 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)34 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)33 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)33 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)33 GridLayout (org.eclipse.swt.layout.GridLayout)33 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)32 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)31 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)31 Composite (org.eclipse.swt.widgets.Composite)31 DefaultRowHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider)28 SelectionEvent (org.eclipse.swt.events.SelectionEvent)28