KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > wizards > datatransfer > ExternalProjectImportWizard


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.wizards.datatransfer;
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.ide.IDEWorkbenchPlugin;
19 import org.eclipse.ui.internal.wizards.datatransfer.DataTransferMessages;
20 import org.eclipse.ui.internal.wizards.datatransfer.WizardProjectsImportPage;
21
22 /**
23  * Standard workbench wizard for importing projects defined
24  * outside of the currently defined projects into Eclipse.
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 ExternalProjectImportWizard();
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, a project is created with the location
39  * specified by the user.
40  * </p>
41  */

42
43 public class ExternalProjectImportWizard extends Wizard implements
44         IImportWizard {
45     private static final String JavaDoc EXTERNAL_PROJECT_SECTION = "ExternalProjectImportWizard";//$NON-NLS-1$
46
private WizardProjectsImportPage mainPage;
47     
48     /**
49      * Constructor for ExternalProjectImportWizard.
50      */

51     public ExternalProjectImportWizard() {
52         super();
53         setNeedsProgressMonitor(true);
54         IDialogSettings workbenchSettings = IDEWorkbenchPlugin.getDefault()
55                 .getDialogSettings();
56         
57         IDialogSettings wizardSettings = workbenchSettings
58                 .getSection(EXTERNAL_PROJECT_SECTION);
59         if (wizardSettings == null) {
60             wizardSettings = workbenchSettings
61                     .addNewSection(EXTERNAL_PROJECT_SECTION);
62         }
63         setDialogSettings(wizardSettings);
64     }
65
66     /* (non-Javadoc)
67      * Method declared on IWizard.
68      */

69     public void addPages() {
70         super.addPages();
71         mainPage = new WizardProjectsImportPage();
72         addPage(mainPage);
73     }
74
75     /* (non-Javadoc)
76      * Method declared on IWorkbenchWizard.
77      */

78     public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
79         setWindowTitle(DataTransferMessages.DataTransfer_importTitle);
80         setDefaultPageImageDescriptor(
81                 IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/importproj_wiz.png")); //$NON-NLS-1$
82

83     }
84
85     /* (non-Javadoc)
86      * Method declared on IWizard.
87      */

88     public boolean performCancel() {
89         mainPage.performCancel();
90         return true;
91     }
92
93     /* (non-Javadoc)
94      * Method declared on IWizard.
95      */

96     public boolean performFinish() {
97         return mainPage.createProjects();
98     }
99
100 }
101
Popular Tags