Bug 115808 - [Perspectives] Save/Restore Perspective State
Summary: [Perspectives] Save/Restore Perspective State
Status: ASSIGNED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P5 enhancement with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2005-11-10 08:56 EST by Amber Beerends CLA
Modified: 2019-09-06 16:05 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Amber Beerends CLA 2005-11-10 08:56:52 EST
We need a public API to allow us to explicitly save the state (primarily the 
layout) of a perspective and a showPerspective API that would allow us to 
specify the state.

The existing saveAndRestoreState functionality does not work for us for a 
variety of reasons.  First, we need the state to be available across devices 
so the local file storage does not work.  Second, we have a “home” perspective 
which should always be displayed upon application load regardless of which 
perspective was visible when the application was closed.  Third, we do not 
want changes to be implicitly saved.  A modification to the layout of the 
perspective should only be saved when the user indicates that he wants to 
preserve it.
Comment 1 Nick Edgar CLA 2006-03-15 11:46:56 EST
Reassigning bugs in component areas that are changing ownership.
Comment 2 Paul Webster CLA 2006-09-28 11:01:25 EDT
There are currently no plans to work on this feature.

PW
Comment 3 Denis Roy CLA 2007-06-22 09:33:09 EDT
Changes requested on bug 193523
Comment 4 Michal Dobisek CLA 2007-07-19 07:14:51 EDT
We have a little different use-case related to saving/restoring perspective. In our application, we have several modules, with each having it's own primary perspective. After the module instance is launched, it derives it's own perspective prom the module primary perspective.
Then there is a user functionality  save/save as/restore layout, which stores the perspective layout into the database (shared among all users/machines).

Since there is no public API for this, we use the following workaround (using the Eclipse internal classes):

// To Save the perspective
XMLMemento memento = XMLMemento.createWriteRoot("perspective");

WorkbenchPage activePage = (WorkbenchPage)PlatformUI.getWorkbench().
        getActiveWorkbenchWindow().getActivePage();        
Perspective perspective = activePage.getActivePerspective();

if(!perspective.saveState(memento).isOK()) {
    log.error("Save state not OK");
}

// To Restore the perspective
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow activeWindow = workbench.getActiveWorkbenchWindow();
IWorkbenchPage activePage = activeWindow.getActivePage();

PerspectiveDescriptor pd = (PerspectiveDescriptor) activePage.getPerspective();
PerspectiveRegistry perspRegistry = (PerspectiveRegistry) workbench.getPerspectiveRegistry();

// Remove the original definition (not custom) - not needed
// In the registry any more, since the module instance
// was already constructed
perspRegistry.deletePerspective(pd);

try {
    perspRegistry.saveCustomPersp(pd, memento);
    
    activePage.resetPerspective();
} catch (IOException e) {
    log.error("Unable to save perspective definition", e);
}

// We don't want to leave this in the registry
perspRegistry.deletePerspective(pd);                    
Comment 5 Eclipse Webmaster CLA 2019-09-06 16:05:55 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.