2
votes

I am currently upgrading my RCP project to Neon and have hit the following problem.

It seems that generics have been added to the JFace databinding which has resulted in new method signatures.

Previously I was able to do

List<AbstractTestModule> modules = getModules();
IObservableList obs = Properties.selfList(AbstractTestModule.class).observe(modules);
viewer.setInput(obs);

I get a compile error because the observe method now expects List<Object>and modules cannot be automatically cast from List<AbstractTestModule> to List<Object>.

The docs are here: http://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fcore%2Fdatabinding%2Fproperty%2FProperties.html

Is there a way to do such a cast or is there a different strategy I could use?

1
List<Object> objects = new ArrayList<>(modules);. - Andy Turner
Is observe in one of your classes? Can you make it accept List<?> instead of List<Object>? - Andy Turner
I think loading the list into a new ArrayList will prevent it from being observable - paul
no, observe is a method in JFace databinding - paul
I'm having surprising difficulty finding the API docs for the current release of JFace, or indeed for any release that uses generics. I find only archived docs for non-generic versions. Inasmuch as an answer to your question may depend on details of the API you're using, it would be helpful if you can post the documented signatures for all the JFace methods involved. Also, present the exact text of the error message -- the details are sometimes key. - John Bollinger

1 Answers

1
votes

You need to specify the generic class to use as the compiler can't infer it:

IObservableList obs = Properties.<AbstractTestModule>selfList(AbstractTestModule.class).observe(modules);