/** * Called when is created Cons * * @param value */ public void onAddCon(String value, boolean fireEvent) { if (value != null && value.trim().length() != 0) { final ContextItem<String> ci = new ContextItem<String>(); ci.getCloseButton() .addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { handleRemoveCon(ci); } }); ci.setTextValue(value); ci.setIcon(ContextItem.IconType.Cons); mDisplay.getContextItemsContainer().add(ci); if (fireEvent) { if (mDataModel.getValue().getCons() == null) mDataModel.getValue().setCons(new ArrayList<String>()); mDataModel.getValue().getCons().add(value); } } }
public void onRemoveCon(final ContextItem<String> ci) { mDisplay.getContextItemsContainer().remove(ci); mDataModel.getValue().getCons().remove(ci.getTextValue()); }