protected void addToSelect(select select, List<String> selectlist, Map<String, ListItem> map, Map<String, List<ListItem>> treemap, String parent, String level, XWikiContext context) { List<ListItem> list = treemap.get(parent); if (list != null) { for (ListItem item : list) { String display = level + getDisplayValue(item.getId(), "", map, context); option option = new option(display, item.getId()); option.addElement(display); if (selectlist.contains(item.getId())) { option.setSelected(true); } select.addElement(option); addToSelect(select, selectlist, map, treemap, item.getId(), level + " ", context); } } }
protected void displayTreeSelectEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) { select select = new select(prefix + name, 1); 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()); }