KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.List JavaDoc;
14
15 import org.eclipse.core.runtime.Platform;
16 import org.eclipse.jface.dialogs.IDialogSettings;
17 import org.eclipse.jface.viewers.IStructuredSelection;
18 import org.eclipse.jface.viewers.StructuredSelection;
19 import org.eclipse.jface.wizard.Wizard;
20 import org.eclipse.ui.IImportWizard;
21 import org.eclipse.ui.IWorkbench;
22 import org.eclipse.ui.PlatformUI;
23 import org.eclipse.ui.ide.IDE;
24 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
25 import org.eclipse.ui.internal.wizards.datatransfer.DataTransferMessages;
26 import org.eclipse.ui.internal.wizards.datatransfer.WizardFileSystemResourceImportPage1;
27 import org.eclipse.ui.plugin.AbstractUIPlugin;
28
29 /**
30  * Standard workbench wizard for importing resources from the local file system
31  * into the workspace.
32  * <p>
33  * This class may be instantiated and used without further configuration;
34  * this class is not intended to be subclassed.
35  * </p>
36  * <p>
37  * Example:
38  * <pre>
39  * IWizard wizard = new FileSystemImportWizard();
40  * wizard.init(workbench, selection);
41  * WizardDialog dialog = new WizardDialog(shell, wizard);
42  * dialog.open();
43  * </pre>
44  * During the call to <code>open</code>, the wizard dialog is presented to the
45  * user. When the user hits Finish, the user-selected files are imported
46  * into the workspace, the dialog closes, and the call to <code>open</code>
47  * returns.
48  * </p>
49  */

50 public class FileSystemImportWizard extends Wizard implements IImportWizard {
51     private IWorkbench workbench;
52
53     private IStructuredSelection selection;
54
55     private WizardFileSystemResourceImportPage1 mainPage;
56
57     /**
58      * Creates a wizard for importing resources into the workspace from
59      * the file system.
60      */

61     public FileSystemImportWizard() {
62         AbstractUIPlugin plugin = (AbstractUIPlugin) Platform
63                 .getPlugin(PlatformUI.PLUGIN_ID);
64         IDialogSettings workbenchSettings = plugin.getDialogSettings();
65         IDialogSettings section = workbenchSettings
66                 .getSection("FileSystemImportWizard");//$NON-NLS-1$
67
if (section == null) {
68             section = workbenchSettings.addNewSection("FileSystemImportWizard");//$NON-NLS-1$
69
}
70         setDialogSettings(section);
71     }
72
73     /* (non-Javadoc)
74      * Method declared on IWizard.
75      */

76     public void addPages() {
77         super.addPages();
78         mainPage = new WizardFileSystemResourceImportPage1(workbench, selection);
79         addPage(mainPage);
80     }
81
82
83     /* (non-Javadoc)
84      * Method declared on IWorkbenchWizard.
85      */

86     public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
87         this.workbench = workbench;
88         this.selection = currentSelection;
89
90         List JavaDoc selectedResources = IDE.computeSelectedResources(currentSelection);
91         if (!selectedResources.isEmpty()) {
92             this.selection = new StructuredSelection(selectedResources);
93         }
94
95         setWindowTitle(DataTransferMessages.DataTransfer_importTitle);
96         setDefaultPageImageDescriptor(IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/importdir_wiz.png"));//$NON-NLS-1$
97
setNeedsProgressMonitor(true);
98     }
99
100     /* (non-Javadoc)
101      * Method declared on IWizard.
102      */

103     public boolean performFinish() {
104         return mainPage.finish();
105     }
106 }
107
Popular Tags