Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » IObservableMap EMF implementation(Implementation of IObservableMap for EMF doesn't work properly)
IObservableMap EMF implementation [message #1238486] Sat, 01 February 2014 14:06 Go to next message
Peter N is currently offline Peter NFriend
Messages: 6
Registered: February 2014
Junior Member
I'm working with EMF databinding now, and in one case, when I use editing properties to get model map feature to work with - I get ClassCastException inside observable:

First, I created map observable for my model map feature (EMap<String, String> field in generated model instance):
EMFEditProperties.map(domain, feature).observe(model) // now I got IObservableMap instance


but when I try to invoke .putAll(...) method on it - I get ClassCastException. When I try to work with it with databinding context - I get similar behavior - databinding doesn't work, and if i look on it in debug, exception just swallowed inside databinding mechanism.

Investigating this issue, I realized, that it seems that there is wrong implementation of IObservableMap in EMF. Some details:

EMFEditProperties.map(...) method creates EMFEditMapProperty instance inside it.
Looking inside EMFEditMapProperty, we have method doSetMap(...):

  protected void doSetMap(Object source, Map map, MapDiff diff)
  {
    EObject eObject = (EObject)source;
    Command command = SetCommand.create(editingDomain, eObject, getFeature(), map);
    editingDomain.getCommandStack().execute(command);
  }


and then inside SetCommand.create(...):

104: List<?> values = value == UNSET_VALUE ? Collections.EMPTY_LIST : (List<?>)value;

as we see, we took Map in doSetMap(...) and then cast it to list inside SetCommand.create(...). Looks like there must be another Command in EMFEditMapProperty, not SetCommand.

The question is, if there is someone working with IObservableMap, explain me please, it is wrong implementation of IObservableMap in EMF, or I just use it in a wrong way.
Re: IObservableMap EMF implementation [message #1240965 is a reply to message #1238486] Fri, 07 February 2014 09:21 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Peter,

It (doSetMap) looks kind of buggy to me. Please open a bugzilla.


On 01/02/2014 3:46 PM, Peter N wrote:
> I'm working with EMF databinding now, and in one case, when I use
> editing properties to get model map feature to work with - I get
> ClassCastException inside observable:
>
> First, I created map observable for my model map feature (EMap<String,
> String> field in generated model instance):
>
> EMFEditProperties.map(domain, feature).observe(model) // now I got
> IObservableMap instance
>
> but when I try to invoke .putAll(...) method on it - I get
> ClassCastException. When I try to work with it with databinding
> context - I get similar behavior - databinding doesn't work, and if i
> look on it in debug, exception just swallowed inside databinding
> mechanism.
>
> Investigating this issue, I realized, that it seems that there is
> wrong implementation of IObservableMap in EMF. Some details:
>
> EMFEditProperties.map(...) method creates EMFEditMapProperty instance
> inside it.
> Looking inside EMFEditMapProperty, we have method doSetMap(...):
>
> protected void doSetMap(Object source, Map map, MapDiff diff)
> {
> EObject eObject = (EObject)source;
> Command command = SetCommand.create(editingDomain, eObject,
> getFeature(), map);
> editingDomain.getCommandStack().execute(command);
> }
>
> and then inside SetCommand.create(...):
>
> 104: List<?> values = value == UNSET_VALUE ? Collections.EMPTY_LIST :
> (List<?>)value;
>
> as we see, we took Map in doSetMap(...) and then cast it to list
> inside SetCommand.create(...). Looks like there must be another
> Command in EMFEditMapProperty, not SetCommand.
>
> The question is, if there is someone working with IObservableMap,
> explain me please, it is wrong implementation of IObservableMap in
> EMF, or I just use it in a wrong way.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: IObservableMap EMF implementation [message #1272966 is a reply to message #1240965] Wed, 19 March 2014 07:32 Go to previous message
Peter N is currently offline Peter NFriend
Messages: 6
Registered: February 2014
Junior Member
Created bug in bugzilla:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=430669
Previous Topic:[EMF] How to get the extension for an EObject/EClass
Next Topic:Binary resource compatibility
Goto Forum:
  


Current Time: Thu Apr 25 01:13:08 GMT 2024

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

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

Back to the top