Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Saving perspective programmatic
Saving perspective programmatic [message #525648] Wed, 07 April 2010 11:02 Go to next message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 102
Registered: July 2009
Location: Jena
Senior Member
Hi all,

I want to save a perspective (save perspective as) programmatic. if I use the command, the perspective dialog comes up to give the perspective name. The perspective name will be created automatically so i dont need this dialog. Is there a ways without breaking internal dependencies?

Regards,
Mark
Re: Saving perspective programmatic [message #525706 is a reply to message #525648] Wed, 07 April 2010 14:08 Go to previous message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 102
Registered: July 2009
Location: Jena
Senior Member
Hi again,
after some looking in the forum I have found a similar posting.
And it seems, that its not possible to save a perspective without importing internal dependencies. The SavePerspectiveAction is internal, so I tried something like this in an Handler:
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
final IWorkbenchPage page = window.getActivePage();
IPerspectiveDescriptor perspDesc = new IPerspectiveDescriptor() {
			
			@Override
			public String getLabel() {
				return page.getPerspective().getLabel() + " - " + UserSingleton.getUser();
			}
			
			@Override
			public ImageDescriptor getImageDescriptor() {
				return page.getPerspective().getImageDescriptor();
			}
			
			@Override
			public String getId() {
				return page.getPerspective().getId() + "." + UserSingleton.getUser();
			}
			
			@Override
			public String getDescription() {
				// TODO Auto-generated method stub
				return page.getPerspective().getDescription() + " (for User " + UserSingleton.getUser() + ")";
			}
		};
		window.getActivePage().savePerspectiveAs(perspDesc);

But it doesnt work because of a class cast exception. The expected class is the PerspectiveDescriptor, which is internal.

I create a multiuser client, where user should switch between their logins, without restarting the client. So the workbench should be saved and restored for each user.

Other ideas to solve this task? There is an command for saving the perspective. Is it possible to attach the name of the new perspective as command parameter? I dont need the Dialog for giving the new perspective a name, because the will be given from the client not the user.

Mark
Previous Topic:how to update the eclipse crossing-version?
Next Topic:Adding session management to perspectives...
Goto Forum:
  


Current Time: Sat Nov 29 01:43:43 GMT 2014

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

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