Skip to main content



      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 04:00 Go to next message
Eclipse UserFriend
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 04:39 Go to previous message
Eclipse UserFriend
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: Tue May 06 14:03:49 EDT 2025

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

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

Back to the top