1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.edit; |
21 |
|
|
22 |
|
import javax.inject.Inject; |
23 |
|
|
24 |
|
import org.apache.commons.lang3.StringUtils; |
25 |
|
import org.xwiki.component.annotation.Component; |
26 |
|
import org.xwiki.component.annotation.InstantiationStrategy; |
27 |
|
import org.xwiki.component.descriptor.ComponentInstantiationStrategy; |
28 |
|
import org.xwiki.edit.internal.DefaultEditorDescriptor; |
29 |
|
import org.xwiki.localization.ContextualLocalizationManager; |
30 |
|
import org.xwiki.stability.Unstable; |
31 |
|
|
32 |
|
|
33 |
|
@link |
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
38 |
|
@Component(roles = EditorDescriptorBuilder.class) |
39 |
|
@InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP) |
40 |
|
@Unstable |
|
|
| 51.2% |
Uncovered Elements: 21 (43) |
Complexity: 15 |
Complexity Density: 0.62 |
|
41 |
|
public class EditorDescriptorBuilder implements EditorDescriptor |
42 |
|
{ |
43 |
|
private String id; |
44 |
|
|
45 |
|
private String name; |
46 |
|
|
47 |
|
private String description; |
48 |
|
|
49 |
|
private String icon; |
50 |
|
|
51 |
|
private String category; |
52 |
|
|
53 |
|
@Inject |
54 |
|
private ContextualLocalizationManager localization; |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
@param |
60 |
|
@return |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
62 |
35 |
public EditorDescriptorBuilder setId(String id)... |
63 |
|
{ |
64 |
35 |
this.id = id; |
65 |
35 |
return this; |
66 |
|
} |
67 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
68 |
0 |
@Override... |
69 |
|
public String getId() |
70 |
|
{ |
71 |
0 |
return this.id; |
72 |
|
} |
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
@param |
78 |
|
@return |
79 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
80 |
0 |
public EditorDescriptorBuilder setName(String name)... |
81 |
|
{ |
82 |
0 |
this.name = name; |
83 |
0 |
return this; |
84 |
|
} |
85 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
86 |
0 |
@Override... |
87 |
|
public String getName() |
88 |
|
{ |
89 |
0 |
return this.name; |
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
@param |
96 |
|
@return |
97 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
98 |
0 |
public EditorDescriptorBuilder setDescription(String description)... |
99 |
|
{ |
100 |
0 |
this.description = description; |
101 |
0 |
return this; |
102 |
|
} |
103 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
104 |
0 |
@Override... |
105 |
|
public String getDescription() |
106 |
|
{ |
107 |
0 |
return this.description; |
108 |
|
} |
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
@param |
114 |
|
@return |
115 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
116 |
0 |
public EditorDescriptorBuilder setIcon(String icon)... |
117 |
|
{ |
118 |
0 |
this.icon = icon; |
119 |
0 |
return this; |
120 |
|
} |
121 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
122 |
0 |
@Override... |
123 |
|
public String getIcon() |
124 |
|
{ |
125 |
0 |
return this.icon; |
126 |
|
} |
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
@param |
132 |
|
@return |
133 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
134 |
35 |
public EditorDescriptorBuilder setCategory(String category)... |
135 |
|
{ |
136 |
35 |
this.category = category; |
137 |
35 |
return this; |
138 |
|
} |
139 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
140 |
0 |
@Override... |
141 |
|
public String getCategory() |
142 |
|
{ |
143 |
0 |
return this.category; |
144 |
|
} |
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
@return |
150 |
|
|
|
|
| 88.2% |
Uncovered Elements: 2 (17) |
Complexity: 5 |
Complexity Density: 0.56 |
|
151 |
219 |
public EditorDescriptor build()... |
152 |
|
{ |
153 |
219 |
if (StringUtils.isEmpty(this.id)) { |
154 |
0 |
throw new RuntimeException("The editor id is mandatory."); |
155 |
|
} |
156 |
219 |
if (StringUtils.isEmpty(this.name)) { |
157 |
27 |
this.name = this.localization.getTranslationPlain(String.format("edit.editor.%s.name", this.id)); |
158 |
27 |
if (StringUtils.isEmpty(this.name)) { |
159 |
18 |
this.name = this.id; |
160 |
|
} |
161 |
|
} |
162 |
219 |
if (this.description == null) { |
163 |
155 |
this.description = |
164 |
|
this.localization.getTranslationPlain(String.format("edit.editor.%s.description", this.id)); |
165 |
|
} |
166 |
219 |
return new DefaultEditorDescriptor(this.id, this.name, this.description, this.icon, this.category); |
167 |
|
} |
168 |
|
} |