1 11 package org.eclipse.ui.internal.registry; 12 13 import java.util.HashMap ; 14 import java.util.Map ; 15 16 import org.eclipse.core.commands.IParameterValues; 17 import org.eclipse.ui.PlatformUI; 18 import org.eclipse.ui.wizards.IWizardCategory; 19 import org.eclipse.ui.wizards.IWizardDescriptor; 20 import org.eclipse.ui.wizards.IWizardRegistry; 21 22 31 public abstract class WizardParameterValues implements IParameterValues { 32 33 36 public static final class Export extends WizardParameterValues { 37 protected IWizardRegistry getWizardRegistry() { 38 return PlatformUI.getWorkbench().getExportWizardRegistry(); 39 } 40 } 41 42 45 public static final class Import extends WizardParameterValues { 46 protected IWizardRegistry getWizardRegistry() { 47 return PlatformUI.getWorkbench().getImportWizardRegistry(); 48 } 49 } 50 51 54 public static final class New extends WizardParameterValues { 55 protected IWizardRegistry getWizardRegistry() { 56 return PlatformUI.getWorkbench().getNewWizardRegistry(); 57 } 58 } 59 60 private void addParameterValues(Map values, IWizardCategory wizardCategory) { 61 62 final IWizardDescriptor[] wizardDescriptors = wizardCategory 63 .getWizards(); 64 for (int i = 0; i < wizardDescriptors.length; i++) { 65 final IWizardDescriptor wizardDescriptor = wizardDescriptors[i]; 66 67 71 String name = wizardDescriptor.getLabel(); 73 final String id = wizardDescriptor.getId(); 74 final String value = (String ) values.get(name); 75 if (value!=null && !value.equals(id)) { 76 name = name + " (" + id + ")"; } 78 values.put(name, id); 79 } 80 81 final IWizardCategory[] childCategories = wizardCategory 82 .getCategories(); 83 for (int i = 0; i < childCategories.length; i++) { 84 final IWizardCategory childCategory = childCategories[i]; 85 addParameterValues(values, childCategory); 86 } 87 } 88 89 public Map getParameterValues() { 90 final Map values = new HashMap (); 91 92 final IWizardRegistry wizardRegistry = getWizardRegistry(); 93 addParameterValues(values, wizardRegistry.getRootCategory()); 94 95 return values; 96 } 97 98 105 protected abstract IWizardRegistry getWizardRegistry(); 106 107 } 108 | Popular Tags |