Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Pass object to a View (via Constructor)
Pass object to a View (via Constructor) [message #759688] Tue, 29 November 2011 15:47 Go to next message
AmFreak Missing name is currently offline AmFreak Missing nameFriend
Messages: 25
Registered: June 2011
Junior Member

i need to pass an object to a view.

I basically have a view with a list of objects, i also have a command "Open second View" to open another view. What i now want is to make it so that the selected object in the list view, is passed to the second view if i exectue the "Open second View" command. I'm able to get the selected object from the ListView in the command handler via

ISelection selection = view.getSite().getSelectionProvider().getSelection();

but i don't know how to pass the object to the second view via a constructor, cause of the way the view is constructed:


So how can i pass the object the moment the second View is constructed (aka in the constructor) ?
Re: Pass object to a View (via Constructor) [message #759717 is a reply to message #759688] Tue, 29 November 2011 18:21 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You can't pass that into the constructor. The most common method of communicating between 2 views is to use the IWorkbenchWindow selection service. See Using the Selection Service.

The other way is for the 2 views to share a common manager or go-between (basically re-implementing a smaller version of the window selection service). Then you could pass the object to the manager, show the view, and have the view get the object from the manager in its init(*) or createPartControl(*) method.


Previous Topic:Traverse all columns of the table n functinality issues
Next Topic:Canceling running jobs
Goto Forum:

Current Time: Wed Jun 20 18:48:36 GMT 2018

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

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

Back to the top