1 28 29 30 package com.opencms.workplace; 31 32 import org.opencms.file.CmsObject; 33 import org.opencms.main.CmsException; 34 35 import com.opencms.legacy.CmsLegacyException; 36 import com.opencms.template.A_CmsXmlContent; 37 38 import java.lang.reflect.InvocationTargetException ; 39 import java.lang.reflect.Method ; 40 import java.util.Hashtable ; 41 42 import org.w3c.dom.Element ; 43 44 54 55 public class CmsButton extends A_CmsWpElement { 56 57 75 76 public Object handleSpecialWorkplaceTag(CmsObject cms, Element n, A_CmsXmlContent doc, 77 Object callingObject, Hashtable parameters, CmsXmlLanguageFile lang) throws CmsException { 78 79 String buttonName = n.getAttribute(CmsWorkplaceDefault.C_BUTTON_NAME); 81 String buttonAction = n.getAttribute(CmsWorkplaceDefault.C_BUTTON_ACTION); 82 String buttonAlt = n.getAttribute(CmsWorkplaceDefault.C_BUTTON_ALT); 83 String buttonHref = n.getAttribute(CmsWorkplaceDefault.C_BUTTON_HREF); 84 String buttonMethod = n.getAttribute(CmsWorkplaceDefault.C_BUTTON_METHOD); 85 if(buttonHref == null || "".equals(buttonHref)) { 86 buttonHref = ""; 87 } 88 89 boolean activate = true; 91 if(buttonMethod != null && !"".equals(buttonMethod)) { 92 Method callMethod = null; 93 try { 94 callMethod = callingObject.getClass().getMethod(buttonMethod, new Class [] { 95 CmsObject.class, CmsXmlLanguageFile.class, Hashtable .class 96 }); 97 activate = ((Boolean )callMethod.invoke(callingObject, new Object [] { 98 cms, lang, parameters 99 })).booleanValue(); 100 } 101 catch(NoSuchMethodException exc) { 102 103 throwException("Could not find button activation method " + buttonMethod 105 + " in calling class " + callingObject.getClass().getName() 106 + " for generating icon.", CmsLegacyException.C_NOT_FOUND); 107 } 108 catch(InvocationTargetException targetEx) { 109 110 Throwable e = targetEx.getTargetException(); 113 if(!(e instanceof CmsException)) { 114 115 throwException("Button activation method " + buttonMethod 116 + " in calling class " + callingObject.getClass().getName() 117 + " throwed an exception. " + e); 118 } 119 else { 120 121 throw (CmsException)e; 124 } 125 } 126 catch(Exception exc2) { 127 throwException("Button activation method " + buttonMethod 128 + " in calling class " + callingObject.getClass().getName() 129 + " was found but could not be invoked. " + exc2); 130 } 131 } 132 133 CmsXmlWpButtonsDefFile buttondef = getButtonDefinitions(cms); 135 buttonAlt = lang.getLanguageValue(CmsWorkplaceDefault.C_LANG_BUTTON + "." + buttonAlt); 136 137 if(activate) { 139 return buttondef.getButton(buttonName, buttonAction, buttonAlt, buttonHref, 140 callingObject); 141 } 142 else { 143 return buttondef.getDeactivatedButton(buttonName, buttonAction, buttonAlt, 144 buttonHref, callingObject); 145 } 146 } 147 } 148 | Popular Tags |