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 import java.io.*; 18 import java.net.URL ; 19 20 25 public class ExternalPackage extends XMLComplexElement { 26 private ExtendedAttributes refExtendedAttributes=new ExtendedAttributes(this); 28 private XMLAttribute attrHref; 29 30 31 private ExtendedAttributes clonedEAs; 32 33 private ExternalPackages myOwner=null; 34 38 public ExternalPackage (ExternalPackages eps) { 39 super(); 40 41 myOwner=eps; 42 attrHref=new ExternalPackage.AttrHref("href"); 43 44 fillStructure(); 45 } 46 47 51 protected void fillStructure () { 52 super.fillStructure(); 53 54 attrHref.setRequired(true); 55 complexStructure.add(attrHref); 56 attributes.add(attrHref); 57 complexStructure.add(refExtendedAttributes); 58 } 59 60 public XMLPanel getPanel () { 61 if (attrHref!=null && attrHref.toString().trim().length()>0) { 62 attrHref.setReadOnly(true); 63 } 64 clonedEAs=(ExtendedAttributes)refExtendedAttributes.clone(); 65 return new XMLGroupPanel(this,new XMLElement[] {attrHref,clonedEAs},toLabel()); 66 } 67 68 75 public String toString () { 76 return attrHref.toString(); 77 } 78 79 public Package getMyPackage() { 80 return (Package )((ExternalPackages)myOwner).getOwner(); 81 } 82 83 public ExternalPackages getOwner () { 84 return myOwner; 85 } 86 87 94 public boolean isValidEnter (XMLPanel groupPanel) { 95 if (clonedEAs!=null) { 96 complexStructure.remove(refExtendedAttributes); 97 refExtendedAttributes=clonedEAs; 98 complexStructure.add(1,refExtendedAttributes); 99 } 100 return true; 101 } 102 103 public class AttrHref extends XMLAttribute { 104 AttrHref (String name) { 105 super(name); 106 } 107 108 public void setValue (Object v) { 109 try { 110 Path path=new Path(v.toString()); 111 String repBS=Path.getRelativePath( 112 path, 113 new Path(((Package )myOwner.getOwner()).getXMLInterface().getParentDirectory((Package )myOwner.getOwner()))); 114 value=XMLUtil.replaceBackslashesWithSlashes(repBS); 115 } catch (Exception ex2) { 116 value=v; 117 } 118 } 119 120 public void setPathDirectly (String path) { 121 value=XMLUtil.replaceBackslashesWithSlashes(path); 122 } 123 124 public XMLPanel getPanel () { 125 return new XMLLocationPanel(this,XMLPanel.BOX_LAYOUT,0); 126 } 127 } 128 129 } 130 | Popular Tags |