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 javax.swing.*; 16 import org.w3c.dom.*; 17 18 23 public class Application extends XMLCollectionElement { 24 private Description refDescription=new Description(); private XMLComplexChoice refChoice; 28 29 private ExtendedAttributes refExtendedAttributes=new ExtendedAttributes(this); private XMLAttribute attrName=new XMLAttribute("Name"); 31 32 33 private transient Package myPackage=null; 34 35 36 private ExtendedAttributes clonedEAs; 37 38 45 public Application (Applications aps,Package p) { 46 super(aps); 47 48 myPackage=p; 49 50 refChoice=new XMLComplexChoice("Choice", 51 new XMLElement[] {new FormalParameters(this,p), 52 new ExternalReference()},0,true) { 53 54 public void setValue (Object v) { 55 super.setValue(v); 56 if (v==choices[1]) { 57 ((FormalParameters)choices[0]).clear(); 58 } else if (v==choices[0]) { 59 ExternalReference er=(ExternalReference)choices[1]; 60 er.set("xref",""); 61 er.set("location",""); 62 er.set("namespace",""); 63 } 64 } 65 }; 66 67 String idPref=getID()+this.ID_DELIMITER+"For"; 69 FormalParameters fps=(FormalParameters)refChoice.getChoices()[0]; 70 fps.setIDPrefix(idPref); 71 72 fillStructure(); 73 } 74 75 79 protected void fillStructure () { 80 super.fillStructure(); 81 complexStructure.add(attrName); 83 attributes.add(attrName); 84 complexStructure.add(refDescription); 85 complexStructure.add(refChoice); 86 complexStructure.add(refExtendedAttributes); 87 } 88 89 public XMLPanel getPanel () { 90 clonedEAs=(ExtendedAttributes)refExtendedAttributes.clone(); 91 return new XMLGroupPanel(this,new XMLElement[] {attrId,attrName,refDescription,refChoice,clonedEAs},toLabel()); 92 } 93 94 102 public String toString () { 103 String disp=attrName.toString(); 104 if (disp.trim().length()==0) { 105 disp=attrId.toString(); 106 } 107 return disp; 108 } 109 110 115 public Package getPackage() { 116 return myPackage; 117 } 118 119 public void fromXML(Node node) { 120 processAttributes(node); 121 122 String idPref=getID()+this.ID_DELIMITER+"For"; 124 FormalParameters fps=(FormalParameters)refChoice.getChoices()[0]; 125 fps.setIDPrefix(idPref); 126 127 processElements(node); 128 129 ((Applications)myCollection).updateID(getID()); 130 } 131 132 135 public boolean isIDUniqueAndValid (XMLPanel groupPanel) { 136 XMLTextPanel tp=(XMLTextPanel)((XMLGroupPanel)groupPanel).getPanel(0); 137 String IDToCheck=tp.getText(); 138 XMLComplexElement app=getCollection().getCollectionElement(IDToCheck); 140 boolean isOK=true; 141 String message=null; 142 String dialogTitle=null; 143 if (app!=null && app!=this) { 144 message=XMLUtil.getLanguageDependentString("ErrorIDMustBeUnique"); 145 dialogTitle=XMLUtil.getLanguageDependentString("DialogIDIsNotUnique"); 146 isOK=false; 147 } else if (!XMLCollection.isIdValid(IDToCheck)) { 148 message=XMLUtil.getLanguageDependentString("ErrorIDMustBeValid"); 149 dialogTitle=XMLUtil.getLanguageDependentString("DialogIDIsNotValid"); 150 isOK=false; 151 } 152 if (!isOK) { 153 XMLPanel.errorMessage(groupPanel.getDialog(),dialogTitle,"",message); 154 ((JTextField)tp.getComponent(2)).requestFocus(); 155 } 156 return isOK; 157 } 158 159 166 public boolean isValidEnter (XMLPanel groupPanel) { 167 if (clonedEAs!=null) { 168 complexStructure.remove(refExtendedAttributes); 169 refExtendedAttributes=clonedEAs; 170 complexStructure.add(4,refExtendedAttributes); 171 } 172 return true; 173 } 174 175 } 176 | Popular Tags |