1 10 11 12 package org.enhydra.jawe.xml; 13 14 import org.enhydra.jawe.xml.panels.*; 15 16 import org.w3c.dom.*; 17 18 21 public class XMLComplexChoice extends XMLChoice { 22 23 private boolean isComboPanel; 24 25 private boolean isVertical; 26 27 private boolean isChoiceVertical; 28 29 private boolean hasBorder; 30 31 private boolean hasTitle; 32 33 45 public XMLComplexChoice (String name,XMLElement[] choices,int choosenIndex) { 46 this(name,choices,choosenIndex,true); 47 } 48 49 64 public XMLComplexChoice (String name,XMLElement[] choices,int choosenIndex, 65 boolean isComboPanel) { 66 67 this(name,choices,choosenIndex,isComboPanel,true,false,true,true); 68 } 69 70 92 public XMLComplexChoice (String name,XMLElement[] choices,int choosenIndex, 93 boolean isComboPanel,boolean isVertical, boolean isChoiceVertical, 94 boolean hasBorder,boolean hasTitle) { 95 96 super(name,choices,choosenIndex); 97 this.isComboPanel=isComboPanel; 98 this.isVertical=isVertical; 99 this.isChoiceVertical=isChoiceVertical; 100 this.hasBorder=hasBorder; 101 this.hasTitle=hasTitle; 102 } 103 104 110 public boolean isEmpty () { 111 if (choices==null) { 112 return true; 113 } else { 114 if (choosen!=null) { 115 return false; 116 } else { 117 return true; 118 } 119 } 120 } 121 122 public void toXML(Node parent) throws DOMException { 123 if (choosen!=null) { 126 ((XMLElement)choosen).toXML(parent); 127 } 128 } 129 130 public void fromXML(String choosenName,Node node) { 131 if (choices!=null) { 133 for (int i=0; i<choices.length; i++) { 136 if (((XMLElement)choices[i]).name.equals(choosenName)) { 137 setValue(choices[i]); 138 ((XMLElement)choices[i]).fromXML(node); 139 break; 140 } 141 } 142 } 143 } 144 145 public XMLPanel getPanel () { 146 if (isComboPanel) { 147 return new XMLComboChoicePanel(this,(hasTitle) ? toLabel():"", 148 XMLPanel.BOX_LAYOUT,isVertical,isChoiceVertical,hasBorder); 149 } 150 else { 151 return new XMLRadioChoicePanel(this,(hasTitle) ? toLabel():"", 152 XMLPanel.BOX_LAYOUT,isVertical,isChoiceVertical,hasBorder); 153 } 154 } 155 156 public Object clone () { 157 XMLComplexChoice d=(XMLComplexChoice)super.clone(); 158 d.isComboPanel=this.isComboPanel; 159 d.isVertical=this.isVertical; 160 d.isChoiceVertical=this.isChoiceVertical; 161 d.hasBorder=this.hasBorder; 162 d.hasTitle=this.hasTitle; 163 return d; 164 } 165 166 } 167 168 | Popular Tags |