In C#, there are observable collections. In Java how do I represent a list a models? Suppose I have a model Item
. I want to show users a list of Items
. Do I create a ItemsModel
(notice plural, encapsulating an ArrayList<Item>
) then in my ItemsView
bind (listen to property change events) to that? This model will also need to listen to PropertyChange events from its underlying Item
. Is this the right way of implementing this? Is there a better way?
Asked
Active
Viewed 422 times
0

Jiew Meng
- 84,767
- 185
- 495
- 805
2 Answers
0
A possible solution could be the Eclipse Databinding. It let's you create a binding from your POJOs to certain SWT Controls. For your special case with Items, you could use the Master-Detail Binding mechanism, for an example see http://wiki.eclipse.org/JFace_Data_Binding/Snippets#Master_Detail

Tom Seidel
- 9,525
- 1
- 26
- 38
-
I am using SWT is it different from JFace? – Jiew Meng Feb 13 '12 at 14:14
0
Depending on the source of your domain model, you could consider changing it to use Eclipse Modeling Framework (EMF). EMF have complete a notification framework for all changes made to the model, which makes it easy to use and bind to. Eclipse Databinding - as mentioned by Tom Seidel - also bind to EMF.

Tonny Madsen
- 12,628
- 4
- 31
- 70