1. Project Clover database Tue Dec 20 2016 21:24:09 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
49
4
1
121
69
5
0.1
12.25
4
1.25

Classes

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

Contributing tests

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