1 7 8 package org.jdesktop.jdnc.markup.attr; 9 10 11 import org.jdesktop.swing.data.Converters; 12 import org.jdesktop.swing.data.Converter; 13 import org.jdesktop.swing.data.MetaData; 14 import org.jdesktop.swing.data.NumberMetaData; 15 import org.jdesktop.swing.data.StringMetaData; 16 import org.jdesktop.swing.table.TabularDataMetaData; 17 18 import java.text.SimpleDateFormat ; 19 20 import java.util.Date ; 21 22 import net.openmarkup.ApplierException; 23 import net.openmarkup.AttributeApplier; 24 import net.openmarkup.Realizable; 25 26 import org.w3c.dom.Element ; 27 28 import org.jdesktop.jdnc.markup.elem.ElementProxy; 29 30 33 public class DataFieldAttributes { 34 35 public static final AttributeApplier typeApplier = new AttributeApplier() { 36 public void apply(Realizable target, String namespaceURI, 37 String attributeName, String attributeValue) throws ApplierException { 38 MetaData metaData = (MetaData) target.getObject(); 39 Class klass = Decoder.decodeType(attributeValue); 40 if (klass != null) { 41 metaData.setElementClass(klass); 42 } 43 } 44 }; 45 46 public static final AttributeApplier decodeFormatApplier = new AttributeApplier() { 47 public void apply(Realizable target, String namespaceURI, 48 String attributeName, String attributeValue) throws ApplierException { 49 MetaData metaData = (MetaData) target.getObject(); 50 if (metaData.getElementClass() == Date .class) { 51 metaData.setDecodeFormat(new SimpleDateFormat (attributeValue)); 52 } 53 54 } 55 }; 56 57 public static final AttributeApplier encodeFormatApplier = new AttributeApplier() { 58 public void apply(Realizable target, String namespaceURI, 59 String attributeName, String attributeValue) throws ApplierException { 60 MetaData metaData = (MetaData) target.getObject(); 61 if (metaData.getElementClass() == Date .class) { 62 metaData.setEncodeFormat(new SimpleDateFormat (attributeValue)); 63 } 64 65 } 66 }; 67 68 69 public static final AttributeApplier titleApplier = new AttributeApplier() { 70 public void apply(Realizable target, String namespaceURI, 71 String attributeName, String attributeValue) throws ApplierException { 72 MetaData metaData = (MetaData) target.getObject(); 73 metaData.setLabel(attributeValue); 74 } 75 }; 76 77 public static final AttributeApplier displaySizeApplier = new AttributeApplier() { 78 public void apply(Realizable target, String namespaceURI, 79 String attributeName, String attributeValue) throws ApplierException { 80 StringMetaData metaData = (StringMetaData) target.getObject(); 81 try { 82 metaData.setDisplayWidth(Integer.parseInt(attributeValue)); 83 } catch (Exception ex) { 84 System.out.println("DataElementAttributes.displayWidthApplier: " + ex); 85 } 86 } 87 }; 88 89 public static final AttributeApplier maximumApplier = new AttributeApplier() { 90 public void apply(Realizable target, String namespaceURI, 91 String attributeName, String attributeValue) throws ApplierException { 92 try { 93 NumberMetaData metaData = (NumberMetaData) target.getObject(); 94 95 metaData.setMaximum(new Integer (Integer.parseInt(attributeValue))); 96 } catch (Exception ex) { 97 System.out.println("DataElementAttributes.maximumApplier: " + ex); 98 } 99 } 100 }; 101 102 public static final AttributeApplier maximumFieldSizeApplier = new AttributeApplier() { 103 public void apply(Realizable target, String namespaceURI, 104 String attributeName, String attributeValue) throws ApplierException { 105 try { 106 StringMetaData metaData = (StringMetaData) target.getObject(); 107 108 metaData.setMaxLength(Integer.parseInt(attributeValue)); 109 } catch (Exception ex) { 110 System.out.println("DataElementAttributes.maximumLengthApplier: " + ex); 111 } 112 } 113 }; 114 115 public static final AttributeApplier minimumApplier = new AttributeApplier() { 116 public void apply(Realizable target, String namespaceURI, 117 String attributeName, String attributeValue) throws ApplierException { 118 try { 119 NumberMetaData metaData = (NumberMetaData) target.getObject(); 120 121 metaData.setMinimum(new Integer (Integer.parseInt(attributeValue))); 122 } catch (Exception ex) { 123 System.out.println("DataElementAttributes.minimumApplier: " + ex); 124 } 125 } 126 }; 127 128 public static final AttributeApplier minimumFieldSizeApplier = new AttributeApplier() { 129 public void apply(Realizable target, String namespaceURI, 130 String attributeName, String attributeValue) throws ApplierException { 131 try { 132 StringMetaData metaData = (StringMetaData) target.getObject(); 133 134 metaData.setMinLength(Integer.parseInt(attributeValue)); 135 } catch (Exception ex) { 136 System.out.println("DataElementAttributes.minimumLengthApplier: " + ex); 137 } 138 } 139 }; 140 141 public static final AttributeApplier multiLineApplier = new AttributeApplier() { 142 public void apply(Realizable target, String namespaceURI, 143 String attributeName, String attributeValue) throws ApplierException { 144 try { 145 StringMetaData metaData = (StringMetaData) target.getObject(); 146 metaData.setMultiLine(Boolean.valueOf(attributeValue).booleanValue()); 147 } catch (Exception ex) { 148 System.out.println("DataElementAttributes.multiLineApplier: " + ex); 149 } 150 } 151 }; 152 153 public static final AttributeApplier nameApplier = new AttributeApplier() { 154 public void apply(Realizable target, String namespaceURI, 155 String attributeName, String attributeValue) throws ApplierException { 156 MetaData metaData = (MetaData) target.getObject(); 157 metaData.setName(attributeValue); 158 } 159 }; 160 161 public static final AttributeApplier isReadOnlyApplier = new AttributeApplier() { 162 public void apply(Realizable target, String namespaceURI, 163 String attributeName, String attributeValue) throws ApplierException { 164 MetaData metaData = (MetaData) target.getObject(); 165 metaData.setReadOnly(Boolean.valueOf(attributeValue).booleanValue()); 166 } 167 }; 168 169 public static final AttributeApplier isRequiredApplier = new AttributeApplier() { 170 public void apply(Realizable target, String namespaceURI, 171 String attributeName, String attributeValue) throws ApplierException { 172 MetaData metaData = (MetaData) target.getObject(); 173 metaData.setRequired(Boolean.valueOf(attributeValue).booleanValue()); 174 } 175 }; 176 177 178 } 179 | Popular Tags |