blob: c0f8140c582216edaac0b999001e116eec704bab [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2000, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.internal.dialogs;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardNode;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWizard;
import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
import org.eclipse.ui.internal.WorkbenchImages;
import org.eclipse.ui.internal.WorkbenchMessages;
import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.internal.activities.ws.WorkbenchTriggerPoints;
import org.eclipse.ui.internal.registry.WizardsRegistryReader;
import org.eclipse.ui.model.AdaptableList;
import org.eclipse.ui.wizards.IWizardCategory;
/**
* The export wizard allows the user to choose which nested export wizard to run.
* The set of available wizards comes from the export wizard extension point.
*/
public class ExportWizard extends Wizard {
private IWorkbench theWorkbench;
private IStructuredSelection selection;
//the list selection page
class SelectionPage extends WorkbenchWizardListSelectionPage {
SelectionPage(IWorkbench w, IStructuredSelection ss, AdaptableList e,
String s) {
super(w, ss, e, s, WorkbenchTriggerPoints.EXPORT_WIZARDS);
}
public void createControl(Composite parent) {
super.createControl(parent);
workbench.getHelpSystem().setHelp(getControl(),
IWorkbenchHelpContextIds.EXPORT_WIZARD_SELECTION_WIZARD_PAGE);
}
protected IWizardNode createWizardNode(WorkbenchWizardElement element) {
return new WorkbenchWizardNode(this, element) {
public IWorkbenchWizard createWizard() throws CoreException {
return wizardElement.createWizard();
}
};
}
}
/**
* Creates the wizard's pages lazily.
*/
public void addPages() {
addPage(new SelectionPage(this.theWorkbench, this.selection,
getAvailableExportWizards(), WorkbenchMessages.ExportWizard_selectDestination));
}
/**
* Returns the export wizards that are available for invocation.
*/
protected AdaptableList getAvailableExportWizards() {
// TODO: exports are still flat - we need to get at the flat list. All
// wizards will be in the "other" category.
IWizardCategory root = WorkbenchPlugin.getDefault()
.getExportWizardRegistry().getRootCategory();
WizardCollectionElement otherCategory = (WizardCollectionElement) root
.findCategory(new Path(
WizardsRegistryReader.UNCATEGORIZED_WIZARD_CATEGORY));
if (otherCategory == null) {
return new AdaptableList();
}
return otherCategory.getWizardAdaptableList();
}
/**
* Initializes the wizard.
*
* @param aWorkbench the workbench
* @param currentSelection the current selectio
*/
public void init(IWorkbench aWorkbench,
IStructuredSelection currentSelection) {
this.theWorkbench = aWorkbench;
this.selection = currentSelection;
setWindowTitle(WorkbenchMessages.ExportWizard_title);
setDefaultPageImageDescriptor(WorkbenchImages
.getImageDescriptor(IWorkbenchGraphicConstants.IMG_WIZBAN_EXPORT_WIZ));
setNeedsProgressMonitor(true);
}
/**
* Subclasses must implement this <code>IWizard</code> method
* to perform any special finish processing for their wizard.
*/
public boolean performFinish() {
((SelectionPage) getPages()[0]).saveWidgetValues();
return true;
}
}