How to pass objects parameters from wizard to MPart? [message #1349485] |
Mon, 12 May 2014 04:00  |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03550 seconds