Setting the input on a dynamically opened part. [message #511703] |
Tue, 02 February 2010 15:34 |
Jens Keller 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04548 seconds