FIX: added missing org.eclipse.pde.runtime_3.1.1.jar reference
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / ui / actions / OpenPHPPerspectiveAction.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.ui.actions;
12
13 import net.sourceforge.phpdt.internal.ui.actions.ActionMessages;
14 import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
15 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
16
17 import org.eclipse.core.resources.ResourcesPlugin;
18 import org.eclipse.core.runtime.IAdaptable;
19 import org.eclipse.jface.action.Action;
20 import org.eclipse.ui.IWorkbench;
21 import org.eclipse.ui.IWorkbenchPage;
22 import org.eclipse.ui.IWorkbenchWindow;
23 import org.eclipse.ui.WorkbenchException;
24
25 /**
26  * Action to programmatically open a Java perspective.
27  * 
28  * <p>
29  * This class may be instantiated; it is not intended to be subclassed.
30  * </p>
31  * 
32  * @since 2.0
33  */
34 public class OpenPHPPerspectiveAction extends Action {
35
36         /**
37          * Create a new <code>OpenPHPPerspectiveAction</code>.
38          */
39         public OpenPHPPerspectiveAction() {
40 //              WorkbenchHelp.setHelp(this, IJavaHelpContextIds.OPEN_JAVA_PERSPECTIVE_ACTION);
41         }
42
43         public void run() {
44                 IWorkbench workbench= PHPeclipsePlugin.getDefault().getWorkbench();
45                 IWorkbenchWindow window= workbench.getActiveWorkbenchWindow();
46                 IWorkbenchPage page= window.getActivePage();
47                 IAdaptable input;
48                 if (page != null)
49                         input= page.getInput();
50                 else
51                         input= ResourcesPlugin.getWorkspace().getRoot();
52                 try {
53                         workbench.showPerspective(PHPeclipsePlugin.ID_PERSPECTIVE, window, input);
54                 } catch (WorkbenchException e) {
55                         ExceptionHandler.handle(e, window.getShell(), 
56                                 ActionMessages.getString("OpenPHPPerspectiveAction.dialog.title"), //$NON-NLS-1$
57                                 ActionMessages.getString("OpenPHPPerspectiveAction.error.open_failed")); //$NON-NLS-1$
58                 }
59         }
60 }