001: /*******************************************************************************
002: * Copyright (c) 2005, 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.internal.dialogs;
011:
012: import org.eclipse.jface.resource.ImageDescriptor;
013: import org.eclipse.jface.viewers.IStructuredSelection;
014: import org.eclipse.jface.wizard.Wizard;
015: import org.eclipse.ui.IWorkbench;
016: import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
017: import org.eclipse.ui.internal.WorkbenchImages;
018: import org.eclipse.ui.internal.WorkbenchMessages;
019:
020: /**
021: * The import/export wizard allows users to choose whether to
022: * show the import wizard or the export wizard.
023: *
024: * @since 3.2
025: *
026: */
027: public class ImportExportWizard extends Wizard {
028: /**
029: * Constant used to to specify to the import/export wizard
030: * which page should initially be shown.
031: */
032: public static final String IMPORT = "import"; //$NON-NLS-1$
033: /**
034: * Constant used to to specify to the import/export wizard
035: * which page should initially be shown.
036: */
037: public static final String EXPORT = "export"; //$NON-NLS-1$
038:
039: private IWorkbench workbench;
040: private IStructuredSelection selection;
041: private ImportExportPage importExportPage;
042: private String page = null;
043:
044: /**
045: * Create an import/export wizard and show the page
046: * with the given id.
047: *
048: * @param pageId
049: */
050: public ImportExportWizard(String pageId) {
051: page = pageId;
052: }
053:
054: /**
055: * Subclasses must implement this <code>IWizard</code> method
056: * to perform any special finish processing for their wizard.
057: */
058: public boolean performFinish() {
059: importExportPage.saveWidgetValues();
060: return true;
061: }
062:
063: /**
064: * Creates the wizard's pages lazily.
065: */
066: public void addPages() {
067: if (page.equals(IMPORT)) {
068: importExportPage = new ImportPage(this .workbench,
069: this .selection);
070: } else if (page.equals(EXPORT)) {
071: importExportPage = new ExportPage(this .workbench,
072: this .selection);
073: }
074: if (importExportPage != null) {
075: addPage(importExportPage);
076: }
077: }
078:
079: /**
080: * Initializes the wizard.
081: *
082: * @param aWorkbench the workbench
083: * @param currentSelection the current selectio
084: */
085: public void init(IWorkbench aWorkbench,
086: IStructuredSelection currentSelection) {
087: this .workbench = aWorkbench;
088: this .selection = currentSelection;
089:
090: ImageDescriptor wizardBannerImage = null;
091: if (IMPORT.equals(page)) {
092: wizardBannerImage = WorkbenchImages
093: .getImageDescriptor(IWorkbenchGraphicConstants.IMG_WIZBAN_IMPORT_WIZ);
094: setWindowTitle(WorkbenchMessages.ImportWizard_title);
095: } else if (EXPORT.equals(page)) {
096: wizardBannerImage = WorkbenchImages
097: .getImageDescriptor(IWorkbenchGraphicConstants.IMG_WIZBAN_EXPORT_WIZ);
098: setWindowTitle(WorkbenchMessages.ExportWizard_title);
099: }
100: if (wizardBannerImage != null) {
101: setDefaultPageImageDescriptor(wizardBannerImage);
102: }
103: setNeedsProgressMonitor(true);
104: }
105: }
|