}
@Override
@SuppressWarnings("unchecked")
public void setAsText(String text) throws IllegalArgumentException {
ImageGallery docs = (ImageGallery) getValue();
if (docs == null) docs = new ImageGallery();
for (String doc : text.split("##")) {
if (StringUtils.hasText(doc)) {
if (doc.startsWith("-")) {
Iterator<Image> it = docs.getImages().iterator();
while (it.hasNext()) {
Image d = it.next();
if (doc.substring(1).equals(d.getUri())) it.remove();
}
} else {
Image document = getImage(doc);
if (document != null) docs.addImage(document);
}
}
}
setValue(docs);
}