use of ca.odell.glazedlists.ObservableElementList 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;
}
use of ca.odell.glazedlists.ObservableElementList in project nebula.widgets.nattable by eclipse.
the class _900_Everything_but_the_kitchen_sink method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
final String[] propertyNames = RowDataListFixture.getPropertyNames();
final Map<String, String> propertyToLabelMap = RowDataListFixture.getPropertyToLabelMap();
ConfigRegistry configRegistry = new ConfigRegistry();
ColumnGroupModel columnGroupModel = new ColumnGroupModel();
// Body
LinkedList<BlinkingRowDataFixture> rowData = new LinkedList<>();
this.baseEventList = GlazedLists.threadSafeList(GlazedLists.eventList(rowData));
ObservableElementList<BlinkingRowDataFixture> observableElementList = new ObservableElementList<>(this.baseEventList, GlazedLists.beanConnector(BlinkingRowDataFixture.class));
FilterList<BlinkingRowDataFixture> filterList = new FilterList<>(observableElementList);
SortedList<BlinkingRowDataFixture> sortedList = new SortedList<>(filterList, null);
FullFeaturedBodyLayerStack<BlinkingRowDataFixture> bodyLayer = new FullFeaturedBodyLayerStack<>(sortedList, new IRowIdAccessor<BlinkingRowDataFixture>() {
@Override
public Serializable getRowId(BlinkingRowDataFixture rowObject) {
return rowObject.getSecurity_description();
}
}, propertyNames, configRegistry, columnGroupModel);
this.bodyDataProvider = bodyLayer.getBodyDataProvider();
this.propertyChangeListener = bodyLayer.getGlazedListEventsLayer();
// blinking
registerBlinkingConfigCells(configRegistry);
// Column header
FullFeaturedColumnHeaderLayerStack<BlinkingRowDataFixture> columnHeaderLayer = new FullFeaturedColumnHeaderLayerStack<>(sortedList, filterList, propertyNames, propertyToLabelMap, bodyLayer, bodyLayer.getSelectionLayer(), columnGroupModel, configRegistry);
// column groups
setUpColumnGroups(columnHeaderLayer);
// Row header
final DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultSummaryRowHeaderDataProvider(this.bodyDataProvider);
DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
rowHeaderDataLayer.setDefaultColumnWidth(50);
ILayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, bodyLayer, bodyLayer.getSelectionLayer());
// Corner
final DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderLayer.getColumnHeaderDataProvider(), rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, columnHeaderLayer);
// Grid
GridLayer gridLayer = new GridLayer(bodyLayer, columnHeaderLayer, rowHeaderLayer, cornerLayer);
this.natTable = new NatTable(parent, gridLayer, false);
this.natTable.setConfigRegistry(configRegistry);
this.natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
// Popup menu
this.natTable.addConfiguration(new HeaderMenuConfiguration(this.natTable) {
@Override
protected PopupMenuBuilder createColumnHeaderMenu(NatTable natTable) {
return super.createColumnHeaderMenu(natTable).withColumnChooserMenuItem();
}
});
this.natTable.addConfiguration(new SingleClickSortConfiguration());
// Editing
ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(bodyLayer.getBodyDataLayer());
bodyLayer.getBodyDataLayer().setConfigLabelAccumulator(columnLabelAccumulator);
this.natTable.addConfiguration(EditableGridExample.editableGridConfiguration(columnLabelAccumulator, this.bodyDataProvider));
this.natTable.addConfiguration(new FilterRowGridExample.FilterRowCustomConfiguration());
// Column chooser
DisplayColumnChooserCommandHandler columnChooserCommandHandler = new DisplayColumnChooserCommandHandler(bodyLayer.getSelectionLayer(), bodyLayer.getColumnHideShowLayer(), columnHeaderLayer.getColumnHeaderLayer(), columnHeaderLayer.getColumnHeaderDataLayer(), columnHeaderLayer.getColumnGroupHeaderLayer(), columnGroupModel);
bodyLayer.registerCommandHandler(columnChooserCommandHandler);
// Summary row configuration
this.natTable.addConfiguration(new MySummaryRow<>(this.bodyDataProvider));
this.natTable.configure();
return this.natTable;
}
use of ca.odell.glazedlists.ObservableElementList 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