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

File StringClass.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% 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 4
0.923076992.3%
 

Contributing tests

This file is covered by 57 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  89384 toggle public StringClass(String name, String prettyname, PropertyMetaClass wclass)
37    {
38  89384 super(name, prettyname, wclass);
39  89385 setSize(30);
40    }
41   
 
42  58689 toggle public StringClass(PropertyMetaClass wclass)
43    {
44  58689 this(XCLASSNAME, "String", wclass);
45    }
46   
 
47  50387 toggle public StringClass()
48    {
49  50387 this(null);
50    }
51   
 
52  12932 toggle public int getSize()
53    {
54  12932 return getIntValue("size");
55    }
56   
 
57  137938 toggle public void setSize(int size)
58    {
59  137939 setIntValue("size", size);
60    }
61   
 
62  5278 toggle public boolean isPicker()
63    {
64  5278 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  390369 toggle @Override
73    public BaseProperty fromString(String value)
74    {
75  390369 BaseProperty property = newProperty();
76  390364 property.setValue(value);
77  390364 return property;
78    }
79   
 
80  365700 toggle @Override
81    public BaseProperty newProperty()
82    {
83  365700 BaseProperty property = new StringProperty();
84  365700 property.setName(getName());
85  365696 return property;
86    }
87   
 
88  5278 toggle @Override
89    public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
90    {
91  5278 input input = new input();
92  5278 input.setAttributeFilter(new XMLAttributeValueFilter());
93  5278 BaseProperty prop = (BaseProperty) object.safeget(name);
94  5278 if (prop != null) {
95  3848 input.setValue(prop.toText());
96    }
97   
98  5278 input.setType("text");
99  5278 input.setName(prefix + name);
100  5278 input.setID(prefix + name);
101  5278 input.setSize(getSize());
102  5278 input.setDisabled(isDisabled());
103   
104  5278 if (isPicker()) {
105  37 input.setClass("suggested");
106  37 String path = "";
107  37 XWiki xwiki = context.getWiki();
108  37 path = xwiki.getURL("Main.WebHome", "view", context);
109   
110  37 String classname = this.getObject().getName();
111  37 String fieldname = this.getName();
112  37 String secondCol = "-", firstCol = "-";
113   
114  37 String script =
115    "\"" + path + "?xpage=suggest&classname=" + classname + "&fieldname=" + fieldname + "&firCol="
116    + firstCol + "&secCol=" + secondCol + "&\"";
117  37 String varname = "\"input\"";
118  37 input.setOnFocus("new ajaxSuggest(this, {script:" + script + ", varname:" + varname + "} )");
119    }
120   
121  5278 buffer.append(input.toString());
122    }
123   
124    }