1 10 11 package org.enhydra.jawe.xml.elements; 12 13 import org.enhydra.jawe.xml.*; 14 import org.enhydra.jawe.xml.panels.*; 15 16 import java.util.*; 17 18 24 public class TypeDeclarations extends XMLCollection { 25 26 29 public TypeDeclarations (Package p) { 30 super(p); 31 } 32 33 40 public XMLElement generateNewElement() { 41 TypeDeclaration td=new TypeDeclaration(this,((Package )myOwner)); 42 td.setRequired(true); 43 return td; 44 } 45 46 57 public TypeDeclaration getDeclaredType (String ID) { 58 return (TypeDeclaration)getCollectionElement(ID); 59 } 60 61 65 public boolean canRemoveElement (XMLElement el) { 66 TypeDeclaration toRemove=(TypeDeclaration)el; 67 68 70 Set allDFS=new HashSet(); 72 allDFS.add(myOwner.get("DataFields")); 73 WorkflowProcesses wps=(WorkflowProcesses)myOwner.get("WorkflowProcesses"); 74 Iterator it=wps.toCollection().iterator(); 75 while (it.hasNext()) { 76 WorkflowProcess wp=(WorkflowProcess)it.next(); 77 allDFS.add(wp.get("DataFields")); 78 } 79 80 it=allDFS.iterator(); 83 while (it.hasNext()) { 84 DataFields dfs=(DataFields)it.next(); 85 Iterator itDFs=dfs.toCollection().iterator(); 86 while (itDFs.hasNext()) { 87 DataField df=(DataField)itDFs.next(); 88 DataType dt=(DataType)df.get("DataType"); 89 Object choosen=((DataTypes)dt.get("Type")).getChoosen(); 90 if (choosen instanceof DeclaredType) { 91 if (((XMLComplexChoice)((DeclaredType)choosen).get("SubType")). 92 getChoosen()==toRemove) { 93 return false; 94 } 95 } 96 } 97 } 98 99 100 102 Set allFPs=new HashSet(); 104 Applications aps=(Applications)myOwner.get("Applications"); 106 Iterator itApps=aps.toCollection().iterator(); 107 while (itApps.hasNext()) { 108 Application app=(Application)itApps.next(); 109 XMLComplexChoice ch=(XMLComplexChoice)app.get("Choice"); 110 allFPs.add(ch.getChoices()[0]); 111 } 112 113 it=wps.toCollection().iterator(); 114 while (it.hasNext()) { 115 WorkflowProcess wp=(WorkflowProcess)it.next(); 116 allFPs.add(wp.get("FormalParameters")); 118 aps=(Applications)wp.get("Applications"); 120 itApps=aps.toCollection().iterator(); 121 while (itApps.hasNext()) { 122 Application app=(Application)itApps.next(); 123 XMLComplexChoice ch=(XMLComplexChoice)app.get("Choice"); 124 allFPs.add(ch.getChoices()[0]); 125 } 126 } 127 128 it=allFPs.iterator(); 131 while (it.hasNext()) { 132 FormalParameters fps=(FormalParameters)it.next(); 133 Iterator itFPs=fps.toCollection().iterator(); 134 while (itFPs.hasNext()) { 135 FormalParameter fp=(FormalParameter)itFPs.next(); 136 DataType dt=(DataType)fp.get("DataType"); 137 Object choosen=((DataTypes)dt.get("Type")).getChoosen(); 138 if (choosen instanceof DeclaredType) { 139 if (((XMLComplexChoice)((DeclaredType)choosen).get("SubType")). 140 getChoosen()==toRemove) { 141 return false; 142 } 143 } 144 } 145 } 146 147 return true; 148 } 149 150 151 public int[] getInvisibleTableFieldOrdinals () { 152 int[] itfo=new int[2]; 153 itfo[0]=3; 154 itfo[1]=4; 155 return itfo; 156 } 157 158 } 159 | Popular Tags |