1 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 35 public class ExportWizard extends Wizard { 36 private IWorkbench theWorkbench; 37 38 private IStructuredSelection selection; 39 40 class SelectionPage extends WorkbenchWizardListSelectionPage { 42 SelectionPage(IWorkbench w, IStructuredSelection ss, AdaptableList e, 43 String 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 65 public void addPages() { 66 addPage(new SelectionPage(this.theWorkbench, this.selection, 67 getAvailableExportWizards(), WorkbenchMessages.ExportWizard_selectDestination)); 68 } 69 70 73 protected AdaptableList getAvailableExportWizards() { 74 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 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 108 public boolean performFinish() { 109 ((SelectionPage) getPages()[0]).saveWidgetValues(); 110 return true; 111 } 112 } 113 | Popular Tags |