1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.wikimacro.internal

File WikiMacroClassDocumentInitializer.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
14
2
1
85
44
2
0.14
7
2
1

Classes

Class Line # Actions
WikiMacroClassDocumentInitializer 42 14 0% 2 0
1.0100%
 

Contributing tests

This file is covered by 4 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
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    * Update XWiki.XWikiComments document with all required informations.
35    *
36    * @version $Id: 2b55a08982933bd89915ce23dcd77b76bf46cc1e $
37    * @since 4.3M1
38    */
39    @Component
40    @Named(WikiMacroConstants.WIKI_MACRO_CLASS)
41    @Singleton
 
42    public class WikiMacroClassDocumentInitializer extends AbstractMandatoryDocumentInitializer implements
43    WikiMacroConstants
44    {
45    private static final String PROPERTY_PIPE = "|";
46   
47    /**
48    * Default constructor.
49    */
 
50  23 toggle public WikiMacroClassDocumentInitializer()
51    {
52  23 super(WIKI_MACRO_CLASS_SPACE, WIKI_MACRO_CLASS_PAGE);
53    }
54   
 
55  57 toggle @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    // The Macro description is using plain text (same as for Java Macros).
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    // The Macro content description is using plain text (same as for Java Macros).
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    // The code property contains wiki markup
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    }