Home » Modeling » EMF » Is there a reason that there isn't an EMFObservableValueEditingSupport class?
Is there a reason that there isn't an EMFObservableValueEditingSupport class? [message #524139] |
Tue, 30 March 2010 21:59 |
Ryan Messages: 74 Registered: July 2009 Location: Indiana |
Member |
|
|
I asked about ObservableValueEditingSupport.create() here:
http://www.eclipse.org/forums/index.php?t=msg&th=165442& amp; amp;start=0&
I ran into an issue today; I had a tableviewer bound to emf objects that have integer fields. The default ObservableValueEditingSupport creates a generic UpdateValueStrategy and as such, edits to an int field in the table fail becuase of a check eType.isInstance(class) (not sure if that's the correct sig). Basically, the default converter returns a string and EMF is expecting an int.
I was able to get this to work by copying the full class ObservableValueEditingSupport and changing the bindValue() call in createBinding() to create an EMFUpdateValueStrategy. The tableviewer then works fine afterwards.
Am I missing something, or did I do the correct thing here? It seems like there should be an EMFObservableValueEditingSupport in the emf databinding plugin. Either that, or my custom class could have been avoided if the default ObservableValueEditingSupport had a second create method that accepted the UpdateValueStrategies.
[Updated on: Tue, 30 March 2010 22:00] Report message to a moderator
|
|
| | |
Re: Is there a reason that there isn't an EMFObservableValueEditingSupport class? [message #524304 is a reply to message #524145] |
Wed, 31 March 2010 13:31 |
Ryan Messages: 74 Registered: July 2009 Location: Indiana |
Member |
|
|
Ed Merks wrote on Tue, 30 March 2010 18:37 | Ryan,
If something looks wrong, create a test case and open a bugzilla
illustrating the problem. EMF does have specialized value converters so
I'm not sure from the tiny bit of context you've provided if that's
being used.
|
Ed,
The main problem is that the standard ObservableValueEditingSupport class internally creates the binding:
protected Binding createBinding(IObservableValue target,
IObservableValue model) {
dirty = false;
Binding binding = dbc.bindValue(target, model, new UpdateValueStrategy(
UpdateValueStrategy.POLICY_CONVERT), null);
target.addChangeListener(new IChangeListener() {
public void handleChange(ChangeEvent event) {
dirty = true;
}
});
return binding;
}
As you can see, it creates an UpdateValueStrategy. The first set of EMF objects I tried this with worked, because the objects just had string properties, and apparently, the standard converters that get created in the UpdateValueStrategy work. The problem is when one of the columns in the table I'm binding is an EInt, the standard UVS tries to create a converter, but fails. Hence, I copied the code for this class, and implemented my own createBinding method that creates an EMFUpdateValueStrategy, which then works fine.
Binding binding = dbc.bindValue(target, model, new EMFUpdateValueStrategy(
UpdateValueStrategy.POLICY_CONVERT), null);
Tom Schindl wrote on Tue, 30 March 2010 20:46 | Yes because this is a pure UI-thing and we are only providing EMF-Model
integration yet. IMHO the ObservableValueEditingSupport should be
enhanced to specify the UpdateValueStrategy.
Tom
|
Tom, that does make the most sense, that the standard OVES should be updated. I'll look for a bug report and create one if I don't find one. Have you bound EMF objects to a jface table with a column bound to an EInt property of an EObject? If so, how did you go about doing it?
Thanks,
Ryan
|
|
| | |
Re: Is there a reason that there isn't an EMFObservableValueEditingSupport class? [message #524934 is a reply to message #524923] |
Sun, 04 April 2010 12:15 |
Ed Merks Messages: 33133 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------030704080005040205070902
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Tom,
A UI specific EMF data binding bundle seems reasonable.
Tom Schindl wrote:
> Hi,
>
> Would you mind filing a bug? I guess we could add a new Bundle which
> holds UI-Specific code (e.g. I have some reuseable LabelProviders who
> use EMF, ...).
>
> Ed any opinions on this?
>
> Tom
>
> Am 02.04.10 22:14, schrieb Ryan:
>
>> I created a bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=308010
>>
>> It would still be nice to have an EMFObservableValueEditingSupport, just
>> as a convience class.
>>
>
>
--------------030704080005040205070902
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Tom,<br>
<br>
A UI specific EMF data binding bundle seems reasonable.<br>
<br>
<br>
Tom Schindl wrote:
<blockquote cite="mid:hp9dku$8lq$1@build.eclipse.org" type="cite">
<pre wrap="">Hi,
Would you mind filing a bug? I guess we could add a new Bundle which
holds UI-Specific code (e.g. I have some reuseable LabelProviders who
use EMF, ...).
Ed any opinions on this?
Tom
Am 02.04.10 22:14, schrieb Ryan:
</pre>
<blockquote type="cite">
<pre wrap="">I created a bug <a class="moz-txt-link-freetext" href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=308010">https://bugs.eclipse.org/bugs/show_bug.cgi?id=308010</a>
It would still be nice to have an EMFObservableValueEditingSupport, just
as a convience class.
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
</body>
</html>
--------------030704080005040205070902--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| | | |
Goto Forum:
Current Time: Tue Apr 16 21:38:49 GMT 2024
Powered by FUDForum. Page generated in 4.47285 seconds
|