Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Creating a perspective on Runtime
Creating a perspective on Runtime [message #331355] Wed, 03 September 2008 13:20 Go to next message
Jan Kohnert is currently offline Jan KohnertFriend
Messages: 196
Registered: July 2009
Senior Member
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 Go to previous messageGo to next message
Achim Loerke is currently offline Achim LoerkeFriend
Messages: 376
Registered: July 2009
Location: Braunschweig, Germany
Senior Member

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


Achim Lörke

Re: Creating a perspective on Runtime [message #331525 is a reply to message #331380] Thu, 11 September 2008 12:25 Go to previous messageGo to next message
Jan Kohnert is currently offline Jan KohnertFriend
Messages: 196
Registered: July 2009
Senior Member
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 #331539 is a reply to message #331525] Thu, 11 September 2008 13:27 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

2 suggestions:

1) you can use the API on IWorkbenchPage to open a perspective within a
page (instead of one perspective per window).

2) To "replicate" the perspectives and have them available on restart as
well, have a look at
org.eclipse.ui.IWorkbenchPage.savePerspectiveAs(IPerspective Descriptor)
You can use
org.eclipse.ui.IPerspectiveRegistry.clonePerspective(String, String,
IPerspectiveDescriptor) to clone the perspectives.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Re: Creating a perspective on Runtime [message #331541 is a reply to message #331539] Thu, 11 September 2008 13:49 Go to previous message
Jan Kohnert is currently offline Jan KohnertFriend
Messages: 196
Registered: July 2009
Senior Member
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);
Previous Topic:can dynamic menus exist in global menubar?
Next Topic:same package in two different bundles: a problem?
Goto Forum:
  


Current Time: Fri Nov 08 22:46:34 GMT 2024

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

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

Back to the top