public Widget asWidget() {
VerticalPanel layout = new VerticalPanel();
layout.setStyleName("window-content");
final Form<ServerGroupRecord> form = new Form(ServerGroupRecord.class);
TextBoxItem nameField = new TextBoxItem("groupName", Console.CONSTANTS.common_label_name())
{
@Override
public boolean validate(String value) {
boolean hasValue = super.validate(value);
boolean hasWhitespace = value.contains(" ");
return hasValue && !hasWhitespace;
}
@Override
public String getErrMessage() {
return Console.MESSAGES.common_validation_notEmptyNoSpace();
}
};
String[] profiles = new String[existingProfiles.size()];
int i=0;
for(ProfileRecord rec : existingProfiles)
{
profiles[i] = rec.getName();
i++;
}
final ComboBoxItem profileSelection = new ComboBoxItem("profileName", "Profile");
profileSelection.setDefaultToFirstOption(true);
profileSelection.setValueMap(profiles);
final ComboBoxItem socketSelection = new ComboBoxItem("socketBinding", "Socket Binding");
socketSelection.setDefaultToFirstOption(true);
socketSelection.setValueMap(existingSockets);
form.setFields(nameField, profileSelection, socketSelection);
DialogueOptions options = new DialogueOptions(
// save
new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// merge base
ServerGroupRecord newGroup = form.getUpdatedEntity();
FormValidation validation = form.validate();
if(validation.hasErrors())
return;
presenter.createNewGroup(newGroup);
}
},
// cancel
new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
presenter.closeDialoge();
}
}
);
// ----------------------------------------
Widget formWidget = form.asWidget();
final FormHelpPanel helpPanel = new FormHelpPanel(
new FormHelpPanel.AddressCallback() {
@Override
public ModelNode getAddress() {