use of org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer in project nebula.widgets.nattable by eclipse.
the class CrossValidationDialogErrorHandling method createExampleControl.
@Override
@SuppressWarnings("unchecked")
public Control createExampleControl(Composite parent) {
Composite panel = new Composite(parent, SWT.NONE);
panel.setLayout(new GridLayout());
GridDataFactory.fillDefaults().grab(true, true).applyTo(panel);
Composite gridPanel = new Composite(panel, SWT.NONE);
gridPanel.setLayout(new GridLayout());
GridDataFactory.fillDefaults().grab(true, true).applyTo(gridPanel);
Composite buttonPanel = new Composite(panel, SWT.NONE);
buttonPanel.setLayout(new GridLayout());
GridDataFactory.fillDefaults().grab(true, true).applyTo(buttonPanel);
// property names of the EventData class
String[] propertyNames = { "title", "description", "where", "fromDate", "toDate" };
// mapping from property to label, needed for column header labels
Map<String, String> propertyToLabelMap = new HashMap<>();
propertyToLabelMap.put("title", "Title");
propertyToLabelMap.put("description", "Description");
propertyToLabelMap.put("where", "Where");
propertyToLabelMap.put("fromDate", "From");
propertyToLabelMap.put("toDate", "To");
this.valuesToShow.addAll(createEventData());
ConfigRegistry configRegistry = new ConfigRegistry();
DefaultGridLayer gridLayer = new DefaultGridLayer(this.valuesToShow, propertyNames, propertyToLabelMap);
DataLayer bodyDataLayer = (DataLayer) gridLayer.getBodyDataLayer();
IRowDataProvider<EventData> bodyDataProvider = (IRowDataProvider<EventData>) bodyDataLayer.getDataProvider();
bodyDataLayer.setConfigLabelAccumulator(new CrossValidationLabelAccumulator(bodyDataProvider));
final NatTable natTable = new NatTable(gridPanel, gridLayer, false);
natTable.setConfigRegistry(configRegistry);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new CrossValidationEditConfiguration(bodyDataProvider));
natTable.configure();
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
return panel;
}
use of org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer in project nebula.widgets.nattable by eclipse.
the class TableEditConfiguration method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
// property names of the NumberValues class
String[] propertyNames = { "columnOneNumber", "columnTwoNumber", "columnThreeNumber", "columnFourNumber", "columnFiveNumber" };
// mapping from property to label, needed for column header labels
Map<String, String> propertyToLabelMap = new HashMap<>();
propertyToLabelMap.put("columnOneNumber", "Column 1");
propertyToLabelMap.put("columnTwoNumber", "Column 2");
propertyToLabelMap.put("columnThreeNumber", "Column 3");
propertyToLabelMap.put("columnFourNumber", "Column 4");
propertyToLabelMap.put("columnFiveNumber", "Column 5");
DefaultGridLayer gridLayer = new DefaultGridLayer(createNumberValuesList(), propertyNames, propertyToLabelMap);
DataLayer bodyDataLayer = (DataLayer) gridLayer.getBodyDataLayer();
final ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(bodyDataLayer);
bodyDataLayer.setConfigLabelAccumulator(columnLabelAccumulator);
registerColumnLabels(columnLabelAccumulator);
NatTable natTable = new NatTable(parent, gridLayer, false);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new TableEditConfiguration());
natTable.configure();
return natTable;
}
use of org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer in project nebula.widgets.nattable by eclipse.
the class _4222_CellPainterExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
// property names of the Person class
String[] propertyNames = { "firstName", "lastName", "password", "description", "age", "money", "married", "gender", "address.street", "address.city", "favouriteFood", "favouriteDrinks" };
// mapping from property to label, needed for column header labels
Map<String, String> propertyToLabelMap = new HashMap<>();
propertyToLabelMap.put("firstName", "Firstname");
propertyToLabelMap.put("lastName", "Lastname");
propertyToLabelMap.put("password", "Password");
propertyToLabelMap.put("description", "Description");
propertyToLabelMap.put("age", "Age");
propertyToLabelMap.put("money", "Money");
propertyToLabelMap.put("married", "Married");
propertyToLabelMap.put("gender", "Gender");
propertyToLabelMap.put("address.street", "Street");
propertyToLabelMap.put("address.city", "City");
propertyToLabelMap.put("favouriteFood", "Food");
propertyToLabelMap.put("favouriteDrinks", "Drinks");
IDataProvider bodyDataProvider = new ListDataProvider<>(PersonService.getExtendedPersonsWithAddress(10), new ExtendedReflectiveColumnPropertyAccessor<ExtendedPersonWithAddress>(propertyNames));
DefaultGridLayer gridLayer = new DefaultGridLayer(bodyDataProvider, new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap));
final DataLayer bodyDataLayer = (DataLayer) gridLayer.getBodyDataLayer();
final ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(bodyDataLayer);
bodyDataLayer.setConfigLabelAccumulator(columnLabelAccumulator);
registerColumnLabels(columnLabelAccumulator);
this.natTable = new NatTable(parent, gridLayer, false);
this.natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
this.natTable.addConfiguration(new PainterConfiguration());
this.natTable.configure();
new NatTableContentTooltip(this.natTable, GridRegion.BODY);
return this.natTable;
}
use of org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer 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