1 7 8 package org.jdesktop.jdnc.markup.elem; 9 10 import java.util.Hashtable ; 11 import java.util.Map ; 12 13 import javax.swing.JLabel ; 14 15 import org.w3c.dom.Element ; 16 import net.openmarkup.ElementAssimilator; 17 import net.openmarkup.ElementHandler; 18 import net.openmarkup.ElementType; 19 import net.openmarkup.Realizable; 20 import org.jdesktop.jdnc.markup.ElementTypes; 21 import org.jdesktop.jdnc.markup.Namespace; 22 23 27 public class EnumerationValuesElement extends ElementProxy { 28 private static final Map elementMap = new Hashtable (); 29 30 public EnumerationValuesElement(Element element, ElementType elementType) { 31 super(element, elementType); 32 } 33 34 protected Map registerElementHandlers() { 35 Map handlerMap = super.registerElementHandlers(); 36 if (handlerMap != null) { 37 handlerMap.put(Namespace.JDNC + ":" + 38 ElementTypes.ENUMERATION_VALUE.getLocalName(), 39 enumerationElementHandler); 40 } 41 return handlerMap; 42 } 43 44 protected Map getElementHandlerMap() { 45 return elementMap; 46 } 47 48 protected void checkAttributes() { 49 } 52 53 public static final ElementAssimilator enumerationAssimilator = new ElementAssimilator() { 54 private final static String enumKey = Namespace.JDNC + ":" + net.openmarkup.Attributes.VALUE; 55 public void assimilate(Realizable parent, Realizable child) { 56 Map map = (Map ) parent.getObject(); 57 JLabel label = (JLabel ) child.getObject(); 58 String key = child.getAttributeNSOptional(Namespace.JDNC, net.openmarkup.Attributes.VALUE); 60 if ((key != null) && (label != null)) { 61 label.putClientProperty(enumKey, key); 62 map.put(key, label); 63 } 64 } 65 }; 66 67 private static final ElementHandler enumerationElementHandler = 68 new ElementHandler(ElementTypes.ENUMERATION_VALUE, enumerationAssimilator); 69 70 } 71 | Popular Tags |