1 10 11 package org.enhydra.jawe.xml.elements; 12 13 import javax.swing.*; 14 15 import org.enhydra.jawe.xml.*; 16 import org.enhydra.jawe.xml.panels.*; 17 18 21 public class Namespace extends XMLComplexElement { 22 private XMLAttribute attrName=new XMLAttribute("Name"); private XMLAttribute attrLocation=new XMLAttribute("location"); 25 28 public Namespace () { 29 super(); 30 31 fillStructure (); 32 } 33 34 38 protected void fillStructure () { 39 attrName.setRequired(true); 40 attrLocation.setRequired(true); 41 complexStructure.add(attrName); 42 attributes.add(attrName); 43 complexStructure.add(attrLocation); 44 attributes.add(attrLocation); 45 } 46 47 53 public XMLPanel getPanel () { 54 return new XMLGroupPanel (this,new XMLElement[] {attrName,attrLocation},toLabel()); 55 } 56 57 public String toString () { 58 String toRet=XMLUtil.getLanguageDependentString("NameKey")+"="+attrName.toString()+", "+ 59 XMLUtil.getLanguageDependentString("locationKey")+"="+attrLocation.toString(); 60 if (toRet==null) { 61 return ""; 62 } else { 63 return toRet; 64 } 65 } 66 67 74 public Object clone () { 75 Namespace ns=(Namespace)super.clone(); 76 ns.attrName=(XMLAttribute)this.attrName.clone(); 77 ns.attrLocation=(XMLAttribute)this.attrLocation.clone(); 78 ns.fillStructure(); 79 return ns; 80 } 81 82 85 public boolean isValidEnter (XMLPanel p) { 86 XMLGroupPanel gp=(XMLGroupPanel)p; 87 try { 88 XMLTextPanel tp=(XMLTextPanel)gp.getPanel(0); 89 String nameToCheck=tp.getText(); 90 if (!XMLCollection.isIdValid(nameToCheck)) { 91 String message=XMLUtil.getLanguageDependentString("ErrorValueIsNotValid"); 92 String dialogTitle=XMLUtil.getLanguageDependentString("Title"); 93 XMLPanel.errorMessage(p.getDialog(),dialogTitle,attrName.toLabel()+": ",message); 94 ((JTextField)tp.getComponent(2)).requestFocus(); 95 return false; 96 } 97 } catch (Exception ex){} 98 99 return true; 100 } 101 102 } 103 | Popular Tags |