oracle.add("Latte");
oracle.add("Moccachino");
oracle.add("Black Coffee + Sugar 026");
oracle.add("Black Coffee - Sugar");
final SuggestBox box = new SuggestBox(oracle);
// create a listener for adding coffee icon to the column
SelectionHandler<Suggestion> addListener = new SelectionHandler<Suggestion>() {
public void onSelection(SelectionEvent<Suggestion> event) {
if (cupArray.getWidgetCount() == 4) {
Window.alert("Easy Tiger!");
box.setText("");
return;
}
cupArray.add(coffeeImages.cupIcon().createImage());
cupArray.getElement().setTitle(box.getText());
box.setText("");
}
};
box.addSelectionHandler(addListener);
int row = clientsFlexTable.getRowCount();
clientsFlexTable.setText(row, 0, name);
clientsFlexTable.setWidget(row, 1, box);
clientsFlexTable.setWidget(row, 2, cupArray);