use of org.eclipse.nebula.widgets.nattable.dataset.EventData in project nebula.widgets.nattable by eclipse.
the class CrossValidationDialogErrorHandling method createEventData.
private List<EventData> createEventData() {
List<EventData> result = new ArrayList<>();
EventData ed = new EventData();
ed.setTitle("My correct event");
ed.setDescription("My event that validates correctly");
ed.setWhere("Somewhere");
ed.setFromDate(new GregorianCalendar(2013, 2, 1).getTime());
ed.setToDate(new GregorianCalendar(2013, 2, 3).getTime());
result.add(ed);
ed = new EventData();
ed.setTitle("My wrong event");
ed.setDescription("My event where validation fails");
ed.setWhere("Somewhere else");
ed.setFromDate(new GregorianCalendar(2013, 2, 3).getTime());
ed.setToDate(new GregorianCalendar(2013, 2, 1).getTime());
result.add(ed);
return result;
}
use of org.eclipse.nebula.widgets.nattable.dataset.EventData 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.dataset.EventData in project nebula.widgets.nattable by eclipse.
the class CrossValidationDialogErrorHandling method validate.
@Override
public boolean validate(int columnIndex, int rowIndex, Object newValue) {
// get the row object out of the dataprovider
EventData rowObject = this.bodyDataProvider.getRowObject(rowIndex);
// as the object itself is not yet updated, we need to validate against
// the given new value
Date fromDate = rowObject.getFromDate();
Date toDate = rowObject.getToDate();
if (columnIndex == 3) {
fromDate = (Date) newValue;
} else if (columnIndex == 4) {
toDate = (Date) newValue;
}
if (!CrossValidationGridExample.isEventDataValid(fromDate, toDate)) {
throw new ValidationFailedException("fromDate is not before toDate");
}
return true;
}
use of org.eclipse.nebula.widgets.nattable.dataset.EventData 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.dataset.EventData in project nebula.widgets.nattable by eclipse.
the class CrossValidationDialogErrorHandling method validate.
@Override
public boolean validate(int columnIndex, int rowIndex, Object newValue) {
// get the row object out of the dataprovider
EventData rowObject = this.bodyDataProvider.getRowObject(rowIndex);
// as the object itself is not yet updated, we need to validate against
// the given new value
Date fromDate = rowObject.getFromDate();
Date toDate = rowObject.getToDate();
if (columnIndex == 3) {
fromDate = (Date) newValue;
} else if (columnIndex == 4) {
toDate = (Date) newValue;
}
if (!_4451_CrossValidationGridExample.isEventDataValid(fromDate, toDate)) {
throw new ValidationFailedException("fromDate is not before toDate");
}
return true;
}
Aggregations