01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui;
11:
12: import org.eclipse.core.resources.ResourcesPlugin;
13: import org.eclipse.core.runtime.IAdaptable;
14: import org.eclipse.jface.action.Action;
15: import org.eclipse.ui.IWorkbenchPage;
16: import org.eclipse.ui.IWorkbenchWindow;
17: import org.eclipse.ui.PlatformUI;
18: import org.eclipse.ui.WorkbenchException;
19:
20: public class OpenPDEPerspectiveAction extends Action {
21: public OpenPDEPerspectiveAction() {
22: }
23:
24: public void run() {
25: IWorkbenchWindow window = PDEPlugin.getActiveWorkbenchWindow();
26: IWorkbenchPage page = window.getActivePage();
27: IAdaptable input;
28: if (page != null)
29: input = page.getInput();
30: else
31: input = ResourcesPlugin.getWorkspace().getRoot();
32: try {
33: PlatformUI.getWorkbench().showPerspective(
34: "org.eclipse.pde.ui.PDEPerspective", //$NON-NLS-1$
35: window, input);
36: notifyResult(true);
37:
38: } catch (WorkbenchException e) {
39: PDEPlugin.logException(e);
40: notifyResult(false);
41: }
42: }
43: }
|