1 11 package org.eclipse.pde.internal.ui.wizards.extension; 12 13 import org.eclipse.core.resources.IProject; 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.core.runtime.IConfigurationElement; 16 import org.eclipse.jface.viewers.ISelectionProvider; 17 import org.eclipse.jface.wizard.IWizardNode; 18 import org.eclipse.pde.core.plugin.IPluginBase; 19 import org.eclipse.pde.internal.ui.wizards.WizardCollectionElement; 20 import org.eclipse.pde.internal.ui.wizards.WizardElement; 21 import org.eclipse.pde.internal.ui.wizards.WizardNode; 22 import org.eclipse.pde.internal.ui.wizards.WizardTreeSelectionPage; 23 import org.eclipse.pde.internal.ui.wizards.templates.NewExtensionTemplateWizard; 24 import org.eclipse.pde.ui.IBasePluginWizard; 25 import org.eclipse.pde.ui.IExtensionWizard; 26 import org.eclipse.pde.ui.templates.ITemplateSection; 27 28 31 public class ExtensionTreeSelectionPage extends WizardTreeSelectionPage { 32 private IProject fProject; 33 private IPluginBase fPluginBase; 34 39 public ExtensionTreeSelectionPage(WizardCollectionElement categories, 40 String baseCategory, String message) { 41 super(categories, baseCategory, message); 42 } 43 public void init(IProject project, IPluginBase pluginBase) { 44 this.fProject = project; 45 this.fPluginBase = pluginBase; 46 } 47 protected IWizardNode createWizardNode(WizardElement element) { 48 return new WizardNode(this, element) { 49 public IBasePluginWizard createWizard() throws CoreException { 50 IExtensionWizard wizard = createWizard(wizardElement); 51 wizard.init(fProject, fPluginBase.getPluginModel()); 52 return wizard; 53 } 54 protected IExtensionWizard createWizard(WizardElement element) 55 throws CoreException { 56 if (element.isTemplate()) { 57 IConfigurationElement template = element.getTemplateElement(); 58 if (template==null) return null; 59 ITemplateSection section = 60 (ITemplateSection) template.createExecutableExtension("class"); return new NewExtensionTemplateWizard(section); 62 } 63 return (IExtensionWizard) element.createExecutableExtension(); 64 } 65 }; 66 } 67 public ISelectionProvider getSelectionProvider() { 68 return wizardSelectionViewer; 69 } 70 } 71 | Popular Tags |