1 7 8 package org.jdesktop.jdnc.markup.elem; 9 10 import org.jdesktop.swing.Application; 11 12 import java.util.Hashtable ; 13 import java.util.Map ; 14 import java.util.Vector ; 15 16 import org.w3c.dom.Element ; 17 18 import net.openmarkup.AttributeHandler; 19 import net.openmarkup.ElementAssimilator; 20 import net.openmarkup.ElementHandler; 21 import net.openmarkup.ElementType; 22 import net.openmarkup.Realizable; 23 import org.jdesktop.jdnc.markup.Attributes; 24 import org.jdesktop.jdnc.markup.ElementTypes; 25 import org.jdesktop.jdnc.markup.Namespace; 26 import org.jdesktop.jdnc.markup.attr.AppAttributes; 27 28 32 public class AppElement extends ElementProxy { 33 34 private static final Map attrMap = new Hashtable (); 35 36 public AppElement(Element element, ElementType elementType) { 37 super(element, elementType); 38 } 39 40 protected Object instantiate() { 41 Application app = null; 42 String id = this.getAttributeNSOptional(Namespace.JDNC, Attributes.ID); 43 if (id.length() > 0) { 44 app = Application.getInstance(id); 45 } else { 46 app = Application.getInstance(); 47 } 48 app.setBaseURL(getObjectRealizer().getDefaultBaseURL()); 49 putORValue("ApplicationID", id); 51 52 return app; 53 } 54 55 public AttributeHandler getAttributeHandler(String namespaceURI, String attrName) { 56 Map handlerMap = getAttributeHandlerMap(); 57 return handlerMap == null ? null : (AttributeHandler) attrMap.get(namespaceURI + ":" + attrName); 58 } 59 60 protected Map getAttributeHandlerMap() { 61 return attrMap; 62 } 63 64 protected void applyAttributesAfter() { 65 super.applyAttributesAfter(); 66 applyAttribute(Namespace.JDNC, Attributes.TITLE); 67 applyAttribute(Namespace.JDNC, Attributes.VERSION_STRING); 68 } 69 70 protected Map registerAttributeHandlers() { 71 Map handlerMap = super.registerAttributeHandlers(); 72 if (handlerMap != null) { 73 handlerMap.put(Namespace.JDNC + ":" + Attributes.TITLE, 74 titleHandler); 75 handlerMap.put(Namespace.JDNC + ":" + Attributes.VERSION_STRING, 76 versionStringHandler); 77 } 78 return handlerMap; 79 } 80 81 protected static final AttributeHandler titleHandler = 82 new AttributeHandler(Namespace.JDNC, Attributes.TITLE, 83 AppAttributes.titleApplier); 84 85 protected static final AttributeHandler versionStringHandler = 86 new AttributeHandler(Namespace.JDNC, Attributes.VERSION_STRING, 87 AppAttributes.versionStringApplier); 88 89 } 90 | Popular Tags |