setHeading(Messages.get("label.testNewsletter", "Test newsletter issue"));
setSize(500, 170);
setResizable(false);
setModal(true);
ButtonBar buttons = new ButtonBar();
final FormPanel form = new FormPanel();
form.setFrame(false);
form.setHeaderVisible(false);
form.setBorders(false);
form.setBodyBorder(false);
form.setLabelWidth(200);
final TextField<String> mail = new TextField<String>();
mail.setFieldLabel(Messages.get("label.email", "Email"));
mail.setName("testemail");
mail.setAllowBlank(false);
form.add(mail);
final TextField<String> user = new TextField<String>();
user.setFieldLabel(Messages.get("label.user", "User"));
user.setName("user");
user.setValue("guest");
form.add(user);
final ComboBox<GWTJahiaLanguage> locale = new ComboBox<GWTJahiaLanguage>();
locale.setStore(new ListStore<GWTJahiaLanguage>());
locale.getStore().add(JahiaGWTParameters.getSiteLanguages());
locale.setDisplayField("displayName");
locale.setTypeAhead(true);
locale.setTriggerAction(ComboBox.TriggerAction.ALL);
locale.setForceSelection(true);
locale.setEditable(false);
locale.setFieldLabel(Messages.get("label.language", "Language"));
locale.setValue(selectedLang);
locale.setName("locale");
form.add(locale);
Button submit = new Button(Messages.get("label.ok"), new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent event) {
if (mail.getValue() == null || mail.getValue().trim().length() == 0) {
MessageBox.alert(Messages.get("label.testNewsletter", "Test newsletter issue"), Messages.get("failure.invalid.emailAddress", "Please enter valid e-mail address"), null);
return;
}
mask();
String data = "testemail=" + URL.encodeQueryString(mail.getValue());
data += "&type=html&user=" + (user.getValue() != null ? URL.encodeQueryString(user.getValue()) : "");
data += "&locale=" + URL.encodeQueryString(locale.getValue().getLanguage());
doAction(linker.getSelectionContext().getSingleSelection(), data);
}
});
Button cancel = new Button(Messages.get("label.cancel"), new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent event) {
hide();
}
});
buttons.add(submit);
buttons.add(cancel);
setButtonAlign(Style.HorizontalAlignment.CENTER);
setBottomComponent(buttons);
add(form);
}