KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > extension > ExtensionTreeSelectionPage


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 /**
29  *
30  */

31 public class ExtensionTreeSelectionPage extends WizardTreeSelectionPage {
32     private IProject fProject;
33     private IPluginBase fPluginBase;
34     /**
35      * @param categories
36      * @param baseCategory
37      * @param message
38      */

39     public ExtensionTreeSelectionPage(WizardCollectionElement categories,
40             String JavaDoc baseCategory, String JavaDoc 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"); //$NON-NLS-1$
61
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