Skip to main content


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 15:34 Go to next message
Jens Keller is currently offline Jens KellerFriend
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 16:29 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
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: Thu Mar 28 18:14:01 GMT 2024

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

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

Back to the top