1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.icon; |
21 |
|
|
22 |
|
import java.util.List; |
23 |
|
|
24 |
|
import javax.inject.Inject; |
25 |
|
import javax.inject.Named; |
26 |
|
import javax.inject.Singleton; |
27 |
|
|
28 |
|
import org.xwiki.component.annotation.Component; |
29 |
|
import org.xwiki.context.Execution; |
30 |
|
import org.xwiki.script.service.ScriptService; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@since |
36 |
|
@version |
37 |
|
|
38 |
|
@Component |
39 |
|
@Named("icon") |
40 |
|
@Singleton |
|
|
| 20.7% |
Uncovered Elements: 46 (58) |
Complexity: 23 |
Complexity Density: 0.52 |
|
41 |
|
public class IconManagerScriptService implements ScriptService |
42 |
|
{ |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
private static final String ERROR_KEY = "scriptservice.icon.error"; |
47 |
|
|
48 |
|
@Inject |
49 |
|
private IconManager iconManager; |
50 |
|
|
51 |
|
@Inject |
52 |
|
private IconSetManager iconSetManager; |
53 |
|
|
54 |
|
@Inject |
55 |
|
private Execution execution; |
56 |
|
|
57 |
|
|
58 |
|
@link |
59 |
|
@param |
60 |
|
@return |
61 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
62 |
123 |
public String render(String iconName)... |
63 |
|
{ |
64 |
123 |
try { |
65 |
123 |
return iconManager.render(iconName); |
66 |
|
} catch (IconException e) { |
67 |
0 |
setLastError(e); |
68 |
0 |
return null; |
69 |
|
} |
70 |
|
} |
71 |
|
|
72 |
|
|
73 |
|
@link |
74 |
|
@param |
75 |
|
@param |
76 |
|
@return |
77 |
|
@since |
78 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
79 |
18 |
public String render(String iconName, String iconSetName)... |
80 |
|
{ |
81 |
18 |
try { |
82 |
18 |
return iconManager.render(iconName, iconSetName); |
83 |
|
} catch (IconException e) { |
84 |
0 |
setLastError(e); |
85 |
0 |
return null; |
86 |
|
} |
87 |
|
} |
88 |
|
|
89 |
|
|
90 |
|
@link |
91 |
|
@param |
92 |
|
@param |
93 |
|
@param |
94 |
|
@return |
95 |
|
@since |
96 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
97 |
0 |
public String render(String iconName, String iconSetName, boolean fallback)... |
98 |
|
{ |
99 |
0 |
try { |
100 |
0 |
return iconManager.render(iconName, iconSetName, fallback); |
101 |
|
} catch (IconException e) { |
102 |
0 |
setLastError(e); |
103 |
0 |
return null; |
104 |
|
} |
105 |
|
} |
106 |
|
|
107 |
|
|
108 |
|
@link |
109 |
|
@param |
110 |
|
@return |
111 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
112 |
2531 |
public String renderHTML(String iconName)... |
113 |
|
{ |
114 |
2530 |
try { |
115 |
2531 |
return iconManager.renderHTML(iconName); |
116 |
|
} catch (IconException e) { |
117 |
0 |
setLastError(e); |
118 |
0 |
return null; |
119 |
|
} |
120 |
|
} |
121 |
|
|
122 |
|
|
123 |
|
@link |
124 |
|
@param |
125 |
|
@param |
126 |
|
@return |
127 |
|
@since |
128 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
129 |
0 |
public String renderHTML(String iconName, String iconSetName)... |
130 |
|
{ |
131 |
0 |
try { |
132 |
0 |
return iconManager.renderHTML(iconName, iconSetName); |
133 |
|
} catch (IconException e) { |
134 |
0 |
setLastError(e); |
135 |
0 |
return null; |
136 |
|
} |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
|
@link |
141 |
|
@param |
142 |
|
@param |
143 |
|
@param |
144 |
|
@return |
145 |
|
@since |
146 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
147 |
0 |
public String renderHTML(String iconName, String iconSetName, boolean fallback)... |
148 |
|
{ |
149 |
0 |
try { |
150 |
0 |
return iconManager.renderHTML(iconName, iconSetName, fallback); |
151 |
|
} catch (IconException e) { |
152 |
0 |
setLastError(e); |
153 |
0 |
return null; |
154 |
|
} |
155 |
|
} |
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
@return |
160 |
|
@since |
161 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
162 |
9 |
public List<String> getIconSetNames()... |
163 |
|
{ |
164 |
9 |
try { |
165 |
9 |
return iconSetManager.getIconSetNames(); |
166 |
|
} catch (IconException e) { |
167 |
0 |
setLastError(e); |
168 |
0 |
return null; |
169 |
|
} |
170 |
|
} |
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
@return |
175 |
|
@since |
176 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
177 |
0 |
public List<String> getIconNames()... |
178 |
|
{ |
179 |
0 |
try { |
180 |
0 |
return iconManager.getIconNames(); |
181 |
|
} catch (IconException e) { |
182 |
0 |
setLastError(e); |
183 |
0 |
return null; |
184 |
|
} |
185 |
|
} |
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
@param |
190 |
|
@return |
191 |
|
@since |
192 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
193 |
0 |
public List<String> getIconNames(String iconSetName)... |
194 |
|
{ |
195 |
0 |
try { |
196 |
0 |
return iconManager.getIconNames(iconSetName); |
197 |
|
} catch (IconException e) { |
198 |
0 |
setLastError(e); |
199 |
0 |
return null; |
200 |
|
} |
201 |
|
} |
202 |
|
|
203 |
|
|
204 |
|
|
205 |
|
@return |
206 |
|
@since |
207 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
208 |
0 |
public String getCurrentIconSetName()... |
209 |
|
{ |
210 |
0 |
try { |
211 |
0 |
IconSet currentIconSet = iconSetManager.getCurrentIconSet(); |
212 |
0 |
if (currentIconSet != null) { |
213 |
0 |
return currentIconSet.getName(); |
214 |
|
} |
215 |
|
} catch (IconException e) { |
216 |
0 |
setLastError(e); |
217 |
|
} |
218 |
|
|
219 |
0 |
return null; |
220 |
|
} |
221 |
|
|
222 |
|
|
223 |
|
|
224 |
|
@return |
225 |
|
@since |
226 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
227 |
0 |
public IconException getLastError()... |
228 |
|
{ |
229 |
0 |
return (IconException) this.execution.getContext().getProperty(ERROR_KEY); |
230 |
|
} |
231 |
|
|
232 |
|
|
233 |
|
@link |
234 |
|
|
235 |
|
@param |
236 |
|
@see |
237 |
|
@since |
238 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
239 |
0 |
private void setLastError(IconException e)... |
240 |
|
{ |
241 |
0 |
this.execution.getContext().setProperty(ERROR_KEY, e); |
242 |
|
} |
243 |
|
} |