1 package discRack.presentation.delements; 2 3 import discRack.presentation.dpanels.*; 4 5 import java.util.*; 6 7 14 public class DComplexElement extends DSimpleElement { 15 16 protected java.util.List complexStructure=new ArrayList(); 17 18 public DComplexElement (String name) { 19 super(name); 20 } 21 22 25 public Collection toComplexType() { 26 return complexStructure; 27 } 28 29 33 public Collection toComplexTypeValues () { 34 java.util.List l=new ArrayList(); 35 Iterator it=complexStructure.iterator(); 36 while (it.hasNext()) { 37 DSimpleElement el=(DSimpleElement)it.next(); 38 l.add(el.toValue()); 39 } 40 return l; 41 } 42 43 47 public void setReadOnly (boolean ro) { 48 super.setReadOnly(ro); 49 Iterator it=complexStructure.iterator(); 50 while (it.hasNext()) { 51 DSimpleElement el=(DSimpleElement)it.next(); 52 el.setReadOnly(ro); 53 } 54 } 55 56 public boolean isEmpty () { 57 boolean isEmpty=true; 58 Iterator it=complexStructure.iterator(); 59 while (it.hasNext()) { 60 DSimpleElement el=(DSimpleElement)it.next(); 61 isEmpty=isEmpty && el.isEmpty(); 62 } 63 return isEmpty; 64 } 65 66 public boolean isValid () { 67 boolean isValid=true; 68 Iterator it=complexStructure.iterator(); 69 while (it.hasNext()) { 70 DSimpleElement el=(DSimpleElement)it.next(); 71 isValid=isValid && el.isValid(); 72 } 73 return isValid; 74 } 75 76 public DPanel getPanel () { 77 DSimpleElement[] c=new DSimpleElement[complexStructure.size()]; 78 complexStructure.toArray(c); 79 return new DGroupPanel(this,c,toName(),true,true); 80 } 81 82 83 public DSimpleElement get (int no) { 84 try { 85 return (DSimpleElement)complexStructure.get(no); 86 } catch (Exception ex) { 87 return null; 88 } 89 } 90 91 95 public void set (int no,Object value) { 96 DSimpleElement el; 97 try { 98 el=get(no); 99 } catch (Exception ex) { 100 el=null; 101 } 102 if (el != null) { 103 el.setValue(value); 104 } 105 } 106 107 108 109 public DSimpleElement get (String name) { 110 Iterator it=complexStructure.iterator(); 111 while (it.hasNext()) { 112 DSimpleElement el=(DSimpleElement)it.next(); 113 if (el.name.equals(name)) { 114 return el; 115 } 116 } 117 return null; 118 } 119 120 124 public void set (String name,Object value) { 125 DSimpleElement el=get(name); 126 if (el != null) { 127 el.setValue(value); 128 } 129 } 130 131 public String toString () { 132 return name; 133 } 134 135 protected void fillStructure () { 136 return; 137 } 138 139 } | Popular Tags |