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.(First post was updated!)
Setting the input on a dynamically opened part. [message #511703] 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
Updates:

- You don't need to define a variable in the Application.e4xmi, it also works without it
- Declare the variable as modifiable to change it multiple times
- You don't need to find the newly opened part because showPart() returns it directly


This time no question and instead a little tutorial on setting the input data on a newly openend part descriptor.
See this 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.

PartToOpen.INPUT_VARIABLE_NAME = "input";

IEclipseContex.modify( PartToOpen.INPUT_VARIABLE_NAME, inputObject );
IEclipseContext.get( PartToOpen.INPUT_VARIABLE_NAME );


This means in detail:


Find and open the part descriptor and use the context of the newly
opened part to modify the variable. You need to declare it modifiable
if you want to change the variable multiple times (for changing the input
of the part):

for( MPartDescriptor partDesc : desc ){
if( partDesc.getId().equals( PartToOpen.ID ) ){
MPart part = servicePart.showPart( partDesc.getId() );
part.getContext().modify( PartToOpen.INPUT_VARIABLE_NAME, partInput );
part.getContext().declareModifiable( PartToOpen.INPUT_VARIABLE_NAME );
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 this eclipsepedia article.


[Updated on: Wed, 03 February 2010 08:43]

Report message to a moderator

Re: Setting the input on a dynamically opened part. [message #511724 is a reply to message #511703] Tue, 02 February 2010 16:29 Go to previous messageGo to next 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.
>
>
Re: Setting the input on a dynamically opened part. [message #511841 is a reply to message #511724] Wed, 03 February 2010 08:31 Go to previous messageGo to next message
Jens Keller is currently offline Jens KellerFriend
Messages: 50
Registered: December 2009
Location: Leipzig, Germany
Member
That's a good idea and we should ask in the forum if others also want to share their knowledge, because i'm also interested in practical tips on working with e4. Do you know a place to host the wiki-page?

Jens Keller
Re: Setting the input on a dynamically opened part. [message #511847 is a reply to message #511841] Wed, 03 February 2010 03:44 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
http://wiki.eclipse.org/E4/Snippets and link it from
http://wiki.eclipse.org/E4#Tutorial

Tom

Am 03.02.10 09:31, schrieb Jens Keller:
> That's a good idea and we should ask in the forum if others also want to
> share their knowledge, because i'm also interested in practical tips on
> working with e4. Do you know a place to host the wiki-page?
>
> Jens Keller
Re: Setting the input on a dynamically opened part. [message #511855 is a reply to message #511847] Wed, 03 February 2010 09:10 Go to previous messageGo to next message
Jens Keller is currently offline Jens KellerFriend
Messages: 50
Registered: December 2009
Location: Leipzig, Germany
Member
I added the link to the snippets wiki and now i'm preparing my first snippet. But i'm not sure about the structure of the wiki. Should i just start adding snippets through links on the main page?
Re: Setting the input on a dynamically opened part. [message #511870 is a reply to message #511855] Wed, 03 February 2010 09:55 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Am 03.02.10 10:10, schrieb Jens Keller:
> I added the link to the snippets wiki and now i'm preparing my first
> snippet. But i'm not sure about the structure of the wiki. Should i just
> start adding snippets through links on the main page?

I would not create a new page for each snippet but create sections on
the Snippet pages.

With:
a) Description about the Snippet (2 - n sentences)
b) The Java-Code, EMF-"Code"

Similar to http://wiki.eclipse.org/Platform_Command_Framework

Tom
Re: Setting the input on a dynamically opened part. [message #511896 is a reply to message #511870] Wed, 03 February 2010 11:03 Go to previous messageGo to next message
Jens Keller is currently offline Jens KellerFriend
Messages: 50
Registered: December 2009
Location: Leipzig, Germany
Member
I added two snippets.
Re: Setting the input on a dynamically opened part. [message #512431 is a reply to message #511896] Fri, 05 February 2010 06:04 Go to previous message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Hello Jens,

thank you for sharing your experience. Very much appreciated!

Cheers, Lars

--
http://www.vogella.de/ - Eclipse plugin and Eclipse RCP Tutorials
http://www.twitter.com/vogella - vogella on Twitter


On 03.02.2010 03:03, Jens Keller wrote:
> I added two snippets.
Re: Setting the input on a dynamically opened part. [message #568317 is a reply to message #511724] Wed, 03 February 2010 08:31 Go to previous message
Jens Keller is currently offline Jens KellerFriend
Messages: 50
Registered: December 2009
Location: Leipzig, Germany
Member
That's a good idea and we should ask in the forum if others also want to share their knowledge, because i'm also interested in practical tips on working with e4. Do you know a place to host the wiki-page?

Jens Keller
Re: Setting the input on a dynamically opened part. [message #568326 is a reply to message #568317] Wed, 03 February 2010 08:39 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
http://wiki.eclipse.org/E4/Snippets and link it from
http://wiki.eclipse.org/E4#Tutorial

Tom

Am 03.02.10 09:31, schrieb Jens Keller:
> That's a good idea and we should ask in the forum if others also want to
> share their knowledge, because i'm also interested in practical tips on
> working with e4. Do you know a place to host the wiki-page?
>
> Jens Keller
Re: Setting the input on a dynamically opened part. [message #568347 is a reply to message #568326] Wed, 03 February 2010 09:10 Go to previous message
Jens Keller is currently offline Jens KellerFriend
Messages: 50
Registered: December 2009
Location: Leipzig, Germany
Member
I added the link to the snippets wiki and now i'm preparing my first snippet. But i'm not sure about the structure of the wiki. Should i just start adding snippets through links on the main page?
Re: Setting the input on a dynamically opened part. [message #568361 is a reply to message #568347] Wed, 03 February 2010 09:55 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Am 03.02.10 10:10, schrieb Jens Keller:
> I added the link to the snippets wiki and now i'm preparing my first
> snippet. But i'm not sure about the structure of the wiki. Should i just
> start adding snippets through links on the main page?

I would not create a new page for each snippet but create sections on
the Snippet pages.

With:
a) Description about the Snippet (2 - n sentences)
b) The Java-Code, EMF-"Code"

Similar to http://wiki.eclipse.org/Platform_Command_Framework

Tom
Re: Setting the input on a dynamically opened part. [message #568391 is a reply to message #511870] Wed, 03 February 2010 11:03 Go to previous message
Jens Keller is currently offline Jens KellerFriend
Messages: 50
Registered: December 2009
Location: Leipzig, Germany
Member
I added two snippets.
Re: Setting the input on a dynamically opened part. [message #568545 is a reply to message #568391] Fri, 05 February 2010 06:04 Go to previous message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

Hello Jens,

thank you for sharing your experience. Very much appreciated!

Cheers, Lars

--
http://www.vogella.de/ - Eclipse plugin and Eclipse RCP Tutorials
http://www.twitter.com/vogella - vogella on Twitter


On 03.02.2010 03:03, Jens Keller wrote:
> I added two snippets.
Previous Topic:Backround of TableViewer is always blue/grey.
Next Topic:Initializing Java Tooling never completes
Goto Forum:
  


Current Time: Fri Mar 29 13:34:59 GMT 2024

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

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

Back to the top