componentHelper.fireComponentMoved(this);
}
private void deselectItem(final TextBox itemBox, final BulletList list) {
if (itemBox.getValue() != null && !"".equals(itemBox.getValue().trim())) {
/**
* Change to the following structure: <li class="token-input-token-facebook">
* <p>
* What's New Scooby-Doo?
* </p>
* <span class="token-input-delete-token-facebook">x</span></li>
*/
final ListItem displayItem = new ListItem();
displayItem.setStyleName("token-input-token-facebook");
Paragraph p = new Paragraph(itemBox.getValue());
displayItem.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
displayItem
.addStyleName("token-input-selected-token-facebook");
}
});
/**
* TODO: Figure out how to select item and allow deleting with
* backspace key displayItem.addKeyDownHandler(new KeyDownHandler()
* { public void onKeyDown(KeyDownEvent event) { if
* (event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE) {
* removeListItem(displayItem, list); } } });
* displayItem.addBlurHandler(new BlurHandler() { public void
* onBlur(BlurEvent blurEvent) { displayItem.removeStyleName(
* "token-input-selected-token-facebook"); } });
*/
Span span = new Span("x");
span.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
removeListItem(displayItem, list);
}
});
displayItem.add(p);
displayItem.add(span);
// hold the original value of the item selected
GWT.log("Adding selected item '" + itemBox.getValue() + "'", null);
itemsSelected.add(itemBox.getValue());
GWT.log("Total: " + itemsSelected, null);