1 7 8 package org.jdesktop.jdnc.markup.elem; 9 10 import org.jdesktop.jdnc.JNForm; 11 12 import java.util.Hashtable ; 13 import java.util.Map ; 14 import java.util.Vector ; 15 16 import javax.swing.Action ; 17 import javax.swing.JComponent ; 18 19 import org.w3c.dom.Element ; 20 21 import net.openmarkup.AttributeHandler; 22 import net.openmarkup.ElementAssimilator; 23 import net.openmarkup.ElementHandler; 24 import net.openmarkup.ElementType; 25 import net.openmarkup.Realizable; 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 32 36 public class ActionPanelElement extends ElementProxy { 37 private static final Map attrMap = new Hashtable (); 38 private static final Map elementMap = new Hashtable (); 39 40 public ActionPanelElement(Element element, ElementType elementType) { 41 super(element, elementType); 42 } 43 44 protected Map getAttributeHandlerMap() { 45 return attrMap; 46 } 47 48 protected Map getElementHandlerMap() { 49 return elementMap; 50 } 51 52 protected Map registerElementHandlers() { 53 Map handlerMap = super.registerElementHandlers(); 54 if (handlerMap != null) { 55 elementMap.put(Namespace.JDNC + ":" + ElementTypes.RESET.getLocalName(), 56 resetActionElementHandler); 57 elementMap.put(Namespace.JDNC + ":" + ElementTypes.SUBMIT.getLocalName(), 58 submitActionElementHandler); 59 } 62 return handlerMap; 63 } 64 65 public static final ElementAssimilator actionAssimilator = new 66 ElementAssimilator() { 67 public void assimilate(Realizable parent, Realizable child) { 68 JNForm form = (JNForm)ElementProxy.getRealizable( 69 (Element )parent.getParentNode()).getObject(); 70 Action action = (Action ) child.getObject(); 71 form.addAction(action); 72 } 73 }; 74 75 protected static final ElementHandler resetActionElementHandler = 76 new ElementHandler(ElementTypes.RESET, ActionPanelElement.actionAssimilator); 77 78 protected static final ElementHandler submitActionElementHandler = 79 new ElementHandler(ElementTypes.SUBMIT, ActionPanelElement.actionAssimilator); 80 } 81 | Popular Tags |