1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.annotation.internal; |
21 |
|
|
22 |
|
import javax.inject.Inject; |
23 |
|
import javax.inject.Named; |
24 |
|
import javax.inject.Singleton; |
25 |
|
|
26 |
|
import org.xwiki.annotation.Annotation; |
27 |
|
import org.xwiki.annotation.AnnotationConfiguration; |
28 |
|
import org.xwiki.component.annotation.Component; |
29 |
|
import org.xwiki.model.reference.EntityReference; |
30 |
|
|
31 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
32 |
|
import com.xpn.xwiki.internal.mandatory.AbstractMandatoryDocumentInitializer; |
33 |
|
import com.xpn.xwiki.objects.classes.BaseClass; |
34 |
|
import com.xpn.xwiki.objects.classes.TextAreaClass.ContentType; |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
@version |
41 |
|
@since |
42 |
|
|
43 |
|
@Component |
44 |
|
|
45 |
|
@Named(AnnotationClassDocumentInitializer.HINT) |
46 |
|
@Singleton |
|
|
| 90.5% |
Uncovered Elements: 2 (21) |
Complexity: 4 |
Complexity Density: 0.25 |
|
47 |
|
public class AnnotationClassDocumentInitializer extends AbstractMandatoryDocumentInitializer |
48 |
|
{ |
49 |
|
static final String HINT = "annotationclass"; |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
@Inject |
55 |
|
protected AnnotationConfiguration configuration; |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
60 |
1 |
public AnnotationClassDocumentInitializer()... |
61 |
|
{ |
62 |
1 |
super(null); |
63 |
|
} |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
65 |
1 |
@Override... |
66 |
|
public EntityReference getDocumentReference() |
67 |
|
{ |
68 |
1 |
return this.configuration.getAnnotationClassReference(); |
69 |
|
} |
70 |
|
|
|
|
| 87.5% |
Uncovered Elements: 2 (16) |
Complexity: 2 |
Complexity Density: 0.14 |
|
71 |
1 |
@Override... |
72 |
|
public boolean updateDocument(XWikiDocument document) |
73 |
|
{ |
74 |
1 |
if (!this.configuration.isInstalled()) { |
75 |
|
|
76 |
0 |
return false; |
77 |
|
} |
78 |
|
|
79 |
1 |
BaseClass annotationClass = document.getXClass(); |
80 |
|
|
81 |
1 |
boolean needsUpdate = false; |
82 |
|
|
83 |
1 |
needsUpdate |= annotationClass.addTextField(Annotation.AUTHOR_FIELD, "Author", 30); |
84 |
1 |
needsUpdate |= annotationClass.addDateField(Annotation.DATE_FIELD, "Date"); |
85 |
|
|
86 |
1 |
needsUpdate |= |
87 |
|
annotationClass.addTextAreaField(Annotation.SELECTION_FIELD, "Selection", 40, 5, ContentType.PURE_TEXT); |
88 |
1 |
needsUpdate |= annotationClass.addTextAreaField(Annotation.SELECTION_LEFT_CONTEXT_FIELD, |
89 |
|
"Selection Left Context", 40, 5, ContentType.PURE_TEXT); |
90 |
1 |
needsUpdate |= annotationClass.addTextAreaField(Annotation.SELECTION_RIGHT_CONTEXT_FIELD, |
91 |
|
"Selection Right Context", 40, 5, ContentType.PURE_TEXT); |
92 |
1 |
needsUpdate |= annotationClass.addTextAreaField(Annotation.ORIGINAL_SELECTION_FIELD, "Original Selection", 40, |
93 |
|
5, ContentType.PURE_TEXT); |
94 |
1 |
needsUpdate |= annotationClass.addTextField(Annotation.TARGET_FIELD, "Target", 30); |
95 |
1 |
needsUpdate |= annotationClass.addTextField(Annotation.STATE_FIELD, "State", 30); |
96 |
|
|
97 |
1 |
needsUpdate |= setClassDocumentFields(document, "Annotation Class"); |
98 |
|
|
99 |
1 |
return needsUpdate; |
100 |
|
} |
101 |
|
} |