/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.internal;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
/**
* Helper class provides window and page level
* save and restore state functions.
*/
public class WorkbenchStateHelper {
/**
* Saves state for the specified IWorkbenchWindow
* @param window - the window to save state for
* @param memento - the memento to save state to
* @return result
*/
public static IStatus saveWindowState(IWorkbenchWindow window, IMemento memento) {
return ((WorkbenchWindow)window).saveState(memento);
}
/**
* Saves state for the specified IWorkbenchPage
* @param page - the page to save state for
* @param memento - the memento to save state to
* @return result
*/
public static IStatus savePageState(IWorkbenchPage page, IMemento memento) {
return ((WorkbenchPage)page).saveState(memento);
}
/**
* Restores window state for the specified IWorkbenchWindow
.
* This includes window attributes such as dimensions and toolbar layout.
* @param window - the window to restore state for
* @param memento - the memento to restore state from
* @return result
*/
public static IStatus restoreWindowState(IWorkbenchWindow window, IMemento memento) {
return ((WorkbenchWindow)window).restoreState(memento, null);
}
/**
* Restores page state for the specified IWorkbenchWindow
.
* This does not include window attributes such as dimensions and toolbar layout.
* @param window - the window to restore state for
* @param memento - the memento to restore state from
* @return result
*/
public static IStatus restorePageState(IWorkbenchWindow window, IMemento memento) {
return ((WorkbenchWindow)window).restorePages(memento, null);
}
}