KickJava   Java API By Example, From Geeks To Geeks.

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


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.internal.dialogs;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.Path;
15 import org.eclipse.jface.viewers.IStructuredSelection;
16 import org.eclipse.jface.wizard.IWizardNode;
17 import org.eclipse.jface.wizard.Wizard;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.ui.IWorkbench;
20 import org.eclipse.ui.IWorkbenchWizard;
21 import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
22 import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
23 import org.eclipse.ui.internal.WorkbenchImages;
24 import org.eclipse.ui.internal.WorkbenchMessages;
25 import org.eclipse.ui.internal.WorkbenchPlugin;
26 import org.eclipse.ui.internal.activities.ws.WorkbenchTriggerPoints;
27 import org.eclipse.ui.internal.registry.WizardsRegistryReader;
28 import org.eclipse.ui.model.AdaptableList;
29 import org.eclipse.ui.wizards.IWizardCategory;
30
31 /**
32  * The export wizard allows the user to choose which nested export wizard to run.
33  * The set of available wizards comes from the export wizard extension point.
34  */

35 public class ExportWizard extends Wizard {
36     private IWorkbench theWorkbench;
37
38     private IStructuredSelection selection;
39
40     //the list selection page
41
class SelectionPage extends WorkbenchWizardListSelectionPage {
42         SelectionPage(IWorkbench w, IStructuredSelection ss, AdaptableList e,
43                 String JavaDoc s) {
44             super(w, ss, e, s, WorkbenchTriggerPoints.EXPORT_WIZARDS);
45         }
46
47         public void createControl(Composite parent) {
48             super.createControl(parent);
49             workbench.getHelpSystem().setHelp(getControl(),
50                     IWorkbenchHelpContextIds.EXPORT_WIZARD_SELECTION_WIZARD_PAGE);
51         }
52
53         protected IWizardNode createWizardNode(WorkbenchWizardElement element) {
54             return new WorkbenchWizardNode(this, element) {
55                 public IWorkbenchWizard createWizard() throws CoreException {
56                     return wizardElement.createWizard();
57                 }
58             };
59         }
60     }
61
62     /**
63      * Creates the wizard's pages lazily.
64      */

65     public void addPages() {
66         addPage(new SelectionPage(this.theWorkbench, this.selection,
67                 getAvailableExportWizards(), WorkbenchMessages.ExportWizard_selectDestination));
68     }
69
70     /**
71      * Returns the export wizards that are available for invocation.
72      */

73     protected AdaptableList getAvailableExportWizards() {
74         // TODO: exports are still flat - we need to get at the flat list. All
75
// wizards will be in the "other" category.
76
IWizardCategory root = WorkbenchPlugin.getDefault()
77                 .getExportWizardRegistry().getRootCategory();
78         WizardCollectionElement otherCategory = (WizardCollectionElement) root
79                 .findCategory(new Path(
80                         WizardsRegistryReader.UNCATEGORIZED_WIZARD_CATEGORY));
81         if (otherCategory == null) {
82             return new AdaptableList();
83         }
84         return otherCategory.getWizardAdaptableList();
85     }
86
87     /**
88      * Initializes the wizard.
89      *
90      * @param aWorkbench the workbench
91      * @param currentSelection the current selectio
92      */

93     public void init(IWorkbench aWorkbench,
94             IStructuredSelection currentSelection) {
95         this.theWorkbench = aWorkbench;
96         this.selection = currentSelection;
97
98         setWindowTitle(WorkbenchMessages.ExportWizard_title);
99         setDefaultPageImageDescriptor(WorkbenchImages
100                 .getImageDescriptor(IWorkbenchGraphicConstants.IMG_WIZBAN_EXPORT_WIZ));
101         setNeedsProgressMonitor(true);
102     }
103
104     /**
105      * Subclasses must implement this <code>IWizard</code> method
106      * to perform any special finish processing for their wizard.
107      */

108     public boolean performFinish() {
109         ((SelectionPage) getPages()[0]).saveWidgetValues();
110         return true;
111     }
112 }
113
Popular Tags