KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > jdnc > markup > elem > MenuBarElement


1 /*
2  * $Id: MenuBarElement.java,v 1.1.1.1 2004/06/16 01:43:40 davidson1 Exp $
3  *
4  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5  * Santa Clara, California 95054, U.S.A. All rights reserved.
6  */

7
8 package org.jdesktop.jdnc.markup.elem;
9
10 import javax.swing.JMenu JavaDoc;
11 import javax.swing.JMenuBar JavaDoc;
12
13 import java.util.Hashtable JavaDoc;
14 import java.util.Map JavaDoc;
15
16 import org.w3c.dom.Element JavaDoc;
17
18 import net.openmarkup.ElementAssimilator;
19 import net.openmarkup.ElementHandler;
20 import net.openmarkup.ElementType;
21 import net.openmarkup.Realizable;
22
23 import org.jdesktop.jdnc.markup.Attributes;
24 import org.jdesktop.jdnc.markup.ElementTypes;
25 import org.jdesktop.jdnc.markup.Namespace;
26
27 public class MenuBarElement extends ElementProxy {
28     private static final Map JavaDoc elementMap = new Hashtable JavaDoc();
29     
30     public MenuBarElement(Element JavaDoc element, ElementType elementType) {
31     super(element, elementType);
32     }
33
34     protected Map JavaDoc getElementHandlerMap() {
35     return elementMap;
36     }
37
38     protected Map JavaDoc registerElementHandlers() {
39     Map JavaDoc handlerMap = super.registerElementHandlers();
40     if (handlerMap != null) {
41         handlerMap.put(Namespace.JDNC + ":" + ElementTypes.MENU.getLocalName(),
42                menuElementHandler);
43     }
44     return handlerMap;
45     }
46
47     public static final ElementAssimilator menuAssimilator = new ElementAssimilator() {
48         public void assimilate(Realizable parent, Realizable child) {
49         JMenuBar JavaDoc menuBar = (JMenuBar JavaDoc)parent.getObject();
50         JMenu JavaDoc menu = (JMenu JavaDoc)child.getObject();
51         menuBar.add(menu);
52         }
53     };
54
55     protected static final ElementHandler menuElementHandler =
56     new ElementHandler(ElementTypes.MENU, MenuBarElement.menuAssimilator);
57 }
58
Popular Tags