Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » DataBinding Help(Need help to upgrade the current databinding code)
DataBinding Help [message #1827999] Thu, 28 May 2020 20:26 Go to next message
Yigal Spinner is currently offline Yigal SpinnerFriend
Messages: 127
Registered: July 2009
Senior Member
We have code that was created in Eclipse Galileo. I need to upgrade the Eclipse to the latest version. I run into an issue that the interface IObservableValue changed definition to IObservableValue<T>

I'm looking for new example how the EMF databinding should be defined but can't find any information

My code is simple:
    public boolean doDataBinding(EditingDomain domain, EObject input) {
        binding = new EMFDataBindingContext();

        IWidgetValueProperty<Text, String> prop = WidgetProperties.text(SWT.Modify);

        IEMFValueProperty value = EMFEditProperties.value(domain, fldFeature);
        IObservableValue<?> ob = value.observe(input);
        binding.bindValue(prop.observeDelayed(FIELD_INPUT_DELAY, txtControl), ob);
        return false;
    }


The warning I get on the code "value.observe(input)" is:
Type safety: The method observe(Object) belongs to the raw type IValueProperty. References to generic type IValueProperty<S,T> should be parameterized

How do I do that???
Where can I find sample code that will help me do databinding for all types of widgets?

Thanks
Yigal
Re: DataBinding Help [message #1828006 is a reply to message #1827999] Fri, 29 May 2020 04:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
The EMF APIs have not been modified to introduce generics so there's no way to avoid this problem. Others have added their own "helper" static method to centralize the annotations to suppress the warnings.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: DataBinding Help [message #1828009 is a reply to message #1828006] Fri, 29 May 2020 06:45 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Presumably your code works, so Java is 'happy' with the partial type information. The easiest approach is to add e.g. @SuppressWarnings("rawtypes") perhaps to individual declarations, perhaps to methods / classes / projects.

If some parameters are already defined then you need to go along with them, otherwise <?> or <Object> will probably do.

Ultimately genetics enable you to write safer code so its best to use them rather than fight them. As Ed Merks writes, helper methods can help.I have a variety of XXXUtil classes for such purposes.

Regards

Ed Willink
Previous Topic:Manage Tool Documentation
Next Topic:[CDO] Offline Clone keeps connecting and disconnecting to master
Goto Forum:
  


Current Time: Wed Apr 24 21:31:27 GMT 2024

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

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

Back to the top