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.IImportWizard;
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 importing resources from the local file system
23: * into the workspace.
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 PreferencesImportWizard();
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 files are imported
38: * into the workspace, the dialog closes, and the call to <code>open</code>
39: * returns.
40: * </p>
41: *
42: * @since 3.1
43: *
44: */
45: public class PreferencesImportWizard extends Wizard implements
46: IImportWizard {
47:
48: private WizardPreferencesImportPage1 mainPage;
49:
50: /**
51: * Creates a wizard for importing resources into the workspace from
52: * the file system.
53: */
54: public PreferencesImportWizard() {
55: IDialogSettings workbenchSettings = WorkbenchPlugin
56: .getDefault().getDialogSettings();
57: IDialogSettings section = workbenchSettings
58: .getSection("PreferencesImportWizard");//$NON-NLS-1$
59: if (section == null) {
60: section = workbenchSettings
61: .addNewSection("PreferencesImportWizard");//$NON-NLS-1$
62: }
63: setDialogSettings(section);
64: }
65:
66: /* (non-Javadoc)
67: * Method declared on IWizard.
68: */
69: public void addPages() {
70: super .addPages();
71: mainPage = new WizardPreferencesImportPage1();
72: addPage(mainPage);
73: }
74:
75: /* (non-Javadoc)
76: * Method declared on IWorkbenchWizard.
77: */
78: public void init(IWorkbench workbench,
79: IStructuredSelection currentSelection) {
80: setWindowTitle(PreferencesMessages.PreferencesImportWizard_import);
81: setDefaultPageImageDescriptor(WorkbenchImages
82: .getImageDescriptor(IWorkbenchGraphicConstants.IMG_WIZBAN_IMPORT_PREF_WIZ));
83: setNeedsProgressMonitor(true);
84: }
85:
86: /* (non-Javadoc)
87: * Method declared on IWizard.
88: */
89: public boolean performFinish() {
90: return mainPage.finish();
91: }
92: }
|