1 28 29 package com.caucho.widget; 30 31 import com.caucho.util.L10N; 32 33 import java.io.IOException; 34 35 38 public class BoxWidget 39 extends XulWidgetContainer 40 { 41 private static final L10N L = new L10N(BoxWidget.class); 42 43 private Orient _orient = Orient.HORIZONTAL; 44 45 public BoxWidget() 46 { 47 } 48 49 public BoxWidget(String id) 50 { 51 setId(id); 52 } 53 54 public BoxWidget(String id, Orient orient) 55 { 56 setId(id); 57 setOrient(orient); 58 } 59 60 63 public void setOrient(Orient orient) 64 { 65 _orient = orient; 66 } 67 68 71 public void setOrient(String orient) 72 { 73 if ("horizontal".equals(orient)) 74 setOrient(Orient.HORIZONTAL); 75 else if ("vertical".equals(orient)) 76 setOrient(Orient.VERTICAL); 77 else 78 throw new IllegalArgumentException("" + orient); 79 } 80 81 public Orient getOrient() 82 { 83 return _orient; 84 } 85 86 public void init(WidgetInit init) 87 throws WidgetException 88 { 89 super.init(init); 90 } 91 92 public void response(WidgetResponse response) 93 throws WidgetException, IOException 94 { 95 Orient orient = getOrient(); 96 97 String id = getId(); 98 String cssClass = getCssClass(response); 99 100 WidgetWriter out = response.getWriter(); 101 102 out.startElement("div"); 103 out.writeAttribute("id", id); 104 105 String orientAttribute = orient == Orient.HORIZONTAL ? "horizontal" : "vertical"; 106 107 out.writeAttribute("class", cssClass, orientAttribute); 108 109 super.response(response); 110 111 out.endElement("div"); 112 } 113 } 114 | Popular Tags |