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.internal.dialogs;
011:
012: import org.eclipse.core.runtime.CoreException;
013: import org.eclipse.core.runtime.Path;
014: import org.eclipse.jface.viewers.IStructuredSelection;
015: import org.eclipse.jface.wizard.IWizardNode;
016: import org.eclipse.jface.wizard.Wizard;
017: import org.eclipse.swt.widgets.Composite;
018: import org.eclipse.ui.IWorkbench;
019: import org.eclipse.ui.IWorkbenchWizard;
020: import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
021: import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
022: import org.eclipse.ui.internal.WorkbenchImages;
023: import org.eclipse.ui.internal.WorkbenchMessages;
024: import org.eclipse.ui.internal.WorkbenchPlugin;
025: import org.eclipse.ui.internal.activities.ws.WorkbenchTriggerPoints;
026: import org.eclipse.ui.internal.registry.WizardsRegistryReader;
027: import org.eclipse.ui.model.AdaptableList;
028: import org.eclipse.ui.wizards.IWizardCategory;
029:
030: /**
031: * The export wizard allows the user to choose which nested export wizard to run.
032: * The set of available wizards comes from the export wizard extension point.
033: */
034: public class ExportWizard extends Wizard {
035: private IWorkbench theWorkbench;
036:
037: private IStructuredSelection selection;
038:
039: //the list selection page
040: class SelectionPage extends WorkbenchWizardListSelectionPage {
041: SelectionPage(IWorkbench w, IStructuredSelection ss,
042: AdaptableList e, String s) {
043: super (w, ss, e, s, WorkbenchTriggerPoints.EXPORT_WIZARDS);
044: }
045:
046: public void createControl(Composite parent) {
047: super .createControl(parent);
048: workbench
049: .getHelpSystem()
050: .setHelp(
051: getControl(),
052: IWorkbenchHelpContextIds.EXPORT_WIZARD_SELECTION_WIZARD_PAGE);
053: }
054:
055: protected IWizardNode createWizardNode(
056: WorkbenchWizardElement element) {
057: return new WorkbenchWizardNode(this , element) {
058: public IWorkbenchWizard createWizard()
059: throws CoreException {
060: return wizardElement.createWizard();
061: }
062: };
063: }
064: }
065:
066: /**
067: * Creates the wizard's pages lazily.
068: */
069: public void addPages() {
070: addPage(new SelectionPage(this .theWorkbench, this .selection,
071: getAvailableExportWizards(),
072: WorkbenchMessages.ExportWizard_selectDestination));
073: }
074:
075: /**
076: * Returns the export wizards that are available for invocation.
077: */
078: protected AdaptableList getAvailableExportWizards() {
079: // TODO: exports are still flat - we need to get at the flat list. All
080: // wizards will be in the "other" category.
081: IWizardCategory root = WorkbenchPlugin.getDefault()
082: .getExportWizardRegistry().getRootCategory();
083: WizardCollectionElement otherCategory = (WizardCollectionElement) root
084: .findCategory(new Path(
085: WizardsRegistryReader.UNCATEGORIZED_WIZARD_CATEGORY));
086: if (otherCategory == null) {
087: return new AdaptableList();
088: }
089: return otherCategory.getWizardAdaptableList();
090: }
091:
092: /**
093: * Initializes the wizard.
094: *
095: * @param aWorkbench the workbench
096: * @param currentSelection the current selectio
097: */
098: public void init(IWorkbench aWorkbench,
099: IStructuredSelection currentSelection) {
100: this .theWorkbench = aWorkbench;
101: this .selection = currentSelection;
102:
103: setWindowTitle(WorkbenchMessages.ExportWizard_title);
104: setDefaultPageImageDescriptor(WorkbenchImages
105: .getImageDescriptor(IWorkbenchGraphicConstants.IMG_WIZBAN_EXPORT_WIZ));
106: setNeedsProgressMonitor(true);
107: }
108:
109: /**
110: * Subclasses must implement this <code>IWizard</code> method
111: * to perform any special finish processing for their wizard.
112: */
113: public boolean performFinish() {
114: ((SelectionPage) getPages()[0]).saveWidgetValues();
115: return true;
116: }
117: }
|