1
2 package org.catacomb.druid.blocks;
3
4 import org.catacomb.druid.build.Context;
5 import org.catacomb.druid.build.GUIPath;
6 import org.catacomb.druid.build.Realizer;
7 import org.catacomb.druid.gui.base.DruMenuBar;
8 import org.catacomb.druid.gui.edit.DruMenu;
9 import org.catacomb.interlish.structure.AddableTo;
10 import org.catacomb.report.E;
11
12
13 import java.util.ArrayList;
14
15
16
17 public class MenuBar implements AddableTo, Realizer {
18
19 public String id;
20
21 public ArrayList<Menu> menus;
22
23
24 public MenuBar() {
25 }
26
27
28 public void add(Object obj) {
29 if (obj instanceof Menu) {
30 addMenu((Menu)obj);
31 } else {
32 E.error("cant add " + obj);
33 }
34 }
35
36 public void addMenu(Menu menu) {
37 if (menus == null) {
38 menus = new ArrayList<Menu>();
39 }
40 menus.add(menu);
41 }
42
43
44
45 public Object realize(Context ctx, GUIPath gpathin) {
46 GUIPath gpath = gpathin;
47 gpath = gpath.extend(id);
48
49 DruMenuBar dmb = new DruMenuBar(id);
50 if (menus != null) {
51 for (Menu mcfg : menus) {
52 DruMenu dm = (DruMenu)(mcfg.realize(ctx, gpath));
53 dmb.addMenu(dm);
54 }
55 }
56
57
58 ctx.addComponent(dmb, gpath);
59
60 return dmb;
61 }
62
63
64
65 }