01: // The contents of this file are subject to the Mozilla Public License Version
02: // 1.1
03: //(the "License"); you may not use this file except in compliance with the
04: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
05: //
06: //Software distributed under the License is distributed on an "AS IS" basis,
07: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
08: //for the specific language governing rights and
09: //limitations under the License.
10: //
11: //The Original Code is "The Columba Project"
12: //
13: //The Initial Developers of the Original Code are Frederik Dietz and Timo
14: // Stich.
15: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16: //
17: //All Rights Reserved.
18: package org.columba.core.gui.menu;
19:
20: import java.awt.Component;
21:
22: import javax.swing.Action;
23: import javax.swing.JMenuItem;
24:
25: /**
26: * Menu element factory.
27: *
28: * @author fdietz
29: *
30: */
31: public class MenuElementFactory {
32:
33: public static IMenuElement createComponentElement(
34: Component component) {
35: MenuElement menuElement = new MenuElement(
36: IMenuElement.TYPE_COMPONENT);
37: menuElement.setComponent(component);
38: return menuElement;
39: }
40:
41: public static IMenuElement createMenuItemElement(JMenuItem menuItem) {
42: MenuElement menuElement = new MenuElement(
43: IMenuElement.TYPE_MENUITEM);
44: menuElement.setMenuItem(menuItem);
45: return menuElement;
46: }
47:
48: public static IMenuElement createActionElement(Action action) {
49: MenuElement menuElement = new MenuElement(
50: IMenuElement.TYPE_ACTION);
51: menuElement.setAction(action);
52: return menuElement;
53: }
54:
55: public static IMenuElement createSeparatorElement() {
56: MenuElement menuElement = new MenuElement(
57: IMenuElement.TYPE_SEPARATOR);
58: return menuElement;
59: }
60:
61: public static IMenuElement createPlaceholderElement(
62: String placeholderId) {
63: MenuElement menuElement = new MenuElement(
64: IMenuElement.TYPE_PLACEHOLDER);
65: menuElement.setPlaceholderId(placeholderId);
66: return menuElement;
67: }
68:
69: public static IMenuElement createMenuElement(String menuId,
70: String menuLabel) {
71: MenuElement menuElement = new MenuElement(
72: IMenuElement.TYPE_MENU);
73: menuElement.setMenuId(menuId);
74: menuElement.setMenuLabel(menuLabel);
75: return menuElement;
76: }
77: }
|