@SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected T readItem(Element child, Set<T> selected, DesignContext context) { T item = super.readItem(child, selected, context); SerializablePredicate<T> provider = getItemEnabledProvider(); if (provider instanceof DeclarativeItemEnabledProvider) { if (child.hasAttr("disabled")) { ((DeclarativeItemEnabledProvider) provider).addDisabled(item); } } else { throw new IllegalStateException(String.format("Don't know how " + "to disable item using current item enabled provider '%s'", provider.getClass().getName())); } return item; }
@Override protected Element writeItem(Element design, T item, DesignContext context) { Element elem = super.writeItem(design, item, context); if (!getItemEnabledProvider().test(item)) { elem.attr("disabled", true); } if (isHtmlContentAllowed()) { // need to unencode HTML entities. AbstractMultiSelect.writeDesign // can't check if HTML content is allowed, so it always encodes // entities like '>', '<' and '&'; in case HTML content is allowed // this is undesirable so we need to unencode entities. Entities // other than '<' and '>' will be taken care by Jsoup. elem.html(DesignFormatter.decodeFromTextNode(elem.html())); } return elem; }