KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > action > SubCoolBarManager


1 /*******************************************************************************
2  * Copyright (c) 2003, 2006 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.jface.action;
12
13 import org.eclipse.core.runtime.Assert;
14
15 /**
16  * A <code>SubCoolBarManager</code> monitors the additional and removal of
17  * items from a parent manager so that visibility of the entire set can be changed as a
18  * unit.
19  *
20  * @since 3.0
21  */

22 public class SubCoolBarManager extends SubContributionManager implements
23         ICoolBarManager {
24
25     /**
26      * Constructs a new manager.
27      *
28      * @param mgr the parent manager. All contributions made to the
29      * <code>SubCoolBarManager</code> are forwarded and appear in the
30      * parent manager.
31      */

32     public SubCoolBarManager(ICoolBarManager mgr) {
33         super(mgr);
34         Assert.isNotNull(mgr);
35     }
36
37     /* (non-Javadoc)
38      * @see org.eclipse.jface.action.ICoolBarManager#add(org.eclipse.jface.action.IToolBarManager)
39      */

40     public void add(IToolBarManager toolBarManager) {
41         Assert.isNotNull(toolBarManager);
42         super.add(new ToolBarContributionItem(toolBarManager));
43     }
44
45     /* (non-Javadoc)
46      * @see org.eclipse.jface.action.ICoolBarManager#getStyle()
47      */

48     public int getStyle() {
49         // It is okay to cast down since we only accept coolBarManager objects in the
50
// constructor
51
return ((ICoolBarManager) getParent()).getStyle();
52     }
53
54     /**
55      * Returns the parent cool bar manager that this sub-manager contributes to.
56      *
57      * @return the parent cool bar manager
58      */

59     protected final ICoolBarManager getParentCoolBarManager() {
60         // Cast is ok because that's the only
61
// thing we accept in the construtor.
62
return (ICoolBarManager) getParent();
63     }
64
65     /* (non-Javadoc)
66      * @see org.eclipse.jface.action.ICoolBarManager#isLayoutLocked()
67      */

68     public boolean getLockLayout() {
69         return getParentCoolBarManager().getLockLayout();
70     }
71
72     /* (non-Javadoc)
73      * @see org.eclipse.jface.action.ICoolBarManager#lockLayout(boolean)
74      */

75     public void setLockLayout(boolean value) {
76     }
77
78     /* (non-Javadoc)
79      * SubCoolBarManagers do not have control of the global context menu.
80      */

81     public IMenuManager getContextMenuManager() {
82         return null;
83     }
84
85     /* (non-Javadoc)
86      * In SubCoolBarManager we do nothing.
87      */

88     public void setContextMenuManager(IMenuManager menuManager) {
89         // do nothing
90
}
91
92     /* (non-Javadoc)
93      * @see org.eclipse.jface.action.IContributionManager#update(boolean)
94      */

95     public void update(boolean force) {
96         // This method is not governed by visibility. The client may
97
// call <code>setVisible</code> and then force an update. At that
98
// point we need to update the parent.
99
getParentCoolBarManager().update(force);
100     }
101
102 }
103
Popular Tags