Creating a perspective on Runtime [message #331355] |
Wed, 03 September 2008 13:20  |
Eclipse User |
|
|
|
Hello,
I'm writing an RCP applikation that runs several instances of processes
that hold one to many instances of tasks performing file transformations.
(like a cron processor).
I want for each processor instance one perspective that hold one view for
each task run by the processor.
So far I have all views of all tasks run within one perspective.
Since I dont know how many processors will finally run I need to create
the perspectives flexible at application startup.
How can I crate a perspective at runtime? Is this possible?
Thanks,
Jan Kohnert
|
|
|
Re: Creating a perspective on Runtime [message #331380 is a reply to message #331355] |
Thu, 04 September 2008 07:25   |
Eclipse User |
|
|
|
On Wed, 3 Sep 2008 13:20:32 +0000 (UTC), jko@swisslab.de (Jan Kohnert)
wrote:
>Hello,
>
>I'm writing an RCP applikation that runs several instances of processes
>that hold one to many instances of tasks performing file transformations.
>(like a cron processor).
>
>I want for each processor instance one perspective that hold one view for
>each task run by the processor.
>
>So far I have all views of all tasks run within one perspective.
>
>Since I dont know how many processors will finally run I need to create
>the perspectives flexible at application startup.
>
>How can I crate a perspective at runtime? Is this possible?
>
>Thanks,
>Jan Kohnert
>
>
I've only found an internal class to do this. You can look into
SavePerspectiveAction to see how a user modified perspective is saved.
Unfortunitely there are classes from org.eclipse.ui.internal invoked.
You may use these classes but the API is not guranteed.
Achim
--
Achim Lörke
Eclipse-Stammtisch in the Braunschweig, Germany area:
http://www.bredex.de/de/news/events.html
|
|
|
Re: Creating a perspective on Runtime [message #331525 is a reply to message #331380] |
Thu, 11 September 2008 12:25   |
Eclipse User |
|
|
|
This problem seems to be more ambitious than I initially thought.
I brought my needs down to a level where several intances of the same
perspective are needed.
It is possible to open a new page by calling the following:
IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().openPag e(Perspective.ID,
null);
And with this it is easy to add views to created pages:
TaskView processorView = (TaskView)page.showView(TaskView.ID, secondaryId,
IWorkbenchPage.VIEW_CREATE);
This way I have several pages using the same perspective holding views
displaying informations bound to the perspective.
Problems that remain:
1. When quiting the application only one (the first) perspective gets
saved (and restored the next app start)
2. It seems to be not posible to add all pages into the same window. with
the approach from above each logical unit that I want to be bound with one
perspective is bound to a WorkbenchPage. Not quite what I initally
wanted...
3. The perspectivebar only shows one, the initial, perspective.
I wonder if the only solution will be a predefined set if perspectives in
plugin.xml. A solution that I really would like to omit...
Thank,
Jan Kohnert
|
|
|
|
Re: Creating a perspective on Runtime [message #331541 is a reply to message #331539] |
Thu, 11 September 2008 13:49  |
Eclipse User |
|
|
|
Thank you Paul!
clonePerspective did the job!.
Cloning:
IPerspectiveRegistry registry =
PlatformUI.getWorkbench().getPerspectiveRegistry();
IPerspectiveDescriptor perspective =
registry.findPerspectiveWithId(Perspective.ID);
IPerspectiveDescriptor newPerspective =
registry.clonePerspective(processor.getId(), processor.getName(),
perspective);
Adding content to the perspective:
IWorkbenchPage page =
PlatformUI.getWorkbench().showPerspective(processor.getId(),
PlatformUI.getWorkbench().getActiveWorkbenchWindow());
// creating view with secondary ID to be able to add miore than one view
of this kinde.
page.showView(TaskView.ID, secondaryId, IWorkbenchPage.VIEW_CREATE);
|
|
|
Powered by
FUDForum. Page generated in 0.29860 seconds