KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > wizards > preferences > PreferencesExportWizard


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.wizards.preferences;
12
13 import org.eclipse.jface.dialogs.IDialogSettings;
14 import org.eclipse.jface.viewers.IStructuredSelection;
15 import org.eclipse.jface.wizard.Wizard;
16 import org.eclipse.ui.IExportWizard;
17 import org.eclipse.ui.IWorkbench;
18 import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
19 import org.eclipse.ui.internal.WorkbenchImages;
20 import org.eclipse.ui.internal.WorkbenchPlugin;
21
22 /**
23  * Standard workbench wizard for exporting preferences from the workspace
24  * to the local file system.
25  * <p>
26  * This class may be instantiated and used without further configuration;
27  * this class is not intended to be subclassed.
28  * </p>
29  * <p>
30  * Example:
31  * <pre>
32  * IWizard wizard = new PreferencesExportWizard();
33  * wizard.init(workbench, selection);
34  * WizardDialog dialog = new WizardDialog(shell, wizard);
35  * dialog.open();
36  * </pre>
37  * During the call to <code>open</code>, the wizard dialog is presented to the
38  * user. When the user hits Finish, the user-selected workspace preferences
39  * are exported to the user-specified location in the local file system,
40  * the dialog closes, and the call to <code>open</code> returns.
41  * </p>
42  *
43  * @since 3.1
44  *
45  */

46 public class PreferencesExportWizard extends Wizard implements 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.getDefault().getDialogSettings();
55         IDialogSettings section = workbenchSettings
56                 .getSection("PreferencesExportWizard");//$NON-NLS-1$
57
if (section == null) {
58             section = workbenchSettings.addNewSection("PreferencesExportWizard");//$NON-NLS-1$
59
}
60         setDialogSettings(section);
61     }
62
63     /* (non-Javadoc)
64      * Method declared on IWizard.
65      */

66     public void addPages() {
67         super.addPages();
68         mainPage = new WizardPreferencesExportPage1();
69         addPage(mainPage);
70     }
71
72     /* (non-Javadoc)
73      * Method declared on IWorkbenchWizard.
74      */

75     public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
76         setWindowTitle(PreferencesMessages.PreferencesExportWizard_export);
77         setDefaultPageImageDescriptor(WorkbenchImages
78                 .getImageDescriptor(IWorkbenchGraphicConstants.IMG_WIZBAN_EXPORT_PREF_WIZ));
79         setNeedsProgressMonitor(true);
80     }
81
82     /* (non-Javadoc)
83      * Method declared on IWizard.
84      */

85     public boolean performFinish() {
86         return mainPage.finish();
87     }
88     
89     
90 }
91
Popular Tags