1) Fixed issue #215: Escaping Strings
[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.phpdt.ui.JavaUI;
16 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
17
18 import org.eclipse.core.resources.ResourcesPlugin;
19 import org.eclipse.core.runtime.IAdaptable;
20 import org.eclipse.jface.action.Action;
21 import org.eclipse.ui.IWorkbench;
22 import org.eclipse.ui.IWorkbenchPage;
23 import org.eclipse.ui.IWorkbenchWindow;
24 import org.eclipse.ui.WorkbenchException;
25
26 /**
27  * Action to programmatically open a Java perspective.
28  * 
29  * <p>
30  * This class may be instantiated; it is not intended to be subclassed.
31  * </p>
32  * 
33  * @since 2.0
34  */
35 public class OpenPHPPerspectiveAction extends Action {
36
37         /**
38          * Create a new <code>OpenPHPPerspectiveAction</code>.
39          */
40         public OpenPHPPerspectiveAction() {
41                 // WorkbenchHelp.setHelp(this,
42                 // IJavaHelpContextIds.OPEN_JAVA_PERSPECTIVE_ACTION);
43         }
44
45         public void run() {
46                 IWorkbench workbench = PHPeclipsePlugin.getDefault().getWorkbench();
47                 IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
48                 IWorkbenchPage page = window.getActivePage();
49                 IAdaptable input;
50                 if (page != null)
51                         input = page.getInput();
52                 else
53                         input = ResourcesPlugin.getWorkspace().getRoot();
54                 try {
55                         workbench.showPerspective(JavaUI.ID_PERSPECTIVE, window,
56                                         input);
57                 } catch (WorkbenchException e) {
58                         ExceptionHandler
59                                         .handle(
60                                                         e,
61                                                         window.getShell(),
62                                                         ActionMessages
63                                                                         .getString("OpenPHPPerspectiveAction.dialog.title"), //$NON-NLS-1$
64                                                         ActionMessages
65                                                                         .getString("OpenPHPPerspectiveAction.error.open_failed")); //$NON-NLS-1$
66                 }
67         }
68 }