Open PHP perspective automatically then a new PHP Project is created
authoraxelcl <axelcl>
Fri, 25 Feb 2005 21:26:20 +0000 (21:26 +0000)
committeraxelcl <axelcl>
Fri, 25 Feb 2005 21:26:20 +0000 (21:26 +0000)
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/JavaUI.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/OpenPHPPerspectiveAction.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/wizards/NewProjectCreationWizard.java

index 5c3b4e8..6236042 100644 (file)
@@ -54,7 +54,7 @@ public final class JavaUI {
         * The id of the Java perspective
         * (value <code>"org.eclipse.jdt.ui.JavaPerspective"</code>).
         */     
-//     public static final String ID_PERSPECTIVE=              "org.eclipse.jdt.ui.JavaPerspective"; //$NON-NLS-1$
+ //    public static final String ID_PERSPECTIVE=              "org.eclipse.jdt.ui.JavaPerspective"; //$NON-NLS-1$
        
        /**
         * The id of the Java hierarchy perspective
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/OpenPHPPerspectiveAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/OpenPHPPerspectiveAction.java
new file mode 100644 (file)
index 0000000..3da1363
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.ui.actions;
+
+import net.sourceforge.phpdt.internal.ui.actions.ActionMessages;
+import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
+import net.sourceforge.phpdt.ui.JavaUI;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.WorkbenchException;
+
+/**
+ * Action to programmatically open a Java perspective.
+ * 
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ * 
+ * @since 2.0
+ */
+public class OpenPHPPerspectiveAction extends Action {
+
+       /**
+        * Create a new <code>OpenPHPPerspectiveAction</code>.
+        */
+       public OpenPHPPerspectiveAction() {
+//             WorkbenchHelp.setHelp(this, IJavaHelpContextIds.OPEN_JAVA_PERSPECTIVE_ACTION);
+       }
+
+       public void run() {
+               IWorkbench workbench= PHPeclipsePlugin.getDefault().getWorkbench();
+               IWorkbenchWindow window= workbench.getActiveWorkbenchWindow();
+               IWorkbenchPage page= window.getActivePage();
+               IAdaptable input;
+               if (page != null)
+                       input= page.getInput();
+               else
+                       input= ResourcesPlugin.getWorkspace().getRoot();
+               try {
+                       workbench.showPerspective(PHPeclipsePlugin.ID_PERSPECTIVE, window, input);
+               } catch (WorkbenchException e) {
+                       ExceptionHandler.handle(e, window.getShell(), 
+                               ActionMessages.getString("OpenPHPPerspectiveAction.dialog.title"), //$NON-NLS-1$
+                               ActionMessages.getString("OpenPHPPerspectiveAction.error.open_failed")); //$NON-NLS-1$
+               }
+       }
+}
index 5edecbb..6663814 100644 (file)
@@ -125,7 +125,8 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
    * The id of the PHP plugin (value <code>"net.sourceforge.phpeclipse"</code>).
    */
   public static final String PLUGIN_ID = "net.sourceforge.phpeclipse"; //$NON-NLS-1$
-
+  public static final String ID_PERSPECTIVE = "net.sourceforge.phpeclipse.PHPPerspective"; //$NON-NLS-1$
+       
   IWorkspace w;
 
   /**
index cbeca0a..c895758 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;
@@ -43,7 +44,8 @@ public class NewProjectCreationWizard extends BasicNewResourceWizard implements
 
                BasicNewProjectResourceWizard.updatePerspective(configurationElement);
                selectAndReveal(newProject);
-
+        // open the PHP perspective
+               new OpenPHPPerspectiveAction().run();
                return true;
        }