Skip to main content



      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 10:47 Go to next message
Eclipse UserFriend
Hi,

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:

window.getActivePage().showView(SecondView.ID);


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 13:21 Go to previous message
Eclipse UserFriend
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.

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


Current Time: Sun Nov 09 18:31:31 EST 2025

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

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

Back to the top