KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > OpenPDEPerspectiveAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui;
12
13 import org.eclipse.core.resources.ResourcesPlugin;
14 import org.eclipse.core.runtime.IAdaptable;
15 import org.eclipse.jface.action.Action;
16 import org.eclipse.ui.IWorkbenchPage;
17 import org.eclipse.ui.IWorkbenchWindow;
18 import org.eclipse.ui.PlatformUI;
19 import org.eclipse.ui.WorkbenchException;
20
21 public class OpenPDEPerspectiveAction extends Action {
22     public OpenPDEPerspectiveAction() {
23     }
24
25     public void run() {
26         IWorkbenchWindow window = PDEPlugin.getActiveWorkbenchWindow();
27         IWorkbenchPage page = window.getActivePage();
28         IAdaptable input;
29         if (page != null)
30             input = page.getInput();
31         else
32             input = ResourcesPlugin.getWorkspace().getRoot();
33         try {
34             PlatformUI.getWorkbench().showPerspective(
35                 "org.eclipse.pde.ui.PDEPerspective", //$NON-NLS-1$
36
window,
37                 input);
38             notifyResult(true);
39             
40         } catch (WorkbenchException e) {
41             PDEPlugin.logException(e);
42             notifyResult(false);
43         }
44     }
45 }
46
Popular Tags