KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > plugin > NewFragmentProjectWizard


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.plugin;
12
13 import java.lang.reflect.InvocationTargetException JavaDoc;
14
15 import org.eclipse.core.resources.IProject;
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.IConfigurationElement;
18 import org.eclipse.core.runtime.IExecutableExtension;
19 import org.eclipse.core.runtime.IPath;
20 import org.eclipse.jface.wizard.IWizardPage;
21 import org.eclipse.pde.internal.ui.PDEPlugin;
22 import org.eclipse.pde.internal.ui.PDEPluginImages;
23 import org.eclipse.pde.internal.ui.PDEUIMessages;
24 import org.eclipse.pde.internal.ui.wizards.IProjectProvider;
25 import org.eclipse.pde.internal.ui.wizards.NewWizard;
26 import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
27
28 public class NewFragmentProjectWizard extends NewWizard implements IExecutableExtension {
29
30     private NewProjectCreationPage fMainPage;
31     private ContentPage fContentPage;
32     private FragmentFieldData fFragmentData;
33     private IProjectProvider fProjectProvider;
34     private IConfigurationElement fConfig;
35     
36     public NewFragmentProjectWizard() {
37         setDefaultPageImageDescriptor(PDEPluginImages.DESC_NEWFRAGPRJ_WIZ);
38         setWindowTitle(PDEUIMessages.NewFragmentProjectWizard_title);
39         setNeedsProgressMonitor(true);
40         PDEPlugin.getDefault().getLabelProvider().connect(this);
41         fFragmentData = new FragmentFieldData();
42     }
43     
44     /* (non-Javadoc)
45      * @see org.eclipse.jface.wizard.Wizard#addPages()
46      */

47     public void addPages() {
48         fMainPage = new NewProjectCreationPage("main", fFragmentData, true); //$NON-NLS-1$
49
fMainPage.setTitle(PDEUIMessages.NewProjectWizard_MainPage_ftitle);
50         fMainPage.setDescription(PDEUIMessages.NewProjectWizard_MainPage_fdesc);
51         addPage(fMainPage);
52         
53         fProjectProvider = new IProjectProvider() {
54             public String JavaDoc getProjectName() {
55                 return fMainPage.getProjectName();
56             }
57             public IProject getProject() {
58                 return fMainPage.getProjectHandle();
59             }
60             public IPath getLocationPath() {
61                 return fMainPage.getLocationPath();
62             }
63         };
64         fContentPage = new FragmentContentPage("page2", fProjectProvider, fMainPage, fFragmentData); //$NON-NLS-1$
65
addPage(fContentPage);
66     }
67     
68     /* (non-Javadoc)
69      * @see org.eclipse.jface.wizard.Wizard#canFinish()
70      */

71     public boolean canFinish() {
72         IWizardPage page = getContainer().getCurrentPage();
73         return (page.isPageComplete() && page!=fMainPage);
74     }
75     /*
76      * (non-Javadoc)
77      *
78      * @see org.eclipse.pde.internal.ui.wizards.NewWizard#performFinish()
79      */

80     public boolean performFinish() {
81         try {
82             fMainPage.updateData();
83             fContentPage.updateData();
84             BasicNewProjectResourceWizard.updatePerspective(fConfig);
85             getContainer().run(false, true,
86                     new NewProjectCreationOperation(fFragmentData, fProjectProvider, null));
87             return true;
88         } catch (InvocationTargetException JavaDoc e) {
89             PDEPlugin.logException(e);
90         } catch (InterruptedException JavaDoc e) {
91         }
92         return false;
93     }
94     
95     /* (non-Javadoc)
96      * @see org.eclipse.jface.wizard.Wizard#dispose()
97      */

98     public void dispose() {
99         super.dispose();
100         PDEPlugin.getDefault().getLabelProvider().disconnect(this);
101     }
102
103     /* (non-Javadoc)
104      * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
105      */

106     public void setInitializationData(IConfigurationElement config, String JavaDoc propertyName, Object JavaDoc data) throws CoreException {
107         fConfig = config;
108     }
109     
110     public String JavaDoc getFragmentId() {
111         return fFragmentData.getId();
112     }
113 }
114
Popular Tags