Search in sources :

Example 1 with AddApplicationMail

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();
}
Also used : HashMap(java.util.HashMap) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) AddApplicationMail(cz.metacentrum.perun.webgui.json.registrarManager.AddApplicationMail) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) HashMap(java.util.HashMap) Map(java.util.Map) AddApplicationMail(cz.metacentrum.perun.webgui.json.registrarManager.AddApplicationMail)

Aggregations

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