Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » How to pass objects parameters from wizard to MPart?
How to pass objects parameters from wizard to MPart? [message #1349485] Mon, 12 May 2014 08:00 Go to next message
Velganesh Subramanian is currently offline Velganesh SubramanianFriend
Messages: 67
Registered: July 2009
Member
I have a wizard to collect couple of values. This wizard, on finish, opens a MPart. I managed to inject EPartService and EModelService. The wizard is opened like this in a handler.
NewConnectionWizard wizard = ContextInjectionFactory.make(
NewConnectionWizard.class, context);
WizardDialog dialog = new WizardDialog(shell, wizard);
dialog.open();

I want to know how to pass objects to the new part. I can't use CIF.make() as my part does not extend MPart. I did some workaround and found an approach. This is the code I have in my NewConnectionWizard.performFinish().
IEclipseContext childContext = context.createChild();
childContext.set("a_for", "apple");
MPart connectionPart = partService.createPart("partdescriptor.connection");
connectionPart.setContext(childContext);
partService.showPart(connectionPart, PartState.ACTIVATE);

I can even get the value in ConnectionPart.createControls (@PostConstruct) method.

Am I following the right approach? I searched for all posts related to IEclipseContext here but I couldn't get a post relevant to this scenario.
Re: How to pass objects parameters from wizard to MPart? [message #1351974 is a reply to message #1349485] Tue, 13 May 2014 08:39 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5487
Registered: July 2009
Senior Member
On 12.05.14 10:00, Velganesh Subramanian wrote:
> I have a wizard to collect couple of values. This wizard, on finish,
> opens a MPart. I managed to inject EPartService and EModelService. The
> wizard is opened like this in a handler.
>
> NewConnectionWizard wizard = ContextInjectionFactory.make(
> NewConnectionWizard.class, context);
> WizardDialog dialog = new WizardDialog(shell, wizard);
> dialog.open();
>
> I want to know how to pass objects to the new part. I can't use
> CIF.make() as my part does not extend MPart. I did some workaround and
> found an approach. This is the code I have in my
> NewConnectionWizard.performFinish().
>
> IEclipseContext childContext = context.createChild();
> childContext.set("a_for", "apple");
> MPart connectionPart = partService.createPart("partdescriptor.connection");
> connectionPart.setContext(childContext);
> partService.showPart(connectionPart, PartState.ACTIVATE);

It is not a good idea to push your own context - it is the systems
responsibility to create and populate the context.

Still currently don't have a solution for you beside using the
persistedState to pass on information.

Tom
Previous Topic:Proper way to open window second time, after closing it once
Next Topic:How to pass data from dynamic menu item to handler?
Goto Forum:
  


Current Time: Sat Dec 20 07:30:18 GMT 2014

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

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