1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.module.googlesitemap.app.field; |
35 |
|
|
36 |
|
import info.magnolia.registry.RegistrationException; |
37 |
|
import info.magnolia.rendering.template.registry.TemplateDefinitionRegistry; |
38 |
|
import info.magnolia.ui.form.field.factory.AbstractFieldFactory; |
39 |
|
|
40 |
|
import java.util.Locale; |
41 |
|
|
42 |
|
import javax.inject.Inject; |
43 |
|
|
44 |
|
import com.vaadin.data.Item; |
45 |
|
import com.vaadin.data.Property; |
46 |
|
import com.vaadin.data.util.converter.Converter; |
47 |
|
import com.vaadin.ui.Field; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
@param |
52 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 8 |
Complexity Density: 0.67 |
|
53 |
|
public class TemplateStaticFieldFactory<T extends TemplateStaticFieldDefinition> extends AbstractFieldFactory<T, String> { |
54 |
|
|
55 |
|
private TemplateDefinitionRegistry templateDefinitionRegistry; |
56 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
57 |
0
|
@Inject... |
58 |
|
public TemplateStaticFieldFactory(T definition, Item relatedFieldItem, TemplateDefinitionRegistry templateDefinitionRegistry) { |
59 |
0
|
super(definition, relatedFieldItem); |
60 |
0
|
this.templateDefinitionRegistry = templateDefinitionRegistry; |
61 |
|
} |
62 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
63 |
0
|
@Override... |
64 |
|
protected Field createFieldComponent() { |
65 |
0
|
TemplateStaticField fieldComponent = new TemplateStaticField(definition.getValue()); |
66 |
0
|
fieldComponent.setConverter(new Converter<String, String>() { |
67 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
68 |
0
|
@Override... |
69 |
|
public String convertToModel(String value, Class<? extends String> targetType, Locale locale) throws ConversionException { |
70 |
0
|
return definition.getValue(); |
71 |
|
} |
72 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
73 |
0
|
@Override... |
74 |
|
public String convertToPresentation(String value, Class<? extends String> targetType, Locale locale) throws ConversionException { |
75 |
0
|
try { |
76 |
0
|
return templateDefinitionRegistry.getTemplateDefinition(definition.getValue()).getTitle(); |
77 |
|
} catch (RegistrationException e) { |
78 |
0
|
return ""; |
79 |
|
} |
80 |
|
} |
81 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
82 |
0
|
@Override... |
83 |
|
public Class<String> getModelType() { |
84 |
0
|
return String.class; |
85 |
|
} |
86 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
87 |
0
|
@Override... |
88 |
|
public Class<String> getPresentationType() { |
89 |
0
|
return String.class; |
90 |
|
} |
91 |
|
}); |
92 |
0
|
return fieldComponent; |
93 |
|
} |
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
0
|
@Override... |
99 |
|
public void setPropertyDataSourceAndDefaultValue(Property property) { |
100 |
0
|
this.field.setPropertyDataSource(property); |
101 |
|
} |
102 |
|
} |