1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.objects.classes

File StringClass.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

6
36
10
1
124
86
13
0.36
3.6
10
1.3

Classes

Class Line # Actions
StringClass 32 36 0% 13 15
0.7115384371.2%
 

Contributing tests

This file is covered by 53 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.classes;
21   
22    import org.apache.ecs.xhtml.input;
23   
24    import com.xpn.xwiki.XWiki;
25    import com.xpn.xwiki.XWikiContext;
26    import com.xpn.xwiki.internal.xml.XMLAttributeValueFilter;
27    import com.xpn.xwiki.objects.BaseCollection;
28    import com.xpn.xwiki.objects.BaseProperty;
29    import com.xpn.xwiki.objects.StringProperty;
30    import com.xpn.xwiki.objects.meta.PropertyMetaClass;
31   
 
32    public class StringClass extends PropertyClass
33    {
34    private static final String XCLASSNAME = "string";
35   
 
36  34145 toggle public StringClass(String name, String prettyname, PropertyMetaClass wclass)
37    {
38  34145 super(name, prettyname, wclass);
39  34145 setSize(30);
40    }
41   
 
42  22672 toggle public StringClass(PropertyMetaClass wclass)
43    {
44  22672 this(XCLASSNAME, "String", wclass);
45    }
46   
 
47  17998 toggle public StringClass()
48    {
49  17998 this(null);
50    }
51   
 
52  4596 toggle public int getSize()
53    {
54  4596 return getIntValue("size");
55    }
56   
 
57  53278 toggle public void setSize(int size)
58    {
59  53278 setIntValue("size", size);
60    }
61   
 
62  1392 toggle public boolean isPicker()
63    {
64  1392 return (getIntValue("picker") == 1);
65    }
66   
 
67  0 toggle public void setPicker(boolean picker)
68    {
69  0 setIntValue("picker", picker ? 1 : 0);
70    }
71   
 
72  125340 toggle @Override
73    public BaseProperty fromString(String value)
74    {
75  125339 BaseProperty property = newProperty();
76  125338 property.setValue(value);
77  125338 return property;
78    }
79   
 
80  118426 toggle @Override
81    public BaseProperty newProperty()
82    {
83  118429 BaseProperty property = new StringProperty();
84  118424 property.setName(getName());
85  118429 return property;
86    }
87   
 
88  1392 toggle @Override
89    public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
90    {
91  1392 input input = new input();
92  1392 input.setAttributeFilter(new XMLAttributeValueFilter());
93  1392 BaseProperty prop = (BaseProperty) object.safeget(name);
94  1392 if (prop != null) {
95  781 input.setValue(prop.toText());
96    }
97   
98  1392 input.setType("text");
99  1392 input.setName(prefix + name);
100  1392 input.setID(prefix + name);
101  1392 input.setSize(getSize());
102  1392 input.setDisabled(isDisabled());
103   
104  1392 if (isPicker()) {
105  0 input.setClass("suggested");
106  0 String path = "";
107  0 XWiki xwiki = context.getWiki();
108  0 path = xwiki.getURL("Main.WebHome", "view", context);
109   
110  0 String classname = this.getObject().getName();
111  0 String fieldname = this.getName();
112  0 String secondCol = "-", firstCol = "-";
113   
114  0 String script =
115    "\"" + path + "?xpage=suggest&classname=" + classname + "&fieldname=" + fieldname + "&firCol="
116    + firstCol + "&secCol=" + secondCol + "&\"";
117  0 String varname = "\"input\"";
118  0 input.setOnFocus("new ajaxSuggest(this, {script:" + script + ", varname:" + varname + "} )");
119    }
120   
121  1392 buffer.append(input.toString());
122    }
123   
124    }