use of org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer 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;
}
Aggregations