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