1 11 package org.eclipse.ui.internal; 12 13 import org.eclipse.ui.IPerspectiveDescriptor; 14 import org.eclipse.ui.IWorkbenchPage; 15 import org.eclipse.ui.IWorkbenchWindow; 16 17 21 public class ClosePerspectiveAction extends PerspectiveAction { 22 23 28 public ClosePerspectiveAction(IWorkbenchWindow window) { 29 super(window); 30 setText(WorkbenchMessages.ClosePerspectiveAction_text); 31 setActionDefinitionId("org.eclipse.ui.window.closePerspective"); setToolTipText(WorkbenchMessages.ClosePerspectiveAction_toolTip); 34 window.getWorkbench().getHelpSystem().setHelp(this, 35 IWorkbenchHelpContextIds.CLOSE_PAGE_ACTION); 36 } 37 38 41 protected void run(IWorkbenchPage page, IPerspectiveDescriptor perspDesc) { 42 Perspective persp = ((WorkbenchPage) page).getActivePerspective(); 43 if (persp != null) { 44 closePerspective((WorkbenchPage) page, persp); 45 } 46 } 47 48 56 public static void closePerspective(WorkbenchPage page, Perspective persp) { 57 if (page != null && persp != null) { 58 page.closePerspective(persp, true, true); 59 } 60 } 61 } 62 | Popular Tags |