01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.wizards.extension;
11:
12: import org.eclipse.core.resources.IProject;
13: import org.eclipse.core.runtime.CoreException;
14: import org.eclipse.core.runtime.IConfigurationElement;
15: import org.eclipse.jface.viewers.ISelectionProvider;
16: import org.eclipse.jface.wizard.IWizardNode;
17: import org.eclipse.pde.core.plugin.IPluginBase;
18: import org.eclipse.pde.internal.ui.wizards.WizardCollectionElement;
19: import org.eclipse.pde.internal.ui.wizards.WizardElement;
20: import org.eclipse.pde.internal.ui.wizards.WizardNode;
21: import org.eclipse.pde.internal.ui.wizards.WizardTreeSelectionPage;
22: import org.eclipse.pde.internal.ui.wizards.templates.NewExtensionTemplateWizard;
23: import org.eclipse.pde.ui.IBasePluginWizard;
24: import org.eclipse.pde.ui.IExtensionWizard;
25: import org.eclipse.pde.ui.templates.ITemplateSection;
26:
27: /**
28: *
29: */
30: public class ExtensionTreeSelectionPage extends WizardTreeSelectionPage {
31: private IProject fProject;
32: private IPluginBase fPluginBase;
33:
34: /**
35: * @param categories
36: * @param baseCategory
37: * @param message
38: */
39: public ExtensionTreeSelectionPage(
40: WizardCollectionElement categories, String baseCategory,
41: String message) {
42: super (categories, baseCategory, message);
43: }
44:
45: public void init(IProject project, IPluginBase pluginBase) {
46: this .fProject = project;
47: this .fPluginBase = pluginBase;
48: }
49:
50: protected IWizardNode createWizardNode(WizardElement element) {
51: return new WizardNode(this , element) {
52: public IBasePluginWizard createWizard()
53: throws CoreException {
54: IExtensionWizard wizard = createWizard(wizardElement);
55: wizard.init(fProject, fPluginBase.getPluginModel());
56: return wizard;
57: }
58:
59: protected IExtensionWizard createWizard(
60: WizardElement element) throws CoreException {
61: if (element.isTemplate()) {
62: IConfigurationElement template = element
63: .getTemplateElement();
64: if (template == null)
65: return null;
66: ITemplateSection section = (ITemplateSection) template
67: .createExecutableExtension("class"); //$NON-NLS-1$
68: return new NewExtensionTemplateWizard(section);
69: }
70: return (IExtensionWizard) element
71: .createExecutableExtension();
72: }
73: };
74: }
75:
76: public ISelectionProvider getSelectionProvider() {
77: return wizardSelectionViewer;
78: }
79: }
|