Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Databinding] ObservableMapLabelProvider and multi value changes
[Databinding] ObservableMapLabelProvider and multi value changes [message #708375] Tue, 02 August 2011 18:52 Go to next message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Hi all,

I have a Person model which contains firstName, lastName and a list of contacts. A Contact has a type, value and some other fields.

Now I have a IObservaleList of Persons and want to show it in my table viewer.
So I use the ObservableListContentProvider and the ObservableMapLabelProvider.

So I observe firstName and lastName successfully.

But I further want to display the contact values field as well. In reflect the changes of the value field in all contacts in the viewer.

Is it possible to observe the multi values using EMFProperties? The FeaturePath doesn't support multi values?

Regards,
Mark
Re: [Databinding] ObservableMapLabelProvider and multi value changes [message #708527 is a reply to message #708375] Tue, 02 August 2011 22:36 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
I'm not sure how you want to display the contacts in a table if they are
lists. Don't one then use a Tree with TreeColumn?

We've added support to observe a single value of a list in EMF 2.7 but
not all elements in there.

Tom

Am 02.08.11 20:52, schrieb Mark Hoffmann:
> Hi all,
>
> I have a Person model which contains firstName, lastName and a list of
> contacts. A Contact has a type, value and some other fields.
>
> Now I have a IObservaleList of Persons and want to show it in my table
> viewer.
> So I use the ObservableListContentProvider and the
> ObservableMapLabelProvider.
>
> So I observe firstName and lastName successfully.
> But I further want to display the contact values field as well. In
> reflect the changes of the value field in all contacts in the viewer.
> Is it possible to observe the multi values using EMFProperties? The
> FeaturePath doesn't support multi values?
>
> Regards,
> Mark
Re: [Databinding] ObservableMapLabelProvider and multi value changes [message #708930 is a reply to message #708375] Wed, 03 August 2011 09:46 Go to previous messageGo to next message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Hi,

the person has a least 3 contacts (phone, mobile, email). I want to display only these first 3 contacts, especially the value of each contact. Each value has its own column.
So what I need is to inform the label provider about changes in the value field of all contacts, of all persons.

I am not sure how to inform the labelprovider about changes in the 3 contacts.

Regards,
Mark
Re: [Databinding] ObservableMapLabelProvider and multi value changes [message #709017 is a reply to message #708930] Wed, 03 August 2011 11:58 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

Then the new 2.7 API is what you are looking for [1] because it allows
you to create a IEMFValueProperty from an element in the list.

Technically EMF-Databinding from 2.7 should work with 2.6 the only
problem is that the requirebundle versions are automatically assigned by
the build process - so the easiest might be if you check out the sources
from CVS.

Tom

[1]http://tomsondev.bestsolution.at/2011/05/06/interesting-new-feature-in-emf-databinding/

Am 03.08.11 11:46, schrieb Mark Hoffmann:
> Hi,
>
> the person has a least 3 contacts (phone, mobile, email). I want to
> display only these first 3 contacts, especially the value of each
> contact. Each value has its own column.
> So what I need is to inform the label provider about changes in the
> value field of all contacts, of all persons.
>
> I am not sure how to inform the labelprovider about changes in the 3
> contacts.
>
> Regards, Mark
Re: [Databinding] ObservableMapLabelProvider and multi value changes [message #709018 is a reply to message #709017] Wed, 03 August 2011 12:01 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Am 03.08.11 13:58, schrieb Tom Schindl:
> Hi,
>
> Then the new 2.7 API is what you are looking for [1] because it allows
> you to create a IEMFValueProperty from an element in the list.
>
> Technically EMF-Databinding from 2.7 should work with 2.6 the only
> problem is that the requirebundle versions are automatically assigned by
> the build process - so the easiest might be if you check out the sources
> from CVS.
>
> Tom
>
> [1]http://tomsondev.bestsolution.at/2011/05/06/interesting-new-feature-in-emf-databinding/
>

The blog also mentions the workaround one could use without the new
features. You'd simply create 3 volatile transient derived features and
then you can use a FeaturePath but I think the new API is much cooler
because it is not cluttering your model with those unneeded features.

Tom
Re: [Databinding] ObservableMapLabelProvider and multi value changes [message #709390 is a reply to message #709018] Wed, 03 August 2011 21:50 Go to previous messageGo to next message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Hi Tom,

thank you for the hint. I got it work using ListElementAccess.
It solves exactly my problem. I had the same idea but I am not firm with the new Properties API.

But some problems occured and I have to reimplement the EMFListValueProperty.
Your code get the structural feature from the object. Here should be checked, if the object is really the container for this feature. In my case the Person model comes from a PersonPackage and the Contact from the ContactPackage. This code leads to the situation eGet tries to get the value feature from the contact with e.g. id = 2
from the Person object, which comes in as source. From this object it tries to take the feature with id 2, which is wrong and in my case no List Wink

protected Object doGetValue(Object source)
  {
    EObject eObject = (EObject)source;
    List< ? > list = (List< ? >)eObject.eGet(eStructuralFeature);
    int idx = elementAccess.getReadValueIndex(list);
    if (idx != WriteData.NO_INDEX)
    {
      return list.get(idx);
    }
    return null;
  }


I got it work giving the EMFListValueProperty the delegate:


public class EMFListValueProperty extends SimpleValueProperty
{
	private final EStructuralFeature eStructuralFeature;
	private final ListElementAccess elementAccess;
	private IListProperty delegate;

	public EMFListValueProperty(IListProperty delegate, EStructuralFeature eStructuralFeature, ListElementAccess elementAccess)
	{
		this.eStructuralFeature = eStructuralFeature;
		this.elementAccess = elementAccess;
		this.delegate = delegate;
	}

	public Object getValueType()
	{
		return eStructuralFeature;
	}

	@Override
	protected Object doGetValue(Object source)
	{
		List< ? > list = (List< ? >)delegate.getList(source);
		int idx = elementAccess.getReadValueIndex(list);
		if (idx != WriteData.NO_INDEX)
		{
			return list.get(idx);
		}
		return null;
	}

	...
}


Should I file a bug? Thank you again.

Regards,
Mark

[Updated on: Wed, 03 August 2011 21:50]

Report message to a moderator

Re: [Databinding] ObservableMapLabelProvider and multi value changes [message #709683 is a reply to message #709390] Thu, 04 August 2011 06:55 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
[...]

> Should I file a bug? Thank you again.
>

Yes.

Tom
Re: [Databinding] ObservableMapLabelProvider and multi value changes [message #710926 is a reply to message #709390] Fri, 05 August 2011 15:27 Go to previous message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
I filed a bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=354016

Regards,
Mark

[Updated on: Fri, 05 August 2011 15:28]

Report message to a moderator

Previous Topic:[CDO] How to run a CDO Server continously (incl. a Hibernate store)
Next Topic:(no subject)
Goto Forum:
  


Current Time: Wed Apr 24 16:36:08 GMT 2024

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

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

Back to the top