Search in sources :

Example 1 with BlinkLayer

use of org.eclipse.nebula.widgets.nattable.blink.BlinkLayer in project nebula.widgets.nattable by eclipse.

the class BlinkingGridExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    final String[] propertyNames = RowDataListFixture.getPropertyNames();
    final Map<String, String> propertyToLabelMap = RowDataListFixture.getPropertyToLabelMap();
    ConfigRegistry configRegistry = new ConfigRegistry();
    // Body
    LinkedList<BlinkingRowDataFixture> rowData = new LinkedList<>();
    EventList<BlinkingRowDataFixture> eventList = GlazedLists.eventList(rowData);
    ObservableElementList<BlinkingRowDataFixture> observableElementList = new ObservableElementList<>(eventList, GlazedLists.beanConnector(BlinkingRowDataFixture.class));
    IColumnPropertyAccessor<BlinkingRowDataFixture> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
    this.bodyDataProvider = new ListDataProvider<>(observableElementList, columnPropertyAccessor);
    final DataLayer bodyLayer = new DataLayer(this.bodyDataProvider);
    GlazedListsEventLayer<BlinkingRowDataFixture> glazedListsEventLayer = new GlazedListsEventLayer<>(bodyLayer, observableElementList);
    BlinkLayer<BlinkingRowDataFixture> blinkingLayer = new BlinkLayer<>(glazedListsEventLayer, this.bodyDataProvider, new IRowIdAccessor<BlinkingRowDataFixture>() {

        @Override
        public Serializable getRowId(BlinkingRowDataFixture rowObject) {
            return rowObject.getSecurity_description();
        }
    }, columnPropertyAccessor, configRegistry);
    registerBlinkingConfigCells(configRegistry);
    insertRowData(glazedListsEventLayer, this.bodyDataProvider);
    // Column header
    final DefaultColumnHeaderDataProvider defaultColumnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
    // Row header
    final DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(this.bodyDataProvider);
    // Corner
    final DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(defaultColumnHeaderDataProvider, rowHeaderDataProvider);
    // Grid
    GridLayer gridLayer = new DefaultGridLayer(blinkingLayer, new DefaultColumnHeaderDataLayer(defaultColumnHeaderDataProvider), new DefaultRowHeaderDataLayer(rowHeaderDataProvider), new DataLayer(cornerDataProvider));
    NatTable natTable = new NatTable(parent, gridLayer, false);
    natTable.setConfigRegistry(configRegistry);
    natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
    natTable.configure();
    return natTable;
}
Also used : Serializable(java.io.Serializable) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) GlazedListsEventLayer(org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer) ObservableElementList(ca.odell.glazedlists.ObservableElementList) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) LinkedList(java.util.LinkedList) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) BlinkingRowDataFixture(org.eclipse.nebula.widgets.nattable.dataset.fixture.data.BlinkingRowDataFixture) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) DefaultGridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider) DefaultGridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer) BlinkLayer(org.eclipse.nebula.widgets.nattable.blink.BlinkLayer)

Example 2 with BlinkLayer

use of org.eclipse.nebula.widgets.nattable.blink.BlinkLayer in project nebula.widgets.nattable by eclipse.

the class BlinkingGlazedListExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    // Data backing the table
    this.baseTupleList.add(new Tuple(this.headers, new Object[] { "Name 1", "Value 1", 1.5d, -1000 }, 0));
    this.baseTupleList.add(new Tuple(this.headers, new Object[] { "Name 2", "Value 2", -2.5d, 2000 }, 1));
    this.baseTupleList.add(new Tuple(this.headers, new Object[] { "Name 3", "Value 3", 3.5d, -3000 }, 2));
    this.baseTupleList.add(new Tuple(this.headers, new Object[] { "Name 4", "Value 4", -4.5d, 4000 }, 3));
    this.baseTupleList.add(new Tuple(this.headers, new Object[] { "Name 5", "Value 5", 5.5d, -5000 }, 4));
    ConfigRegistry configRegistry = new ConfigRegistry();
    ObservableElementList<Tuple> observableTupleList = new ObservableElementList<>(this.baseTupleList, GlazedLists.beanConnector(Tuple.class));
    TupleColumnPropertyAccessor columnPropertyAccessor = new TupleColumnPropertyAccessor();
    ListDataProvider<Tuple> bodyDataProvider = new ListDataProvider<>(observableTupleList, columnPropertyAccessor);
    DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
    // Enable capturing glazed list update events
    GlazedListsEventLayer<Tuple> glazedListEventsLayer = new GlazedListsEventLayer<>(bodyDataLayer, this.baseTupleList);
    // Enable blinking
    final BlinkLayer<Tuple> blinkingLayer = new BlinkLayer<>(glazedListEventsLayer, bodyDataProvider, getRowIdAccessor(), columnPropertyAccessor, configRegistry);
    registerBlinkingConfigCells(configRegistry);
    // Add Listener to existing elements
    try {
        this.baseTupleList.getReadWriteLock().readLock().lock();
        for (Tuple tuple : this.baseTupleList) {
            tuple.addPropertyChangeListener(glazedListEventsLayer);
        }
    } finally {
        this.baseTupleList.getReadWriteLock().readLock().unlock();
    }
    // Setup row/column and corner layers
    ColumnHeaderDataProvider defaultColumnHeaderDataProvider = new ColumnHeaderDataProvider();
    DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
    DefaultCornerDataProvider defaultCornerDataProvider = new DefaultCornerDataProvider(defaultColumnHeaderDataProvider, rowHeaderDataProvider);
    // Build composite for all regions
    DefaultGridLayer gridLayer = new DefaultGridLayer(blinkingLayer, new DefaultColumnHeaderDataLayer(defaultColumnHeaderDataProvider), new DefaultRowHeaderDataLayer(rowHeaderDataProvider), new DataLayer(defaultCornerDataProvider));
    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) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) GlazedListsEventLayer(org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer) ObservableElementList(ca.odell.glazedlists.ObservableElementList) ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) DefaultGridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer) BlinkLayer(org.eclipse.nebula.widgets.nattable.blink.BlinkLayer)

Aggregations

ObservableElementList (ca.odell.glazedlists.ObservableElementList)2 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)2 BlinkLayer (org.eclipse.nebula.widgets.nattable.blink.BlinkLayer)2 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)2 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)2 GlazedListsEventLayer (org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer)2 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)2 DefaultRowHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider)2 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)2 DefaultGridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer)2 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)2 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)2 Serializable (java.io.Serializable)1 LinkedList (java.util.LinkedList)1 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)1 ReflectiveColumnPropertyAccessor (org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor)1 BlinkingRowDataFixture (org.eclipse.nebula.widgets.nattable.dataset.fixture.data.BlinkingRowDataFixture)1 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)1 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)1