paul
paul

Reputation: 13516

New Generics in databinding Lists causing compile errors

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?

Upvotes: 2

Views: 216

Answers (1)

greg-449
greg-449

Reputation: 111142

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);

Upvotes: 1

Related Questions