Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Adding session management to perspectives...
Adding session management to perspectives... [message #522878] Wed, 24 March 2010 10:20 Go to next message
Martin D. is currently offline Martin D.Friend
Messages: 5
Registered: March 2010
Location: Germany
Junior Member
Hello,
I hope you can help me with my problem...

I tried to add some kind of session management to the eclipse perspectives (to use it in my software for dynamically generated perspectives).

Therefore, I use the Perspective's saveState(memento) method to get the configuration, and the restoreState(memento) / restoreState() methods to restore the configuration.
After doing the restore (especially when switching to another perspective and back again), my eclipse behaves very strange:
The editor area (which should be hidden) becomes partly visible, some views become deformed (e.g. their frame and header tab is at a different place than their visible content, no content is displayed or when you move a view the window layout manager runs amok) etc., and in fact can not be used any more until a full restarted Sad After restarting, everything is just fine again...

Here you find the conceptual code fragments I use:
public static XMLMemento getPerspectiveConfiguration(IPerspectiveDescriptor perspDesc) throws Exception {
  Perspective perspective = ((WorkbenchPage) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()).findPerspective(perspDesc);
  XMLMemento memento = XMLMemento.createWriteRoot(IWorkbenchConstants.TAG_PERSPECTIVE);
  IStatus status = perspective.saveState(memento);
  StringWriter writer = new StringWriter();
  memento.save(writer);
  if (status.getSeverity() == IStatus.OK)
    return memento;
  else
    return null;
}
public static IStatus setPerspectiveConfiguration (IPerspectiveDescriptor perspDesc, IMemento memento) throws Exception {
  Perspective perspective = ((WorkbenchPage) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()).findPerspective(perspDesc);
  MultiStatus status = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, "restoring perspective", null);
  status.merge(perspective.restoreState(memento));
  status.merge(perspective.restoreState());
  return status;
}


My main question is, if this behaviour is a bug, or if I forget something (e.g. refresh the perspective window) ?
I know that this is actually a hack of the perspectives and I assume that initializing/restoring them more than once is not intended by design Smile

[Updated on: Wed, 24 March 2010 10:21]

Report message to a moderator

Re: Adding session management to perspectives... [message #524315 is a reply to message #522878] Wed, 31 March 2010 14:00 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Martin Dyrba wrote:
>
> My main question is, if this behaviour is a bug, or if I forget
> something (e.g. refresh the perspective window) ?
> I know that this is actually a hack of the perspectives and I assume
> that initializing/restoring them more than once is not intended by
> design :)

Correct, it's just not designed to do that. At all. Not even close :-)

However, it does have provisions for saving the current layout as a
custom layout, and that's what I would try (all internal, so nothing is
guaranteed to work).

My guess is you would want to use
org.eclipse.ui.internal.Perspective.saveDescAs(IPerspectiveD escriptor)
to save the current state. Then you can set that perspective descriptor
as the active perspective and do a
org.eclipse.ui.IWorkbenchPage.resetPerspective()

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/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Adding session management to perspectives... [message #525717 is a reply to message #522878] Wed, 07 April 2010 14:40 Go to previous message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Hi Martin,

I have the same problem, I think (http:// www.eclipse.org/forums/index.php?t=msg&th=165890&sta rt=0&).

Are you any further? Maybe we can find a solution together.
You can contact me via hoffmann-mark at gmx dot de

Regards Mark
Previous Topic:Saving perspective programmatic
Next Topic:Different Pages of Properties View for selection in the same Common Navigator
Goto Forum:
  


Current Time: Fri Apr 26 11:12:05 GMT 2024

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

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

Back to the top