1 28 29 30 package com.opencms.workplace; 31 32 import org.opencms.file.CmsFile; 33 import org.opencms.file.CmsObject; 34 import org.opencms.main.CmsException; 35 import org.opencms.main.CmsLog; 36 37 import com.opencms.template.CmsTemplateClassManager; 38 import com.opencms.template.CmsXmlTemplateFile; 39 40 import java.util.Hashtable ; 41 42 import org.w3c.dom.Element ; 43 44 53 54 public class CmsXmlWpTemplateFile extends CmsXmlTemplateFile { 55 56 private Hashtable m_wpTags = new Hashtable (); 57 58 59 private CmsXmlLanguageFile m_languageFile = null; 60 61 64 public CmsXmlWpTemplateFile() throws CmsException { 65 super(); 66 registerMyTags(); 67 } 68 69 76 public CmsXmlWpTemplateFile(CmsObject cms, CmsFile file) throws CmsException { 77 super(); 78 registerMyTags(); 79 init(cms, file); 80 } 81 82 89 public CmsXmlWpTemplateFile(CmsObject cms, String filename) throws CmsException { 90 super(); 91 registerMyTags(); 92 init(cms, filename); 93 } 94 95 98 public void clearStartup() { 99 setData(CmsWorkplaceDefault.C_TAG_STARTUP, ""); 100 } 101 102 118 public void fastSetXmlData(String tag, String data) { 119 fastSetData(tag, data); 120 } 121 122 126 public CmsXmlLanguageFile getLanguageFile() { 127 return m_languageFile; 128 } 129 130 139 public String getProcessedXmlDataValue(String tag) throws CmsException { 140 return getProcessedDataValue(tag); 141 } 142 143 153 public String getProcessedXmlDataValue(String tag, Object callingObject) throws CmsException { 154 return getProcessedDataValue(tag, callingObject); 155 } 156 157 171 public String getProcessedXmlDataValue(String tag, Object callingObject, 172 Object userObj) throws CmsException { 173 return getProcessedDataValue(tag, callingObject, userObj); 174 } 175 176 185 public String getXmlDataValue(String tag) throws CmsException { 186 return getDataValue(tag); 187 } 188 189 193 public String getXmlDocumentTagName() { 194 return "WORKPLACE"; 195 } 196 197 211 public Object handleAnyTag(Element n, Object callingObject, Object userObj) throws CmsException { 212 Object result = null; 213 I_CmsWpElement workplaceObject = null; 214 String tagname = n.getTagName().toLowerCase(); 215 String classname = null; 216 classname = (String )m_wpTags.get(tagname); 217 if(classname == null || "".equals(classname)) { 218 throwException("Don't know which class handles " + tagname + " tags."); 219 } 220 Object loadedClass = CmsTemplateClassManager.getClassInstance(classname); 221 if(!(loadedClass instanceof I_CmsWpElement)) { 222 throwException("Loaded class " + classname + " is not implementing I_CmsWpElement"); 223 } 224 processNode(n, m_mainProcessTags, null, callingObject, userObj); 225 workplaceObject = (I_CmsWpElement)loadedClass; 226 try { 227 result = workplaceObject.handleSpecialWorkplaceTag(m_cms, n, this, callingObject, 228 (Hashtable )userObj, m_languageFile); 229 }catch(Exception e) { 230 String errorMessage = "Error while building workplace element \"" + tagname + "\": " + e; 231 if(e instanceof CmsException) { 232 if(CmsLog.getLog(this).isWarnEnabled()) { 233 CmsLog.getLog(this).warn(errorMessage, e); 234 } 235 throw (CmsException)e; 236 }else { 237 throwException(errorMessage, e); 238 } 239 } 240 return result; 241 } 242 243 249 250 public boolean hasXmlData(String tag) throws CmsException { 251 return hasData(tag); 252 } 253 254 262 public void init(CmsObject cms, CmsFile file) throws CmsException { 263 m_languageFile = new CmsXmlLanguageFile(cms); 264 String encoding = m_languageFile.getEncoding(); 265 if (encoding != null) { 266 cms.getRequestContext().setEncoding(encoding); 267 } 268 super.init(cms, file); 269 } 270 271 279 public void init(CmsObject cms, String filename) throws CmsException { 280 m_languageFile = new CmsXmlLanguageFile(cms); 281 String encoding = m_languageFile.getEncoding(); 282 if (encoding != null) { 283 cms.getRequestContext().setEncoding(encoding); 284 } 285 super.init(cms, filename); 286 } 287 288 292 293 private void registerMyTags() { 294 registerTag("BUTTON", "com.opencms.workplace.CmsButton"); 295 registerTag("ICON", "com.opencms.workplace.CmsIcon"); 296 registerTag("BUTTONSEPARATOR", "com.opencms.workplace.CmsButtonSeparator"); 297 298 registerTag("ERRORPAGE", "com.opencms.workplace.CmsErrorpage"); 300 registerTag("FILELIST", "com.opencms.workplace.CmsFileList"); 301 registerTag("FILETYPELIST", "com.opencms.workplace.CmsFileTypeList"); 302 registerTag("INPUTFIELD", "com.opencms.workplace.CmsInput"); 303 registerTag("JAVASCRIPTBUTTON", "com.opencms.workplace.CmsButtonJavascript"); 304 registerTag("LABEL", "com.opencms.workplace.CmsLabel"); 305 registerTag("PASSWORD", "com.opencms.workplace.CmsInputPassword"); 306 registerTag("SUBMITBUTTON", "com.opencms.workplace.CmsButtonSubmit"); 307 registerTag("TEXTBUTTON", "com.opencms.workplace.CmsButtonText"); 308 registerTag("SELECT", "com.opencms.workplace.CmsSelectBox"); 309 registerTag("PROJECTLIST", "com.opencms.workplace.CmsProjectlist"); 310 registerTag("PROJECTHISTORY", "com.opencms.workplace.CmsProjecthistory"); 311 registerTag("MODULELIST", "com.opencms.workplace.CmsModulelist"); 312 registerTag("CONTEXTMENUE", "com.opencms.workplace.CmsContextmenue"); 313 registerTag("MESSAGEBOX", "com.opencms.workplace.CmsMessagebox"); 314 registerTag("RADIOBUTTON", "com.opencms.workplace.CmsRadioButtons"); 315 registerTag("PANELBAR", "com.opencms.workplace.CmsPanel"); 316 registerTag("TASKLIST", "com.opencms.workplace.CmsTaskList"); 317 registerTag("TASKDOCU", "com.opencms.workplace.CmsTaskDocu"); 318 registerTag("PREFSSCROLLER", "com.opencms.workplace.CmsPrefsScroller"); 319 registerTag("BACKBUTTON", "com.opencms.workplace.CmsBackbutton"); 320 registerTag("ELEMENT", CmsXmlTemplateFile.class, "handleElementTag", C_REGISTER_MAIN_RUN); 322 } 323 324 338 private void registerTag(String tagname, String elementClassName) { 339 super.registerTag(tagname, CmsXmlWpTemplateFile.class, "handleAnyTag", C_REGISTER_MAIN_RUN); 340 m_wpTags.put(tagname.toLowerCase(), elementClassName); 341 } 342 343 349 public void removeXmlData(String tag) { 350 removeData(tag); 351 } 352 353 361 public void setXmlData(String tag, String data) { 362 setData(tag, data); 363 } 364 } 365
| Popular Tags
|