1 33 34 package com.icesoft.faces.component.panelpositioned; 35 36 import com.icesoft.faces.component.CSS_DEFAULT; 37 import com.icesoft.faces.component.dragdrop.DndEvent; 38 import com.icesoft.faces.component.ext.taglib.Util; 39 import com.icesoft.faces.component.panelseries.UISeries; 40 import com.icesoft.faces.context.effects.JavascriptContext; 41 42 import javax.faces.context.FacesContext; 43 import javax.faces.el.MethodBinding; 44 import javax.faces.el.ValueBinding; 45 import javax.faces.event.AbortProcessingException; 46 import javax.faces.event.FacesEvent; 47 import javax.faces.event.PhaseId; 48 49 52 public class PanelPositioned extends UISeries { 53 54 public static final String COMPONENET_TYPE = 55 "com.icesoft.faces.dragdrop.PanelPositioned"; 56 public static final String DEFAULT_RENDERER_TYPE = 57 "com.icesoft.faces.dragdrop.PanelPositionedRenderer"; 58 public static final String COMPONENT_FAMILY = 59 "com.icesoft.faces.dragdrop.PanelPositionedFamily"; 60 61 private String styleClass; 62 private String style; 63 private MethodBinding listener; 64 private String overlap; 65 private String constraint; 66 private String handle; 67 private String hoverclass; 68 69 70 71 public PanelPositioned() { 72 super(); 73 setRendererType(DEFAULT_RENDERER_TYPE); 74 JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS, 75 FacesContext.getCurrentInstance()); 76 } 77 78 public String getFamily() { 79 return COMPONENT_FAMILY; 80 } 81 82 83 public String getRendererType() { 84 return DEFAULT_RENDERER_TYPE; 85 } 86 87 public String getStyleClass() { 88 return Util.getQualifiedStyleClass(this, 89 styleClass, 90 CSS_DEFAULT.POSITIONED_PANEL_DEFAULT_CLASS, 91 "styleClass"); 92 } 93 94 public void setStyleClass(String styleClass) { 95 this.styleClass = styleClass; 96 } 97 98 public String getStyle() { 99 if (style != null) { 100 return style; 101 } 102 ValueBinding vb = getValueBinding("style"); 103 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 104 } 105 106 public void setStyle(String style) { 107 this.style = style; 108 } 109 110 public MethodBinding getListener() { 111 return listener; 112 } 113 114 public void setListener(MethodBinding listener) { 115 this.listener = listener; 116 } 117 118 public String getOverlap() { 119 if (overlap != null) { 120 return overlap; 121 } 122 ValueBinding vb = getValueBinding("overlap"); 123 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 124 } 125 126 132 public void setOverlap(String overlap) { 133 this.overlap = overlap; 134 } 135 136 public String getConstraint() { 137 if (constraint != null) { 138 return constraint; 139 } 140 ValueBinding vb = getValueBinding("constraint"); 141 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 142 } 143 144 150 public void setConstraint(String constraint) { 151 this.constraint = constraint; 152 } 153 154 public String getHandle() { 155 if (handle != null) { 156 return handle; 157 } 158 ValueBinding vb = getValueBinding("handle"); 159 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 160 } 161 162 169 public void setHandle(String handle) { 170 this.handle = handle; 171 } 172 173 public String getHoverclass() { 174 if (hoverclass != null) { 175 return hoverclass; 176 } 177 ValueBinding vb = getValueBinding("hoverclass"); 178 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 179 } 180 181 187 public void setHoverclass(String hoverclass) { 188 this.hoverclass = hoverclass; 189 } 190 191 192 public void broadcast(FacesEvent event) 193 throws AbortProcessingException { 194 195 196 if (event instanceof PanelPositionedEvent) { 197 try { 198 199 PanelPositionedEvent de = (PanelPositionedEvent) event; 200 de.process(); MethodBinding mb = de.getListener(); 202 Object [] oa = {de}; 203 mb.invoke(FacesContext.getCurrentInstance(), oa); 204 } catch (Exception e) { 205 e.printStackTrace(); 206 } 207 } 208 super.broadcast(event); 209 } 210 211 214 public void queueEvent(FacesEvent event) { 215 if (event instanceof DndEvent) { 216 217 event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES); 218 } 219 super.queueEvent(event); 220 } 221 222 public Object saveState(FacesContext context) { 223 Object [] values = new Object [4]; 224 values[0] = super.saveState(context); 225 values[1] = styleClass; 226 values[2] = style; 227 values[3] = listener; 228 return values; 229 } 230 231 public void restoreState(FacesContext context, Object stateIn) { 232 Object [] state = (Object []) stateIn; 233 super.restoreState(context, state[0]); 234 styleClass = (String ) state[1]; 235 style = (String ) state[2]; 236 listener = (MethodBinding) state[3]; 237 } 238 239 240 } 241 | Popular Tags |