* @see IPersistablePart
*/
public IStatus saveState(IMemento memento) {
RelationshipInfo[] relationships = computeRelation();
MultiStatus result = new MultiStatus(
PlatformUI.PLUGIN_ID,
IStatus.OK,
WorkbenchMessages.RootLayoutContainer_problemsSavingPerspective, null);
// Loop through the relationship array.
for (int i = 0; i < relationships.length; i++) {
// Save the relationship info ..
// private LayoutPart part;
// private int relationship;
// private float ratio;
// private LayoutPart relative;
RelationshipInfo info = relationships[i];
IMemento childMem = memento
.createChild(IWorkbenchConstants.TAG_INFO);
childMem.putString(IWorkbenchConstants.TAG_PART, info.part.getID());
if (info.relative != null) {
childMem.putString(IWorkbenchConstants.TAG_RELATIVE,
info.relative.getID());
childMem.putInteger(IWorkbenchConstants.TAG_RELATIONSHIP,
info.relationship);
childMem.putInteger(IWorkbenchConstants.TAG_RATIO_LEFT,
info.left);
childMem.putInteger(IWorkbenchConstants.TAG_RATIO_RIGHT,
info.right);
// The ratio is only needed for saving workspaces that can be read by old versions
// of Eclipse. It is not used in newer versions of Eclipse, which use the "left"
// and "right" attributes instead.
childMem.putFloat(IWorkbenchConstants.TAG_RATIO, info
.getRatio());
}
// Is this part a folder or a placeholder for one?
ViewStack folder = null;
if (info.part instanceof ViewStack) {
folder = (ViewStack) info.part;
} else if (info.part instanceof ContainerPlaceholder) {
LayoutPart part = ((ContainerPlaceholder) info.part)
.getRealContainer();
if (part instanceof ViewStack) {
folder = (ViewStack) part;
}
}
// If this is a folder (ViewStack) save the contents.
if (folder != null) {
childMem.putString(IWorkbenchConstants.TAG_FOLDER, "true");//$NON-NLS-1$
IMemento folderMem = childMem
.createChild(IWorkbenchConstants.TAG_FOLDER);
result.add(folder.saveState(folderMem));
}
}
return result;
}