1 17 package org.alfresco.web.ui.common.component; 18 19 import javax.faces.component.UICommand; 20 import javax.faces.component.UIComponent; 21 import javax.faces.context.FacesContext; 22 import javax.faces.el.ValueBinding; 23 import javax.faces.event.AbortProcessingException; 24 import javax.faces.event.ActionEvent; 25 import javax.faces.event.FacesEvent; 26 27 30 public class UIModeList extends UICommand 31 { 32 35 38 public UIModeList() 39 { 40 setRendererType("org.alfresco.faces.ModeListRenderer"); 41 } 42 43 44 47 50 public String getFamily() 51 { 52 return "org.alfresco.faces.Controls"; 53 } 54 55 58 public void restoreState(FacesContext context, Object state) 59 { 60 Object values[] = (Object [])state; 61 super.restoreState(context, values[0]); 63 this.iconColumnWidth = (Integer )values[1]; 64 this.horizontal = (Boolean )values[2]; 65 this.disabled = (Boolean )values[3]; 66 this.label = (String )values[4]; 67 this.menu = (Boolean )values[5]; 68 this.menuImage = (String )values[6]; 69 } 70 71 74 public Object saveState(FacesContext context) 75 { 76 Object values[] = new Object [7]; 77 values[0] = super.saveState(context); 79 values[1] = this.iconColumnWidth; 80 values[2] = this.horizontal; 81 values[3] = this.disabled; 82 values[4] = this.label; 83 values[5] = this.menu; 84 values[6] = this.menuImage; 85 return (values); 86 } 87 88 91 public void broadcast(FacesEvent event) throws AbortProcessingException 92 { 93 if (event instanceof ModeListItemSelectedEvent) 94 { 95 setValue( ((ModeListItemSelectedEvent)event).SelectedValue ); 97 } 98 99 super.broadcast(event); 101 } 102 103 104 107 112 public boolean isHorizontal() 113 { 114 ValueBinding vb = getValueBinding("horizontal"); 115 if (vb != null) 116 { 117 this.horizontal = (Boolean )vb.getValue(getFacesContext()); 118 } 119 120 if (this.horizontal != null) 121 { 122 return this.horizontal.booleanValue(); 123 } 124 else 125 { 126 return false; 128 } 129 } 130 131 136 public void setHorizontal(boolean horizontal) 137 { 138 this.horizontal = horizontal; 139 } 140 141 146 public int getIconColumnWidth() 147 { 148 ValueBinding vb = getValueBinding("iconColumnWidth"); 149 if (vb != null) 150 { 151 this.iconColumnWidth = (Integer )vb.getValue(getFacesContext()); 152 } 153 154 if (this.iconColumnWidth != null) 155 { 156 return this.iconColumnWidth.intValue(); 157 } 158 else 159 { 160 return 20; 162 } 163 } 164 165 170 public void setIconColumnWidth(int iconColumnWidth) 171 { 172 this.iconColumnWidth = Integer.valueOf(iconColumnWidth); 173 } 174 175 180 public boolean isDisabled() 181 { 182 ValueBinding vb = getValueBinding("disabled"); 183 if (vb != null) 184 { 185 this.disabled = (Boolean )vb.getValue(getFacesContext()); 186 } 187 188 if (this.disabled != null) 189 { 190 return this.disabled.booleanValue(); 191 } 192 else 193 { 194 return false; 196 } 197 } 198 199 204 public void setDisabled(boolean disabled) 205 { 206 this.disabled = disabled; 207 } 208 209 214 public boolean isMenu() 215 { 216 ValueBinding vb = getValueBinding("menu"); 217 if (vb != null) 218 { 219 this.menu = (Boolean )vb.getValue(getFacesContext()); 220 } 221 222 if (this.menu != null) 223 { 224 return this.menu.booleanValue(); 225 } 226 else 227 { 228 return false; 230 } 231 } 232 233 238 public void setMenu(boolean menu) 239 { 240 this.menu = menu; 241 } 242 243 246 public String getLabel() 247 { 248 ValueBinding vb = getValueBinding("label"); 249 if (vb != null) 250 { 251 this.label = (String )vb.getValue(getFacesContext()); 252 } 253 254 return this.label; 255 } 256 257 260 public void setLabel(String label) 261 { 262 this.label = label; 263 } 264 265 268 public String getMenuImage() 269 { 270 ValueBinding vb = getValueBinding("menuImage"); 271 if (vb != null) 272 { 273 this.menuImage = (String )vb.getValue(getFacesContext()); 274 } 275 276 return this.menuImage; 277 } 278 279 282 public void setMenuImage(String menuImage) 283 { 284 this.menuImage = menuImage; 285 } 286 287 288 291 292 private Integer iconColumnWidth; 293 294 295 private Boolean horizontal = null; 296 297 298 private Boolean disabled = null; 299 300 301 private Boolean menu = null; 302 303 304 private String menuImage = null; 305 306 307 private String label; 308 309 310 313 316 public static class ModeListItemSelectedEvent extends ActionEvent 317 { 318 private static final long serialVersionUID = 3618135654274774322L; 319 320 public ModeListItemSelectedEvent(UIComponent component, Object selectedValue) 321 { 322 super(component); 323 SelectedValue = selectedValue; 324 } 325 326 public Object SelectedValue = null; 327 } 328 } 329 | Popular Tags |