01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.wizards.preferences;
11:
12: import org.eclipse.jface.dialogs.IDialogSettings;
13: import org.eclipse.jface.viewers.IStructuredSelection;
14: import org.eclipse.jface.wizard.Wizard;
15: import org.eclipse.ui.IExportWizard;
16: import org.eclipse.ui.IWorkbench;
17: import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
18: import org.eclipse.ui.internal.WorkbenchImages;
19: import org.eclipse.ui.internal.WorkbenchPlugin;
20:
21: /**
22: * Standard workbench wizard for exporting preferences from the workspace
23: * to the local file system.
24: * <p>
25: * This class may be instantiated and used without further configuration;
26: * this class is not intended to be subclassed.
27: * </p>
28: * <p>
29: * Example:
30: * <pre>
31: * IWizard wizard = new PreferencesExportWizard();
32: * wizard.init(workbench, selection);
33: * WizardDialog dialog = new WizardDialog(shell, wizard);
34: * dialog.open();
35: * </pre>
36: * During the call to <code>open</code>, the wizard dialog is presented to the
37: * user. When the user hits Finish, the user-selected workspace preferences
38: * are exported to the user-specified location in the local file system,
39: * the dialog closes, and the call to <code>open</code> returns.
40: * </p>
41: *
42: * @since 3.1
43: *
44: */
45: public class PreferencesExportWizard extends Wizard implements
46: IExportWizard {
47:
48: private WizardPreferencesExportPage1 mainPage;
49:
50: /**
51: * Creates a wizard for exporting workspace preferences to the local file system.
52: */
53: public PreferencesExportWizard() {
54: IDialogSettings workbenchSettings = WorkbenchPlugin
55: .getDefault().getDialogSettings();
56: IDialogSettings section = workbenchSettings
57: .getSection("PreferencesExportWizard");//$NON-NLS-1$
58: if (section == null) {
59: section = workbenchSettings
60: .addNewSection("PreferencesExportWizard");//$NON-NLS-1$
61: }
62: setDialogSettings(section);
63: }
64:
65: /* (non-Javadoc)
66: * Method declared on IWizard.
67: */
68: public void addPages() {
69: super .addPages();
70: mainPage = new WizardPreferencesExportPage1();
71: addPage(mainPage);
72: }
73:
74: /* (non-Javadoc)
75: * Method declared on IWorkbenchWizard.
76: */
77: public void init(IWorkbench workbench,
78: IStructuredSelection currentSelection) {
79: setWindowTitle(PreferencesMessages.PreferencesExportWizard_export);
80: setDefaultPageImageDescriptor(WorkbenchImages
81: .getImageDescriptor(IWorkbenchGraphicConstants.IMG_WIZBAN_EXPORT_PREF_WIZ));
82: setNeedsProgressMonitor(true);
83: }
84:
85: /* (non-Javadoc)
86: * Method declared on IWizard.
87: */
88: public boolean performFinish() {
89: return mainPage.finish();
90: }
91:
92: }
|