VerticalPanel layout = new VerticalPanel();
layout.setStyleName("window-content");
final PojoForm<Role> form = new PojoForm<Role>();
final TextBoxItem nameItem = new TextBoxItem("name", "Name");
final StandardRoleFormItem baseRoleItem = new StandardRoleFormItem("baseRole", "Base Role");
baseRoleItem.setValues();
final EnumFormItem<Role.Type> typeItem = new EnumFormItem<Role.Type>("type", "Type");
typeItem.setDefaultToFirst(true);
typeItem.setValues(UIHelper.enumFormItemsForScopedRoleTyp());
final MultiselectListBoxItem scopeItem = new MultiselectListBoxItem("scope", "Scope", 3);
final CheckBoxItem includeAllItem = new CheckBoxItem("includeAll", "Include All");
form.setFields(nameItem, baseRoleItem, typeItem, scopeItem, includeAllItem);
layout.add(new ScopedRoleHelpPanel().asWidget());
layout.add(form.asWidget());
typeItem.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(final ChangeEvent event) {
Role.Type type = typeItem.getValue();
updateScope(type, scopeItem, form);
}
});
updateScope(typeItem.getValue(), scopeItem, form);
DialogueOptions options = new DialogueOptions(
new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
FormValidation validation = form.validate();
if (!validation.hasErrors()) {
Role scopedRole = new Role(nameItem.getValue(), nameItem.getValue(),
baseRoleItem.getValue(), typeItem.getValue(), scopeItem.getValue());
scopedRole.setIncludeAll(includeAllItem.getValue());
presenter.addScopedRole(scopedRole);
}
}
},