1 11 package org.eclipse.ui.internal; 12 13 import org.eclipse.ui.IWorkbenchPage; 14 import org.eclipse.ui.IWorkbenchPartReference; 15 import org.eclipse.ui.IWorkbenchWindow; 16 import org.eclipse.ui.presentations.IStackPresentationSite; 17 18 21 public class MinimizePartAction extends PageEventAction { 22 23 28 public MinimizePartAction(IWorkbenchWindow window) { 29 super(WorkbenchMessages.MinimizePartAction_text, window); 30 setToolTipText(WorkbenchMessages.MinimizePartAction_toolTip); 31 updateState(); 33 window.getWorkbench().getHelpSystem().setHelp(this, 34 IWorkbenchHelpContextIds.MINIMIZE_PART_ACTION); 35 setActionDefinitionId("org.eclipse.ui.window.minimizePart"); } 37 38 41 public void pageActivated(IWorkbenchPage page) { 42 super.pageActivated(page); 43 updateState(); 44 } 45 46 49 public void pageClosed(IWorkbenchPage page) { 50 super.pageClosed(page); 51 updateState(); 52 } 53 54 57 public void run() { 58 if (getWorkbenchWindow() == null) { 59 return; 61 } 62 63 IWorkbenchPage page = getActivePage(); 64 if (page != null) { 65 if (page instanceof WorkbenchPage) { 66 IWorkbenchPartReference partRef = page.getActivePartReference(); 67 68 if (partRef != null) { 69 ((WorkbenchPage) page).setState(partRef, IStackPresentationSite.STATE_MINIMIZED); 70 } 71 } 72 } 73 } 74 75 78 private void updateState() { 79 setEnabled(getActivePage() != null); 80 } 81 } 82 | Popular Tags |