public void onAddDetail(final Detail d, boolean fireEvent) { final DetailItem<Detail> di = new DetailItem<Detail>(d); di.getCloseButton() .addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { handleRemoveDetail(di); } }); mDisplay.getContextItemsContainer().add(di); if (fireEvent) { if (mDataModel.getValue().getDetails() == null) mDataModel.getValue().setDetails(new ArrayList<Detail>()); mDataModel.getValue().getDetails().add(d); } }
public void onRemoveDetail(final DetailItem<Detail> di) { mDisplay.getContextItemsContainer().remove(di); mDataModel.getValue().getDetails().remove(di.getValue()); }