KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > MinimizePartAction


1 /*******************************************************************************
2  * Copyright (c) 2004, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 /**
19  * @since 3.0
20  */

21 public class MinimizePartAction extends PageEventAction {
22
23     /**
24      * Creates a MaximizePartAction.
25      *
26      * @param window the window
27      */

28     public MinimizePartAction(IWorkbenchWindow window) {
29         super(WorkbenchMessages.MinimizePartAction_text, window);
30         setToolTipText(WorkbenchMessages.MinimizePartAction_toolTip);
31         // @issue missing action id
32
updateState();
33         window.getWorkbench().getHelpSystem().setHelp(this,
34                 IWorkbenchHelpContextIds.MINIMIZE_PART_ACTION);
35         setActionDefinitionId("org.eclipse.ui.window.minimizePart"); //$NON-NLS-1$
36
}
37
38     /* (non-Javadoc)
39      * Method declared on PageEventAction.
40      */

41     public void pageActivated(IWorkbenchPage page) {
42         super.pageActivated(page);
43         updateState();
44     }
45
46     /* (non-Javadoc)
47      * Method declared on PageEventAction.
48      */

49     public void pageClosed(IWorkbenchPage page) {
50         super.pageClosed(page);
51         updateState();
52     }
53
54     /* (non-Javadoc)
55      * Method declared on IAction.
56      */

57     public void run() {
58         if (getWorkbenchWindow() == null) {
59             // action has been dispose
60
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     /**
76      * Updates the enabled state.
77      */

78     private void updateState() {
79         setEnabled(getActivePage() != null);
80     }
81 }
82
Popular Tags