1 18 19 package org.objectweb.jac.aspects.gui.web; 20 21 22 import java.io.IOException ; 23 import java.io.PrintWriter ; 24 import java.util.Collection ; 25 import java.util.Hashtable ; 26 import java.util.Iterator ; 27 import java.util.Map ; 28 import java.util.Vector ; 29 import org.objectweb.jac.aspects.gui.*; 30 import org.objectweb.jac.util.ExtArrays; 31 32 public class Panel extends AbstractCompositeView 33 implements PanelView, HTMLViewer 34 { 35 36 int geometry; 37 int subPanesCount; 38 boolean[] scrollings; 39 40 Vector subPanes = new Vector (); 41 Map splitterLocations; 42 Map paneContainers; 43 44 public Panel(ViewFactory factory, 45 int subPanesCount, int geometry, 46 Map paneContainers, 47 boolean[] scrollings, Map splitterLocations) { 48 this.factory = factory; 49 this.geometry = geometry; 50 this.subPanesCount = subPanesCount; 51 this.scrollings = scrollings; 52 this.paneContainers = paneContainers; 53 this.splitterLocations=splitterLocations; 54 construct(); 55 } 56 57 protected void construct() 58 { 59 subPanes.clear(); 60 components.clear(); 61 Vector subScrollPanes = new Vector (); 62 for(int i=0;i<subPanesCount;i++) { 63 CompositeView subPane; 64 if (paneContainers.containsKey(Integer.toString(i))) { 65 subPane = factory.createCompositeView( 66 "subpane["+i+"]",(String )paneContainers.get(Integer.toString(i)), 67 new Object [] {}, 68 context); 69 } else { 70 subPane = 71 factory.createCompositeView("subpane["+i+"]","SingleSlotContainer", 72 ExtArrays.emptyObjectArray, 73 context); 74 } 75 subPanes.add(subPane); 76 add(subPane); 77 89 } 90 } 91 92 public void setSplitterLocation(int splitId, float location) { 93 if (splitterLocations==null) 94 splitterLocations = new Hashtable (); 95 splitterLocations.put(new Integer (splitId),new Float (location)); 96 } 97 98 101 protected float getSplitterLocation(int splitId) { 102 if (splitterLocations==null) { 103 return 50; 104 } else { 105 Float value = (Float )splitterLocations.get(new Integer (splitId)); 106 if (value!=null) 107 return value.floatValue()*100; 108 else 109 return 50; 110 } 111 } 112 113 119 120 public void addView(View component, Object extraInfo) { 121 int i=new Integer ((String )extraInfo).intValue(); 122 CompositeView subPane=(CompositeView)subPanes.get(i); 123 subPane.addView(component); 124 } 125 126 public Collection getViews() { 127 return subPanes; 128 } 129 130 public View getView(Object id) { 131 return (View)subPanes.get(Integer.parseInt((String )id)); 132 } 133 134 public void close(boolean validate) { 135 Iterator it = subPanes.iterator(); 136 while(it.hasNext()) { 137 View sp = (View)it.next(); 138 sp.close(validate); 139 } 140 } 141 142 public void removeAllViews() { 143 } 145 146 148 public void genHTML(PrintWriter out) throws IOException { 149 switch(subPanesCount) { 150 case 1: 151 out.println("<div class=\""+getClass().getName()+"\" id=\""+label+"\">"); 152 ((HTMLViewer)components.get(0)).genHTML(out); 154 out.println("</div>"); 155 break; 156 case 2: 157 if (geometry==Constants.HORIZONTAL) { 158 out.println("<table style=\"width:100%;height:100%\">"+ 159 "<tr class=\"up\" style=\"height:"+ 160 (100-getSplitterLocation(0))+"%\"><td>"); 161 ((HTMLViewer)components.get(0)).genHTML(out); 162 out.println("</td></tr>"); 163 out.println("<tr class=\"down\" height=\""+ 164 getSplitterLocation(0)+"%\"><td>"); 165 ((HTMLViewer)components.get(1)).genHTML(out); 166 out.println("</td></tr></table>"); 167 } else { 168 out.println("<table style=\"width:100%;height:100%\">"+ 169 "<tr><td class=\"left\" width=\""+ 170 getSplitterLocation(0)+"%\">"); 171 ((HTMLViewer)components.get(0)).genHTML(out); 172 out.println("</td>"); 173 out.println("<td class=\"right\" width=\""+ 174 (100-getSplitterLocation(0))+"%\">"); 175 ((HTMLViewer)components.get(1)).genHTML(out); 176 out.println("</td></tr></table"); 177 } 178 break; 179 case 3: 180 if (geometry<Constants.VERTICAL) { 181 if (geometry==Constants.HORIZONTAL_UP) { 182 out.println("<div class=\"upper\" style=\"bottom:"+ 183 (100-getSplitterLocation(0))+"%\">"); 184 out.println("<div class=\"left\" style=\"right:"+ 185 (100-getSplitterLocation(1))+"%\">"); 186 ((HTMLViewer)components.get(0)).genHTML(out); 187 out.println("</div>"); 188 out.println("<div class=\"right\" style=\"left:"+ 189 getSplitterLocation(1)+"%\">"); 190 ((HTMLViewer)components.get(1)).genHTML(out); 191 out.println("</div>"); 192 out.println("</div>"); 193 out.println("<div class=\"lower\" style=\"top:"+ 194 getSplitterLocation(0)+"%\">"); 195 ((HTMLViewer)components.get(2)).genHTML(out); 196 out.println("</div>"); 197 } else { 198 out.println("<div class=\"upper\" style=\"bottom:"+ 199 (100-getSplitterLocation(0))+"%\">"); 200 ((HTMLViewer)components.get(2)).genHTML(out); 201 out.println("</div>"); 202 out.println("<div class=\"lower\" style=\"top:"+ 203 getSplitterLocation(0)+"%\">"); 204 out.println("<div class=\"left\" style=\"right:"+ 205 (100-getSplitterLocation(1))+"%\">"); 206 ((HTMLViewer)components.get(0)).genHTML(out); 207 out.println("</div>"); 208 out.println("<div class=\"right\" style=\"left:"+ 209 getSplitterLocation(1)+"%\">"); 210 ((HTMLViewer)components.get(1)).genHTML(out); 211 out.println("</div>"); 212 out.println("</div>"); 213 } 214 } else { 215 if (geometry==Constants.VERTICAL_LEFT) { 216 out.println("<div class=\"left\" style=\"right:"+ 217 (100-getSplitterLocation(0))+"%\">"); 218 out.println("<div class=\"upper\" style=\"bottom:"+ 219 (100-getSplitterLocation(1))+"%\">"); 220 ((HTMLViewer)components.get(0)).genHTML(out); 221 out.println("</div>"); 222 out.println("<div class=\"lower\" style=\"top:"+ 223 getSplitterLocation(1)+"%\">"); 224 ((HTMLViewer)components.get(1)).genHTML(out); 225 out.println("</div>"); 226 out.println("</div>"); 227 out.println("<div class=\"right\" style=\"left:"+ 228 getSplitterLocation(0)+"%\">"); 229 ((HTMLViewer)components.get(2)).genHTML(out); 230 out.println("</div>"); 231 } else { 232 out.println("<div class=\"left\" style=\"right:"+ 233 (100-getSplitterLocation(0))+"%\">"); 234 ((HTMLViewer)components.get(2)).genHTML(out); 235 out.println("</div>"); 236 out.println("<div class=\"right\" style=\"left:"+ 237 getSplitterLocation(0)+"%\">"); 238 out.println("<div class=\"upper\" style=\"bottom:"+ 239 (100-getSplitterLocation(1))+"%\">"); 240 ((HTMLViewer)components.get(0)).genHTML(out); 241 out.println("</div>"); 242 out.println("<div class=\"lower\" style=\"top:"+ 243 getSplitterLocation(1)+"%\">"); 244 ((HTMLViewer)components.get(1)).genHTML(out); 245 out.println("</div>"); 246 out.println("</div>"); 247 } 248 } 249 break; 250 case 4: 251 if (geometry==Constants.VERTICAL) { 252 out.println("<div class=\"left\" style=\"right:"+ 253 (100-getSplitterLocation(0))+"%\">"); 254 out.println("<div class=\"upper\" style=\"bottom:"+ 255 (100-getSplitterLocation(1))+"%\">"); 256 ((HTMLViewer)components.get(0)).genHTML(out); 257 out.println("</div>"); 258 out.println("<div class=\"lower\" style=\"top:"+ 259 getSplitterLocation(1)+"%\">"); 260 ((HTMLViewer)components.get(1)).genHTML(out); 261 out.println("</div>"); 262 out.println("</div>"); 263 out.println("<div class=\"right\" style=\"left:"+ 264 getSplitterLocation(0)+"%\">"); 265 out.println("<div class=\"upper\" style=\"bottom:"+ 266 (100-getSplitterLocation(2))+"%\">"); 267 ((HTMLViewer)components.get(2)).genHTML(out); 268 out.println("</div>"); 269 out.println("<div class=\"lower\" style=\"top:"+ 270 getSplitterLocation(2)+"%\">"); 271 ((HTMLViewer)components.get(3)).genHTML(out); 272 out.println("</div>"); 273 out.println("</div>"); 274 } else { 275 out.println("<div class=\"upper\" style=\"bottom:"+ 276 (100-getSplitterLocation(0))+"%\">"); 277 out.println("<div class=\"left\" style=\"right:"+ 278 (100-getSplitterLocation(1))+"%\">"); 279 ((HTMLViewer)components.get(0)).genHTML(out); 280 out.println("</div>"); 281 out.println("<div class=\"right\" style=\"left:"+ 282 getSplitterLocation(1)+"%\">"); 283 ((HTMLViewer)components.get(1)).genHTML(out); 284 out.println("</div>"); 285 out.println("</div>"); 286 out.println("<div class=\"lower\" style=\"top:"+ 287 getSplitterLocation(0)+"%\">"); 288 out.println("<div class=\"left\" style=\"right:"+ 289 (100-getSplitterLocation(2))+"%\">"); 290 ((HTMLViewer)components.get(2)).genHTML(out); 291 out.println("</div>"); 292 out.println("<div class=\"right\" style=\"left:"+ 293 getSplitterLocation(2)+"%\">"); 294 ((HTMLViewer)components.get(3)).genHTML(out); 295 out.println("</div>"); 296 out.println("</div>"); 297 } 298 break; 299 } 300 } 301 } 302 | Popular Tags |