Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Resolved] - EMF / JFace howto do a 'double' databinding
[Resolved] - EMF / JFace howto do a 'double' databinding [message #759163] Sun, 27 November 2011 08:50 Go to next message
Bernard Sarter is currently offline Bernard SarterFriend
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

Re: EMF / JFace howto do a 'double' databinding [message #759751 is a reply to message #759163] Tue, 29 November 2011 20:25 Go to previous message
Bernard Sarter is currently offline Bernard SarterFriend
Messages: 88
Registered: August 2011
Location: Paris, France
Member
Ok, I missed the other constructor of the ObservableMapCellLabelProvider ...
Previous Topic:[XCore] Can't build it
Next Topic:Getting started with EMF, a few newbie questions
Goto Forum:
  


Current Time: Thu Apr 25 06:14:43 GMT 2024

Powered by FUDForum. Page generated in 0.03210 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top