| /******************************************************************************* |
| * Copyright (c) 2000, 2003 IBM Corporation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Common Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/cpl-v10.html |
| * |
| * Contributors: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.ui.wizards.datatransfer; |
| |
| import java.net.MalformedURLException; |
| import java.net.URL; |
| |
| import org.eclipse.core.runtime.Platform; |
| import org.eclipse.jface.resource.ImageDescriptor; |
| import org.eclipse.jface.viewers.IStructuredSelection; |
| import org.eclipse.jface.wizard.Wizard; |
| import org.eclipse.ui.IImportWizard; |
| import org.eclipse.ui.IWorkbench; |
| import org.eclipse.ui.PlatformUI; |
| import org.eclipse.ui.plugin.AbstractUIPlugin; |
| |
| import org.eclipse.ui.internal.wizards.datatransfer.DataTransferMessages; |
| import org.eclipse.ui.internal.wizards.datatransfer.WizardProjectsImportPage; |
| |
| /** |
| * Standard workbench wizard for importing projects defined |
| * outside of the currently defined projects into Eclipse. |
| * <p> |
| * This class may be instantiated and used without further configuration; |
| * this class is not intended to be subclassed. |
| * </p> |
| * <p> |
| * Example: |
| * <pre> |
| * IWizard wizard = new ExternalProjectImportWizard(); |
| * wizard.init(workbench, selection); |
| * WizardDialog dialog = new WizardDialog(shell, wizard); |
| * dialog.open(); |
| * </pre> |
| * During the call to <code>open</code>, the wizard dialog is presented to the |
| * user. When the user hits Finish, a project is created with the location |
| * specified by the user. |
| * </p> |
| */ |
| |
| public class ExternalProjectImportWizard extends Wizard implements |
| IImportWizard { |
| private WizardProjectsImportPage mainPage; |
| |
| /** |
| * Constructor for ExternalProjectImportWizard. |
| */ |
| public ExternalProjectImportWizard() { |
| super(); |
| setNeedsProgressMonitor(true); |
| } |
| |
| /* (non-Javadoc) |
| * Method declared on IWizard. |
| */ |
| public void addPages() { |
| super.addPages(); |
| mainPage = new WizardProjectsImportPage(); |
| addPage(mainPage); |
| } |
| |
| /** |
| * Returns the image descriptor with the given relative path. |
| */ |
| private ImageDescriptor getImageDescriptor(String relativePath) { |
| String iconPath = "icons/full/"; //$NON-NLS-1$ |
| try { |
| AbstractUIPlugin plugin = (AbstractUIPlugin) Platform |
| .getPlugin(PlatformUI.PLUGIN_ID); |
| URL installURL = plugin.getDescriptor().getInstallURL(); |
| URL url = new URL(installURL, iconPath + relativePath); |
| return ImageDescriptor.createFromURL(url); |
| } catch (MalformedURLException e) { |
| // Should not happen |
| return null; |
| } |
| } |
| |
| /* (non-Javadoc) |
| * Method declared on IWorkbenchWizard. |
| */ |
| public void init(IWorkbench workbench, IStructuredSelection currentSelection) { |
| setWindowTitle(DataTransferMessages |
| .getString("DataTransfer.importTitle")); //$NON-NLS-1$ |
| setDefaultPageImageDescriptor(getImageDescriptor("wizban/importdir_wiz.gif")); //$NON-NLS-1$ |
| |
| } |
| |
| /* (non-Javadoc) |
| * Method declared on IWizard. |
| */ |
| public boolean performCancel() { |
| return true; |
| } |
| |
| /* (non-Javadoc) |
| * Method declared on IWizard. |
| */ |
| public boolean performFinish() { |
| return mainPage.createProjects(); |
| } |
| |
| } |