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 javax.swing.*; 17 import java.util.*; 18 import org.w3c.dom.*; 19 20 25 public class FormalParameter extends XMLCollectionElement { 26 private DataType refDataType; 27 private Description refDescription=new Description(); 29 private XMLAttribute attrIndex=new XMLAttribute("Index"); 30 private XMLAttribute attrMode=new XMLAttribute("Mode", 32 new String [] { 33 "", 34 "IN", 35 "OUT", 36 "INOUT" 37 },1); 38 39 40 48 public FormalParameter (FormalParameters fps,Package p) { 49 super(fps); 50 51 refDataType=new DataType(p); 52 fillStructure(); 53 } 54 55 59 protected void fillStructure () { 60 super.fillStructure(); 61 if (myCollection.getOwner() instanceof WorkflowProcess) { 63 attrId.setValue(""); 64 } 65 complexStructure.add(attrIndex); 66 attributes.add(attrIndex); 67 complexStructure.add(attrMode); 68 attributes.add(attrMode); 69 refDataType.setRequired(true); 70 complexStructure.add(refDataType); 71 complexStructure.add(refDescription); 72 } 73 74 75 public void fromXML (Node node) { 76 attrMode.setValue(""); 77 super.fromXML(node); 78 } 79 80 83 public boolean isIDUniqueAndValid (XMLPanel groupPanel) { 84 XMLTextPanel tp=(XMLTextPanel)((XMLGroupPanel)groupPanel).getPanel(0); 85 String IDToCheck=tp.getText(); 86 FormalParameter fp=((FormalParameters)getCollection()).getFormalParameter(IDToCheck); 88 boolean isOK=true; 89 String message=null; 90 String dialogTitle=null; 91 if (fp!=null && fp!=this) { 92 message=XMLUtil.getLanguageDependentString("ErrorIDMustBeUnique"); 93 dialogTitle=XMLUtil.getLanguageDependentString("DialogIDIsNotUnique"); 94 isOK=false; 95 } else if (!XMLCollection.isIdValid(IDToCheck)) { 96 message=XMLUtil.getLanguageDependentString("ErrorIDMustBeValid"); 97 dialogTitle=XMLUtil.getLanguageDependentString("DialogIDIsNotValid"); 98 isOK=false; 99 } 100 if (!isOK) { 101 XMLPanel.errorMessage(groupPanel.getDialog(),dialogTitle,"",message); 102 ((JTextField)tp.getComponent(2)).requestFocus(); 103 } 104 return isOK; 105 } 106 107 public String toString () { 108 if (myCollection.getOwner() instanceof WorkflowProcess) { 109 return attrId.toString(); 110 } else { 111 return super.toString(); 112 } 113 } 114 115 119 public Collection toComplexTypeValues () { 120 java.util.List l=new ArrayList(); 121 Iterator it=complexStructure.iterator(); 122 while (it.hasNext()) { 123 XMLElement el=(XMLElement)it.next(); 124 if (el instanceof XMLAttribute) { 125 l.add(el.toString()); 126 } else if (el instanceof DataType) { 127 DataType dt=(DataType)el; 128 DataTypes dtt=(DataTypes)dt.get("Type"); 129 Object type=dtt.toValue(); 130 if (type instanceof BasicType) { 131 l.add(el.toValue()+" - "+((XMLAttribute)((BasicType)type).get("Type")).getChoosen()); 132 } else if (type instanceof DeclaredType) { 133 l.add(el.toValue()+" - "+((XMLComplexChoice)((DeclaredType)type).get("SubType")).getChoosen()); 134 } else { 135 l.add(el.toValue()); 136 } 137 } else { 138 l.add(el.toValue()); 139 } 140 } 141 return l; 142 } 143 144 145 } 146 | Popular Tags |