Programmatically show a part [message #938908] |
Wed, 10 October 2012 05:07  |
Eclipse User |
|
|
|
Hi,
I am trying to open and close a part programmatically with a handler. In Eclipse 3.x this was done calling showView()/hideView() on the active page.
I have read the tutorial of Lars Vogel on this already http://www.vogella.com/articles/EclipseRCP/article.html#modeldynamics_example2
There the part is created from scratch and added to the window.
What I am trying to do instead is defining the part in the application model within a PartStack (TrimmedWindow - Controls - PartSashContainer - PartStackContainer). The part is configured to be not visible and not to be rendered.
I created a handler that uses EPartService and tried to call
@Execute
public void execute(EPartService partService, @Named(PART_ID) String viewId) {
MPart part = partService.createPart(viewId);
}
There I get an AssertionException because the is no PartDescriptor. AFAIK I need a PartDescriptor only if I will use the same view in different perspectives, so why do I always need a PartDescriptor if I simply want to create a Part that is already defined? When I'm adding a PartDescriptor, the part is opened at the right place, but when activating the part I get
java.lang.IllegalArgumentException: Widget has the wrong parent
Seems the wrong parent composite is injected.
So the next try was to call
partService.showPart(viewId, PartState.VISIBLE);
I also tried the other states, but I always get
java.lang.IllegalArgumentException: Widget has the wrong parent
Debugging into it it looks like the PartServiceImpl always tries to create the part by adding it to the window instead of the PartStackContainer where it already was defined.
I'm not sure if I ran into a bug or if I am simply doing things wrong. Could you please give me a hint how to create/destroy parts programmatically at specific positions within a PartSashContainer the right way?
Greez,
Dirk
|
|
|
|
|
|
Re: Programmatically show a part [message #941312 is a reply to message #941228] |
Fri, 12 October 2012 07:47  |
Eclipse User |
|
|
|
Hi Sopot,
thanks for the answer, as posted before the solution for my "special" issue was simply injecting the part and setting the visible flag to true. That's all. But thanks for clearing the EPartService.createPart() ... now I understand what it is for and that I tried to use it in the wrong context.
Thanks,
Dirk
|
|
|
Powered by
FUDForum. Page generated in 0.06186 seconds