[xwiki-notifications] r5590 - in xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects: classes meta

tmortagne (SVN) notifications at xwiki.org
Thu Nov 1 10:32:13 CET 2007


Author: tmortagne
Date: 2007-11-01 10:32:13 +0100 (Thu, 01 Nov 2007)
New Revision: 5590

Modified:
   xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/DBListClass.java
   xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/ListClass.java
   xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/StaticListClass.java
   xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/StringClass.java
   xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/meta/DBListMetaClass.java
   xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/meta/ListMetaClass.java
   xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/meta/StaticListMetaClass.java
   xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/meta/StringMetaClass.java
Log:
XWIKI-1780: Improve rights management

Modified: xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/DBListClass.java
===================================================================
--- xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/DBListClass.java	2007-10-31 23:30:04 UTC (rev 5589)
+++ xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/DBListClass.java	2007-11-01 09:32:13 UTC (rev 5590)
@@ -1,239 +1,454 @@
-/*
- * Copyright 2006-2007, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- */
-
-package com.xpn.xwiki.objects.classes;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.xpn.xwiki.XWiki;
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.objects.meta.PropertyMetaClass;
-import com.xpn.xwiki.plugin.query.QueryPlugin;
-
-public class DBListClass extends ListClass
-{
-    private List cachedDBList;
-
-    public DBListClass(String name, String prettyname, PropertyMetaClass wclass)
-    {
-        super(name, prettyname, wclass);
-    }
-
-    public DBListClass(PropertyMetaClass wclass)
-    {
-        super("dblist", "DB List", wclass);
-    }
-
-    public DBListClass()
-    {
-        this(null);
-    }
-
-    public List makeList(List list)
-    {
-        List list2 = new ArrayList();
-        for (int i = 0; i < list.size(); i++) {
-            Object result = list.get(i);
-            if (result instanceof String) {
-                list2.add(new ListItem((String) result));
-            } else {
-                Object[] res = (Object[]) result;
-                if (res.length == 1) {
-                    list2.add(new ListItem(res[0].toString()));
-                } else if (res.length == 2) {
-                    list2.add(new ListItem(res[0].toString(), res[1].toString()));
-                } else {
-                    list2.add(new ListItem(res[0].toString(), res[1].toString(), res[2]
-                        .toString()));
-                }
-            }
-        }
-        return list2;
-    }
-
-    public List getDBList(XWikiContext context)
-    {
-        List list = getCachedDBList();
-        if (list==null) {
-
-            XWiki xwiki = context.getWiki();
-            String query = getQuery(context);
-
-            if (query == null)
-                list = new ArrayList();
-            else {
-
-                try {
-                    if ((xwiki.getHibernateStore() != null) && (!query.startsWith("/"))) {
-                        list = makeList(xwiki.search(query, context));
-                    } else  {
-                        list = makeList(((QueryPlugin) xwiki.getPlugin("query", context)).xpath(query).list());
-                    }
-                } catch (Exception e) {
-                    e.printStackTrace();
-                    list = new ArrayList();
-                }
-            }
-            setCachedDBList(list);
-        }
-        return list;
-    }
-
-    public List getList(XWikiContext context)
-    {
-        List dblist = getDBList(context);
-        List list = new ArrayList();
-        for (int i = 0; i < dblist.size(); i++) {
-            list.add(((ListItem) dblist.get(i)).getId());
-        }
-        return list;
-    }
-
-    public Map getMap(XWikiContext context)
-    {
-        List list = getDBList(context);
-        Map map = new HashMap();
-        if ((list == null) || (list.size() == 0)) {
-            return map;
-        }
-        for (int i = 0; i < list.size(); i++) {
-            Object res = list.get(i);
-            if (res instanceof String) {
-                map.put(res, res);
-            } else {
-                ListItem item = (ListItem) res;
-                map.put(item.getId(), item);
-            }
-        }
-        return map;
-    }
-
-    public String getQuery(XWikiContext context)
-    {
-        String sql = getSql();
-        try {
-            sql = context.getDoc().getRenderedContent(sql, context);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        if ((sql == null) || (sql.trim().equals(""))) {
-            String classname = getClassname();
-            String idField = getIdField();
-            String valueField = getValueField();
-            if ((valueField == null) || (valueField.trim().equals(""))) {
-                valueField = idField;
-            }
-            if (context.getWiki().getHibernateStore() != null) {
-                String select = "select ";
-                String tables = " from XWikiDocument as doc, BaseObject as obj";
-                String where =
-                    " where doc.fullName=obj.name and obj.className='" + classname + "'";
-                if (idField.startsWith("doc.") || idField.startsWith("obj.")) {
-                    select += idField + ",";
-                } else {
-                    select += "idprop.value,";
-                    tables += ", StringProperty as idprop";
-                    where += " and obj.id=idprop.id.id and idprop.id.name='" + idField + "'";
-                }
-                if (valueField.startsWith("doc.") || valueField.startsWith("obj.")) {
-                    select += valueField + ",";
-                }
-                else {
-                    if (idField.equals(valueField)) {
-                        select += "idprop.value,";
-                    } else {
-                        select += "valueprop.value,";
-                        tables += ", StringProperty as valueprop";
-                        where +=
-                            " and obj.id=valueprop.id.id and valueprop.id.name='" + valueField
-                                + "'";
-                    }
-                }
-                // Let's create the sql
-                sql = select + tables + where;
-            } else {
-                // TODO: query plugin impl.
-                // We need to generate the right query for the query plugin
-            }
-
-        }
-        return context.getWiki().parseContent(sql, context);
-    }
-
-    public String getSql()
-    {
-        return getLargeStringValue("sql");
-    }
-
-    public void setSql(String sql)
-    {
-        setLargeStringValue("sql", sql);
-    }
-
-    public String getClassname()
-    {
-        return getStringValue("classname");
-    }
-
-    public void setClassname(String classname)
-    {
-        setStringValue("classname", classname);
-    }
-
-    public String getIdField()
-    {
-        return getStringValue("idField");
-    }
-
-    public void setIdField(String idField)
-    {
-        setStringValue("idField", idField);
-    }
-
-    public String getValueField()
-    {
-        return getStringValue("valueField");
-    }
-
-    public void setValueField(String valueField)
-    {
-        setStringValue("valueField", valueField);
-    }
-
-    public List getCachedDBList() {
-        if (isCache())
-            return cachedDBList;
-        else
-            return null;
-    }
-
-    public void setCachedDBList(List cachedDBList) {
-        if (isCache())
-            this.cachedDBList = cachedDBList;
-    }
-
-    public void flushCache() {
-        this.cachedDBList = null;
-    }
-}
+/*
+ * Copyright 2006-2007, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ */
+
+package com.xpn.xwiki.objects.classes;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import com.xpn.xwiki.XWiki;
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.objects.meta.PropertyMetaClass;
+import com.xpn.xwiki.plugin.query.QueryPlugin;
+
+import java.text.CharacterIterator;
+import java.text.StringCharacterIterator;
+import java.util.StringTokenizer;
+import org.apache.commons.lang.StringUtils;
+import org.apache.ecs.xhtml.input;
+import com.xpn.xwiki.objects.BaseCollection;
+import com.xpn.xwiki.objects.BaseProperty;
+import com.xpn.xwiki.objects.DBStringListProperty;
+import com.xpn.xwiki.objects.ListProperty;
+import com.xpn.xwiki.XWikiException;
+
+
+public class DBListClass extends ListClass
+{
+    private List cachedDBList;
+
+    public DBListClass(String name, String prettyname, PropertyMetaClass wclass)
+    {
+        super(name, prettyname, wclass);
+    }
+
+    public DBListClass(PropertyMetaClass wclass)
+    {
+        super("dblist", "DB List", wclass);
+    }
+
+    public DBListClass()
+    {
+        this(null);
+    }
+
+    public List makeList(List list)
+    {
+        List list2 = new ArrayList();
+        for (int i = 0; i < list.size(); i++) {
+            Object result = list.get(i);
+            if (result instanceof String) {
+                list2.add(new ListItem((String) result));
+            } else {
+                Object[] res = (Object[]) result;
+                if (res.length == 1) {
+                    list2.add(new ListItem(res[0].toString()));
+                } else if (res.length == 2) {
+                    list2.add(new ListItem(res[0].toString(), res[1].toString()));
+                } else {
+                    list2.add(new ListItem(res[0].toString(), res[1].toString(), res[2]
+                        .toString()));
+                }
+            }
+        }
+        return list2;
+    }
+
+    public List getDBList(XWikiContext context)
+    {
+        List list = getCachedDBList();
+        if (list==null) {
+
+            XWiki xwiki = context.getWiki();
+            String query = getQuery(context);
+
+            if (query == null)
+                list = new ArrayList();
+            else {
+
+                try {
+                    if ((xwiki.getHibernateStore() != null) && (!query.startsWith("/"))) {
+                        list = makeList(xwiki.search(query, context));
+                    } else  {
+                        list = makeList(((QueryPlugin) xwiki.getPlugin("query", context)).xpath(query).list());
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    list = new ArrayList();
+                }
+            }
+            setCachedDBList(list);
+        }
+        return list;
+    }
+
+    public List getList(XWikiContext context)
+    {
+        List dblist = getDBList(context);
+        List list = new ArrayList();
+        for (int i = 0; i < dblist.size(); i++) {
+            list.add(((ListItem) dblist.get(i)).getId());
+        }
+        return list;
+    }
+
+    public Map getMap(XWikiContext context)
+    {
+        List list = getDBList(context);
+        Map map = new HashMap();
+        if ((list == null) || (list.size() == 0)) {
+            return map;
+        }
+        for (int i = 0; i < list.size(); i++) {
+            Object res = list.get(i);
+            if (res instanceof String) {
+                map.put(res, res);
+            } else {
+                ListItem item = (ListItem) res;
+                map.put(item.getId(), item);
+            }
+        }
+        return map;
+    }
+
+    public String getQuery(XWikiContext context)
+    {
+        String sql = getSql();
+        try {
+            sql = context.getDoc().getRenderedContent(sql, context);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        if ((sql == null) || (sql.trim().equals(""))) {
+            String classname = getClassname();
+            String idField = getIdField();
+            String valueField = getValueField();
+            if ((valueField == null) || (valueField.trim().equals(""))) {
+                valueField = idField;
+            }
+            if (context.getWiki().getHibernateStore() != null) {
+                String select = "select ";
+                String tables = " from XWikiDocument as doc, BaseObject as obj";
+                String where =
+                    " where doc.fullName=obj.name and obj.className='" + classname + "'";
+                if (idField.startsWith("doc.") || idField.startsWith("obj.")) {
+                    select += idField + ",";
+                } else {
+                    select += "idprop.value,";
+                    tables += ", StringProperty as idprop";
+                    where += " and obj.id=idprop.id.id and idprop.id.name='" + idField + "'";
+                }
+                if (valueField.startsWith("doc.") || valueField.startsWith("obj.")) {
+                    select += valueField + ",";
+                }
+                else {
+                    if (idField.equals(valueField)) {
+                        select += "idprop.value,";
+                    } else {
+                        select += "valueprop.value,";
+                        tables += ", StringProperty as valueprop";
+                        where +=
+                            " and obj.id=valueprop.id.id and valueprop.id.name='" + valueField
+                                + "'";
+                    }
+                }
+                // Let's create the sql
+                sql = select + tables + where;
+            } else {
+                // TODO: query plugin impl.
+                // We need to generate the right query for the query plugin
+            }
+
+        }
+        return context.getWiki().parseContent(sql, context);
+    }
+
+    public String getSql()
+    {
+        return getLargeStringValue("sql");
+    }
+
+    public void setSql(String sql)
+    {
+        setLargeStringValue("sql", sql);
+    }
+
+    public String getClassname()
+    {
+        return getStringValue("classname");
+    }
+
+    public void setClassname(String classname)
+    {
+        setStringValue("classname", classname);
+    }
+
+    public String getIdField()
+    {
+        return getStringValue("idField");
+    }
+
+    public void setIdField(String idField)
+    {
+        setStringValue("idField", idField);
+    }
+
+    public String getValueField()
+    {
+        return getStringValue("valueField");
+    }
+
+    public void setValueField(String valueField)
+    {
+        setStringValue("valueField", valueField);
+    }
+
+    public List getCachedDBList() {
+        if (isCache())
+            return cachedDBList;
+        else
+            return null;
+    }
+
+    public void setCachedDBList(List cachedDBList) {
+        if (isCache())
+            this.cachedDBList = cachedDBList;
+    }
+
+    public void flushCache() {
+        this.cachedDBList = null;
+    }
+    
+ // return first or second col from user query
+    public String returnCol(String hibquery, boolean first) {
+    	String firstCol = "-", secondCol = "-";
+    	
+    	int fromIndx = hibquery.indexOf("from");
+		 
+		if(fromIndx > 0) {
+			 String firstPart = hibquery.substring(0, fromIndx);
+			 firstPart.replaceAll("\\s+", " ");
+			 int comIndx = hibquery.indexOf(",");
+			 
+			 //there are more than one columns to select- take the second one (the value)
+			 if(comIndx > 0 && comIndx < fromIndx) {
+
+				 StringTokenizer st = new StringTokenizer(firstPart, " ,()", true);
+				 ArrayList words = new ArrayList();
+				 
+				 while(st.hasMoreTokens()) 
+					 words.add(st.nextToken().toLowerCase());
+				 
+				 int comma = words.indexOf(",") - 1;
+				 while(words.get(comma).toString().compareTo(" ") == 0) {
+					 comma--;
+				 }
+				 firstCol = words.get(comma).toString().trim();
+				 
+				 comma = words.indexOf(",") + 1;
+				 while(words.get(comma).toString().compareTo(" ") == 0) {
+					  comma++;
+				 }
+				 				 
+              	 if(words.get(comma).toString().compareTo("(") == 0) {
+              		 int i = comma+1;
+              		 while(words.get(i).toString().compareTo(")") != 0) {
+              			 secondCol += words.get(i).toString();
+              			 i++;
+              		 }
+              		 secondCol += ")";
+              	 }
+              	 else secondCol = words.get(comma).toString().trim();
+			 }
+			 //has only one column
+			 else {
+				  int i = fromIndx - 1;
+				  while(firstPart.charAt(i) == ' ')
+					  i--;
+				  String col = " ";
+				  while(firstPart.charAt(i) != ' ') {
+					  col += firstPart.charAt(i);
+					  i--;
+				  }
+				  String reverse = " ";
+				  for(i = (col.length()-1); i >= 0; i--)
+					  reverse += col.charAt(i);
+				  firstCol = reverse.trim();
+			 }
+		}
+		if(first == true) return firstCol;
+		else return secondCol;
+    }
+    
+    //the result of the second query, to retrieve the value
+    public String getValue(String val, String sql, XWikiContext context) {
+    	String firstCol = returnCol(sql, true);
+		String secondCol = returnCol(sql, false);
+		
+		String newsql = sql.substring(0, sql.indexOf(firstCol));
+		newsql += secondCol + " ";
+		newsql += sql.substring(sql.indexOf("from"));
+		newsql += "and " + firstCol + "='" + val + "'";
+		
+		Object[] list = null;
+		XWiki xwiki = context.getWiki();
+		String res = "";
+		try {
+				list = xwiki.search(newsql, context).toArray();
+				if(list.length > 0) res = list[0].toString();
+			}catch(Exception e) {
+				e.printStackTrace();
+			}  
+		return res;
+    }
+    
+    
+    //override the method from parent ListClass
+    public void displayEdit(StringBuffer buffer, String name, String prefix,
+            BaseCollection object, XWikiContext context)
+        {
+            //input display  	
+            if (getDisplayType().equals("input")) {
+            	input input = new input();
+                input.setType("text");
+                input.setSize(getSize());
+                boolean changeInputName = false;
+                boolean setInpVal = true;
+                
+                BaseProperty prop = (BaseProperty) object.safeget(name);
+                String val = "";
+                if (prop != null)  val = prop.toFormString();
+                
+                if(isPicker()) {
+                	input.addAttribute("autocomplete", "off");
+                	String path = "";
+                	try {
+                   	 	XWiki xwiki = context.getWiki();
+                   	 	path = xwiki.getURL("Main.WebHome", "view", context);
+                	} catch(XWikiException e) {
+                		e.printStackTrace();
+                	  }
+               	 	String classname = this.getObject().getName();
+               	 	String fieldname = this.getName();
+               	 	String hibquery = this.getSql();
+               	 	String secondCol = "-", firstCol = "-";
+               	 	
+               	 	if(hibquery != null && !hibquery.equals("")) {
+               	 		firstCol = returnCol(hibquery, true);
+               	 		secondCol = returnCol(hibquery, false);
+               	 		       	 		
+               	 		if(secondCol.compareTo("-") != 0) {
+               	 			changeInputName = true;                    		 
+               	 			input hidden = new input();
+               	 			hidden.setID(prefix + name);
+               	 			hidden.setName(prefix + name);
+               	 			hidden.setType("hidden");
+               	 			if(val != null && !val.equals("")) hidden.setValue(val);
+               	 			buffer.append(hidden.toString());
+               	 			
+               	 			input.setValue(getValue(val, hibquery, context));
+               	 			setInpVal = false;
+               	 		}
+               	 	}
+               	 	
+               	 	String script = "\""+path+"?xpage=suggest&amp;classname="+classname+"&amp;fieldname="+fieldname+"&amp;firCol="+firstCol+"&amp;secCol="+secondCol+"&amp;\"";            	 	
+               	 	String varname = "\"input\"";
+               	    String seps = "\""+this.getSeparators()+"\"";
+               	    if(isMultiSelect())
+               	    	input.setOnFocus("new ajaxSuggest(this, {script:"+script+", varname:"+varname+", seps:"+seps+"} )");
+               	    else
+               	    	input.setOnFocus("new ajaxSuggest(this, {script:"+script+", varname:"+varname+"} )");
+         	 	  
+               	 
+               	 	
+                }
+               	 	
+               	if(changeInputName == true) {
+               	 		input.setName(prefix + name + "_suggest");
+               	 		input.setID(prefix + name + "_suggest");
+               	}
+                else {
+               	 		input.setName(prefix + name);
+               	 		input.setID(prefix + name);
+               	 	 }
+               	if(setInpVal == true) input.setValue(val);
+               
+                buffer.append(input.toString());
+                                
+            } else if (getDisplayType().equals("radio") || getDisplayType().equals("checkbox")) {
+                displayRadioEdit(buffer, name, prefix, object, context);
+            } else {
+                displaySelectEdit(buffer, name, prefix, object, context);
+            }
+
+            if (!getDisplayType().equals("input")) {
+                org.apache.ecs.xhtml.input hidden = new input(input.hidden, prefix + name, "");
+                buffer.append(hidden);
+            }
+        }
+    
+    public void displayView(StringBuffer buffer, String name, String prefix,
+            BaseCollection object, XWikiContext context)
+        {
+    		if(isPicker() && getSql().compareTo("") != 0) {
+    			BaseProperty prop = (BaseProperty) object.safeget(name);
+    			String val = "";
+    			if(prop != null) val = prop.toFormString();
+    			Map map = getMap(context);
+ 
+    			String  secondCol = returnCol(getSql(), false);
+    			if(secondCol.compareTo("-") != 0) {
+    				String res = getValue(val, getSql(), context);
+            		buffer.append(getDisplayValue(res, name, map, context));
+    			}
+    			else buffer.append(getDisplayValue(val, name, map, context));
+    		}
+    		else {
+    				List selectlist;
+                    String separator = getSeparator();
+                    BaseProperty prop = (BaseProperty) object.safeget(name);
+                    Map map = getMap(context);
+                    if ((prop instanceof ListProperty) || (prop instanceof DBStringListProperty)) {
+                        selectlist = (List) prop.getValue();
+                        List newlist = new ArrayList();
+                        for (Iterator it = selectlist.iterator(); it.hasNext();) {
+                            newlist.add(getDisplayValue(it.next(), name, map, context));
+                        }
+                        buffer.append(StringUtils.join(newlist.toArray(), separator));
+                    } else {
+                    	buffer.append(getDisplayValue(prop.getValue(), name, map, context));
+                    }
+    		}  
+        }
+}

Modified: xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/ListClass.java
===================================================================
--- xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/ListClass.java	2007-10-31 23:30:04 UTC (rev 5589)
+++ xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/ListClass.java	2007-11-01 09:32:13 UTC (rev 5590)
@@ -72,11 +72,14 @@
         this(null);
     }
 
-    public String getSeparators()
-    {
-        return null;
+    public String getSeparators() {
+        return getStringValue("separators");
     }
 
+    public void setSeparators(String separators) {
+        setStringValue("separators", separators);
+    }
+
     public String getDisplayType()
     {
         return getStringValue("displayType");

Modified: xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/StaticListClass.java
===================================================================
--- xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/StaticListClass.java	2007-10-31 23:30:04 UTC (rev 5589)
+++ xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/StaticListClass.java	2007-11-01 09:32:13 UTC (rev 5590)
@@ -1,66 +1,124 @@
-/*
- * Copyright 2006-2007, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- */
-
-package com.xpn.xwiki.objects.classes;
-
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.objects.meta.PropertyMetaClass;
-
-import java.util.List;
-import java.util.Map;
-
-public class StaticListClass extends ListClass {
-
-    public StaticListClass(PropertyMetaClass wclass) {
-        super("staticlist", "Static List", wclass);
-        setSeparators(" ,|");
-    }
-
-    public StaticListClass() {
-        this(null);
-    }
-
-    public String getValues() {
-        return getStringValue("values");
-    }
-
-    public void setValues(String values) {
-        setStringValue("values", values);
-    }
-
-    public String getSeparators() {
-        return getStringValue("separators");
-    }
-
-    public void setSeparators(String separators) {
-        setStringValue("separators", separators);
-    }
-
-    public List getList(XWikiContext context) {
-        String values = getValues();
-        return getListFromString(values);
-    }
-
-    public Map getMap(XWikiContext context) {
-        String values = getValues();
-        return getMapFromString(values);
-    }
-}
+/*
+ * Copyright 2006-2007, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ */
+
+package com.xpn.xwiki.objects.classes;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.objects.meta.PropertyMetaClass;
+import com.xpn.xwiki.XWiki;
+
+import java.util.List;
+import java.util.Map;
+import com.xpn.xwiki.XWiki;
+import com.xpn.xwiki.XWikiException;
+
+import com.xpn.xwiki.objects.BaseCollection;
+import com.xpn.xwiki.objects.BaseProperty;
+import org.apache.ecs.xhtml.input;
+
+public class StaticListClass extends ListClass {
+
+    public StaticListClass(PropertyMetaClass wclass) {
+        super("staticlist", "Static List", wclass);
+        setSeparators(" ,|");
+    }
+
+    public StaticListClass() {
+        this(null);
+    }
+
+    public String getValues() {
+        return getStringValue("values");
+    }
+
+    public void setValues(String values) {
+        setStringValue("values", values);
+    }
+
+    public String getSeparators() {
+        return getStringValue("separators");
+    }
+
+    public void setSeparators(String separators) {
+        setStringValue("separators", separators);
+    }
+
+    public List getList(XWikiContext context) {
+        String values = getValues();
+        return getListFromString(values);
+    }
+
+    public Map getMap(XWikiContext context) {
+        String values = getValues();
+        return getMapFromString(values);
+    }
+    
+    public void displayEdit(StringBuffer buffer, String name, String prefix,
+            BaseCollection object, XWikiContext context)
+        {
+            if (getDisplayType().equals("input")) {
+                input input = new input();
+                BaseProperty prop = (BaseProperty) object.safeget(name);
+                if (prop != null) {
+                    input.setValue(prop.toFormString());
+                }
+                input.setType("text");
+                input.setSize(getSize());
+                input.setName(prefix + name);
+                input.setID(prefix + name);
+                
+                if(isPicker()) {
+                	input.addAttribute("autocomplete", "off");
+                	String path = "";
+                	try {
+                   	 	XWiki xwiki = context.getWiki();
+                   	 	path = xwiki.getURL("Main.WebHome", "view", context);
+                	} catch(XWikiException e) {
+                		e.printStackTrace();
+                	}
+                	
+                	String classname = this.getObject().getName();
+               	 	String fieldname = this.getName();
+               	 	String secondCol = "-", firstCol = "-";
+               	 	
+               	 	String script = "\""+path+"?xpage=suggest&amp;classname="+classname+"&amp;fieldname="+fieldname+"&amp;firCol="+firstCol+"&amp;secCol="+secondCol+"&amp;\"";
+            	 	String varname = "\"input\"";
+            	 	String seps = "\""+this.getSeparators()+"\"";
+            	 	if(isMultiSelect())
+            	 		input.setOnFocus("new ajaxSuggest(this, {script:"+script+", varname:"+varname+", seps:"+seps+"} )");
+            	 	else
+            	 		input.setOnFocus("new ajaxSuggest(this, {script:"+script+", varname:"+varname+"} )");
+                }
+                
+                buffer.append(input.toString());
+                
+            } else if (getDisplayType().equals("radio") || getDisplayType().equals("checkbox")) {
+                displayRadioEdit(buffer, name, prefix, object, context);
+            } else {
+                displaySelectEdit(buffer, name, prefix, object, context);
+            }
+
+            if (!getDisplayType().equals("input")) {
+                org.apache.ecs.xhtml.input hidden = new input(input.hidden, prefix + name, "");
+                buffer.append(hidden);
+            }
+        }
+}

Modified: xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/StringClass.java
===================================================================
--- xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/StringClass.java	2007-10-31 23:30:04 UTC (rev 5589)
+++ xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/StringClass.java	2007-11-01 09:32:13 UTC (rev 5590)
@@ -34,6 +34,9 @@
 import com.xpn.xwiki.plugin.query.XWikiCriteria;
 import com.xpn.xwiki.plugin.query.XWikiQuery;
 
+import com.xpn.xwiki.XWiki;
+import com.xpn.xwiki.XWikiException;
+
 public class StringClass extends PropertyClass
 {
 
@@ -62,7 +65,17 @@
     {
         setIntValue("size", size);
     }
+    
+    public boolean isPicker()
+    {
+        return (getIntValue("picker") == 1);
+    }
 
+    public void setPicker(boolean picker)
+    {
+        setIntValue("picker", picker ? 1 : 0);
+    }
+    
     public BaseProperty fromString(String value)
     {
         BaseProperty property = newProperty();
@@ -90,6 +103,26 @@
         input.setName(prefix + name);
         input.setID(prefix + name);
         input.setSize(getSize());
+        
+        if(isPicker()) {
+        	input.addAttribute("autocomplete", "off");
+        	String path = "";
+        	try {
+           	 	XWiki xwiki = context.getWiki();
+           	 	path = xwiki.getURL("Main.WebHome", "view", context);
+        	} catch(XWikiException e) {
+        		e.printStackTrace();
+        	  }
+        	
+        	String classname = this.getObject().getName();
+       	 	String fieldname = this.getName();
+       	 	String secondCol = "-", firstCol = "-";
+       	 	
+       	 	String script = "\""+path+"?xpage=suggest&amp;classname="+classname+"&amp;fieldname="+fieldname+"&amp;firCol="+firstCol+"&amp;secCol="+secondCol+"&amp;\"";
+    	 	String varname = "\"input\"";
+    	 	input.setOnFocus("new ajaxSuggest(this, {script:"+script+", varname:"+varname+"} )");
+        }
+        
         buffer.append(input.toString());
     }
 

Modified: xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/meta/DBListMetaClass.java
===================================================================
--- xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/meta/DBListMetaClass.java	2007-10-31 23:30:04 UTC (rev 5589)
+++ xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/meta/DBListMetaClass.java	2007-11-01 09:32:13 UTC (rev 5590)
@@ -1,67 +1,79 @@
-/*
- * Copyright 2006-2007, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- */
-
-package com.xpn.xwiki.objects.meta;
-
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.objects.BaseCollection;
-import com.xpn.xwiki.objects.classes.DBListClass;
-import com.xpn.xwiki.objects.classes.TextAreaClass;
-import com.xpn.xwiki.objects.classes.StringClass;
-
-public class DBListMetaClass extends ListMetaClass {
-
-    public DBListMetaClass() {
-        super();
-        setPrettyName("Database List Class");
-        setName(DBListClass.class.getName());
-
-        TextAreaClass sql_class = new TextAreaClass(this);
-        sql_class.setName("sql");
-        sql_class.setPrettyName("Hibernate Query");
-        sql_class.setSize(80);
-        sql_class.setRows(5);
-        safeput("sql", sql_class);
-
-        StringClass classname_class = new StringClass(this);
-        classname_class.setName("classname");
-        classname_class.setPrettyName("XWiki Class Name");
-        classname_class.setSize(20);
-        safeput("classname", classname_class);
-
-        StringClass idfield_class = new StringClass(this);
-        idfield_class.setName("idField");
-        idfield_class.setPrettyName("Id Field Name");
-        idfield_class.setSize(20);
-        safeput("idField", idfield_class);
-
-        StringClass valuefield_class = new StringClass(this);
-        valuefield_class.setName("valueField");
-        valuefield_class.setPrettyName("Value Field Name");
-        valuefield_class.setSize(20);
-        safeput("valueField", valuefield_class);
-    }
-
-    public BaseCollection newObject(XWikiContext context) {
-        return new DBListClass();
-    }
-}
-
+/*
+ * Copyright 2006-2007, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ */
+
+package com.xpn.xwiki.objects.meta;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.objects.BaseCollection;
+import com.xpn.xwiki.objects.classes.DBListClass;
+import com.xpn.xwiki.objects.classes.TextAreaClass;
+import com.xpn.xwiki.objects.classes.StringClass;
+
+import com.xpn.xwiki.objects.classes.BooleanClass;
+import com.xpn.xwiki.objects.classes.ListClass;
+import com.xpn.xwiki.objects.classes.NumberClass;
+import com.xpn.xwiki.objects.classes.StaticListClass;
+
+public class DBListMetaClass extends ListMetaClass {
+
+    public DBListMetaClass() {
+        super();
+        setPrettyName("Database List Class");
+        setName(DBListClass.class.getName());
+
+        TextAreaClass sql_class = new TextAreaClass(this);
+        sql_class.setName("sql");
+        sql_class.setPrettyName("Hibernate Query");
+        sql_class.setSize(80);
+        sql_class.setRows(5);
+        safeput("sql", sql_class);
+
+        StringClass classname_class = new StringClass(this);
+        classname_class.setName("classname");
+        classname_class.setPrettyName("XWiki Class Name");
+        classname_class.setSize(20);
+        safeput("classname", classname_class);
+
+        StringClass idfield_class = new StringClass(this);
+        idfield_class.setName("idField");
+        idfield_class.setPrettyName("Id Field Name");
+        idfield_class.setSize(20);
+        safeput("idField", idfield_class);
+
+        StringClass valuefield_class = new StringClass(this);
+        valuefield_class.setName("valueField");
+        valuefield_class.setPrettyName("Value Field Name");
+        valuefield_class.setSize(20);
+        safeput("valueField", valuefield_class);
+        
+        BooleanClass picker_class = new BooleanClass(this);
+        picker_class.setName("picker");
+        picker_class.setPrettyName("Use Suggest");
+        picker_class.setDisplayType("yesno");
+        picker_class.setUnmodifiable(true);
+        safeput("picker", picker_class);
+    }
+
+    public BaseCollection newObject(XWikiContext context) {
+        return new DBListClass();
+    }
+}
+

Modified: xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/meta/ListMetaClass.java
===================================================================
--- xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/meta/ListMetaClass.java	2007-10-31 23:30:04 UTC (rev 5589)
+++ xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/meta/ListMetaClass.java	2007-11-01 09:32:13 UTC (rev 5590)
@@ -1,90 +1,96 @@
-/*
- * Copyright 2006-2007, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- */
-
-package com.xpn.xwiki.objects.meta;
-
-import com.xpn.xwiki.objects.classes.BooleanClass;
-import com.xpn.xwiki.objects.classes.ListClass;
-import com.xpn.xwiki.objects.classes.NumberClass;
-import com.xpn.xwiki.objects.classes.StaticListClass;
-import com.xpn.xwiki.objects.classes.StringClass;
-
-public class ListMetaClass extends PropertyMetaClass {
-
-    public ListMetaClass() {
-        super();
-        setPrettyName("List Class");
-        setName(ListClass.class.getName());
-
-        StaticListClass type_class = new StaticListClass(this);
-        type_class.setName("displayType");
-        type_class.setPrettyName("Display Type");
-        type_class.setValues("input|select|radio|checkbox");
-        safeput("displayType", type_class);
-
-        BooleanClass multi_class = new BooleanClass(this);
-        multi_class.setName("multiSelect");
-        multi_class.setPrettyName("Multiple Select");
-        multi_class.setDisplayType("yesno");
-        multi_class.setUnmodifiable(true);
-        safeput("multiSelect", multi_class);
-
-        BooleanClass relational_class = new BooleanClass(this);
-        relational_class.setName("relationalStorage");
-        relational_class.setPrettyName("Relational Storage");
-        relational_class.setDisplayType("yesno");
-        relational_class.setUnmodifiable(true);
-        safeput("relationalStorage", relational_class);
-
-        BooleanClass picker_class = new BooleanClass(this);
-        picker_class.setName("picker");
-        picker_class.setPrettyName("Use Picker");
-        picker_class.setDisplayType("yesno");
-        picker_class.setUnmodifiable(true);
-        safeput("picker", picker_class);
-
-        NumberClass size_class = new NumberClass(this);
-        size_class.setName("size");
-        size_class.setPrettyName("Size");
-        size_class.setSize(5);
-        size_class.setNumberType("integer");
-        safeput("size", size_class);
-
-        StringClass separator_class = new StringClass(this);
-        separator_class.setName("separator");
-        separator_class.setPrettyName("Join separator");
-        separator_class.setSize(20);
-        safeput("separator", separator_class);
-
-        StaticListClass sort_class = new StaticListClass(this);
-        sort_class.setName("sort");
-        sort_class.setPrettyName("Sort");
-        sort_class.setValues("none|id|value");
-        safeput("sort", sort_class);
-
-        BooleanClass cache_class = new BooleanClass(this);
-        cache_class.setName("cache");
-        cache_class.setPrettyName("Cache");
-        cache_class.setDisplayType("yesno");
-        cache_class.setUnmodifiable(true);
-        safeput("cache", cache_class);
-    }
-}
+/*
+ * Copyright 2006-2007, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ */
+
+package com.xpn.xwiki.objects.meta;
+
+import com.xpn.xwiki.objects.classes.BooleanClass;
+import com.xpn.xwiki.objects.classes.ListClass;
+import com.xpn.xwiki.objects.classes.NumberClass;
+import com.xpn.xwiki.objects.classes.StaticListClass;
+import com.xpn.xwiki.objects.classes.StringClass;
+
+public class ListMetaClass extends PropertyMetaClass {
+
+    public ListMetaClass() {
+        super();
+        setPrettyName("List Class");
+        setName(ListClass.class.getName());
+
+        StaticListClass type_class = new StaticListClass(this);
+        type_class.setName("displayType");
+        type_class.setPrettyName("Display Type");
+        type_class.setValues("input|select|radio|checkbox");
+        safeput("displayType", type_class);
+
+        BooleanClass multi_class = new BooleanClass(this);
+        multi_class.setName("multiSelect");
+        multi_class.setPrettyName("Multiple Select");
+        multi_class.setDisplayType("yesno");
+        multi_class.setUnmodifiable(true);
+        safeput("multiSelect", multi_class);
+        
+        StringClass separators_class = new StringClass(this);
+        separators_class.setName("separators");
+        separators_class.setPrettyName("Separators");
+        separators_class.setSize(5);
+        safeput("separators", separators_class);
+
+        BooleanClass relational_class = new BooleanClass(this);
+        relational_class.setName("relationalStorage");
+        relational_class.setPrettyName("Relational Storage");
+        relational_class.setDisplayType("yesno");
+        relational_class.setUnmodifiable(true);
+        safeput("relationalStorage", relational_class);
+
+        BooleanClass picker_class = new BooleanClass(this);
+        picker_class.setName("picker");
+        picker_class.setPrettyName("Use Picker");
+        picker_class.setDisplayType("yesno");
+        picker_class.setUnmodifiable(true);
+        safeput("picker", picker_class);
+
+        NumberClass size_class = new NumberClass(this);
+        size_class.setName("size");
+        size_class.setPrettyName("Size");
+        size_class.setSize(5);
+        size_class.setNumberType("integer");
+        safeput("size", size_class);
+
+        StringClass separator_class = new StringClass(this);
+        separator_class.setName("separator");
+        separator_class.setPrettyName("Join separator");
+        separator_class.setSize(20);
+        safeput("separator", separator_class);
+
+        StaticListClass sort_class = new StaticListClass(this);
+        sort_class.setName("sort");
+        sort_class.setPrettyName("Sort");
+        sort_class.setValues("none|id|value");
+        safeput("sort", sort_class);
+
+        BooleanClass cache_class = new BooleanClass(this);
+        cache_class.setName("cache");
+        cache_class.setPrettyName("Cache");
+        cache_class.setDisplayType("yesno");
+        cache_class.setUnmodifiable(true);
+        safeput("cache", cache_class);
+    }
+}

Modified: xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/meta/StaticListMetaClass.java
===================================================================
--- xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/meta/StaticListMetaClass.java	2007-10-31 23:30:04 UTC (rev 5589)
+++ xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/meta/StaticListMetaClass.java	2007-11-01 09:32:13 UTC (rev 5590)
@@ -1,53 +1,64 @@
-/*
- * Copyright 2006-2007, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- */
-
-package com.xpn.xwiki.objects.meta;
-
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.objects.BaseCollection;
-import com.xpn.xwiki.objects.classes.StaticListClass;
-import com.xpn.xwiki.objects.classes.StringClass;
-
-public class StaticListMetaClass extends ListMetaClass {
-
-
-    public StaticListMetaClass() {
-        super();
-        setPrettyName("Static List Class");
-        setName(StaticListClass.class.getName());
-
-        StringClass values_class = new StringClass(this);
-        values_class.setName("values");
-        values_class.setPrettyName("Values");
-        values_class.setSize(40);
-        safeput("values", values_class);
-
-        StringClass separators_class = new StringClass(this);
-        separators_class.setName("separators");
-        separators_class.setPrettyName("Separators");
-        separators_class.setSize(5);
-        safeput("separators", separators_class);        
-    }
-
-    public BaseCollection newObject(XWikiContext context) {
-        return new StaticListClass();
-    }
-}
+/*
+ * Copyright 2006-2007, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ */
+
+package com.xpn.xwiki.objects.meta;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.objects.BaseCollection;
+import com.xpn.xwiki.objects.classes.StaticListClass;
+import com.xpn.xwiki.objects.classes.StringClass;
+
+import com.xpn.xwiki.objects.classes.BooleanClass;
+import com.xpn.xwiki.objects.classes.ListClass;
+import com.xpn.xwiki.objects.classes.NumberClass;
+
+public class StaticListMetaClass extends ListMetaClass {
+
+
+    public StaticListMetaClass() {
+        super();
+        setPrettyName("Static List Class");
+        setName(StaticListClass.class.getName());
+
+        StringClass values_class = new StringClass(this);
+        values_class.setName("values");
+        values_class.setPrettyName("Values");
+        values_class.setSize(40);
+        safeput("values", values_class);
+
+        StringClass separators_class = new StringClass(this);
+        separators_class.setName("separators");
+        separators_class.setPrettyName("Separators");
+        separators_class.setSize(5);
+        safeput("separators", separators_class);        
+        
+        BooleanClass picker_class = new BooleanClass(this);
+        picker_class.setName("picker");
+        picker_class.setPrettyName("Use Suggest");
+        picker_class.setDisplayType("yesno");
+        picker_class.setUnmodifiable(true);
+        safeput("picker", picker_class);
+    }
+
+    public BaseCollection newObject(XWikiContext context) {
+        return new StaticListClass();
+    }
+}

Modified: xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/meta/StringMetaClass.java
===================================================================
--- xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/meta/StringMetaClass.java	2007-10-31 23:30:04 UTC (rev 5589)
+++ xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/meta/StringMetaClass.java	2007-11-01 09:32:13 UTC (rev 5590)
@@ -1,51 +1,59 @@
-/*
- * Copyright 2006-2007, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- */
-
-package com.xpn.xwiki.objects.meta;
-
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.objects.BaseCollection;
-import com.xpn.xwiki.objects.classes.NumberClass;
-import com.xpn.xwiki.objects.classes.StringClass;
-
-public class StringMetaClass extends PropertyMetaClass
-{
-
-    public StringMetaClass()
-    {
-        super();
-        // setType("stringmetaclass");
-        setPrettyName("String Class");
-        setName(StringClass.class.getName());
-
-        NumberClass size_class = new NumberClass(this);
-        size_class.setName("size");
-        size_class.setPrettyName("Size");
-        size_class.setSize(5);
-        size_class.setNumberType("integer");
-        safeput("size", size_class);
-    }
-
-    public BaseCollection newObject(XWikiContext context)
-    {
-        return new StringClass();
-    }
-}
+/*
+ * Copyright 2006-2007, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ */
+
+package com.xpn.xwiki.objects.meta;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.objects.BaseCollection;
+import com.xpn.xwiki.objects.classes.NumberClass;
+import com.xpn.xwiki.objects.classes.StringClass;
+import com.xpn.xwiki.objects.classes.BooleanClass;
+
+public class StringMetaClass extends PropertyMetaClass
+{
+
+    public StringMetaClass()
+    {
+        super();
+        // setType("stringmetaclass");
+        setPrettyName("String Class");
+        setName(StringClass.class.getName());
+
+        NumberClass size_class = new NumberClass(this);
+        size_class.setName("size");
+        size_class.setPrettyName("Size");
+        size_class.setSize(5);
+        size_class.setNumberType("integer");
+        safeput("size", size_class);
+        
+        BooleanClass picker_class = new BooleanClass(this);
+        picker_class.setName("picker");
+        picker_class.setPrettyName("Use Suggest");
+        picker_class.setDisplayType("yesno");
+        picker_class.setUnmodifiable(true);
+        safeput("picker", picker_class);
+    }
+
+    public BaseCollection newObject(XWikiContext context)
+    {
+        return new StringClass();
+    }
+}



More information about the notifications mailing list