KickJava   Java API By Example, From Geeks To Geeks.

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


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