001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.wizards.datatransfer;
011:
012: import org.eclipse.jface.dialogs.IDialogSettings;
013: import org.eclipse.jface.viewers.IStructuredSelection;
014: import org.eclipse.jface.wizard.Wizard;
015: import org.eclipse.ui.IImportWizard;
016: import org.eclipse.ui.IWorkbench;
017: import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
018: import org.eclipse.ui.internal.wizards.datatransfer.DataTransferMessages;
019: import org.eclipse.ui.internal.wizards.datatransfer.WizardProjectsImportPage;
020:
021: /**
022: * Standard workbench wizard for importing projects defined
023: * outside of the currently defined projects into Eclipse.
024: * <p>
025: * This class may be instantiated and used without further configuration;
026: * this class is not intended to be subclassed.
027: * </p>
028: * <p>
029: * Example:
030: * <pre>
031: * IWizard wizard = new ExternalProjectImportWizard();
032: * wizard.init(workbench, selection);
033: * WizardDialog dialog = new WizardDialog(shell, wizard);
034: * dialog.open();
035: * </pre>
036: * During the call to <code>open</code>, the wizard dialog is presented to the
037: * user. When the user hits Finish, a project is created with the location
038: * specified by the user.
039: * </p>
040: */
041:
042: public class ExternalProjectImportWizard extends Wizard implements
043: IImportWizard {
044: private static final String EXTERNAL_PROJECT_SECTION = "ExternalProjectImportWizard";//$NON-NLS-1$
045: private WizardProjectsImportPage mainPage;
046:
047: /**
048: * Constructor for ExternalProjectImportWizard.
049: */
050: public ExternalProjectImportWizard() {
051: super ();
052: setNeedsProgressMonitor(true);
053: IDialogSettings workbenchSettings = IDEWorkbenchPlugin
054: .getDefault().getDialogSettings();
055:
056: IDialogSettings wizardSettings = workbenchSettings
057: .getSection(EXTERNAL_PROJECT_SECTION);
058: if (wizardSettings == null) {
059: wizardSettings = workbenchSettings
060: .addNewSection(EXTERNAL_PROJECT_SECTION);
061: }
062: setDialogSettings(wizardSettings);
063: }
064:
065: /* (non-Javadoc)
066: * Method declared on IWizard.
067: */
068: public void addPages() {
069: super .addPages();
070: mainPage = new WizardProjectsImportPage();
071: addPage(mainPage);
072: }
073:
074: /* (non-Javadoc)
075: * Method declared on IWorkbenchWizard.
076: */
077: public void init(IWorkbench workbench,
078: IStructuredSelection currentSelection) {
079: setWindowTitle(DataTransferMessages.DataTransfer_importTitle);
080: setDefaultPageImageDescriptor(IDEWorkbenchPlugin
081: .getIDEImageDescriptor("wizban/importproj_wiz.png")); //$NON-NLS-1$
082:
083: }
084:
085: /* (non-Javadoc)
086: * Method declared on IWizard.
087: */
088: public boolean performCancel() {
089: mainPage.performCancel();
090: return true;
091: }
092:
093: /* (non-Javadoc)
094: * Method declared on IWizard.
095: */
096: public boolean performFinish() {
097: return mainPage.createProjects();
098: }
099:
100: }
|