Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Setting the input on a dynamically opened part.
Setting the input on a dynamically opened part. [message #568276] Tue, 02 February 2010 10:34 Go to next message
Jens Keller is currently offline Jens Keller
Messages: 50
Registered: December 2009
Location: Leipzig, Germany
Member
This time no question and instead a little tutorial on setting the input data on a newly openend part descriptor.
See http://www.eclipse.org/forums/index.php?t=msg&th=160958& amp;start=0& thread for a way to open a part descriptor at runtime.

First you need to define a variable in your Application.e4xmi which is used to pass the part input.

<variables>input</variables>

Then you can use the IEclipseContext to modify and read this variable.

IEclipseContex.modify( "input", inputObject );
IEclipseContext.get( "input" );

This means in detail:


Open the part descriptor:

EPartService.showPart( partDescriptor.getID() );


Find the newly opened part and use it's IEclipseContext to modify the variable:

Collection<MPart> col = servicePart.getParts();
for(MPart part : col){
if( part.getId().equals( partDescriptor.getID() ) ){
part.getContext().modify( "input", partInput );
break;
}
}


And now the following method in the part should get called:

@Inject
@Optional
public void setPartInput( @Named( "input" ) Object partInput ) { ... }


For more information you can look in the e4 photo demo ( in Libray.java at line 117 the variable
is modified to promote the actual selected photo to the other parts which implement a setSelection() method)
or http://wiki.eclipse.org/E4/EAS/Selection eclipsepedia article.
Re: Setting the input on a dynamically opened part. [message #568302 is a reply to message #568276] Tue, 02 February 2010 11:29 Go to previous message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5296
Registered: July 2009
Senior Member
Maybe you want to start a wiki-page documenting little snippets with
code so that people can be pointed there always?

Tom

Am 02.02.10 16:34, schrieb Jens Keller:
> This time no question and instead a little tutorial on setting the input
> data on a newly openend part descriptor. See
> http://www.eclipse.org/forums/index.php?t=msg&th=160958& amp;start=0& thread
> for a way to open a part descriptor at runtime.
> First you need to define a variable in your Application.e4xmi which is
> used to pass the part input.
>
> <variables>input</variables>
>
> Then you can use the IEclipseContext to modify and read this variable.
> IEclipseContex.modify( "input", inputObject );
> IEclipseContext.get( "input" );
>
> This means in detail:
>
>
> Open the part descriptor:
>
> EPartService.showPart( partDescriptor.getID() );
>
>
> Find the newly opened part and use it's IEclipseContext to modify the
> variable:
>
> Collection<MPart> col = servicePart.getParts();
> for(MPart part : col){
> if( part.getId().equals(
> partDescriptor.getID() ) ){
> part.getContext().modify( "input",
> partInput );
> break;
> }
> }
>
>
> And now the following method in the part should get called:
>
> @Inject
> @Optional
> public void setPartInput( @Named( "input" ) Object partInput ) { ... }
>
>
> For more information you can look in the e4 photo demo ( in Libray.java
> at line 117 the variable is modified to promote the actual selected
> photo to the other parts which implement a setSelection() method) or
> http://wiki.eclipse.org/E4/EAS/Selection eclipsepedia article.
>
>
Previous Topic:Problems extending the application model with PartDescriptor's.
Next Topic:New e4 snippets wiki-page
Goto Forum:
  


Current Time: Fri Aug 29 20:39:01 EDT 2014

Powered by FUDForum. Page generated in 0.01630 seconds