1 13 package info.magnolia.cms.gui.control; 14 15 import info.magnolia.cms.gui.misc.CssConstants; 16 17 import java.util.Hashtable ; 18 import java.util.Map ; 19 20 import javax.servlet.http.HttpServletRequest ; 21 22 import org.apache.commons.lang.StringUtils; 23 import org.apache.log4j.Logger; 24 25 26 30 public class TreeColumn extends ControlSuper { 31 32 public static final String EDIT_CSSCLASS_EDIT = CssConstants.CSSCLASS_EDIT; 33 34 public static final String EDIT_CSSCLASS_SELECT = CssConstants.CSSCLASS_SELECT; 35 36 public static final String EDIT_NAMEADDITION = "_EditNodeData"; 38 public static final String EDIT_JSSAVE = ".saveNodeData(this.value);"; 40 public static final String EMPTY = "-"; 42 45 private static Logger log = Logger.getLogger(TreeColumn.class); 46 47 boolean isMeta; 48 49 boolean isLabel; 50 51 boolean isIcons; 52 53 boolean iconsActivation; 54 55 boolean iconsPermission; 56 57 boolean isNodeDataValue; 58 59 boolean isNodeDataType; 60 61 String dateFormat; 62 63 String title = StringUtils.EMPTY; 64 65 boolean permissionWrite; 66 67 String htmlEdit = StringUtils.EMPTY; 68 69 TreeColumnHtmlRenderer htmlRenderer; 70 71 private String javascriptTree = StringUtils.EMPTY; 72 73 private int width = 1; 74 75 private Map keyValue = new Hashtable (); 78 79 84 public TreeColumn(String javascriptTree, HttpServletRequest request) { 85 this.setJavascriptTree(javascriptTree); 86 this.setCssClass("mgnlTreeText"); this.setRequest(request); 88 this.setHtmlRenderer(new TreeColumnHtmlRendererImpl()); 90 } 91 92 public void setIsMeta(boolean b) { 93 this.isMeta = b; 94 } 95 96 public boolean getIsMeta() { 97 return this.isMeta; 98 } 99 100 public void setIsIcons(boolean b) { 101 this.isIcons = b; 102 } 103 104 public boolean getIsIcons() { 105 return this.isIcons; 106 } 107 108 public void setIconsActivation(boolean b) { 109 this.iconsActivation = b; 110 } 111 112 public boolean getIconsActivation() { 113 return this.iconsActivation; 114 } 115 116 public void setIconsPermission(boolean b) { 117 this.iconsPermission = b; 118 } 119 120 public boolean getIconsPermission() { 121 return this.iconsPermission; 122 } 123 124 public void setIsLabel(boolean b) { 125 this.isLabel = b; 126 } 127 128 public boolean getIsLabel() { 129 return this.isLabel; 130 } 131 132 public void setIsNodeDataValue(boolean b) { 133 this.isNodeDataValue = b; 134 } 135 136 public boolean getIsNodeDataValue() { 137 return this.isNodeDataValue; 138 } 139 140 public void setIsNodeDataType(boolean b) { 141 this.isNodeDataType = b; 142 } 143 144 public boolean getIsNodeDataType() { 145 return this.isNodeDataType; 146 } 147 148 public void setDateFormat(String s) { 149 this.dateFormat = s; 150 } 151 152 public String getDateFormat() { 153 return this.dateFormat; 154 } 155 156 public void setTitle(String s) { 157 this.title = s; 158 } 159 160 public String getTitle() { 161 return this.title; 162 } 163 164 169 public void setWidth(int i) { 170 this.width = i; 171 } 172 173 public int getWidth() { 174 return this.width; 175 } 176 177 public void setPermissionWrite(boolean b) { 178 this.permissionWrite = b; 179 } 180 181 public boolean getPermissionWrite() { 182 return this.permissionWrite; 183 } 184 185 191 public void setJavascriptTree(String variableName) { 192 this.javascriptTree = variableName; 193 } 194 195 public String getJavascriptTree() { 196 return this.javascriptTree; 197 } 198 199 public void setKeyValue(Map h) { 200 this.keyValue = h; 201 } 202 203 public Map getKeyValue() { 204 return this.keyValue; 205 } 206 207 public String getKeyValue(String key) { 208 return (String ) this.getKeyValue().get(key); 209 } 210 211 public void addKeyValue(String key, String value) { 212 this.getKeyValue().put(key, value); 213 } 214 215 public void setHtmlEdit(String s) { 216 this.htmlEdit = s; 217 } 218 219 public String getHtmlEdit() { 220 return this.htmlEdit; 221 } 222 223 public void setHtmlEdit() { 224 Edit edit = new Edit(); 225 edit.setName(this.getJavascriptTree() + EDIT_NAMEADDITION); 226 edit.setSaveInfo(false); 227 edit.setCssClass(EDIT_CSSCLASS_EDIT); 228 edit.setEvent("onkeydown", this.getJavascriptTree() + ".editNodeDataKeydown(event,this);"); edit.setEvent("onblur", this.getJavascriptTree() + EDIT_JSSAVE); this.setHtmlEdit(edit.getHtml()); 232 } 233 234 public String getHtml() { 235 String html = null; 236 try { 237 html = htmlRenderer.renderHtml(this, this.getWebsiteNode()); 238 } 239 catch (Exception e) { 240 log.error(e.getMessage(), e); 241 } 242 if (StringUtils.isEmpty(html)) { 244 html = TreeColumn.EMPTY; 245 } 246 return html; 247 } 248 249 252 public TreeColumnHtmlRenderer getHtmlRenderer() { 253 return htmlRenderer; 254 } 255 256 259 public void setHtmlRenderer(TreeColumnHtmlRenderer htmlRenderer) { 260 this.htmlRenderer = htmlRenderer; 261 } 262 } 263 | Popular Tags |