View | Details | Raw Unified | Return to bug 85373 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/application/IWorkbenchConfigurer.java (-1 / +19 lines)
Lines 13-18 Link Here
13
import org.eclipse.core.runtime.IStatus;
13
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.jface.resource.ImageDescriptor;
14
import org.eclipse.jface.resource.ImageDescriptor;
15
import org.eclipse.jface.window.WindowManager;
15
import org.eclipse.jface.window.WindowManager;
16
import org.eclipse.ui.IMemento;
16
import org.eclipse.ui.IWorkbench;
17
import org.eclipse.ui.IWorkbench;
17
import org.eclipse.ui.IWorkbenchWindow;
18
import org.eclipse.ui.IWorkbenchWindow;
18
19
Lines 36-42 Link Here
36
     * could not be restored, but that startup should continue
37
     * could not be restored, but that startup should continue
37
     * with a reset state.
38
     * with a reset state.
38
     * 
39
     * 
39
     * @see #restoreState
40
     * @see #restoreState()
40
     */
41
     */
41
    public static final int RESTORE_CODE_RESET = 1;
42
    public static final int RESTORE_CODE_RESET = 1;
42
43
Lines 75-80 Link Here
75
     * 	<code>false</code> to forget current workbench state on close.
76
     * 	<code>false</code> to forget current workbench state on close.
76
     */
77
     */
77
    public void setSaveAndRestore(boolean enabled);
78
    public void setSaveAndRestore(boolean enabled);
79
80
	/**
81
	 * Saves the current state of the workbench using the
82
	 * specified memento.
83
	 * 
84
	 * @param memento the storage area for object's state
85
	 * @return a status object indicating whether the save was successful
86
	 */
87
	public IStatus saveSate(IMemento memento);
88
	
89
	/**
90
	 * Restores the Workbench state using the specified memento.
91
	 * 
92
	 * @param memento the storage area for object's state
93
	 * @return a status object indicating whether the restore was successful
94
	 */
95
	public IStatus restoreState(IMemento memento);
78
96
79
    /**
97
    /**
80
     * Returns the workbench window manager.
98
     * Returns the workbench window manager.
(-)Eclipse UI/org/eclipse/ui/application/IWorkbenchWindowConfigurer.java (+20 lines)
Lines 10-21 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.application;
11
package org.eclipse.ui.application;
12
12
13
import org.eclipse.core.runtime.IStatus;
13
import org.eclipse.swt.dnd.DropTargetListener;
14
import org.eclipse.swt.dnd.DropTargetListener;
14
import org.eclipse.swt.dnd.Transfer;
15
import org.eclipse.swt.dnd.Transfer;
15
import org.eclipse.swt.graphics.Point;
16
import org.eclipse.swt.graphics.Point;
16
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.swt.widgets.Control;
18
import org.eclipse.swt.widgets.Control;
18
import org.eclipse.swt.widgets.Menu;
19
import org.eclipse.swt.widgets.Menu;
20
import org.eclipse.ui.IMemento;
19
import org.eclipse.ui.IWorkbenchWindow;
21
import org.eclipse.ui.IWorkbenchWindow;
20
import org.eclipse.ui.presentations.AbstractPresentationFactory;
22
import org.eclipse.ui.presentations.AbstractPresentationFactory;
21
23
Lines 393-396 Link Here
393
     * @return the page composite, suitable for laying out in the parent 
395
     * @return the page composite, suitable for laying out in the parent 
394
     */
396
     */
395
    public Control createPageComposite(Composite parent);
397
    public Control createPageComposite(Composite parent);
398
	
399
	/**
400
	 * Saves the state of the <code>WorkbenchWindow</code> using
401
	 * the specified memento.
402
	 * 
403
	 * @param memento the storage area for object's state
404
	 * @return a status object indicating whether the save was successful
405
	 */
406
	public IStatus saveState(IMemento memento);
407
	
408
	/**
409
	 * Restores the state of the <code>WorkbenchWindow</code> using
410
	 * the specified memento.
411
	 * 
412
	 * @param memento the storage area for object's state
413
	 * @return a status object indicating whether the restore was successful
414
	 */
415
	public IStatus restoreState(IMemento memento);
396
}
416
}
(-)Eclipse UI/org/eclipse/ui/application/WorkbenchAdvisor.java (+29 lines)
Lines 18-23 Link Here
18
import org.eclipse.swt.widgets.Control;
18
import org.eclipse.swt.widgets.Control;
19
import org.eclipse.swt.widgets.Display;
19
import org.eclipse.swt.widgets.Display;
20
import org.eclipse.swt.widgets.Shell;
20
import org.eclipse.swt.widgets.Shell;
21
import org.eclipse.ui.IMemento;
21
import org.eclipse.ui.IWorkbenchPreferenceConstants;
22
import org.eclipse.ui.IWorkbenchPreferenceConstants;
22
import org.eclipse.ui.IWorkbenchWindow;
23
import org.eclipse.ui.IWorkbenchWindow;
23
import org.eclipse.ui.PlatformUI;
24
import org.eclipse.ui.PlatformUI;
Lines 740-745 Link Here
740
	 */
741
	 */
741
	public Control createEmptyWindowContents(IWorkbenchWindowConfigurer configurer, Composite parent) {
742
	public Control createEmptyWindowContents(IWorkbenchWindowConfigurer configurer, Composite parent) {
742
		return null;
743
		return null;
744
	}
745
	
746
	/**
747
	 * Saves the state of the workbench using the specified memento.
748
	 * <p>
749
	 * The default implementation of this uses <code>IWorkbenchConfigurer.saveState</code>.
750
	 * Subclasses may override.
751
	 * 
752
	 * @param memento the storage area for object's state
753
	 * @return a status object indicating whether the save was successful
754
	 */
755
	public IStatus saveState(IMemento memento) {
756
		// default behavior
757
		return getWorkbenchConfigurer().saveSate(memento);
758
	}
759
	
760
	/**
761
	 * Restores the state of the workbench using the specified memento.
762
	 * <p>
763
	 * The default implementation of this uses <code>IWorkbenchConfigurer.restoreState</code>.
764
	 * Subclasses may override.
765
	 *  
766
	 * @param memento the storage area for object's state
767
	 * @return a status object indicating whether the restore was successful
768
	 */
769
	public IStatus restoreState(IMemento memento) {
770
		// default behavior
771
		return getWorkbenchConfigurer().restoreState(memento);
743
	}
772
	}
744
}
773
}
745
774
(-)Eclipse UI/org/eclipse/ui/application/WorkbenchWindowAdvisor.java (-1 / +33 lines)
Lines 10-19 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.application;
11
package org.eclipse.ui.application;
12
12
13
import org.eclipse.core.runtime.IStatus;
13
import org.eclipse.swt.widgets.Composite;
14
import org.eclipse.swt.widgets.Composite;
14
import org.eclipse.swt.widgets.Control;
15
import org.eclipse.swt.widgets.Control;
15
import org.eclipse.swt.widgets.Shell;
16
import org.eclipse.swt.widgets.Shell;
17
import org.eclipse.ui.IMemento;
16
import org.eclipse.ui.IWorkbenchPreferenceConstants;
18
import org.eclipse.ui.IWorkbenchPreferenceConstants;
19
import org.eclipse.ui.IWorkbenchWindow;
17
import org.eclipse.ui.PlatformUI;
20
import org.eclipse.ui.PlatformUI;
18
import org.eclipse.ui.WorkbenchException;
21
import org.eclipse.ui.WorkbenchException;
19
import org.eclipse.ui.internal.WorkbenchWindowConfigurer;
22
import org.eclipse.ui.internal.WorkbenchWindowConfigurer;
Lines 376-380 Link Here
376
    public void dispose() {
379
    public void dispose() {
377
        // do nothing.
380
        // do nothing.
378
    }
381
    }
379
    
382
	
383
	/**
384
	 * Saves the state of the workbench window using the specified memento.
385
	 * <p>
386
	 * The default implementation of this uses <code>IWorkbenchWindowConfigurer.saveState</code>.
387
	 * Subclasses may override.
388
	 * 
389
	 * @param window the window that is being saved
390
	 * @param memento the storage area for object's state
391
	 * @return a status object indicating whether the save was successful
392
	 */
393
	public IStatus saveState (IWorkbenchWindow window, IMemento memento) {
394
		// default behavior
395
		return windowConfigurer.saveState(memento);
396
	}
397
	
398
	/**
399
	 * Restores the state of the workbench window using the specified memento.
400
	 * <p>
401
	 * The default implementation of this uses <code>IWorkbenchWindowConfigurer.restoreState</code>.
402
	 * Subclasses may override.
403
	 * 
404
	 * @param window the window that is being restored
405
	 * @param memento the storage area for object's state
406
	 * @return a status object indicating whether the restore was successful
407
	 */
408
	public IStatus restoreState (IWorkbenchWindow window, IMemento memento) {
409
		// default behavior
410
		return windowConfigurer.restoreState(memento);
411
	}
380
}
412
}
(-)Eclipse UI/org/eclipse/ui/internal/Workbench.java (-6 / +6 lines)
Lines 1252-1258 Link Here
1252
				}
1252
				}
1253
1253
1254
				// Restore the saved state
1254
				// Restore the saved state
1255
				IStatus restoreResult = restoreState(memento);
1255
				IStatus restoreResult = getAdvisor().restoreState(memento);
1256
				reader.close();
1256
				reader.close();
1257
				if (restoreResult.getSeverity() == IStatus.ERROR) {
1257
				if (restoreResult.getSeverity() == IStatus.ERROR) {
1258
					ErrorDialog.openError(null,
1258
					ErrorDialog.openError(null,
Lines 1322-1328 Link Here
1322
	private XMLMemento recordWorkbenchState() {
1322
	private XMLMemento recordWorkbenchState() {
1323
		XMLMemento memento = XMLMemento
1323
		XMLMemento memento = XMLMemento
1324
				.createWriteRoot(IWorkbenchConstants.TAG_WORKBENCH);
1324
				.createWriteRoot(IWorkbenchConstants.TAG_WORKBENCH);
1325
		IStatus status = saveState(memento);
1325
		IStatus status = getAdvisor().saveState(memento);
1326
		if (status.getSeverity() != IStatus.OK) {
1326
		if (status.getSeverity() != IStatus.OK) {
1327
			// don't use newWindow as parent because it has not yet been opened
1327
			// don't use newWindow as parent because it has not yet been opened
1328
			// (bug 76724)
1328
			// (bug 76724)
Lines 1344-1350 Link Here
1344
	/*
1344
	/*
1345
	 * Restores the state of the previously saved workbench
1345
	 * Restores the state of the previously saved workbench
1346
	 */
1346
	 */
1347
	private IStatus restoreState(IMemento memento) {
1347
	IStatus restoreState(IMemento memento) {
1348
1348
1349
		MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK,
1349
		MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK,
1350
				WorkbenchMessages.Workbench_problemsRestoring, null);
1350
				WorkbenchMessages.Workbench_problemsRestoring, null);
Lines 1387-1393 Link Here
1387
			// for any exception that might hose us before we get a chance to
1387
			// for any exception that might hose us before we get a chance to
1388
			// open it. If one occurs, remove the new window from the manager.
1388
			// open it. If one occurs, remove the new window from the manager.
1389
			try {
1389
			try {
1390
				result.merge(newWindow.restoreState(childMem, null));
1390
				result.merge(newWindow.restoreState(childMem));
1391
				try {
1391
				try {
1392
					newWindow.fireWindowRestored();
1392
					newWindow.fireWindowRestored();
1393
				} catch (WorkbenchException e) {
1393
				} catch (WorkbenchException e) {
Lines 1561-1567 Link Here
1561
	/*
1561
	/*
1562
	 * Saves the current state of the workbench so it can be restored later on
1562
	 * Saves the current state of the workbench so it can be restored later on
1563
	 */
1563
	 */
1564
	private IStatus saveState(IMemento memento) {
1564
	IStatus saveState(IMemento memento) {
1565
		MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK,
1565
		MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK,
1566
				WorkbenchMessages.Workbench_problemsSaving, null);
1566
				WorkbenchMessages.Workbench_problemsSaving, null);
1567
1567
Lines 1574-1580 Link Here
1574
			WorkbenchWindow window = (WorkbenchWindow) windows[nX];
1574
			WorkbenchWindow window = (WorkbenchWindow) windows[nX];
1575
			IMemento childMem = memento
1575
			IMemento childMem = memento
1576
					.createChild(IWorkbenchConstants.TAG_WINDOW);
1576
					.createChild(IWorkbenchConstants.TAG_WINDOW);
1577
			result.merge(window.saveState(childMem));
1577
			result.merge(window.recordState(childMem));
1578
		}
1578
		}
1579
		result.add(getEditorHistory().saveState(
1579
		result.add(getEditorHistory().saveState(
1580
				memento.createChild(IWorkbenchConstants.TAG_MRU_LIST))); //$NON-NLS-1$
1580
				memento.createChild(IWorkbenchConstants.TAG_MRU_LIST))); //$NON-NLS-1$
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchConfigurer.java (+15 lines)
Lines 16-21 Link Here
16
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.jface.resource.ImageDescriptor;
17
import org.eclipse.jface.resource.ImageDescriptor;
18
import org.eclipse.jface.window.WindowManager;
18
import org.eclipse.jface.window.WindowManager;
19
import org.eclipse.ui.IMemento;
19
import org.eclipse.ui.IWorkbench;
20
import org.eclipse.ui.IWorkbench;
20
import org.eclipse.ui.IWorkbenchWindow;
21
import org.eclipse.ui.IWorkbenchWindow;
21
import org.eclipse.ui.PlatformUI;
22
import org.eclipse.ui.PlatformUI;
Lines 177-180 Link Here
177
    public void openFirstTimeWindow() {
178
    public void openFirstTimeWindow() {
178
        ((Workbench) getWorkbench()).openFirstTimeWindow();
179
        ((Workbench) getWorkbench()).openFirstTimeWindow();
179
    }
180
    }
181
182
	/* (non-Javadoc)
183
	 * @see org.eclipse.ui.application.IWorkbenchConfigurer#saveSate(org.eclipse.ui.IMemento)
184
	 */
185
	public IStatus saveSate(IMemento memento) {
186
		return ((Workbench) getWorkbench()).saveState(memento);
187
	}
188
189
	/* (non-Javadoc)
190
	 * @see org.eclipse.ui.application.IWorkbenchConfigurer#restoreState(org.eclipse.ui.IMemento)
191
	 */
192
	public IStatus restoreState(IMemento memento) {
193
		return ((Workbench) getWorkbench()).restoreState(memento);
194
	}
180
}
195
}
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java (+21 lines)
Lines 1373-1378 Link Here
1373
    }
1373
    }
1374
1374
1375
    /**
1375
    /**
1376
     * Restores the state of the workbench window using the specified memento.
1377
     * 
1378
     * @param memento the storage area for object's state
1379
     * @return a status object indicating whether the restore was successful
1380
     */
1381
    IStatus restoreState(IMemento memento) {
1382
		return getWindowAdvisor().restoreState(this, memento);
1383
    }
1384
			
1385
    /**
1376
     * @see IPersistable.
1386
     * @see IPersistable.
1377
     */
1387
     */
1378
    public IStatus restoreState(IMemento memento,
1388
    public IStatus restoreState(IMemento memento,
Lines 2505-2510 Link Here
2505
        return getWorkbenchImpl().getAdvisor();
2515
        return getWorkbenchImpl().getAdvisor();
2506
    }
2516
    }
2507
2517
2518
	/**
2519
	 * Records the state of the workbench window using the 
2520
	 * specified memento.
2521
	 * 
2522
	 * @param memento the storage area for object's state
2523
	 * @return a status object indicating whether the record was successful
2524
	 */
2525
	IStatus recordState(IMemento memento) {
2526
		return getWindowAdvisor().saveState(this, memento);
2527
	}
2528
	
2508
    /**
2529
    /**
2509
     * Returns the window advisor, creating a new one for this
2530
     * Returns the window advisor, creating a new one for this
2510
     * window if needed.
2531
     * window if needed.
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchWindowConfigurer.java (+16 lines)
Lines 14-19 Link Here
14
import java.util.HashMap;
14
import java.util.HashMap;
15
import java.util.Map;
15
import java.util.Map;
16
16
17
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.jface.action.IAction;
18
import org.eclipse.jface.action.IContributionItem;
19
import org.eclipse.jface.action.IContributionItem;
19
import org.eclipse.jface.action.ICoolBarManager;
20
import org.eclipse.jface.action.ICoolBarManager;
Lines 29-34 Link Here
29
import org.eclipse.swt.widgets.Control;
30
import org.eclipse.swt.widgets.Control;
30
import org.eclipse.swt.widgets.Menu;
31
import org.eclipse.swt.widgets.Menu;
31
import org.eclipse.swt.widgets.Shell;
32
import org.eclipse.swt.widgets.Shell;
33
import org.eclipse.ui.IMemento;
32
import org.eclipse.ui.IWorkbenchPage;
34
import org.eclipse.ui.IWorkbenchPage;
33
import org.eclipse.ui.IWorkbenchWindow;
35
import org.eclipse.ui.IWorkbenchWindow;
34
import org.eclipse.ui.application.IActionBarConfigurer;
36
import org.eclipse.ui.application.IActionBarConfigurer;
Lines 600-603 Link Here
600
    public Control createPageComposite(Composite parent) {
602
    public Control createPageComposite(Composite parent) {
601
        return window.createPageComposite(parent);
603
        return window.createPageComposite(parent);
602
    }
604
    }
605
606
	/* (non-Javadoc)
607
	 * @see org.eclipse.ui.application.IWorkbenchWindowConfigurer#saveState(org.eclipse.ui.IMemento)
608
	 */
609
	public IStatus saveState(IMemento memento) {
610
		return window.saveState(memento);
611
	}
612
613
	/* (non-Javadoc)
614
	 * @see org.eclipse.ui.application.IWorkbenchWindowConfigurer#restoreState(org.eclipse.ui.IMemento)
615
	 */
616
	public IStatus restoreState(IMemento memento) {
617
		return window.restoreState(memento, null);
618
	}
603
}
619
}

Return to bug 85373