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

File UIExtensionClassDocumentInitializer.java

 

Coverage histogram

../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

2
13
2
1
82
41
3
0.23
6.5
2
1.5

Classes

Class Line # Actions
UIExtensionClassDocumentInitializer 44 13 0% 3 3
0.823529482.4%
 

Contributing tests

No tests hitting this source file were found.

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.uiextension.internal;
21   
22    import javax.inject.Named;
23    import javax.inject.Singleton;
24   
25    import org.xwiki.component.annotation.Component;
26    import org.xwiki.rendering.syntax.Syntax;
27   
28    import com.xpn.xwiki.XWiki;
29    import com.xpn.xwiki.doc.XWikiDocument;
30    import com.xpn.xwiki.internal.mandatory.AbstractMandatoryDocumentInitializer;
31    import com.xpn.xwiki.objects.classes.BaseClass;
32    import com.xpn.xwiki.objects.classes.TextAreaClass.ContentType;
33    import com.xpn.xwiki.objects.classes.TextAreaClass.EditorType;
34   
35    /**
36    * Update XWiki.UIExtensionClass document with all required informations.
37    *
38    * @version $Id: d5e32de20dcb5da8330d0eeba74c098b423ba258 $
39    * @since 8.1RC1
40    */
41    @Component
42    @Named("XWiki.UIExtensionClass")
43    @Singleton
 
44    public class UIExtensionClassDocumentInitializer extends AbstractMandatoryDocumentInitializer
45    implements WikiUIExtensionConstants
46    {
47    /**
48    * Default constructor.
49    */
 
50  60 toggle public UIExtensionClassDocumentInitializer()
51    {
52  60 super(XWiki.SYSTEM_SPACE, "UIExtensionClass");
53    }
54   
 
55  92 toggle @Override
56    public boolean updateDocument(XWikiDocument document)
57    {
58  92 boolean needsUpdate = false;
59   
60  92 BaseClass bclass = document.getXClass();
61   
62    // Force the class document to use the 2.1 syntax default syntax, the same syntax used in the custom displayer.
63  92 if (!Syntax.XWIKI_2_1.equals(document.getSyntax())) {
64  0 document.setSyntax(Syntax.XWIKI_2_1);
65  0 needsUpdate = true;
66    }
67   
68  92 needsUpdate |= bclass.addTextField(EXTENSION_POINT_ID_PROPERTY, "Extension Point ID", 30);
69  92 needsUpdate |= bclass.addTextField(ID_PROPERTY, "Extension ID", 30);
70    // The content property supports wiki syntax, but it uses script macros most of the time.
71  92 needsUpdate |= bclass.addTextAreaField(CONTENT_PROPERTY, "Extension Content", 40, 10, EditorType.TEXT);
72    // The parameters property doesn't support wiki syntax.
73  92 needsUpdate |=
74    bclass.addTextAreaField(PARAMETERS_PROPERTY, "Extension Parameters", 40, 10, ContentType.PURE_TEXT);
75  92 needsUpdate |= bclass.addStaticListField(SCOPE_PROPERTY, "Extension Scope", 1, false,
76    "wiki=Current Wiki|user=Current User|global=Global", "select");
77   
78  92 needsUpdate |= setClassDocumentFields(document, "UI Extension Class");
79   
80  92 return needsUpdate;
81    }
82    }