1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package com.xpn.xwiki.objects.meta

File ListMetaClass.java

 

Coverage histogram

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

Code metrics

2
60
4
1
135
80
5
0.08
15
4
1.25

Classes

Class Line # Actions
ListMetaClass 32 60 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 21 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 com.xpn.xwiki.objects.meta;
21   
22    import com.xpn.xwiki.objects.classes.BooleanClass;
23    import com.xpn.xwiki.objects.classes.NumberClass;
24    import com.xpn.xwiki.objects.classes.StaticListClass;
25    import com.xpn.xwiki.objects.classes.StringClass;
26   
27    /**
28    * Defines the default meta properties for all list XClass property types.
29    *
30    * @version $Id: 5fd9c2303c9bf178329c5f21ef2fa1f1d50c92f5 $
31    */
 
32    public class ListMetaClass extends PropertyMetaClass
33    {
34    /**
35    * Default constructor. Initializes the default meta properties of all List XClass property.
36    */
 
37  488 toggle public ListMetaClass()
38    {
39  488 addPresentationMetaProperties();
40   
41  488 BooleanClass relationalStorageClass = newCheckBox(false);
42  488 relationalStorageClass.setName("relationalStorage");
43  488 relationalStorageClass.setPrettyName("Relational Storage");
44  488 safeput(relationalStorageClass.getName(), relationalStorageClass);
45   
46  488 BooleanClass cacheClass = newCheckBox(false);
47  488 cacheClass.setName("cache");
48  488 cacheClass.setPrettyName("Cache");
49  488 safeput(cacheClass.getName(), cacheClass);
50   
51  488 StringClass defaultClass = new StringClass(this);
52  488 defaultClass.setName("defaultValue");
53  488 defaultClass.setPrettyName("Default value");
54  488 defaultClass.setUnmodifiable(true);
55  488 defaultClass.setSize(40);
56  488 safeput(defaultClass.getName(), defaultClass);
57    }
58   
59    /**
60    * Adds the meta properties that control how the XClass property is displayed in edit and view mode.
61    */
 
62  488 toggle private void addPresentationMetaProperties()
63    {
64  488 StaticListClass displayTypeClass = new StaticListClass(this);
65  488 displayTypeClass.setName("displayType");
66  488 displayTypeClass.setPrettyName("Display Type");
67  488 displayTypeClass.setValues("input|select|radio|checkbox");
68  488 safeput(displayTypeClass.getName(), displayTypeClass);
69   
70  488 BooleanClass multiSelectClass = newCheckBox(false);
71  488 multiSelectClass.setName("multiSelect");
72  488 multiSelectClass.setPrettyName("Multiple Select");
73  488 safeput(multiSelectClass.getName(), multiSelectClass);
74   
75  488 BooleanClass pickerClass = newCheckBox(true);
76  488 pickerClass.setName("picker");
77  488 pickerClass.setPrettyName("Use Suggest");
78  488 safeput(pickerClass.getName(), pickerClass);
79   
80  488 NumberClass sizeClass = new NumberClass(this);
81  488 sizeClass.setName("size");
82  488 sizeClass.setPrettyName("Size");
83  488 sizeClass.setSize(5);
84  488 sizeClass.setNumberType("integer");
85  488 safeput(sizeClass.getName(), sizeClass);
86   
87  488 addValueSeparatorMetaProperties();
88   
89  488 StaticListClass sortClass = new StaticListClass(this);
90  488 sortClass.setName("sort");
91  488 sortClass.setPrettyName("Sort");
92  488 sortClass.setValues("none|id|value");
93  488 safeput(sortClass.getName(), sortClass);
94   
95   
96  488 StaticListClass freeTextClass = new StaticListClass(this);
97  488 freeTextClass.setName("freeText");
98  488 freeTextClass.setPrettyName("Free text");
99  488 freeTextClass.setValues("discouraged|forbidden|allowed");
100  488 safeput(freeTextClass.getName(), freeTextClass);
101    }
102   
103    /**
104    * Adds the meta properties that control how list values are separated in edit and view mode.
105    */
 
106  488 toggle private void addValueSeparatorMetaProperties()
107    {
108  488 StringClass separatorsClass = new StringClass(this);
109  488 separatorsClass.setName("separators");
110  488 separatorsClass.setPrettyName("Multiselect separators (for editing)");
111  488 separatorsClass.setSize(5);
112  488 safeput(separatorsClass.getName(), separatorsClass);
113   
114  488 StringClass separatorClass = new StringClass(this);
115  488 separatorClass.setName("separator");
116  488 separatorClass.setPrettyName("Join separator (for display)");
117  488 separatorClass.setSize(5);
118  488 safeput(separatorClass.getName(), separatorClass);
119    }
120   
121    /**
122    * Creates a new boolean property that is displayed as a check box.
123    *
124    * @param checked whether the check box is checked or not by default
125    * @return a new {@link BooleanClass} instance that is displayed as a check box
126    */
 
127  1952 toggle private BooleanClass newCheckBox(boolean checked)
128    {
129  1952 BooleanClass checkBox = new BooleanClass(this);
130  1952 checkBox.setDisplayType("yesno");
131  1952 checkBox.setDisplayFormType("checkbox");
132  1952 checkBox.setDefaultValue(checked ? 1 : 0);
133  1952 return checkBox;
134    }
135    }