I discovered some problems when trying to load a perspective stored in advance in a XMLMemento file.

I wrote a procedure to store a customized perspective w/ all included views in a given .xml file.

Furthermore I'd like to restore this saved perspective for example on another workstation.

My procedure loads the saved XMLMemento from the xml file by calling the function createReadRoot(reader) from the XMLMemento class.
As far as I can tell this is working correctly since I can access the elements within the xml file (e.g. the descriptor or view tags).

Then I tried to restore the perspective by creating a new instance of it and calling the restoreState(XMLMemento) function. Afterwards I tried to add the just created perpective to the perspective registry and load it over the load perspective dialog provided from the RCP Framework (Menubar->Window->Perspective->Other...).

And now my problem:
======================
The perspective is not being displayed. Something happens within my application and the current perspective changes but it is not my saved perspective which is being displayed.

Is there a proper way to load such a stored perspective from an XMLMemento file?

On 02/01/2011 05:22 AM, sluettmann wrote:
>
> Is there a proper way to load such a stored perspective from an
> XMLMemento file?

There's no API and hence now supported way to do what you want.

You will have to look through the code that saves customized perspective
descriptors (see org.eclipse.ui.internal.SavePerspectiveAction for the
behaviour of "Save Perspective As") and then trick the system into
loading that perspective back.

Am I the first one who tries to save / load perspectives?
There must be something like a structured way to do so.
For example:
1) Load memento
2) create PerspectiveDescriptor and restoreState
3) create Perspective
4) .... a.s.o

I did use that code u mentioned (org.eclipse.ui.internal.SavePerspectiveAction) to save the perspectives but I can't trace the way back of loading it, cause I don't know the function that is called if u open the Dialog (Perspective->Other) and click OK.