Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Creating and initializing a view based on some initial data
Creating and initializing a view based on some initial data [message #990197] Tue, 11 December 2012 11:30 Go to next message
Levente Mising name is currently offline Levente Mising name
Messages: 3
Registered: December 2010
Junior Member
Dear gurus,

When a view is created, is there a way to pass in some information based on which it can initialize its component widgets?

For example, in my application I am trying to create multiple instances of the same view, each instance showing information about a different product. One of the widgets in this view is a ComboViewer which displays the product type (stock, future, option, etc).

I would like to initialize the selection in the ComboViewer to the type of the product that is used to initialize the view.

So far I was only able to do this as a two-step process:

1. Create/show the view using IWorkbenchPage.showView(viewId, secondaryId, IWorkbenchPage.VIEW_ACTIVATE) which returns a IViewPart

2. Cast the reurned IViewPart to my view's type and explicitly call an initialization method on the view:

((MyViewType) viewPart).initialize(myProductObject)

Is there any way to do this in a single step somehow, by specifying the myProductObject to use at view creation time? Is there any way in the view's createPartControl() method to retrieve this initialization data?

I am looking for a solution that does not use a static registry.

Best regards,
Levente
Re: Creating and initializing a view based on some initial data [message #990203 is a reply to message #990197] Tue, 11 December 2012 11:52 Go to previous message
John Steele is currently offline John Steele
Messages: 49
Registered: January 2010
Member
You could store the values in the application context. It's a good place to store data that needs to be shared/passed between views.

Instead of casting the view and then setting the data, the view could simply query the application context for the data it needs at creation time.
Previous Topic:Evaluate the activeWhen expression at runtime
Next Topic:Creating a MultiPage Editor from a "Open Editor"
Goto Forum:
  


Current Time: Sat Oct 25 12:47:27 GMT 2014

Powered by FUDForum. Page generated in 0.01889 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software