1 10 11 package org.enhydra.jawe.xml.elements; 12 13 import org.enhydra.jawe.xml.*; 14 import org.enhydra.jawe.xml.panels.*; 15 import org.enhydra.jawe.xml.elements.specialpanels.*; 16 17 import java.util.*; 18 import org.w3c.dom.*; 19 20 public class DataTypes extends XMLComplexChoice { 21 private BasicType basicType; 22 private DeclaredType declaredType; 23 private SchemaType schemaType; 24 private ExternalReference externalReference; 25 private RecordType recordType; 26 private UnionType unionType; 27 private EnumerationType enumerationType; 28 private ArrayType arrayType; 29 private ListType listType; 30 31 private XMLComplexElement myOwner=null; 32 private transient Package myPackage=null; 33 34 Set invisibles=new HashSet(); 35 int choosenIndex=0; 36 37 public DataTypes (XMLComplexElement myOwner,Package p, 38 int[] invisibleTypes,int choosenIndex) { 39 40 super("Type",null,0); 41 42 this.myOwner=myOwner; 43 myPackage=p; 44 45 if (invisibleTypes!=null && invisibleTypes.length>0) { 46 for (int i=0; i<invisibleTypes.length; i++) { 47 invisibles.add(new Integer (invisibleTypes[i])); 48 } 49 } 50 51 this.choosenIndex=choosenIndex; 52 } 53 54 public void setValue(Object v) { 55 super.setValue(v); 56 if (!(v instanceof BasicType)) { 58 basicType=null; 59 } 60 if (!(v instanceof DeclaredType)) { 61 declaredType=null; 62 } 63 if (!(v instanceof SchemaType)) { 64 schemaType=null; 65 } 66 if (!(v instanceof ExternalReference)) { 67 externalReference=null; 68 } 69 if (!(v instanceof RecordType)) { 70 recordType=null; 71 } 72 if (!(v instanceof UnionType)) { 73 unionType=null; 74 } 75 if (!(v instanceof EnumerationType)) { 76 enumerationType=null; 77 } 78 if (!(v instanceof ArrayType)) { 79 arrayType=null; 80 } 81 if (!(v instanceof ListType)) { 82 listType=null; 83 } 84 } 85 86 public XMLPanel getPanel () { 87 return new XMLDataTypesPanel(this,toLabel()); 88 } 89 90 public Object [] getChoices() { 91 ArrayList chs=new ArrayList(); 92 if (!invisibles.contains(new Integer (0))) { 93 if (basicType==null) { 94 basicType=new BasicType(); 95 } 96 chs.add(basicType); 97 } 98 if (!invisibles.contains(new Integer (1))) { 99 if (declaredType==null) { 100 declaredType=new DeclaredType(myPackage); 101 } 102 chs.add(declaredType); 103 } 104 if (!invisibles.contains(new Integer (2))) { 105 if (schemaType==null) { 106 schemaType=new SchemaType(); 107 } 108 chs.add(schemaType); 109 } 110 if (!invisibles.contains(new Integer (3))) { 111 if (externalReference==null) { 112 externalReference=new ExternalReference(); 113 } 114 chs.add(externalReference); 115 } 116 if (!invisibles.contains(new Integer (4))) { 117 if (recordType==null) { 118 recordType=new RecordType(myPackage); 119 } 120 chs.add(recordType); 121 } 122 if (!invisibles.contains(new Integer (5))) { 123 if (unionType==null) { 124 unionType=new UnionType(myPackage); 125 } 126 chs.add(unionType); 127 } 128 if (!invisibles.contains(new Integer (6))) { 129 if (enumerationType==null) { 130 enumerationType=new EnumerationType(); 131 } 132 chs.add(enumerationType); 133 } 134 if (!invisibles.contains(new Integer (7))) { 135 if (arrayType==null) { 136 arrayType=new ArrayType(this,myPackage); 137 } 138 chs.add(arrayType); 139 } 140 if (!invisibles.contains(new Integer (8))) { 141 if (listType==null) { 142 listType=new ListType(this,myPackage); 143 } 144 chs.add(listType); 145 } 146 if (choosen==null) { 147 choosen=chs.get(choosenIndex); 148 } 149 choices=chs.toArray(); 150 return choices; 151 } 152 153 public XMLComplexElement getOwner () { 154 return myOwner; 155 } 156 162 public String toString () { 163 if (choosen!=null) { 164 return ((XMLElement)choosen).toString(); 165 } else { 166 return ""; 167 } 168 } 169 170 public void fromXML(String choosen,Node node) { 171 getChoices(); 173 super.fromXML(choosen,node); 174 } 175 176 } 177 178 | Popular Tags |