01: /*******************************************************************************
02: * Copyright (c) 2004, 2005 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.ui.internal;
11:
12: import org.eclipse.ui.IWorkbenchPage;
13: import org.eclipse.ui.IWorkbenchPartReference;
14: import org.eclipse.ui.IWorkbenchWindow;
15: import org.eclipse.ui.presentations.IStackPresentationSite;
16:
17: /**
18: * @since 3.0
19: */
20: public class MinimizePartAction extends PageEventAction {
21:
22: /**
23: * Creates a MaximizePartAction.
24: *
25: * @param window the window
26: */
27: public MinimizePartAction(IWorkbenchWindow window) {
28: super (WorkbenchMessages.MinimizePartAction_text, window);
29: setToolTipText(WorkbenchMessages.MinimizePartAction_toolTip);
30: // @issue missing action id
31: updateState();
32: window.getWorkbench().getHelpSystem().setHelp(this ,
33: IWorkbenchHelpContextIds.MINIMIZE_PART_ACTION);
34: setActionDefinitionId("org.eclipse.ui.window.minimizePart"); //$NON-NLS-1$
35: }
36:
37: /* (non-Javadoc)
38: * Method declared on PageEventAction.
39: */
40: public void pageActivated(IWorkbenchPage page) {
41: super .pageActivated(page);
42: updateState();
43: }
44:
45: /* (non-Javadoc)
46: * Method declared on PageEventAction.
47: */
48: public void pageClosed(IWorkbenchPage page) {
49: super .pageClosed(page);
50: updateState();
51: }
52:
53: /* (non-Javadoc)
54: * Method declared on IAction.
55: */
56: public void run() {
57: if (getWorkbenchWindow() == null) {
58: // action has been dispose
59: return;
60: }
61:
62: IWorkbenchPage page = getActivePage();
63: if (page != null) {
64: if (page instanceof WorkbenchPage) {
65: IWorkbenchPartReference partRef = page
66: .getActivePartReference();
67:
68: if (partRef != null) {
69: ((WorkbenchPage) page).setState(partRef,
70: IStackPresentationSite.STATE_MINIMIZED);
71: }
72: }
73: }
74: }
75:
76: /**
77: * Updates the enabled state.
78: */
79: private void updateState() {
80: setEnabled(getActivePage() != null);
81: }
82: }
|