1 20 package org.enhydra.barracuda.core.comp; 21 22 import java.util.*; 23 24 import org.apache.log4j.*; 25 import org.w3c.dom.*; 26 import org.w3c.dom.html.*; 27 28 import org.enhydra.barracuda.core.comp.renderer.*; 29 import org.enhydra.barracuda.core.comp.renderer.html.*; 30 import org.enhydra.barracuda.core.comp.renderer.xml.*; 31 import org.enhydra.barracuda.core.util.dom.DOMUtil; 32 import org.enhydra.barracuda.core.view.*; 33 import org.enhydra.barracuda.plankton.*; 34 35 47 public class BToggleButton extends BInput { 48 49 protected static final Logger logger = Logger.getLogger(BToggleButton.class.getName()); 51 52 protected boolean selected = false; 54 55 59 public BToggleButton() {} 60 61 67 71 88 public BToggleButton(String itype, String iname, String ivalue, boolean iselected) { 89 this (itype, iname, ivalue, iselected, null, null); 90 } 91 92 113 BToggleButton(String itype, String iname, String ivalue, boolean iselected, View iview, ViewContext idvc) { 114 if (idvc!=null) setDefaultViewContext(idvc); 115 if (itype!=null) setType(itype); 116 if (iname!=null) setName(iname); 117 if (ivalue!=null) setValue(ivalue); 118 setSelected(iselected); 119 if (iview!=null) setView(iview); 120 } 121 122 123 124 125 129 static { 130 HTMLRendererFactory rfHTML = new HTMLRendererFactory(); 131 installRendererFactory(rfHTML, BToggleButton.class, HTMLElement.class); 132 installRendererFactory(rfHTML, BToggleButton.class, HTMLDocument.class); 133 134 } 135 136 139 static class HTMLRendererFactory implements RendererFactory { 140 public Renderer getInstance() {return new HTMLToggleRenderer();} 141 } 142 143 144 145 146 155 public void setType(String itype) { 156 itype = itype.toLowerCase(); 157 if (itype!=null && !itype.equals(RADIO) && !itype.equals(CHECKBOX)) { 158 itype = CHECKBOX; 159 } 160 super.setType(itype); 161 } 162 163 168 public void setSelected(boolean iselected) { 169 selected = iselected; 170 invalidate(); 171 } 172 173 178 public boolean isSelected() { 179 return selected; 180 } 181 182 190 206 } | Popular Tags |