1 7 8 package org.jdesktop.jdnc.markup.elem; 9 10 import javax.swing.JMenu ; 11 import javax.swing.JMenuBar ; 12 13 import java.util.Hashtable ; 14 import java.util.Map ; 15 16 import org.w3c.dom.Element ; 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 elementMap = new Hashtable (); 29 30 public MenuBarElement(Element element, ElementType elementType) { 31 super(element, elementType); 32 } 33 34 protected Map getElementHandlerMap() { 35 return elementMap; 36 } 37 38 protected Map registerElementHandlers() { 39 Map 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 menuBar = (JMenuBar )parent.getObject(); 50 JMenu menu = (JMenu )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 |