2

I've got an arraylist of SpecialParts. A SpecialPart is an object that holds a bunch of information about itself: name, ID, date created, etc.

I've got a ListView that presents the user with all the names of the SpecialParts in this arraylist. The user can select one of these parts in the list and then do stuff with it.

My problem is that ListView (in my case, '...swt.widgets.List') ONLY holds Strings of the names. So even though I'd rather refer to these SpecialParts by their unique ID field, ListView doesn't hold that info.

Everywhere else we refer to these parts ONLY by unique ID, and I'd like to continue doing that.

I could create another column in this ListView, have it store the ID, set it to be invisible to the user, and then pull it out from there. But that feels gross, if not totally against the MVC contract.

How should I go about referring to these parts by unique ID when the list contains only String names? Am I thinking about this problem correctly?

(last note -- I'm only vaguely aware of the MVC paradigm, not a pro, so if anything I said about it is wrong, I'm sorry. also, this is Java, if it helps)

1 Answer 1

2

There exist bindings you can use to bind list items with data. This does exactly what I need.

http://www.vogella.com/tutorials/EclipseDataBinding/article.html#tutorial_observablemaplabelprovider

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.