KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > dialogs > ImportExportWizard


1 /*******************************************************************************
2  * Copyright (c) 2005, 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.internal.dialogs;
12
13 import org.eclipse.jface.resource.ImageDescriptor;
14 import org.eclipse.jface.viewers.IStructuredSelection;
15 import org.eclipse.jface.wizard.Wizard;
16 import org.eclipse.ui.IWorkbench;
17 import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
18 import org.eclipse.ui.internal.WorkbenchImages;
19 import org.eclipse.ui.internal.WorkbenchMessages;
20
21 /**
22  * The import/export wizard allows users to choose whether to
23  * show the import wizard or the export wizard.
24  *
25  * @since 3.2
26  *
27  */

28 public class ImportExportWizard extends Wizard {
29     /**
30      * Constant used to to specify to the import/export wizard
31      * which page should initially be shown.
32      */

33     public static final String JavaDoc IMPORT = "import"; //$NON-NLS-1$
34
/**
35      * Constant used to to specify to the import/export wizard
36      * which page should initially be shown.
37      */

38     public static final String JavaDoc EXPORT = "export"; //$NON-NLS-1$
39

40     private IWorkbench workbench;
41     private IStructuredSelection selection;
42     private ImportExportPage importExportPage;
43     private String JavaDoc page = null;
44     
45     /**
46      * Create an import/export wizard and show the page
47      * with the given id.
48      *
49      * @param pageId
50      */

51     public ImportExportWizard(String JavaDoc pageId){
52         page = pageId;
53     }
54     
55     /**
56      * Subclasses must implement this <code>IWizard</code> method
57      * to perform any special finish processing for their wizard.
58      */

59     public boolean performFinish() {
60         importExportPage.saveWidgetValues();
61         return true;
62     }
63
64     /**
65      * Creates the wizard's pages lazily.
66      */

67     public void addPages() {
68         if (page.equals(IMPORT)) {
69             importExportPage = new ImportPage(this.workbench, this.selection);
70         } else if (page.equals(EXPORT)) {
71             importExportPage = new ExportPage(this.workbench, this.selection);
72         }
73         if (importExportPage != null) {
74             addPage(importExportPage);
75         }
76     }
77
78     /**
79      * Initializes the wizard.
80      *
81      * @param aWorkbench the workbench
82      * @param currentSelection the current selectio
83      */

84     public void init(IWorkbench aWorkbench,
85             IStructuredSelection currentSelection) {
86         this.workbench = aWorkbench;
87         this.selection = currentSelection;
88
89         ImageDescriptor wizardBannerImage = null;
90         if (IMPORT.equals(page)){
91             wizardBannerImage = WorkbenchImages
92                 .getImageDescriptor(IWorkbenchGraphicConstants.IMG_WIZBAN_IMPORT_WIZ);
93             setWindowTitle(WorkbenchMessages.ImportWizard_title);
94         }
95         else if (EXPORT.equals(page)){
96             wizardBannerImage = WorkbenchImages
97                     .getImageDescriptor(IWorkbenchGraphicConstants.IMG_WIZBAN_EXPORT_WIZ);
98             setWindowTitle(WorkbenchMessages.ExportWizard_title);
99         }
100         if (wizardBannerImage != null) {
101             setDefaultPageImageDescriptor(wizardBannerImage);
102         }
103         setNeedsProgressMonitor(true);
104     }
105 }
106
Popular Tags