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.table.TableColumnModel ; 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 ; 25 26 31 public class TableColumnsElement extends ElementProxy { 32 private static final Map elementMap = new Hashtable (); 33 34 public TableColumnsElement(Element element, ElementType elementType) { 35 super(element, elementType); 36 } 37 38 protected Map getElementHandlerMap() { 39 return elementMap; 40 } 41 42 public Object instantiate() { 43 return new DefaultTableColumnModelExt(); 44 } 45 46 protected Map registerElementHandlers() { 47 Map 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 columnModel = (TableColumnModel )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 |