1 31 32 package org.opencms.workplace.list; 33 34 import org.opencms.i18n.CmsMessageContainer; 35 import org.opencms.jsp.CmsJspActionElement; 36 import org.opencms.util.CmsStringUtil; 37 import org.opencms.workplace.CmsWorkplace; 38 39 import java.io.File ; 40 41 50 public class CmsListResourceTypeIconAction extends CmsListExplorerDirectAction { 51 52 58 public CmsListResourceTypeIconAction(String id, A_CmsListExplorerDialog wp) { 59 60 super(id, wp); 61 } 62 63 66 public CmsMessageContainer getHelpText() { 67 68 if (super.getHelpText() == null || super.getHelpText().equals(EMPTY_MESSAGE)) { 69 return Messages.get().container(Messages.GUI_EXPLORER_LIST_ACTION_RES_HELP_0); 70 } 71 return super.getHelpText(); 72 } 73 74 77 public String getIconPath() { 78 79 return getResourceUtil().getIconPathExplorer(); 80 } 81 82 85 public CmsMessageContainer getName() { 86 87 if (super.getName() == null) { 88 return new CmsMessageContainer(null, getResourceUtil().getResourceTypeName()); 89 } 90 return super.getName(); 91 } 92 93 96 protected String defButtonHtml( 97 CmsJspActionElement jsp, 98 String id, 99 String helpId, 100 String name, 101 String helpText, 102 boolean enabled, 103 String iconPath, 104 String confirmationMessage, 105 String onClick, 106 boolean singleHelp) { 107 108 StringBuffer html = new StringBuffer (1024); 109 html.append("\t<span class=\"link"); 110 if (enabled) { 111 html.append("\""); 112 } else { 113 html.append(" linkdisabled\""); 114 } 115 if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(helpText)) { 116 if (!singleHelp) { 117 html.append(" onMouseOver=\"sMH('"); 118 html.append(id); 119 html.append("');\" onMouseOut=\"hMH('"); 120 html.append(id); 121 html.append("');\""); 122 } else { 123 html.append(" onMouseOver=\"sMHS('"); 124 html.append(id); 125 html.append("', '"); 126 html.append(helpId); 127 html.append("');\" onMouseOut=\"hMH('"); 128 html.append(id); 129 html.append("', '"); 130 html.append(helpId); 131 html.append("');\""); 132 } 133 } 134 if (enabled && CmsStringUtil.isNotEmptyOrWhitespaceOnly(onClick)) { 135 html.append(" onClick=\""); 136 if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(confirmationMessage)) { 137 html.append("if (confirm('" + CmsStringUtil.escapeJavaScript(confirmationMessage) + "')) {"); 138 } 139 html.append(onClick); 140 if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(confirmationMessage)) { 141 html.append(" }"); 142 } 143 html.append("\""); 144 } 145 html.append(" title='"); 146 html.append(name); 147 html.append("'"); 148 html.append(" style='display: block; width: 20px; height: 20px;'>"); 149 if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(iconPath)) { 150 html.append("<img SRC='"); 151 html.append(CmsWorkplace.getSkinUri()); 152 if (!enabled) { 153 StringBuffer icon = new StringBuffer (128); 154 icon.append(iconPath.substring(0, iconPath.lastIndexOf('.'))); 155 icon.append("_disabled"); 156 icon.append(iconPath.substring(iconPath.lastIndexOf('.'))); 157 if (jsp != null) { 158 String resorcesRoot = jsp.getJspContext().getServletConfig().getServletContext().getRealPath( 159 "/resources/"); 160 File test = new File (resorcesRoot + "/" + icon.toString()); 161 if (test.exists()) { 162 html.append(icon); 163 } else { 164 html.append(iconPath); 165 } 166 } else { 167 html.append(iconPath); 168 } 169 } else { 170 html.append(iconPath); 171 } 172 html.append("'"); 173 if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(name)) { 174 html.append(" alt='"); 175 html.append(name); 176 html.append("'"); 177 html.append(" title='"); 178 html.append(name); 179 html.append("'"); 180 } 181 html.append(" style='width: 16px; height: 16px;"); 182 if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(getResourceUtil().getStyleSiblings())) { 183 html.append(getResourceUtil().getStyleSiblings()); 184 } 185 html.append("' >"); 186 } 187 html.append("</span>\n"); 188 if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(helpText) && !singleHelp) { 189 html.append("<div class='help' id='help"); 190 html.append(helpId); 191 html.append("' onMouseOver=\"sMH('"); 192 html.append(id); 193 html.append("');\" onMouseOut=\"hMH('"); 194 html.append(id); 195 html.append("');\">"); 196 html.append(helpText); 197 html.append("</div>\n"); 198 } 199 return html.toString(); 200 } 201 } 202 | Popular Tags |