Search in sources :

Example 1 with UpdateApplicationMail

use of cz.metacentrum.perun.webgui.json.registrarManager.UpdateApplicationMail in project perun by CESNET.

the class EditMailTabItem method draw.

public Widget draw() {
    this.titleWidget.setText("Edit notification");
    // languages
    ArrayList<String> languages = appMail.getLocales();
    if (!Utils.getNativeLanguage().isEmpty() && !languages.contains(Utils.getNativeLanguage().get(0))) {
        languages.add(Utils.getNativeLanguage().get(0));
    }
    if (!languages.contains("en"))
        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.SAVE, ButtonTranslation.INSTANCE.saveEmailNotificationForApplication(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            // values
            boolean send = sendingEnabledCheckBox.getValue();
            appMail.setSend(send);
            // 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);
                appMail.setMessage(locale, mt);
            }
            // request
            UpdateApplicationMail req = new UpdateApplicationMail(JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab, true));
            req.updateMail(appMail);
        }
    });
    tabMenu.addWidget(saveButton);
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, isRefreshParentOnClose());
        }
    }));
    // 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();
}
Also used : ClickEvent(com.google.gwt.event.dom.client.ClickEvent) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) UpdateApplicationMail(cz.metacentrum.perun.webgui.json.registrarManager.UpdateApplicationMail) MailText(cz.metacentrum.perun.webgui.model.MailText) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 UpdateApplicationMail (cz.metacentrum.perun.webgui.json.registrarManager.UpdateApplicationMail)1 MailText (cz.metacentrum.perun.webgui.model.MailText)1 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)1 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1