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.IContainer;
13: import org.eclipse.core.resources.IProject;
14: import org.eclipse.jdt.core.IJavaProject;
15: import org.eclipse.jface.dialogs.IDialogSettings;
16: import org.eclipse.jface.viewers.IStructuredSelection;
17: import org.eclipse.jface.wizard.Wizard;
18: import org.eclipse.pde.core.plugin.IPluginExtensionPoint;
19: import org.eclipse.pde.internal.ui.PDEPlugin;
20: import org.eclipse.pde.internal.ui.PDEPluginImages;
21: import org.eclipse.pde.internal.ui.PDEUIMessages;
22: import org.eclipse.ui.INewWizard;
23: import org.eclipse.ui.IWorkbench;
24:
25: public class NewSchemaFileWizard extends Wizard implements INewWizard {
26: private NewSchemaFileMainPage mainPage;
27: private IContainer container;
28: private IPluginExtensionPoint point;
29: private boolean isPluginIdFinal;
30:
31: public NewSchemaFileWizard() {
32: this (null, null, false);
33: }
34:
35: public NewSchemaFileWizard(IProject project,
36: IPluginExtensionPoint point, boolean isFinalPluginId) {
37: initialize();
38: this .container = project;
39: this .point = point;
40: this .isPluginIdFinal = isFinalPluginId;
41: }
42:
43: public void initialize() {
44: setDialogSettings(getSettingsSection());
45: setDefaultPageImageDescriptor(PDEPluginImages.DESC_EXT_POINT_SCHEMA_WIZ);
46: setWindowTitle(PDEUIMessages.NewSchemaFileWizard_wtitle);
47: setNeedsProgressMonitor(true);
48: }
49:
50: public void addPages() {
51: mainPage = new NewSchemaFileMainPage(container, point,
52: isPluginIdFinal);
53: addPage(mainPage);
54: }
55:
56: private IDialogSettings getSettingsSection() {
57: IDialogSettings root = PDEPlugin.getDefault()
58: .getDialogSettings();
59: IDialogSettings section = root
60: .getSection("newExtensionPointWizard"); //$NON-NLS-1$
61: if (section == null)
62: section = root.addNewSection("newExtensionPointWizard"); //$NON-NLS-1$
63: return section;
64: }
65:
66: public void init(IWorkbench workbench,
67: IStructuredSelection selection) {
68: Object sel = selection.getFirstElement();
69: if (sel instanceof IJavaProject) {
70: container = ((IJavaProject) sel).getProject();
71: } else if (sel instanceof IContainer)
72: container = (IContainer) sel;
73: }
74:
75: public boolean performFinish() {
76: return mainPage.finish();
77: }
78: }
|