001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.uml.ui.products.ad.application;
043:
044: import java.awt.Point;
045: import org.netbeans.modules.uml.ui.products.ad.application.action.IContributionManager;
046: import javax.swing.JSeparator;
047: import javax.swing.JToolBar;
048: import javax.swing.JMenuBar;
049: import javax.swing.JMenu;
050: import org.netbeans.modules.uml.ui.swing.testbed.addin.menu.Separator;
051:
052: public interface IMenuManager extends IContributionManager {
053:
054: /**
055: * Adds a menu listener to this menu.
056: * Has no effect if an identical listener is already registered.
057: *
058: * @param listener a menu listener
059: */
060: //public void addMenuListener(IMenuListener listener);
061: /**
062: * Finds the contribution item with the given id.
063: *
064: * @param id the contribution item id
065: * @return the contribution item, or <code>null</code> if
066: * no item with the given id can be found
067: */
068: public Object find(String id);
069:
070: /**
071: * Returns all contribution items known to this manager.
072: *
073: * @return a list of contribution items
074: */
075: public Object[] getItems();
076:
077: /**
078: * Finds the manager for the menu at the given path. A path
079: * consists of contribution item ids separated by the separator
080: * character. The path separator character is <code>'/'</code>.
081: * <p>
082: * Convenience for <code>findUsingPath(path)</code> which
083: * extracts an <code>IMenuManager</code> if possible.
084: * </p>
085: *
086: * @param path the path string
087: * @return the menu contribution item, or <code>null</code>
088: * if there is no such contribution item or if the item does
089: * not have an associated menu manager
090: */
091: public IMenuManager findMenuUsingPath(String path);
092:
093: /**
094: * Finds the contribution item at the given path. A path
095: * consists of contribution item ids separated by the separator
096: * character. The path separator character is <code>'/'</code>.
097: *
098: * @param path the path string
099: * @return the contribution item, or <code>null</code> if there is no
100: * such contribution item
101: */
102: // public IContributionItem findUsingPath(String path);
103: public Object findUsingPath(String path);
104:
105: /**
106: * Returns whether all items should be removed when the menu is first shown,
107: * but before notifying menu listeners. The default is <code>false</code>.
108: *
109: * @return <code>true</code> if all items should be removed when shown, <code>false</code> if not
110: */
111: public boolean getRemoveAllWhenShown();
112:
113: /**
114: * Returns whether this menu should be enabled or not.
115: *
116: * @return <code>true</code> if enabled, and
117: * <code>false</code> if disabled
118: */
119: public boolean isEnabled();
120:
121: /**
122: * Removes the given menu listener from this menu.
123: * Has no effect if an identical listener is not registered.
124: *
125: * @param listener the menu listener
126: */
127: //public void removeMenuListener(IMenuListener listener);
128: /**
129: * Sets whether all items should be removed when the menu is first shown,
130: * but before notifying menu listeners.
131: *
132: * @param removeAll <code>true</code> if all items should be removed when shown, <code>false</code> if not
133: */
134: public void setRemoveAllWhenShown(boolean removeAll);
135:
136: /**
137: * Incrementally builds the menu from the contribution items, and
138: * does so recursively for all submenus.
139: *
140: * @param force <code>true</code> means update even if not dirty,
141: * and <code>false</code> for normal incremental updating
142: */
143: public void updateAll(boolean force);
144:
145: /**
146: * @param label
147: * @param id
148: * @return
149: */
150: public IMenuManager createSubMenu(String label, String id);
151:
152: public IMenuManager createOrGetSubMenu(String label, String id);
153:
154: public void setLocation(Point p);
155:
156: public Point getLocation();
157:
158: public void setContextObject(Object obj);
159:
160: public Object getContextObject();
161:
162: /**
163: * Removes and returns the contribution item with the given id from this manager.
164: * Returns <code>null</code> if this manager has no contribution items
165: * with the given id.
166: *
167: * @param id the contribution item id
168: * @return the item that was found and removed, or <code>null</code> if none
169: */
170: public Object remove(String id);
171:
172: /**
173: * Removes the given contribution item from the contribution items
174: * known to this manager.
175: *
176: * @param item the contribution item
177: * @return the <code>item</code> parameter if the item was removed,
178: * and <code>null</code> if it was not found
179: */
180: public Object remove(Object item);
181:
182: // public void add(JSeparator item);
183:
184: // public void add(java.lang.Object obj);
185:
186: public void add(Separator item, String key);
187:
188: public void add(IMenuManager item);
189:
190: // public boolean isDynamic();
191:
192: public boolean isVisible();
193:
194: public void setVisible(boolean visible);
195:
196: public void setParent(IMenuManager parent);
197:
198: public void setLabel(String label);
199:
200: public String getLabel();
201:
202: public boolean isSeparator();
203:
204: public String getId();
205:
206: public void fill(JMenu parent, int index);
207:
208: public void fill(JMenuBar menu, int index);
209:
210: public void fill(JToolBar parent, int index);
211:
212: }
|