Search in sources :

Example 36 with IConfigRegistry

use of org.eclipse.nebula.widgets.nattable.config.IConfigRegistry in project nebula.widgets.nattable by eclipse.

the class Creating_a_summary_row method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    this.myDataProvider = new IDataProvider() {

        @Override
        public int getColumnCount() {
            return 4;
        }

        @Override
        public int getRowCount() {
            return 10;
        }

        @Override
        public Object getDataValue(int columnIndex, int rowIndex) {
            if (columnIndex >= getColumnCount() || rowIndex >= getRowCount()) {
                throw new RuntimeException("Data value requested is out of bounds");
            }
            return (columnIndex % 2 == 0) ? 10 : "Apple";
        }

        @Override
        public void setDataValue(int columnIndex, int rowIndex, Object newValue) {
        }
    };
    IConfigRegistry configRegistry = new ConfigRegistry();
    IUniqueIndexLayer dataLayer = new DataLayer(this.myDataProvider);
    // Plug in the SummaryRowLayer
    IUniqueIndexLayer 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 MySummaryRowConfig(this.myDataProvider));
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
    natTable.setConfigRegistry(configRegistry);
    natTable.configure();
    return natTable;
}
Also used : IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) 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) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) SummaryRowLayer(org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) IUniqueIndexLayer(org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer)

Example 37 with IConfigRegistry

use of org.eclipse.nebula.widgets.nattable.config.IConfigRegistry in project nebula.widgets.nattable by eclipse.

the class Applying_style_to_a_cell method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    SelectionExampleGridLayer gridLayer = new SelectionExampleGridLayer();
    NatTable natTable = new NatTable(parent, gridLayer, false);
    DataLayer bodyDataLayer = gridLayer.getBodyDataLayer();
    // Label accumulator - adds labels to all cells with the given data
    // value
    CellOverrideLabelAccumulator<RowDataFixture> cellLabelAccumulator = new CellOverrideLabelAccumulator<>(gridLayer.getBodyDataProvider());
    cellLabelAccumulator.registerOverride("AAA", 2, CELL_LABEL);
    // Register your cell style, against the label applied to the cell
    // Other configuration which can be added (apart from style) include
    // CellConfigAttributes, EditConfigAttributes, SortConfigAttributes etc.
    IConfigRegistry configRegistry = new ConfigRegistry();
    addColumnHighlight(configRegistry);
    // Register label accumulator
    bodyDataLayer.setConfigLabelAccumulator(cellLabelAccumulator);
    gridLayer.getSelectionLayer().addConfiguration(new DefaultSelectionLayerConfiguration());
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
    natTable.setConfigRegistry(configRegistry);
    natTable.configure();
    return natTable;
}
Also used : SelectionExampleGridLayer(org.eclipse.nebula.widgets.nattable.examples.fixtures.SelectionExampleGridLayer) 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) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) RowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture) CellOverrideLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.CellOverrideLabelAccumulator) DefaultSelectionLayerConfiguration(org.eclipse.nebula.widgets.nattable.selection.config.DefaultSelectionLayerConfiguration)

Example 38 with IConfigRegistry

use of org.eclipse.nebula.widgets.nattable.config.IConfigRegistry 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 39 with IConfigRegistry

use of org.eclipse.nebula.widgets.nattable.config.IConfigRegistry in project nebula.widgets.nattable by eclipse.

the class FillHandlePasteTest method setup.

@Before
public void setup() {
    this.natTable.addConfiguration(new FillHandleConfiguration(this.selectionLayer));
    this.natTable.addConfiguration(new AbstractRegistryConfiguration() {

        @Override
        public void configureRegistry(IConfigRegistry configRegistry) {
            configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, EditableRule.ALWAYS_EDITABLE);
        }
    });
    this.natTable.configure();
}
Also used : AbstractRegistryConfiguration(org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) FillHandleConfiguration(org.eclipse.nebula.widgets.nattable.fillhandle.config.FillHandleConfiguration) Before(org.junit.Before)

Example 40 with IConfigRegistry

use of org.eclipse.nebula.widgets.nattable.config.IConfigRegistry in project nebula.widgets.nattable by eclipse.

the class FillHandleSeriesTest method setup.

@Before
public void setup() {
    this.natTable.addConfiguration(new FillHandleConfiguration(this.selectionLayer));
    this.natTable.addConfiguration(new AbstractRegistryConfiguration() {

        @Override
        public void configureRegistry(IConfigRegistry configRegistry) {
            configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, EditableRule.ALWAYS_EDITABLE);
        }
    });
    this.natTable.configure();
}
Also used : AbstractRegistryConfiguration(org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) FillHandleConfiguration(org.eclipse.nebula.widgets.nattable.fillhandle.config.FillHandleConfiguration) Before(org.junit.Before)

Aggregations

IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)64 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)42 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)42 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)38 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)37 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)34 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)31 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)29 HashMap (java.util.HashMap)28 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)27 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)26 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)24 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)24 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)24 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)23 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)23 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)23 GridLayout (org.eclipse.swt.layout.GridLayout)23 Composite (org.eclipse.swt.widgets.Composite)23 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)20