Fix - Unless clicking an element except the first one, it is impossible to enable...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / wizards / NewProjectCreationWizard.java
index cbeca0a..176d442 100644 (file)
@@ -3,6 +3,7 @@ package net.sourceforge.phpeclipse.wizards;
 import java.lang.reflect.InvocationTargetException;
 
 import net.sourceforge.phpdt.core.JavaCore;
+import net.sourceforge.phpdt.ui.actions.OpenPHPPerspectiveAction;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 
 import org.eclipse.core.resources.IProject;
@@ -22,41 +23,53 @@ import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
 import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
 import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
 
-public class NewProjectCreationWizard extends BasicNewResourceWizard implements INewWizard, IExecutableExtension {
+public class NewProjectCreationWizard extends BasicNewResourceWizard implements
+               INewWizard, IExecutableExtension {
        protected WizardNewProjectCreationPage projectPage;
+
        protected IConfigurationElement configurationElement;
+
        protected IProject newProject;
-       
+
        public NewProjectCreationWizard() {
-               setWindowTitle(PHPWizardMessages.getString("NewProjectCreationWizard.windowTitle"));
+               setWindowTitle(PHPWizardMessages
+                               .getString("NewProjectCreationWizard.windowTitle"));
        }
 
        public boolean performFinish() {
-               IRunnableWithProgress projectCreationOperation = new WorkspaceModifyDelegatingOperation(getProjectCreationRunnable());
+               IRunnableWithProgress projectCreationOperation = new WorkspaceModifyDelegatingOperation(
+                               getProjectCreationRunnable());
 
                try {
                        getContainer().run(false, true, projectCreationOperation);
-               } catch (Exception e) { 
+               } catch (Exception e) {
                        PHPeclipsePlugin.log(e);
                        return false;
                }
 
                BasicNewProjectResourceWizard.updatePerspective(configurationElement);
                selectAndReveal(newProject);
-
+               // open the PHP perspective
+               new OpenPHPPerspectiveAction().run();
                return true;
        }
 
        protected IRunnableWithProgress getProjectCreationRunnable() {
                return new IRunnableWithProgress() {
-                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                       public void run(IProgressMonitor monitor)
+                                       throws InvocationTargetException, InterruptedException {
                                int remainingWorkUnits = 10;
-                               monitor.beginTask(PHPWizardMessages.getString("NewProjectCreationWizard.projectCreationMessage"), remainingWorkUnits);
+                               monitor
+                                               .beginTask(
+                                                               PHPWizardMessages
+                                                                               .getString("NewProjectCreationWizard.projectCreationMessage"),
+                                                               remainingWorkUnits);
 
                                IWorkspace workspace = PHPeclipsePlugin.getWorkspace();
                                newProject = projectPage.getProjectHandle();
-                               
-                               IProjectDescription description = workspace.newProjectDescription(newProject.getName());
+
+                               IProjectDescription description = workspace
+                                               .newProjectDescription(newProject.getName());
                                IPath path = Platform.getLocation();
                                IPath customPath = projectPage.getLocationPath();
                                if (!path.equals(customPath)) {
@@ -66,14 +79,21 @@ public class NewProjectCreationWizard extends BasicNewResourceWizard implements
 
                                try {
                                        if (!newProject.exists()) {
-                                               newProject.create(description, new SubProgressMonitor(monitor, 1));
+                                               newProject.create(description, new SubProgressMonitor(
+                                                               monitor, 1));
                                                remainingWorkUnits--;
                                        }
                                        if (!newProject.isOpen()) {
                                                newProject.open(new SubProgressMonitor(monitor, 1));
                                                remainingWorkUnits--;
                                        }
-                                       JavaCore.addPHPNature(newProject, new SubProgressMonitor(monitor, remainingWorkUnits));
+                                       JavaCore.addPHPNature(newProject, new SubProgressMonitor(
+                                                       monitor, remainingWorkUnits));
+
+                                       // patch #1692034 - set the coding of this PHPeclipse
+                                       // project to UTF-8 by default for all operating systems:
+                                       newProject.setDefaultCharset("UTF-8", monitor);
+
                                } catch (CoreException e) {
                                        throw new InvocationTargetException(e);
                                } finally {
@@ -86,14 +106,18 @@ public class NewProjectCreationWizard extends BasicNewResourceWizard implements
        public void addPages() {
                super.addPages();
 
-               projectPage = new WizardNewProjectCreationPage(PHPWizardMessages.getString("WizardNewProjectCreationPage.pageName"));
-               projectPage.setTitle(PHPWizardMessages.getString("WizardNewProjectCreationPage.pageTitle"));
-               projectPage.setDescription(PHPWizardMessages.getString("WizardNewProjectCreationPage.pageDescription"));
+               projectPage = new WizardNewProjectCreationPage(PHPWizardMessages
+                               .getString("WizardNewProjectCreationPage.pageName"));
+               projectPage.setTitle(PHPWizardMessages
+                               .getString("WizardNewProjectCreationPage.pageTitle"));
+               projectPage.setDescription(PHPWizardMessages
+                               .getString("WizardNewProjectCreationPage.pageDescription"));
 
                addPage(projectPage);
        }
 
-       public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+       public void setInitializationData(IConfigurationElement config,
+                       String propertyName, Object data) throws CoreException {
                configurationElement = config;
        }