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 36 public class ImportWizard extends Wizard { 37 38 class SelectionPage extends WorkbenchWizardListSelectionPage { 40 SelectionPage(IWorkbench w, IStructuredSelection ss, AdaptableList e, 41 String s) { 42 super(w, ss, e, s, WorkbenchTriggerPoints.IMPORT_WIZARDS); 43 } 44 45 public void createControl(Composite parent) { 46 super.createControl(parent); 47 getWorkbench() 48 .getHelpSystem() 49 .setHelp( 50 getControl(), 51 IWorkbenchHelpContextIds.IMPORT_WIZARD_SELECTION_WIZARD_PAGE); 52 } 53 54 public IWizardNode createWizardNode(WorkbenchWizardElement element) { 55 return new WorkbenchWizardNode(this, element) { 56 public IWorkbenchWizard createWizard() throws CoreException { 57 return wizardElement.createWizard(); 58 } 59 }; 60 } 61 62 63 } 64 65 private IStructuredSelection selection; 66 67 private IWorkbench workbench; 68 69 72 public void addPages() { 73 addPage(new SelectionPage(this.workbench, this.selection, 74 getAvailableImportWizards(), WorkbenchMessages.ImportWizard_selectSource)); 75 } 76 77 80 protected AdaptableList getAvailableImportWizards() { 81 IWizardCategory root = WorkbenchPlugin.getDefault() 84 .getImportWizardRegistry().getRootCategory(); 85 WizardCollectionElement otherCategory = (WizardCollectionElement) root 86 .findCategory(new Path( 87 WizardsRegistryReader.UNCATEGORIZED_WIZARD_CATEGORY)); 88 if (otherCategory == null) { 89 return new AdaptableList(); 90 } 91 return otherCategory.getWizardAdaptableList(); 92 } 93 94 100 public void init(IWorkbench aWorkbench, 101 IStructuredSelection currentSelection) { 102 this.workbench = aWorkbench; 103 this.selection = currentSelection; 104 105 setWindowTitle(WorkbenchMessages.ImportWizard_title); 106 setDefaultPageImageDescriptor(WorkbenchImages 107 .getImageDescriptor(IWorkbenchGraphicConstants.IMG_WIZBAN_IMPORT_WIZ)); 108 setNeedsProgressMonitor(true); 109 } 110 111 114 public boolean performFinish() { 115 ((SelectionPage) getPages()[0]).saveWidgetValues(); 116 return true; 117 } 118 } 119 | Popular Tags |