use of cz.metacentrum.perun.webgui.json.registrarManager.AddApplicationMail in project perun by CESNET.
the class CreateMailTabItem method draw.
public Widget draw() {
String title = "";
if (group != null) {
title = group.getName();
entity = PerunEntity.GROUP;
entityId = groupId;
} else {
title = vo.getName();
entity = PerunEntity.VIRTUAL_ORGANIZATION;
entityId = voId;
}
this.titleWidget.setText("Add email notification");
// languages
ArrayList<String> languages = new ArrayList<String>();
if (!Utils.getNativeLanguage().isEmpty()) {
languages.add(Utils.getNativeLanguage().get(0));
}
languages.add(0, "en");
// vertical panel
VerticalPanel vp = new VerticalPanel();
vp.setWidth("500px");
vp.setHeight("350px");
// tab panel
tabPanel.addStyleName("smallTabPanel");
tabPanel.addStyleName("smallTabPanelWithBorder");
tabPanel.setHeight("350px");
// basic settings
tabPanel.add(basicInformationTab(), "Basic settings");
// for each locale add tab
for (String locale : languages) {
tabPanel.add(messageTab(locale), "Lang: " + locale);
}
tabPanel.add(availableTagsTab(), "Available tags");
// add menu
final TabItem tab = this;
TabMenu tabMenu = new TabMenu();
saveButton = TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createEmailNotificationForApplication(), new ClickHandler() {
public void onClick(ClickEvent event) {
String appType = applicationTypeListbox.getValue(applicationTypeListbox.getSelectedIndex());
String mailType = mailTypeListbox.getValue(mailTypeListbox.getSelectedIndex());
boolean send = sendingEnabledCheckBox.getValue();
HashMap<String, MailText> messages = new HashMap<String, MailText>();
// messages
for (Map.Entry<String, TextArea> entry : messagesTextAreas.entrySet()) {
String locale = entry.getKey();
String subject = messagesSubjects.get(entry.getKey()).getValue();
String text = entry.getValue().getText();
MailText mt = MailText.construct(locale, subject, text);
messages.put(locale, mt);
}
// create object
ApplicationMail appMail = ApplicationMail.construct(appType, form.getId(), mailType, send, messages);
// request
AddApplicationMail req = new AddApplicationMail(entity, JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab));
req.addMail(appMail, entityId);
}
});
tabMenu.addWidget(saveButton);
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
// add tab panel to main panel
vp.add(tabPanel);
vp.setCellWidth(tabPanel, "500px");
vp.setCellHeight(tabPanel, "350px");
vp.add(tabMenu);
vp.setCellHeight(tabMenu, "30px");
vp.setCellHorizontalAlignment(tabMenu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
Aggregations