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 CmsIcon extends A_CmsWpElement { 56 57 74 75 public Object handleSpecialWorkplaceTag(CmsObject cms, Element n, A_CmsXmlContent doc, 76 Object callingObject, Hashtable parameters, CmsXmlLanguageFile lang) throws CmsException { 77 78 String iconName = n.getAttribute(CmsWorkplaceDefault.C_ICON_NAME); 80 String iconLabel = n.getAttribute(CmsWorkplaceDefault.C_ICON_LABEL); 81 String iconAction = n.getAttribute(CmsWorkplaceDefault.C_ICON_ACTION); 82 String iconHref = n.getAttribute(CmsWorkplaceDefault.C_ICON_HREF); 83 String iconTarget = n.getAttribute(CmsWorkplaceDefault.C_ICON_TARGET); 84 String iconActiveMethod = n.getAttribute(CmsWorkplaceDefault.C_ICON_ACTIVE_METHOD); 85 String iconVisibleMethod = n.getAttribute(CmsWorkplaceDefault.C_ICON_VISIBLE_METHOD); 86 if(iconHref == null || "".equals(iconHref)) { 87 iconHref = ""; 88 } 89 90 boolean activate = true; 92 if(iconActiveMethod != null && !"".equals(iconActiveMethod)) { 93 Method groupsMethod = null; 94 try { 95 groupsMethod = callingObject.getClass().getMethod(iconActiveMethod, 96 new Class [] { 97 CmsObject.class, CmsXmlLanguageFile.class, Hashtable .class 98 }); 99 activate = ((Boolean )groupsMethod.invoke(callingObject, new Object [] { 100 cms, lang, parameters 101 })).booleanValue(); 102 } 103 catch(NoSuchMethodException exc) { 104 105 throwException("Could not find icon activation method " + iconActiveMethod 107 + " in calling class " + callingObject.getClass().getName() 108 + " for generating icon.", CmsLegacyException.C_NOT_FOUND); 109 } 110 catch(InvocationTargetException targetEx) { 111 112 Throwable e = targetEx.getTargetException(); 115 if(!(e instanceof CmsException)) { 116 117 throwException("Icon activation method " + iconActiveMethod 118 + " in calling class " + callingObject.getClass().getName() 119 + " throwed an exception. " + e); 120 } 121 else { 122 123 throw (CmsException)e; 126 } 127 } 128 catch(Exception exc2) { 129 throwException("Icon activation method " + iconActiveMethod 130 + " in calling class " + callingObject.getClass().getName() 131 + " was found but could not be invoked. " + exc2); 132 } 133 } 134 135 boolean visible = true; 137 if(iconVisibleMethod != null && !"".equals(iconVisibleMethod)) { 138 Method groupsMethod = null; 139 try { 140 groupsMethod = callingObject.getClass().getMethod(iconVisibleMethod, new Class [] { 141 CmsObject.class, CmsXmlLanguageFile.class, Hashtable .class 142 }); 143 visible = ((Boolean )groupsMethod.invoke(callingObject, new Object [] { 144 cms, lang, parameters 145 })).booleanValue(); 146 } 147 catch(NoSuchMethodException exc) { 148 149 throwException("Could not find icon activation method " + iconVisibleMethod 151 + " in calling class " + callingObject.getClass().getName() 152 + " for generating icon.", CmsLegacyException.C_NOT_FOUND); 153 } 154 catch(InvocationTargetException targetEx) { 155 156 Throwable e = targetEx.getTargetException(); 159 if(!(e instanceof CmsException)) { 160 161 throwException("Icon activation method " + iconVisibleMethod 162 + " in calling class " + callingObject.getClass().getName() 163 + " throwed an exception. " + e); 164 } 165 else { 166 167 throw (CmsException)e; 170 } 171 } 172 catch(Exception exc2) { 173 throwException("Icon activation method " + iconVisibleMethod 174 + " in calling class " + callingObject.getClass().getName() 175 + " was found but could not be invoked. " + exc2); 176 } 177 } 178 179 CmsXmlWpTemplateFile icondef = getIconDefinitions(cms); 181 StringBuffer iconLabelBuffer = new StringBuffer (lang.getLanguageValue(CmsWorkplaceDefault.C_LANG_ICON + "." + iconLabel)); 182 183 if(iconLabelBuffer.toString().indexOf("- ") != -1) { 185 iconLabelBuffer.insert(iconLabelBuffer.toString().indexOf("- ") + 2, "<BR>"); 186 } 187 188 icondef.setData(CmsWorkplaceDefault.C_ICON_NAME, iconName); 190 icondef.setData(CmsWorkplaceDefault.C_ICON_LABEL, iconLabelBuffer.toString()); 191 icondef.setData(CmsWorkplaceDefault.C_ICON_ACTION, iconAction); 192 icondef.setData(CmsWorkplaceDefault.C_ICON_HREF, iconHref); 193 icondef.setData(CmsWorkplaceDefault.C_ICON_TARGET, iconTarget); 194 if(visible) { 195 if(activate) { 196 return icondef.getProcessedDataValue("defaulticon", callingObject); 197 } 198 else { 199 return icondef.getProcessedDataValue("deactivatedicon", callingObject); 200 } 201 } 202 else { 203 return icondef.getProcessedDataValue("noicon", callingObject); 204 } 205 } 206 } 207
| Popular Tags
|