1 11 package org.eclipse.jdt.ui.actions; 12 13 import org.eclipse.jface.action.Action; 14 15 import org.eclipse.core.resources.ResourcesPlugin; 16 import org.eclipse.core.runtime.IAdaptable; 17 18 import org.eclipse.ui.IWorkbench; 19 import org.eclipse.ui.IWorkbenchPage; 20 import org.eclipse.ui.IWorkbenchWindow; 21 import org.eclipse.ui.WorkbenchException; 22 import org.eclipse.ui.PlatformUI; 23 24 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; 25 import org.eclipse.jdt.internal.ui.JavaPlugin; 26 import org.eclipse.jdt.internal.ui.actions.ActionMessages; 27 import org.eclipse.jdt.internal.ui.util.ExceptionHandler; 28 29 import org.eclipse.jdt.ui.JavaUI; 30 31 40 public class OpenJavaBrowsingPerspectiveAction extends Action { 41 42 45 public OpenJavaBrowsingPerspectiveAction() { 46 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.OPEN_JAVA_BROWSING_PERSPECTIVE_ACTION); 47 } 48 49 public void run() { 50 IWorkbench workbench= JavaPlugin.getDefault().getWorkbench(); 51 IWorkbenchWindow window= workbench.getActiveWorkbenchWindow(); 52 IWorkbenchPage page= window.getActivePage(); 53 IAdaptable input; 54 if (page != null) 55 input= page.getInput(); 56 else 57 input= ResourcesPlugin.getWorkspace().getRoot(); 58 try { 59 workbench.showPerspective(JavaUI.ID_BROWSING_PERSPECTIVE, window, input); 60 } catch (WorkbenchException e) { 61 ExceptionHandler.handle(e, window.getShell(), 62 ActionMessages.OpenJavaBrowsingPerspectiveAction_dialog_title, 63 ActionMessages.OpenJavaBrowsingPerspectiveAction_error_open_failed); 64 } 65 } 66 } 67 | Popular Tags |