// Save the version number.
memento.putString(IWorkbenchConstants.TAG_VERSION, VERSION_STRING);
result.add(p.saveState(memento));
if (!saveInnerViewState) {
Rectangle bounds = page.getWorkbenchWindow().getShell().getBounds();
IMemento boundsMem = memento
.createChild(IWorkbenchConstants.TAG_WINDOW);
boundsMem.putInteger(IWorkbenchConstants.TAG_X, bounds.x);
boundsMem.putInteger(IWorkbenchConstants.TAG_Y, bounds.y);
boundsMem.putInteger(IWorkbenchConstants.TAG_HEIGHT, bounds.height);
boundsMem.putInteger(IWorkbenchConstants.TAG_WIDTH, bounds.width);
}
// Save the "always on" action sets.
Iterator itr = alwaysOnActionSets.iterator();
while (itr.hasNext()) {
IActionSetDescriptor desc = (IActionSetDescriptor) itr.next();
IMemento child = memento
.createChild(IWorkbenchConstants.TAG_ALWAYS_ON_ACTION_SET);
child.putString(IWorkbenchConstants.TAG_ID, desc.getId());
}
// Save the "always off" action sets.
itr = alwaysOffActionSets.iterator();
while (itr.hasNext()) {
IActionSetDescriptor desc = (IActionSetDescriptor) itr.next();
IMemento child = memento
.createChild(IWorkbenchConstants.TAG_ALWAYS_OFF_ACTION_SET);
child.putString(IWorkbenchConstants.TAG_ID, desc.getId());
}
// Save "show view actions"
itr = showViewShortcuts.iterator();
while (itr.hasNext()) {
String str = (String) itr.next();
IMemento child = memento
.createChild(IWorkbenchConstants.TAG_SHOW_VIEW_ACTION);
child.putString(IWorkbenchConstants.TAG_ID, str);
}
// Save "show in times"
itr = showInTimes.keySet().iterator();
while (itr.hasNext()) {
String id = (String) itr.next();
Long time = (Long) showInTimes.get(id);
IMemento child = memento
.createChild(IWorkbenchConstants.TAG_SHOW_IN_TIME);
child.putString(IWorkbenchConstants.TAG_ID, id);
child.putString(IWorkbenchConstants.TAG_TIME, time.toString());
}
// Save "new wizard actions".
itr = newWizardShortcuts.iterator();
while (itr.hasNext()) {
String str = (String) itr.next();
IMemento child = memento
.createChild(IWorkbenchConstants.TAG_NEW_WIZARD_ACTION);
child.putString(IWorkbenchConstants.TAG_ID, str);
}
// Save "perspective actions".
itr = perspectiveShortcuts.iterator();
while (itr.hasNext()) {
String str = (String) itr.next();
IMemento child = memento
.createChild(IWorkbenchConstants.TAG_PERSPECTIVE_ACTION);
child.putString(IWorkbenchConstants.TAG_ID, str);
}
// Get visible views.
List viewPanes = new ArrayList(5);
presentation.collectViewPanes(viewPanes);
// Save the views.
itr = viewPanes.iterator();
int errors = 0;
while (itr.hasNext()) {
ViewPane pane = (ViewPane) itr.next();
IViewReference ref = pane.getViewReference();
IMemento viewMemento = memento
.createChild(IWorkbenchConstants.TAG_VIEW);
viewMemento.putString(IWorkbenchConstants.TAG_ID, ViewFactory
.getKey(ref));
}
// save all fastview state
if (fastViewManager != null)
fastViewManager.saveState(memento);
// Save the view layout recs.
for (Iterator i = mapIDtoViewLayoutRec.keySet().iterator(); i.hasNext();) {
String compoundId = (String) i.next();
ViewLayoutRec rec = (ViewLayoutRec) mapIDtoViewLayoutRec
.get(compoundId);
if (rec != null
&& (!rec.isCloseable || !rec.isMoveable || rec.isStandalone)) {
IMemento layoutMemento = memento
.createChild(IWorkbenchConstants.TAG_VIEW_LAYOUT_REC);
layoutMemento.putString(IWorkbenchConstants.TAG_ID, compoundId);
if (!rec.isCloseable) {
layoutMemento.putString(IWorkbenchConstants.TAG_CLOSEABLE,
IWorkbenchConstants.FALSE);
}
if (!rec.isMoveable) {
layoutMemento.putString(IWorkbenchConstants.TAG_MOVEABLE,
IWorkbenchConstants.FALSE);
}
if (rec.isStandalone) {
layoutMemento.putString(IWorkbenchConstants.TAG_STANDALONE,
IWorkbenchConstants.TRUE);
layoutMemento.putString(IWorkbenchConstants.TAG_SHOW_TITLE,
String.valueOf(rec.showTitle));
}
}
}
if (errors > 0) {
String message = WorkbenchMessages.Perspective_multipleErrors;
if (errors == 1) {
message = WorkbenchMessages.Perspective_oneError;
}
MessageDialog.openError(null,
WorkbenchMessages.Error, message);
}
// Save the layout.
IMemento childMem = memento.createChild(IWorkbenchConstants.TAG_LAYOUT);
result.add(presentation.saveState(childMem));
// Save the editor visibility state
if (isEditorAreaVisible()) {
memento.putInteger(IWorkbenchConstants.TAG_AREA_VISIBLE, 1);