Search in sources :

Example 11 with XMLAttributeValueFilter

use of com.xpn.xwiki.internal.xml.XMLAttributeValueFilter in project xwiki-platform by xwiki.

the class NumberClass method displayEdit.

@Override
public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
    input input = new input();
    input.setAttributeFilter(new XMLAttributeValueFilter());
    BaseProperty prop = (BaseProperty) object.safeget(name);
    if (prop != null) {
        input.setValue(prop.toText());
    }
    input.setType("text");
    input.setName(prefix + name);
    input.setID(prefix + name);
    input.setSize(getSize());
    input.setDisabled(isDisabled());
    buffer.append(input.toString());
}
Also used : org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) XMLAttributeValueFilter(com.xpn.xwiki.internal.xml.XMLAttributeValueFilter) BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Example 12 with XMLAttributeValueFilter

use of com.xpn.xwiki.internal.xml.XMLAttributeValueFilter in project xwiki-platform by xwiki.

the class DBTreeListClass method displayTreeSelectEdit.

protected void displayTreeSelectEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
    select select = new select(prefix + name, 1);
    select.setAttributeFilter(new XMLAttributeValueFilter());
    select.setMultiple(isMultiSelect());
    select.setSize(getSize());
    select.setName(prefix + name);
    select.setID(prefix + name);
    select.setDisabled(isDisabled());
    Map<String, ListItem> map = getMap(context);
    Map<String, List<ListItem>> treemap = getTreeMap(context);
    List<String> selectlist;
    BaseProperty prop = (BaseProperty) object.safeget(name);
    if (prop == null) {
        selectlist = new ArrayList<String>();
    } else if (prop instanceof ListProperty) {
        selectlist = ((ListProperty) prop).getList();
    } else {
        selectlist = new ArrayList<String>();
        selectlist.add(String.valueOf(prop.getValue()));
    }
    // Add options from Set
    addToSelect(select, selectlist, map, treemap, "", "", context);
    buffer.append(select.toString());
}
Also used : ListProperty(com.xpn.xwiki.objects.ListProperty) org.apache.ecs.xhtml.select(org.apache.ecs.xhtml.select) XMLAttributeValueFilter(com.xpn.xwiki.internal.xml.XMLAttributeValueFilter) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Example 13 with XMLAttributeValueFilter

use of com.xpn.xwiki.internal.xml.XMLAttributeValueFilter in project xwiki-platform by xwiki.

the class LevelsClass method displayEdit.

@Override
public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
    select select = new select(prefix + name, 1);
    select.setAttributeFilter(new XMLAttributeValueFilter());
    select.setMultiple(isMultiSelect());
    select.setSize(getSize());
    select.setName(prefix + name);
    select.setID(prefix + name);
    select.setDisabled(isDisabled());
    List<String> list = getList(context);
    BaseProperty prop = (BaseProperty) object.safeget(name);
    List<String> selectlist = toList(prop);
    // Add options from Set
    for (String value : list) {
        String display = getText(value, context);
        option option = new option(display, value);
        option.setAttributeFilter(new XMLAttributeValueFilter());
        option.addElement(XMLUtils.escape(display));
        // If we don't have this option in the list then add it
        if (!list.contains(value)) {
            list.add(value);
        }
        if (selectlist.contains(value)) {
            option.setSelected(true);
        }
        select.addElement(option);
    }
    buffer.append(select.toString());
    input in = new input();
    in.setAttributeFilter(new XMLAttributeValueFilter());
    in.setType("hidden");
    in.setName(prefix + name);
    in.setDisabled(isDisabled());
    buffer.append(in.toString());
}
Also used : org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) org.apache.ecs.xhtml.select(org.apache.ecs.xhtml.select) XMLAttributeValueFilter(com.xpn.xwiki.internal.xml.XMLAttributeValueFilter) BaseProperty(com.xpn.xwiki.objects.BaseProperty) org.apache.ecs.xhtml.option(org.apache.ecs.xhtml.option)

Example 14 with XMLAttributeValueFilter

use of com.xpn.xwiki.internal.xml.XMLAttributeValueFilter in project xwiki-platform by xwiki.

the class ListClass method displaySelectEdit.

protected void displaySelectEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
    select select = new select(prefix + name, 1);
    select.setAttributeFilter(new XMLAttributeValueFilter());
    select.setMultiple(isMultiSelect());
    select.setSize(getSize());
    select.setName(prefix + name);
    select.setID(prefix + name);
    select.setDisabled(isDisabled());
    List<String> list = getList(context);
    Map<String, ListItem> map = getMap(context);
    String sort = getSort();
    if (!"none".equals(sort)) {
        if ("id".equals(sort)) {
            Collections.sort(list);
        }
        if ("value".equals(sort)) {
            Collections.sort(list, new MapComparator(map));
        }
    }
    List<String> selectlist = toList((BaseProperty) object.safeget(name));
    // Add the selected values that are not in the predefined list.
    for (String item : selectlist) {
        if (!list.contains(item)) {
            list.add(item);
        }
    }
    // Add options from Set
    for (String rawvalue : list) {
        String value = getElementValue(rawvalue);
        String display = getDisplayValue(rawvalue, name, map, context);
        option option = new option(display, value);
        option.setAttributeFilter(new XMLAttributeValueFilter());
        option.addElement(XMLUtils.escape(display));
        if (selectlist.contains(value)) {
            option.setSelected(true);
        }
        select.addElement(option);
    }
    buffer.append(select.toString());
}
Also used : org.apache.ecs.xhtml.select(org.apache.ecs.xhtml.select) XMLAttributeValueFilter(com.xpn.xwiki.internal.xml.XMLAttributeValueFilter) org.apache.ecs.xhtml.option(org.apache.ecs.xhtml.option)

Example 15 with XMLAttributeValueFilter

use of com.xpn.xwiki.internal.xml.XMLAttributeValueFilter in project xwiki-platform by xwiki.

the class PropertyClass method displayEdit.

@Override
public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
    input input = new input();
    input.setAttributeFilter(new XMLAttributeValueFilter());
    BaseProperty prop = (BaseProperty) object.safeget(name);
    if (prop != null) {
        input.setValue(prop.toText());
    }
    input.setType("text");
    input.setName(prefix + name);
    input.setID(prefix + name);
    input.setDisabled(isDisabled());
    buffer.append(input.toString());
}
Also used : org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) XMLAttributeValueFilter(com.xpn.xwiki.internal.xml.XMLAttributeValueFilter) BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Aggregations

XMLAttributeValueFilter (com.xpn.xwiki.internal.xml.XMLAttributeValueFilter)16 org.apache.ecs.xhtml.input (org.apache.ecs.xhtml.input)13 BaseProperty (com.xpn.xwiki.objects.BaseProperty)12 org.apache.ecs.xhtml.select (org.apache.ecs.xhtml.select)4 XWiki (com.xpn.xwiki.XWiki)3 IntegerProperty (com.xpn.xwiki.objects.IntegerProperty)3 org.apache.ecs.xhtml.option (org.apache.ecs.xhtml.option)3 ListProperty (com.xpn.xwiki.objects.ListProperty)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 org.apache.ecs.xhtml.div (org.apache.ecs.xhtml.div)1 org.apache.ecs.xhtml.label (org.apache.ecs.xhtml.label)1