Source code: com/virtuosotechnologies/lib/basiccommand/builder/MenuBarBuilderNode.java
1 /*
2 ================================================================================
3
4 FILE: MenuBarBuilderNode.java
5
6 PROJECT:
7
8 Virtuoso Utilities
9
10 CONTENTS:
11
12 A builder that creates a menu bar
13
14 PROGRAMMERS:
15
16 Daniel Azuma (DA) <dazuma@kagi.com>
17
18 COPYRIGHT:
19
20 Copyright (C) 2003 Daniel Azuma (dazuma@kagi.com)
21
22 This program is free software; you can redistribute it and/or
23 modify it under the terms of the GNU General Public License as
24 published by the Free Software Foundation; either version 2
25 of the License, or (at your option) any later version.
26
27 This program is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 GNU General Public License for more details.
31
32 You should have received a copy of the GNU General Public
33 License along with this program; if not, write to
34 Free Software Foundation, Inc.
35 59 Temple Place, Suite 330
36 Boston, MA 02111-1307 USA
37
38 ================================================================================
39 */
40
41
42 package com.virtuosotechnologies.lib.basiccommand.builder;
43
44
45 import javax.swing.JMenuBar;
46
47 import com.virtuosotechnologies.lib.command.CommandNode;
48 import com.virtuosotechnologies.lib.command.CommandNodeFlavor;
49 import com.virtuosotechnologies.lib.basiccommand.BasicCommandNode;
50
51
52 /**
53 * A builder that creates a menu bar
54 */
55 public class MenuBarBuilderNode
56 extends AbstractAWTContainerBuilderNode
57 {
58 /**
59 * Constructor
60 */
61 public MenuBarBuilderNode(
62 CommandNode commandNode)
63 {
64 super(commandNode, null, END_POSITION);
65 }
66
67
68 /**
69 * Constructor
70 */
71 public MenuBarBuilderNode(
72 CommandNode commandNode,
73 JMenuBar menuBar)
74 {
75 super(commandNode, null, END_POSITION, menuBar);
76 }
77
78
79 /**
80 * Override this method to create the initial element object.
81 */
82 protected Object createInitialElement()
83 {
84 return new JMenuBar();
85 }
86
87
88 /**
89 * Create a child node
90 */
91 protected AbstractBuilderNode createChildNode(
92 CommandNode cn,
93 int index)
94 {
95 AbstractBuilderNode child = null;
96 CommandNodeFlavor flavor = cn.getFlavor();
97 if (flavor.equalsOrExtends(BasicCommandNode.SEPARATOR_FLAVOR))
98 {
99 child = new MenuBarGlueBuilderNode(cn, this, index);
100 }
101 else if (flavor.equalsOrExtends(BasicCommandNode.GROUP_FLAVOR))
102 {
103 child = new MenuBarGroupBuilderNode(cn, this, index);
104 }
105 else if (flavor.equalsOrExtends(BasicCommandNode.RADIOCONTAINER_FLAVOR))
106 {
107 child = new MenuRadioMenuBuilderNode(cn, this, index);
108 }
109 else if (flavor.equalsOrExtends(BasicCommandNode.CONTAINER_FLAVOR))
110 {
111 child = new MenuBuilderNode(cn, this, index);
112 }
113 return child;
114 }
115
116
117 /**
118 * Get the built menu bar
119 */
120 public JMenuBar getJMenuBar()
121 {
122 return (JMenuBar)getElement();
123 }
124 }