[Resolved] - EMF / JFace howto do a 'double' databinding [message #759163] |
Sun, 27 November 2011 08:50 |
Bernard Sarter Messages: 88 Registered: August 2011 Location: Paris, France |
Member |
|
|
Hello,
I would like to do a "double" databinding between an EMF model and a JFace TableViewer:
A) one EAttribute of an EOBject shall provide the text of a Cell,
* and *
B) one other EAttribute of an other EObject shall provide the background colour of the same Cell.
I know how to do A) (see snippet below), but I don't have the beginning of an idea about how to do B), ie how to add a second binding and a second LabelProvider to the same column.
@Override
public void createPartControl(Composite parent) {
fViewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI);
final Table table = fViewer.getTable();
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 0, 0));
ObservableListContentProvider cp = new ObservableListContentProvider();
fViewer.setContentProvider(cp);
IObservableSet set = cp.getKnownElements();
{
IValueProperty property = EMFProperties.value(SysmodPackage.Literals.MODEL_ELEMENT__NAME);
final TableViewerColumn column = new TableViewerColumn(fViewer, SWT.LEAD);
column.getColumn().setText("title");
column.setLabelProvider(new ObservableMapCellLabelProvider(property.observeDetail(set)) {
@Override
public void update(ViewerCell cell) {
String s = (String) attributeMaps[0].get(cell.getElement());
cell.setText(s);
}
});
}
final IObservableList data = EMFProperties.list(SysmodPackage.Literals.MODEL__FOO).observeDetail(master);
fViewer.setInput(data);
Any suggestions or comments welcome!
Best regards,
Bernard.
[Updated on: Tue, 29 November 2011 20:26] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03210 seconds