| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
package org.itracker.web.taglib; |
| 20 |
|
|
| 21 |
|
import java.net.MalformedURLException; |
| 22 |
|
import java.util.Locale; |
| 23 |
|
|
| 24 |
|
import javax.servlet.http.HttpSession; |
| 25 |
|
import javax.servlet.jsp.JspException; |
| 26 |
|
import javax.servlet.jsp.tagext.TagSupport; |
| 27 |
|
|
| 28 |
|
import org.apache.struts.taglib.TagUtils; |
| 29 |
|
import org.itracker.core.resources.ITrackerResources; |
| 30 |
|
import org.itracker.model.UserPreferences; |
| 31 |
|
import org.itracker.services.util.HTMLUtilities; |
| 32 |
|
import org.itracker.web.util.Constants; |
| 33 |
|
|
|
|
|
| 0% |
Uncovered Elements: 148 (148) |
Complexity: 40 |
Complexity Density: 0.47 |
|
| 34 |
|
public final class FormatImageActionTag extends TagSupport { |
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
private static final long serialVersionUID = 1L; |
| 39 |
|
|
| 40 |
|
private String action = null; |
| 41 |
|
private String forward = null; |
| 42 |
|
private String module = null; |
| 43 |
|
private String paramName = null; |
| 44 |
|
private String paramValue = null; |
| 45 |
|
private String src = null; |
| 46 |
|
private String altKey = null; |
| 47 |
|
private String arg0 = null; |
| 48 |
|
private String textActionKey = null; |
| 49 |
|
private String border = null; |
| 50 |
|
private String caller = null; |
| 51 |
|
private String targetAction = null; |
| 52 |
|
private String target = null; |
| 53 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 54 |
0
|
public String getAction() {... |
| 55 |
0
|
return action; |
| 56 |
|
} |
| 57 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 58 |
0
|
public void setAction(String value) {... |
| 59 |
0
|
action = value; |
| 60 |
|
} |
| 61 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 62 |
0
|
public String getForward() {... |
| 63 |
0
|
return forward; |
| 64 |
|
} |
| 65 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 66 |
0
|
public void setForward(String value) {... |
| 67 |
0
|
forward = value; |
| 68 |
|
} |
| 69 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 70 |
0
|
public String getModule() {... |
| 71 |
0
|
return module; |
| 72 |
|
} |
| 73 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 74 |
0
|
public void setModule(String module) {... |
| 75 |
0
|
this.module = module; |
| 76 |
|
} |
| 77 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 78 |
0
|
public String getParamName() {... |
| 79 |
0
|
return paramName; |
| 80 |
|
} |
| 81 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 82 |
0
|
public void setParamName(String value) {... |
| 83 |
0
|
paramName = value; |
| 84 |
|
} |
| 85 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 86 |
0
|
public Object getParamValue() {... |
| 87 |
0
|
return paramValue; |
| 88 |
|
} |
| 89 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 1 |
|
| 90 |
0
|
public void setParamValue(Object value) {... |
| 91 |
0
|
paramValue = (value != null ? value.toString() : null); |
| 92 |
|
} |
| 93 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 94 |
0
|
public String getSrc() {... |
| 95 |
0
|
return src; |
| 96 |
|
} |
| 97 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 98 |
0
|
public void setSrc(String value) {... |
| 99 |
0
|
src = value; |
| 100 |
|
} |
| 101 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 102 |
0
|
public String getAltKey() {... |
| 103 |
0
|
return altKey; |
| 104 |
|
} |
| 105 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 106 |
0
|
public void setAltKey(String value) {... |
| 107 |
0
|
altKey = value; |
| 108 |
|
} |
| 109 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 110 |
0
|
public Object getArg0() {... |
| 111 |
0
|
return arg0; |
| 112 |
|
} |
| 113 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 1 |
|
| 114 |
0
|
public void setArg0(Object value) {... |
| 115 |
0
|
arg0 = (value != null ? value.toString() : null); |
| 116 |
|
} |
| 117 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 118 |
0
|
public String getTextActionKey() {... |
| 119 |
0
|
return textActionKey; |
| 120 |
|
} |
| 121 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 122 |
0
|
public void setTextActionKey(String value) {... |
| 123 |
0
|
textActionKey = value; |
| 124 |
|
} |
| 125 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 126 |
0
|
public String getBorder() {... |
| 127 |
0
|
return border; |
| 128 |
|
} |
| 129 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 130 |
0
|
public void setBorder(String value) {... |
| 131 |
0
|
border = value; |
| 132 |
|
} |
| 133 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 134 |
0
|
public String getCaller() {... |
| 135 |
0
|
return caller; |
| 136 |
|
} |
| 137 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 138 |
0
|
public void setCaller(String value) {... |
| 139 |
0
|
caller = value; |
| 140 |
|
} |
| 141 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 142 |
0
|
public String getTargetAction() {... |
| 143 |
0
|
return targetAction; |
| 144 |
|
} |
| 145 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 146 |
0
|
public void setTargetAction(String value) {... |
| 147 |
0
|
targetAction = value; |
| 148 |
|
} |
| 149 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 150 |
0
|
public String getTarget() {... |
| 151 |
0
|
return target; |
| 152 |
|
} |
| 153 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 154 |
0
|
public void setTarget(String value) {... |
| 155 |
0
|
target = value; |
| 156 |
|
} |
| 157 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 158 |
0
|
public int doStartTag() throws JspException {... |
| 159 |
0
|
return SKIP_BODY; |
| 160 |
|
} |
| 161 |
|
|
|
|
|
| 0% |
Uncovered Elements: 72 (72) |
Complexity: 11 |
Complexity Density: 0.25 |
|
| 162 |
0
|
public int doEndTag() throws JspException {... |
| 163 |
0
|
boolean hasParams = false; |
| 164 |
0
|
boolean useTextActions = false; |
| 165 |
0
|
Locale locale = null; |
| 166 |
|
|
| 167 |
0
|
HttpSession session = pageContext.getSession(); |
| 168 |
0
|
if (session != null) { |
| 169 |
0
|
locale = (Locale) session.getAttribute(Constants.LOCALE_KEY); |
| 170 |
0
|
UserPreferences currUserPrefs = (UserPreferences) session |
| 171 |
|
.getAttribute(Constants.PREFERENCES_KEY); |
| 172 |
0
|
useTextActions = (currUserPrefs != null ? currUserPrefs |
| 173 |
|
.getUseTextActions() : false); |
| 174 |
|
} |
| 175 |
|
|
| 176 |
0
|
StringBuffer buf = new StringBuffer("<a href=\""); |
| 177 |
0
|
try { |
| 178 |
0
|
buf.append(TagUtils.getInstance().computeURL(pageContext, forward, |
| 179 |
|
null, null, action, module, null, null, false)); |
| 180 |
|
} catch (MalformedURLException murle) { |
| 181 |
0
|
buf.append(HTMLUtilities.escapeTags(forward)); |
| 182 |
|
} |
| 183 |
0
|
if (paramName != null && paramValue != null) { |
| 184 |
0
|
buf.append("?" + paramName + "=" + paramValue); |
| 185 |
0
|
hasParams = true; |
| 186 |
|
} |
| 187 |
0
|
if (caller != null) { |
| 188 |
0
|
buf.append((hasParams ? "&" : "?") + "caller=" + HTMLUtilities.escapeTags(caller)); |
| 189 |
0
|
hasParams = true; |
| 190 |
|
} |
| 191 |
0
|
if (targetAction != null) { |
| 192 |
0
|
buf.append((hasParams ? "&" : "?") + "action=" + HTMLUtilities.escapeTags(targetAction)); |
| 193 |
0
|
hasParams = true; |
| 194 |
|
} |
| 195 |
0
|
buf.append("\""); |
| 196 |
0
|
if (target != null) { |
| 197 |
0
|
buf.append(" target=\"" + target + "\""); |
| 198 |
|
} |
| 199 |
0
|
if (useTextActions) { |
| 200 |
0
|
buf.append(" title=\"" |
| 201 |
|
+ ITrackerResources.getString(altKey, locale, |
| 202 |
0
|
(arg0 == null ? "" : arg0)) + "\""); |
| 203 |
0
|
buf.append(" class=\"action\">"); |
| 204 |
0
|
buf.append(ITrackerResources.getString(textActionKey, locale)); |
| 205 |
|
} else { |
| 206 |
0
|
buf.append(">"); |
| 207 |
0
|
buf.append("<img src=\""); |
| 208 |
0
|
try { |
| 209 |
0
|
buf.append(TagUtils.getInstance().computeURL(pageContext, null, |
| 210 |
|
null, src, null, "", null, null, false)); |
| 211 |
|
|
| 212 |
|
} catch (MalformedURLException murle) { |
| 213 |
0
|
buf.append(HTMLUtilities.escapeTags(src)); |
| 214 |
|
} |
| 215 |
0
|
buf.append("\""); |
| 216 |
0
|
if (altKey != null) { |
| 217 |
0
|
buf.append(" alt=\"" |
| 218 |
|
+ ITrackerResources.getString(altKey, locale, |
| 219 |
0
|
(arg0 == null ? "" : arg0)) + "\""); |
| 220 |
0
|
buf.append(" title=\"" |
| 221 |
|
+ ITrackerResources.getString(altKey, locale, |
| 222 |
0
|
(arg0 == null ? "" : arg0)) + "\""); |
| 223 |
|
} else { |
| 224 |
0
|
buf.append(" alt=\"\""); |
| 225 |
|
} |
| 226 |
0
|
buf.append(" style=\"border:" |
| 227 |
0
|
+ (border == null ? "0" : border + "px") + ";\""); |
| 228 |
0
|
buf.append(" />"); |
| 229 |
|
} |
| 230 |
0
|
buf.append("</a>"); |
| 231 |
|
|
| 232 |
0
|
TagUtils.getInstance().write(pageContext, buf.toString()); |
| 233 |
0
|
clearState(); |
| 234 |
0
|
return (EVAL_PAGE); |
| 235 |
|
} |
| 236 |
|
|
| 237 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 238 |
0
|
public void release() {... |
| 239 |
0
|
super.release(); |
| 240 |
0
|
clearState(); |
| 241 |
|
} |
| 242 |
|
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
|
| 243 |
0
|
private void clearState() {... |
| 244 |
0
|
action = null; |
| 245 |
0
|
forward = null; |
| 246 |
0
|
paramName = null; |
| 247 |
0
|
paramValue = null; |
| 248 |
0
|
src = null; |
| 249 |
0
|
altKey = null; |
| 250 |
0
|
arg0 = null; |
| 251 |
0
|
textActionKey = null; |
| 252 |
0
|
border = null; |
| 253 |
0
|
caller = null; |
| 254 |
0
|
target = null; |
| 255 |
0
|
targetAction = null; |
| 256 |
0
|
module = null; |
| 257 |
|
} |
| 258 |
|
} |