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 After restarting, everything is just fine again...

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

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()