1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.wikimacro.internal; |
21 |
|
|
22 |
|
import javax.inject.Named; |
23 |
|
import javax.inject.Singleton; |
24 |
|
|
25 |
|
import org.xwiki.component.annotation.Component; |
26 |
|
|
27 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
28 |
|
import com.xpn.xwiki.internal.mandatory.AbstractMandatoryDocumentInitializer; |
29 |
|
import com.xpn.xwiki.objects.classes.BaseClass; |
30 |
|
import com.xpn.xwiki.objects.classes.ListClass; |
31 |
|
import com.xpn.xwiki.objects.classes.TextAreaClass; |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
@version |
37 |
|
@since |
38 |
|
|
39 |
|
@Component |
40 |
|
@Named(WikiMacroConstants.WIKI_MACRO_CLASS) |
41 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 2 |
Complexity Density: 0.14 |
|
42 |
|
public class WikiMacroClassDocumentInitializer extends AbstractMandatoryDocumentInitializer implements |
43 |
|
WikiMacroConstants |
44 |
|
{ |
45 |
|
private static final String PROPERTY_PIPE = "|"; |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
50 |
23 |
public WikiMacroClassDocumentInitializer()... |
51 |
|
{ |
52 |
23 |
super(WIKI_MACRO_CLASS_SPACE, WIKI_MACRO_CLASS_PAGE); |
53 |
|
} |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
|
55 |
57 |
@Override... |
56 |
|
public boolean updateDocument(XWikiDocument document) |
57 |
|
{ |
58 |
57 |
boolean needsUpdate = false; |
59 |
|
|
60 |
57 |
BaseClass bclass = document.getXClass(); |
61 |
|
|
62 |
57 |
needsUpdate |= bclass.addTextField(MACRO_ID_PROPERTY, "Macro id", 30); |
63 |
57 |
needsUpdate |= bclass.addTextField(MACRO_NAME_PROPERTY, "Macro name", 30); |
64 |
|
|
65 |
57 |
needsUpdate |= bclass.addTextAreaField(MACRO_DESCRIPTION_PROPERTY, "Macro description", 40, 5, |
66 |
|
TextAreaClass.ContentType.PURE_TEXT); |
67 |
57 |
needsUpdate |= bclass.addTextField(MACRO_DEFAULT_CATEGORY_PROPERTY, "Default category", 30); |
68 |
57 |
needsUpdate |= bclass.addBooleanField(MACRO_INLINE_PROPERTY, "Supports inline mode", "yesno"); |
69 |
57 |
needsUpdate |= bclass.addStaticListField(MACRO_VISIBILITY_PROPERTY, "Macro visibility", 1, false, |
70 |
|
"Current User|Current Wiki|Global", ListClass.DISPLAYTYPE_SELECT, PROPERTY_PIPE); |
71 |
57 |
needsUpdate |= bclass.addStaticListField(MACRO_CONTENT_TYPE_PROPERTY, "Macro content type", 1, false, |
72 |
|
"Optional|Mandatory|No content", ListClass.DISPLAYTYPE_SELECT, PROPERTY_PIPE); |
73 |
|
|
74 |
57 |
needsUpdate |= bclass.addTextAreaField(MACRO_CONTENT_DESCRIPTION_PROPERTY, |
75 |
|
"Content description (Not applicable for \"No content\" type)", 40, 5, |
76 |
|
TextAreaClass.ContentType.PURE_TEXT); |
77 |
|
|
78 |
57 |
needsUpdate |= bclass.addTextAreaField(MACRO_CODE_PROPERTY, "Macro code", 40, 20, |
79 |
|
TextAreaClass.EditorType.TEXT); |
80 |
|
|
81 |
57 |
needsUpdate |= setClassDocumentFields(document, "XWiki Wiki Macro Class"); |
82 |
|
|
83 |
57 |
return needsUpdate; |
84 |
|
} |
85 |
|
} |