KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: TableColumnsElement.java,v 1.2 2005/01/26 15:59:20 kleopatra 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 java.util.Hashtable JavaDoc;
11 import java.util.Map JavaDoc;
12
13 import javax.swing.table.TableColumnModel JavaDoc;
14
15 import net.openmarkup.ElementAssimilator;
16 import net.openmarkup.ElementHandler;
17 import net.openmarkup.ElementType;
18 import net.openmarkup.Realizable;
19
20 import org.jdesktop.jdnc.markup.ElementTypes;
21 import org.jdesktop.jdnc.markup.Namespace;
22 import org.jdesktop.swing.table.DefaultTableColumnModelExt;
23 import org.jdesktop.swing.table.TableColumnExt;
24 import org.w3c.dom.Element JavaDoc;
25
26 /**
27  *
28  * @author Amy Fowler
29  * @author Ramesh Gupta
30  */

31 public class TableColumnsElement extends ElementProxy {
32     private static final Map JavaDoc elementMap = new Hashtable JavaDoc();
33
34     public TableColumnsElement(Element JavaDoc element, ElementType elementType) {
35         super(element, elementType);
36     }
37
38     protected Map JavaDoc getElementHandlerMap() {
39         return elementMap;
40     }
41
42     public Object JavaDoc instantiate() {
43         return new DefaultTableColumnModelExt();
44     }
45
46     protected Map JavaDoc registerElementHandlers() {
47         Map JavaDoc handlerMap = super.registerElementHandlers();
48         if (handlerMap != null) {
49             handlerMap.put(Namespace.JDNC + ":" +
50                            ElementTypes.TABLE_COLUMN.getLocalName(),
51                            tableColumnElementHandler);
52         }
53         return handlerMap;
54     }
55
56     public static final ElementAssimilator tableColumnAssimilator = new ElementAssimilator() {
57         public void assimilate(Realizable parent, Realizable child) {
58             TableColumnModel JavaDoc columnModel = (TableColumnModel JavaDoc)parent.getObject();
59             TableColumnExt column = (TableColumnExt)child.getObject();
60             columnModel.addColumn(column);
61         }
62     };
63
64     private static final ElementHandler tableColumnElementHandler =
65          new ElementHandler(ElementTypes.TABLE_COLUMN, tableColumnAssimilator);
66
67 }
68
Popular Tags