1 11 package org.eclipse.ui.internal.cheatsheets.actions; 12 13 import org.eclipse.core.runtime.*; 14 import org.eclipse.jface.action.Action; 15 import org.eclipse.ui.*; 16 import org.eclipse.ui.cheatsheets.*; 17 import org.eclipse.ui.internal.cheatsheets.*; 18 19 28 public class OpenPerspective extends Action implements ICheatSheetAction { 29 30 33 public OpenPerspective() { 34 } 35 36 37 40 public void run(String [] params, ICheatSheetManager manager) { 41 try { 42 if(params == null || params[0] == null) { 43 return; 44 } 45 46 IWorkbench workbench = PlatformUI.getWorkbench(); 47 IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); 48 IWorkbenchPage page = window.getActivePage(); 49 50 IPerspectiveDescriptor perspective = workbench.getPerspectiveRegistry().findPerspectiveWithId(params[0]); 51 page.setPerspective(perspective); 52 } catch(Exception e) { 53 IStatus status = new Status(IStatus.ERROR, ICheatSheetResource.CHEAT_SHEET_PLUGIN_ID, IStatus.OK, Messages.ERROR_OPENING_PERSPECTIVE, null); 54 CheatSheetPlugin.getPlugin().getLog().log(status); 55 } 56 } 57 } 58 | Popular Tags |