Adding session management to perspectives... [message #522878] |
Wed, 24 March 2010 10:20 |
Martin D. 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 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
[Updated on: Wed, 24 March 2010 10:21] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05565 seconds