"Jamie", "Jill", "Jackie", "Susan", "Helen", "Emily", "Karen",
"Abigail", "Kaitlyn", "Laura", "Joanna", "Tasha"});
MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
oracle.addAll(femaleNames);
final SuggestBox b = new SuggestBox(oracle);
b.setTitle(suggestBoxName);
p.add(b);
final CheckBox selectsFirst = new CheckBox("Selects first suggestion");
selectsFirst.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
public void onValueChange(ValueChangeEvent<Boolean> event) {
b.setAutoSelectEnabled(event.getValue());
}
});
selectsFirst.setChecked(b.isAutoSelectEnabled());
p.add(selectsFirst);
final EventReporter<String, SuggestBox> handler = new EventReporter<String, SuggestBox>(
report);
handler.new CheckBoxEvent("KeyDown", p) {
@Override
public HandlerRegistration addHandler() {
return b.addKeyDownHandler(handler);
}
};
handler.new CheckBoxListener("ChangeListener", p) {
@Override
public void addListener() {
b.addChangeListener(handler);
}
@Override
public void removeListener() {
b.removeChangeListener(handler);
}
};
handler.new CheckBoxListener("Suggestion listener", p) {
@Override
public void addListener() {
b.addEventHandler(handler);
}
@Override
public void removeListener() {
b.removeEventHandler(handler);
}
};
b.addKeyUpHandler(handler);
b.addKeyPressHandler(handler);
b.addFocusListener(handler);
b.addSelectionHandler(handler);
b.addValueChangeHandler(handler);
return b;
}