1 7 8 package org.jdesktop.jdnc.markup.elem; 9 10 import java.awt.Component ; 11 import java.awt.Container ; 12 13 import java.util.Hashtable ; 14 import java.util.Map ; 15 import java.util.Vector ; 16 17 import javax.swing.JComponent ; 18 19 import net.openmarkup.AttributeHandler; 20 import net.openmarkup.ElementAssimilator; 21 import net.openmarkup.ElementHandler; 22 import net.openmarkup.ElementType; 23 import net.openmarkup.Realizable; 24 25 import org.w3c.dom.Element ; 26 27 import org.jdesktop.jdnc.markup.Attributes; 28 import org.jdesktop.jdnc.markup.ElementTypes; 29 import org.jdesktop.jdnc.markup.Namespace; 30 import org.jdesktop.jdnc.markup.attr.ComponentAttributes; 31 import org.jdesktop.jdnc.markup.attr.RootPaneAttributes; 32 33 37 public class ContainerElement extends ComponentElement { 38 39 private static final Map attrMap = new Hashtable (); 40 private static final Map elementMap = new Hashtable (); 41 42 public ContainerElement(Element element, ElementType elementType) { 43 super(element, elementType); 44 } 45 46 public ElementHandler getElementHandler(String namespaceURI, String elementName) { 47 Map handlerMap = getElementHandlerMap(); 48 return handlerMap == null ? null : (ElementHandler) handlerMap.get(namespaceURI + ":" + elementName); 49 } 50 51 public AttributeHandler getAttributeHandler(String namespaceURI, String attrName) { 52 Map handlerMap = getAttributeHandlerMap(); 53 return handlerMap == null ? null : (AttributeHandler) attrMap.get(namespaceURI + ":" + attrName); 54 } 55 56 protected Map getAttributeHandlerMap() { 57 return attrMap; 58 } 59 60 protected Map getElementHandlerMap() { 61 return elementMap; 62 } 63 69 protected Map registerAttributeHandlers() { 70 Map handlerMap = super.registerAttributeHandlers(); 71 if (handlerMap != null) { 72 } 74 return handlerMap; 75 } 76 77 protected Map registerElementHandlers() { 78 Map handlerMap = super.registerElementHandlers(); 79 if (handlerMap != null) { 80 handlerMap.put(Namespace.JDNC + ":" + 81 ElementTypes.EDITOR.getLocalName(), 82 editorElementHandler); 83 handlerMap.put(Namespace.JDNC + ":" + 84 ElementTypes.FORM.getLocalName(), 85 formElementHandler); 86 handlerMap.put(Namespace.JDNC + ":" + 87 ElementTypes.TABLE.getLocalName(), 88 tableElementHandler); 89 handlerMap.put(Namespace.JDNC + ":" + 90 ElementTypes.TREE_TABLE.getLocalName(), 91 treeTableElementHandler); 92 } 93 return handlerMap; 94 } 95 96 public static final ElementAssimilator componentAssimilator = new ElementAssimilator() { 97 public void assimilate(Realizable parent, Realizable child) { 98 Container container = (Container )parent.getObject(); 99 Component component = (Component )child.getObject(); 100 container.add(component); 101 } 102 }; 103 104 106 protected static final ElementHandler editorElementHandler = 107 new ElementHandler(ElementTypes.EDITOR, 108 ContainerElement.componentAssimilator); 109 110 protected static final ElementHandler formElementHandler = 111 new ElementHandler(ElementTypes.TABLE, 112 ContainerElement.componentAssimilator); 113 114 protected static final ElementHandler tableElementHandler = 115 new ElementHandler(ElementTypes.TABLE, 116 ContainerElement.componentAssimilator); 117 118 protected static final ElementHandler treeTableElementHandler = 119 new ElementHandler(ElementTypes.TREE_TABLE, 120 ContainerElement.componentAssimilator); 121 122 123 } 124 | Popular Tags |