final DynamicForm form = new DynamicForm();
form.setID("severityForm");
form.setWidth(200);
form.setItemHoverWidth(200);
final ComboBoxItem severityLevel = new ComboBoxItem();
severityLevel.setTitle("Severity Level");
severityLevel.setValueMap("Severity 1", "Severity 2", "Severity 3");
severityLevel.setDefaultValue("Severity 2");
severityLevel.addItemHoverHandler(new ItemHoverHandler() {
public void onItemHover(ItemHoverEvent event) {
String prompt = "Status can only be changed by the bug's owner";
if (!severityLevel.isDisabled()) {
prompt = getHoverText((String) severityLevel.getValue());
}
severityLevel.setPrompt(prompt);
}
});
final ButtonItem buttonItem = new ButtonItem();
buttonItem.setTop(40);
buttonItem.setWidth(150);
buttonItem.setTitle("Enable/disable field");
buttonItem.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
severityLevel.setDisabled(!severityLevel.isDisabled());
}
});
form.setFields(severityLevel, buttonItem);