KickJava   Java API By Example, From Geeks To Geeks.

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


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.IExportWizard;
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.WizardArchiveFileResourceExportPage1;
27 import org.eclipse.ui.plugin.AbstractUIPlugin;
28
29 /**
30  * Standard workbench wizard for exporting resources from the workspace
31  * to a zip file.
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 ZipFileExportWizard();
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 workspace resources
46  * are exported to the user-specified zip file, the dialog closes, and the call
47  * to <code>open</code> returns.
48  * </p>
49  */

50 public class ZipFileExportWizard extends Wizard implements IExportWizard {
51     private IStructuredSelection selection;
52
53     private WizardArchiveFileResourceExportPage1 mainPage;
54
55     /**
56      * Creates a wizard for exporting workspace resources to a zip file.
57      */

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

73     public void addPages() {
74         super.addPages();
75         mainPage = new WizardArchiveFileResourceExportPage1(selection);
76         addPage(mainPage);
77     }
78
79     /* (non-Javadoc)
80      * Method declared on IWorkbenchWizard.
81      */

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

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