1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.icon.internal; |
21 |
|
|
22 |
|
import java.util.List; |
23 |
|
|
24 |
|
import javax.inject.Inject; |
25 |
|
import javax.inject.Singleton; |
26 |
|
|
27 |
|
import org.xwiki.component.annotation.Component; |
28 |
|
import org.xwiki.icon.IconException; |
29 |
|
import org.xwiki.icon.IconManager; |
30 |
|
import org.xwiki.icon.IconRenderer; |
31 |
|
import org.xwiki.icon.IconSet; |
32 |
|
import org.xwiki.icon.IconSetManager; |
33 |
|
|
34 |
|
|
35 |
|
@link |
36 |
|
|
37 |
|
@since |
38 |
|
@version |
39 |
|
|
40 |
|
@Component |
41 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (40) |
Complexity: 17 |
Complexity Density: 0.77 |
|
42 |
|
public class DefaultIconManager implements IconManager |
43 |
|
{ |
44 |
|
@Inject |
45 |
|
private IconSetManager iconSetManager; |
46 |
|
|
47 |
|
@Inject |
48 |
|
private IconRenderer iconRenderer; |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
50 |
125 |
@Override... |
51 |
|
public String render(String iconName) throws IconException |
52 |
|
{ |
53 |
125 |
return iconRenderer.render(iconName, getIconSet(iconName)); |
54 |
|
} |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
56 |
21 |
@Override... |
57 |
|
public String render(String iconName, String iconSetName) throws IconException |
58 |
|
{ |
59 |
21 |
return this.render(iconName, iconSetName, true); |
60 |
|
} |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
62 |
27 |
@Override... |
63 |
|
public String render(String iconName, String iconSetName, boolean fallback) throws IconException |
64 |
|
{ |
65 |
27 |
IconSet iconSet = getIconSet(iconName, iconSetName, fallback); |
66 |
27 |
if (iconSet == null) { |
67 |
1 |
return ""; |
68 |
|
} |
69 |
26 |
return iconRenderer.render(iconName, iconSet); |
70 |
|
} |
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
72 |
2533 |
@Override... |
73 |
|
public String renderHTML(String iconName) throws IconException |
74 |
|
{ |
75 |
2533 |
return iconRenderer.renderHTML(iconName, getIconSet(iconName)); |
76 |
|
} |
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
78 |
3 |
@Override... |
79 |
|
public String renderHTML(String iconName, String iconSetName) throws IconException |
80 |
|
{ |
81 |
3 |
return this.renderHTML(iconName, iconSetName, true); |
82 |
|
} |
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
84 |
9 |
@Override... |
85 |
|
public String renderHTML(String iconName, String iconSetName, boolean fallback) throws IconException |
86 |
|
{ |
87 |
9 |
IconSet iconSet = getIconSet(iconName, iconSetName, fallback); |
88 |
9 |
if (iconSet == null) { |
89 |
1 |
return ""; |
90 |
|
} |
91 |
8 |
return iconRenderer.renderHTML(iconName, iconSet); |
92 |
|
} |
93 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
94 |
1 |
@Override... |
95 |
|
public List<String> getIconNames() throws IconException |
96 |
|
{ |
97 |
1 |
return iconSetManager.getCurrentIconSet().getIconNames(); |
98 |
|
} |
99 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
100 |
1 |
@Override... |
101 |
|
public List<String> getIconNames(String iconSetName) throws IconException |
102 |
|
{ |
103 |
1 |
return iconSetManager.getIconSet(iconSetName).getIconNames(); |
104 |
|
} |
105 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
106 |
2657 |
private IconSet getIconSet(String iconName) throws IconException... |
107 |
|
{ |
108 |
|
|
109 |
2657 |
IconSet currentIconSet = iconSetManager.getCurrentIconSet(); |
110 |
2658 |
if (currentIconSet != null && currentIconSet.getIcon(iconName) != null) { |
111 |
2 |
return currentIconSet; |
112 |
|
} |
113 |
|
|
114 |
|
|
115 |
2655 |
return iconSetManager.getDefaultIconSet(); |
116 |
|
} |
117 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 4 |
Complexity Density: 1 |
|
118 |
36 |
private IconSet getIconSet(String iconName, String iconSetName, boolean fallback) throws IconException... |
119 |
|
{ |
120 |
|
|
121 |
36 |
IconSet iconSet = iconSetManager.getIconSet(iconSetName); |
122 |
|
|
123 |
|
|
124 |
36 |
if ((iconSet == null || iconSet.getIcon(iconName) == null) && fallback) { |
125 |
8 |
return iconSetManager.getDefaultIconSet(); |
126 |
|
} |
127 |
|
|
128 |
|
|
129 |
28 |
return iconSet; |
130 |
|
} |
131 |
|
} |