Thursday 26 July 2012

Bragging

In this Post I ll brag about the the first question I answered on StackOverFlow.com. The best part is that my answer got accepted too.  Well The question was as follows:

I have been following the tutorial here. In the advanced tutorial ResourceSelectionHistory stores the selected items and the retrieves it when the dialog is relaunched. I wanted the ResourceSelectionHistory to store objects and not just strings, is there i way to do that. I also want the items to open in the editor when the user clicks on them. When I click on an item in the actual populated list it opens, but not when I click on the part showing history.

The person here wants to IMemento to tell him what type of object was stored in the History. As the person who first answered the question said that these classes are very restrictive. and they expect you to do only what they want you do do.

I have figured out a way that could be used to do what the questioner want: Follow along.....

You can store strings, integers and Boolean to IMemento. You can cleverly utilize them to reveal the type of object. For example you can use element.putInteger("objType", 1); if your object is of say type A and element.putInteger("objType", 2); if its of type B. Hope that helps.

ge33ek

No comments:

Post a Comment