KickJava   Java API By Example, From Geeks To Geeks.

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


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.IImportWizard;
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 /**
24  * Standard workbench wizard for importing resources from the local file system
25  * into the workspace.
26  * <p>
27  * This class may be instantiated and used without further configuration;
28  * this class is not intended to be subclassed.
29  * </p>
30  * <p>
31  * Example:
32  * <pre>
33  * IWizard wizard = new PreferencesImportWizard();
34  * wizard.init(workbench, selection);
35  * WizardDialog dialog = new WizardDialog(shell, wizard);
36  * dialog.open();
37  * </pre>
38  * During the call to <code>open</code>, the wizard dialog is presented to the
39  * user. When the user hits Finish, the user-selected files are imported
40  * into the workspace, the dialog closes, and the call to <code>open</code>
41  * returns.
42  * </p>
43  *
44  * @since 3.1
45  *
46  */

47 public class PreferencesImportWizard extends Wizard implements IImportWizard {
48
49     private WizardPreferencesImportPage1 mainPage;
50     
51     /**
52      * Creates a wizard for importing resources into the workspace from
53      * the file system.
54      */

55     public PreferencesImportWizard() {
56         IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
57         IDialogSettings section = workbenchSettings
58                 .getSection("PreferencesImportWizard");//$NON-NLS-1$
59
if (section == null) {
60             section = workbenchSettings.addNewSection("PreferencesImportWizard");//$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 WizardPreferencesImportPage1();
71         addPage(mainPage);
72     }
73
74     /* (non-Javadoc)
75      * Method declared on IWorkbenchWizard.
76      */

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

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