Documentation update from hudson build on Thu 28 Aug 2008 09:25:08 PM CDT
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / wizards / TempnewPHPProject.java
1 package net.sourceforge.phpeclipse.wizards;
2
3 import java.lang.reflect.InvocationTargetException;
4
5 import net.sourceforge.phpdt.core.JavaCore;
6 import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
7
8 import org.eclipse.core.resources.IProject;
9 import org.eclipse.core.resources.IProjectDescription;
10 import org.eclipse.core.runtime.CoreException;
11 import org.eclipse.core.runtime.IConfigurationElement;
12 import org.eclipse.core.runtime.IPath;
13 import org.eclipse.core.runtime.IProgressMonitor;
14 import org.eclipse.core.runtime.NullProgressMonitor;
15 import org.eclipse.core.runtime.Platform;
16 import org.eclipse.swt.widgets.Shell;
17 import org.eclipse.ui.INewWizard;
18 import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
19 import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
20 import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
21
22 public class TempnewPHPProject extends BasicNewResourceWizard implements
23                 INewWizard {
24         /*
25          * This class has been added to cvs to provide a project page that works
26          * correctly and doesn't freezde while i investigate the errors completely
27          */
28         private WizardNewProjectCreationPage phpProjPage;
29
30         private IConfigurationElement fConfigElement;
31
32         public TempnewPHPProject() {
33                 setNeedsProgressMonitor(true);
34                 setWindowTitle("New Project creation"); //$NON-NLS-1$
35
36         }
37
38         public void addPages() {
39                 super.addPages();
40                 phpProjPage = new WizardNewProjectCreationPage(
41                                 "NewProjectCreationWizard"); //$NON-NLS-1$
42                 phpProjPage.setTitle(PHPWizardMessages
43                                 .getString("WizardNewProjectCreationPage.pageTitle")); //$NON-NLS-1$
44                 phpProjPage.setDescription(PHPWizardMessages
45                                 .getString("WizardNewProjectCreationPage.pageDescription")); //$NON-NLS-1$
46                 addPage(phpProjPage);
47         }
48
49         public void setInitializationData(IConfigurationElement cfig,
50                         String propertyName, Object data) {
51                 fConfigElement = cfig;
52         }
53
54         protected void initializeDefaultPageImageDescriptor() {
55                 // not used yet
56         }
57
58         protected void finishPage() throws InterruptedException, CoreException {
59                 createProject(phpProjPage.getProjectHandle(), phpProjPage
60                                 .getLocationPath(), new NullProgressMonitor());
61                 BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
62                 selectAndReveal(phpProjPage.getProjectHandle());
63         }
64
65         protected void handleFinishException(Shell shell,
66                         InvocationTargetException e) {
67                 ExceptionHandler.handle(e, getShell(), "Error title", "Error message");
68         }
69
70         public boolean performFinish() {
71                 try {
72                         finishPage();
73                 } catch (InterruptedException e) {
74                 } catch (CoreException e) {
75                 }
76                 return true;
77         }
78
79         public void createProject(IProject project, IPath locationPath,
80                         IProgressMonitor monitor) throws CoreException {
81                 try {
82                         if (!project.exists()) {
83                                 IProjectDescription desc = project.getWorkspace()
84                                                 .newProjectDescription(project.getName());
85                                 if (Platform.getLocation().equals(locationPath)) {
86                                         locationPath = null;
87                                 }
88                                 desc.setLocation(locationPath);
89                                 project.create(desc, monitor);
90                                 monitor = null;
91                         }
92                         if (!project.isOpen()) {
93                                 project.open(monitor);
94                                 monitor = null;
95                         }
96                         JavaCore.addPHPNature(project, new NullProgressMonitor());
97                 } finally {
98                         if (monitor != null) {
99                                 monitor.done();
100                         }
101                 }
102         }
103 }