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 java.util.List;
013:
014: import org.eclipse.core.runtime.Platform;
015: import org.eclipse.jface.dialogs.IDialogSettings;
016: import org.eclipse.jface.viewers.IStructuredSelection;
017: import org.eclipse.jface.viewers.StructuredSelection;
018: import org.eclipse.jface.wizard.Wizard;
019: import org.eclipse.ui.IExportWizard;
020: import org.eclipse.ui.IWorkbench;
021: import org.eclipse.ui.PlatformUI;
022: import org.eclipse.ui.ide.IDE;
023: import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
024: import org.eclipse.ui.internal.wizards.datatransfer.DataTransferMessages;
025: import org.eclipse.ui.internal.wizards.datatransfer.WizardArchiveFileResourceExportPage1;
026: import org.eclipse.ui.plugin.AbstractUIPlugin;
027:
028: /**
029: * Standard workbench wizard for exporting resources from the workspace
030: * to a zip file.
031: * <p>
032: * This class may be instantiated and used without further configuration;
033: * this class is not intended to be subclassed.
034: * </p>
035: * <p>
036: * Example:
037: * <pre>
038: * IWizard wizard = new ZipFileExportWizard();
039: * wizard.init(workbench, selection);
040: * WizardDialog dialog = new WizardDialog(shell, wizard);
041: * dialog.open();
042: * </pre>
043: * During the call to <code>open</code>, the wizard dialog is presented to the
044: * user. When the user hits Finish, the user-selected workspace resources
045: * are exported to the user-specified zip file, the dialog closes, and the call
046: * to <code>open</code> returns.
047: * </p>
048: */
049: public class ZipFileExportWizard extends Wizard implements
050: IExportWizard {
051: private IStructuredSelection selection;
052:
053: private WizardArchiveFileResourceExportPage1 mainPage;
054:
055: /**
056: * Creates a wizard for exporting workspace resources to a zip file.
057: */
058: public ZipFileExportWizard() {
059: AbstractUIPlugin plugin = (AbstractUIPlugin) Platform
060: .getPlugin(PlatformUI.PLUGIN_ID);
061: IDialogSettings workbenchSettings = plugin.getDialogSettings();
062: IDialogSettings section = workbenchSettings
063: .getSection("ZipFileExportWizard");//$NON-NLS-1$
064: if (section == null) {
065: section = workbenchSettings
066: .addNewSection("ZipFileExportWizard");//$NON-NLS-1$
067: }
068: setDialogSettings(section);
069: }
070:
071: /* (non-Javadoc)
072: * Method declared on IWizard.
073: */
074: public void addPages() {
075: super .addPages();
076: mainPage = new WizardArchiveFileResourceExportPage1(selection);
077: addPage(mainPage);
078: }
079:
080: /* (non-Javadoc)
081: * Method declared on IWorkbenchWizard.
082: */
083: public void init(IWorkbench workbench,
084: IStructuredSelection currentSelection) {
085: this .selection = currentSelection;
086: List selectedResources = IDE
087: .computeSelectedResources(currentSelection);
088: if (!selectedResources.isEmpty()) {
089: this .selection = new StructuredSelection(selectedResources);
090: }
091:
092: setWindowTitle(DataTransferMessages.DataTransfer_export);
093: setDefaultPageImageDescriptor(IDEWorkbenchPlugin
094: .getIDEImageDescriptor("wizban/exportzip_wiz.png"));//$NON-NLS-1$
095: setNeedsProgressMonitor(true);
096: }
097:
098: /* (non-Javadoc)
099: * Method declared on IWizard.
100: */
101: public boolean performFinish() {
102: return mainPage.finish();
103: }
104: }
|