KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > jdnc > markup > elem > ActionPanelElement


1 /*
2  * $Id: ActionPanelElement.java,v 1.1.1.1 2004/06/16 01:43:40 davidson1 Exp $
3  *
4  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5  * Santa Clara, California 95054, U.S.A. All rights reserved.
6  */

7
8 package org.jdesktop.jdnc.markup.elem;
9
10 import org.jdesktop.jdnc.JNForm;
11
12 import java.util.Hashtable JavaDoc;
13 import java.util.Map JavaDoc;
14 import java.util.Vector JavaDoc;
15
16 import javax.swing.Action JavaDoc;
17 import javax.swing.JComponent JavaDoc;
18
19 import org.w3c.dom.Element JavaDoc;
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 /**
33  *
34  * @author Amy Fowler
35  */

36 public class ActionPanelElement extends ElementProxy {
37     private static final Map JavaDoc attrMap = new Hashtable JavaDoc();
38     private static final Map JavaDoc elementMap = new Hashtable JavaDoc();
39
40     public ActionPanelElement(Element JavaDoc element, ElementType elementType) {
41         super(element, elementType);
42     }
43
44     protected Map JavaDoc getAttributeHandlerMap() {
45         return attrMap;
46     }
47
48     protected Map JavaDoc getElementHandlerMap() {
49         return elementMap;
50     }
51
52     protected Map JavaDoc registerElementHandlers() {
53         Map JavaDoc 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             //elementMap.put(Namespace.JDNC + ":" + ElementTypes.ACTION.getLocalName(),
60
//actionElementHandler);
61
}
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 JavaDoc)parent.getParentNode()).getObject();
70             Action JavaDoc action = (Action JavaDoc) 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