From: axelcl Date: Fri, 25 Feb 2005 21:26:20 +0000 (+0000) Subject: Open PHP perspective automatically then a new PHP Project is created X-Git-Url: http://git.phpeclipse.com Open PHP perspective automatically then a new PHP Project is created --- diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/JavaUI.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/JavaUI.java index 5c3b4e8..6236042 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/JavaUI.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/JavaUI.java @@ -54,7 +54,7 @@ public final class JavaUI { * The id of the Java perspective * (value "org.eclipse.jdt.ui.JavaPerspective"). */ -// 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 index 0000000..3da1363 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/OpenPHPPerspectiveAction.java @@ -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. + * + *

+ * This class may be instantiated; it is not intended to be subclassed. + *

+ * + * @since 2.0 + */ +public class OpenPHPPerspectiveAction extends Action { + + /** + * Create a new OpenPHPPerspectiveAction. + */ + 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$ + } + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java index 5edecbb..6663814 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java @@ -125,7 +125,8 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon * The id of the PHP plugin (value "net.sourceforge.phpeclipse"). */ 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; /** diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/wizards/NewProjectCreationWizard.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/wizards/NewProjectCreationWizard.java index cbeca0a..c895758 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/wizards/NewProjectCreationWizard.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/wizards/NewProjectCreationWizard.java @@ -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; }