Search in sources :

Example 36 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent 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));
            req.updateMail(appMail);
        }
    });
    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 : 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)

Example 37 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.

the class EditMailTabItem method messageTab.

/**
	 * Returns message texarea
	 *
	 * @param locale
	 * @return
	 */
private Widget messageTab(String locale) {
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("500px", "350px");
    vp.setSpacing(10);
    // layout
    FlexTable ft = new FlexTable();
    ft.setStyleName("inputFormFlexTable");
    FlexCellFormatter ftf = ft.getFlexCellFormatter();
    // inputs
    TextBox tb = new TextBox();
    tb.setWidth("385px");
    messagesSubjects.put(locale, tb);
    TextArea ta = new TextArea();
    ta.setSize("450px", "190px");
    messagesTextAreas.put(locale, ta);
    // adds inputs to the flex table
    ft.setHTML(0, 0, "Subject:");
    ftf.setStyleName(0, 0, "itemName");
    ft.setWidget(0, 1, tb);
    ftf.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_RIGHT);
    ft.setHTML(1, 0, "Text:");
    ftf.setStyleName(1, 0, "itemName");
    //ftf.setColSpan(1, 0, 2);
    Anchor a = new Anchor("see available tags >>");
    a.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            // select last tab
            tabPanel.selectTab(tabPanel.getWidgetCount() - 1);
        }
    });
    ft.setWidget(1, 1, a);
    ft.setWidget(2, 0, ta);
    ftf.setColSpan(2, 0, 2);
    vp.add(ft);
    vp.add(new HTML("&nbsp;"));
    // fill values
    MailText message = appMail.getMessage(locale);
    if (message != null) {
        ta.setText(message.getText());
        tb.setText(message.getSubject());
    }
    return vp;
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) MailText(cz.metacentrum.perun.webgui.model.MailText)

Example 38 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.

the class MailsTabItem method draw.

public Widget draw() {
    final GetApplicationMails mailsRequest;
    String title = "";
    if (group != null) {
        title = group.getName();
        entity = PerunEntity.GROUP;
        entityId = group.getId();
        mailsRequest = new GetApplicationMails(entity, group.getId());
    } else {
        title = vo.getName();
        entityId = vo.getId();
        mailsRequest = new GetApplicationMails(entity, vo.getId());
    }
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(title) + ": " + "Email notifications");
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu menu = new TabMenu();
    firstTabPanel.add(menu);
    firstTabPanel.setCellHeight(menu, "30px");
    menu.addWidget(UiElements.getRefreshButton(this));
    // add button
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addMail(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new CreateMailTabItem(vo, group, form));
        }
    }));
    // remove button
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeMail());
    menu.addWidget(removeButton);
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<ApplicationMail> list = mailsRequest.getTableSelectedList();
            String text = "Following mail definitions will be removed and users won't receive them anymore.";
            UiElements.showDeleteConfirm(list, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    for (int i = 0; i < list.size(); i++) {
                        if (i != list.size() - 1) {
                            DeleteApplicationMail request = new DeleteApplicationMail(entity, JsonCallbackEvents.disableButtonEvents(removeButton));
                            request.deleteMail(list.get(i).getId(), entityId);
                        } else {
                            // refresh table on last call
                            DeleteApplicationMail request = new DeleteApplicationMail(entity, JsonCallbackEvents.disableButtonEvents(removeButton, JsonCallbackEvents.refreshTableEvents(mailsRequest)));
                            request.deleteMail(list.get(i).getId(), entityId);
                        }
                    }
                }
            });
        }
    });
    // enable button
    CustomButton enableButton = TabMenu.getPredefinedButton(ButtonType.ENABLE, ButtonTranslation.INSTANCE.enableMail(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            ArrayList<ApplicationMail> list = mailsRequest.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                SetSendingEnabled request = new SetSendingEnabled(JsonCallbackEvents.refreshTableEvents(mailsRequest));
                request.setEnabled(list, true);
            }
        }
    });
    menu.addWidget(enableButton);
    // disable button
    CustomButton disableButton = TabMenu.getPredefinedButton(ButtonType.DISABLE, ButtonTranslation.INSTANCE.disableMail(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            ArrayList<ApplicationMail> list = mailsRequest.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                SetSendingEnabled request = new SetSendingEnabled(JsonCallbackEvents.refreshTableEvents(mailsRequest));
                request.setEnabled(list, false);
            }
        }
    });
    menu.addWidget(disableButton);
    menu.addWidget(new CustomButton(ButtonTranslation.INSTANCE.mailFooterButton() + "…", ButtonTranslation.INSTANCE.editMailFooter(), SmallIcons.INSTANCE.emailIcon(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (group == null) {
                session.getTabManager().addTabToCurrentTab(new EditMailFooterTabItem(vo));
            } else {
                session.getTabManager().addTabToCurrentTab(new EditMailFooterTabItem(group));
            }
        }
    }));
    CustomButton copy;
    if (group == null) {
        copy = new CustomButton(ButtonTranslation.INSTANCE.copyFromVoButton() + "…", ButtonTranslation.INSTANCE.copyMailsFromVo(), SmallIcons.INSTANCE.copyIcon(), new ClickHandler() {

            public void onClick(ClickEvent event) {
                session.getTabManager().addTabToCurrentTab(new CopyMailsTabItem(voId, 0));
            }
        });
    } else {
        copy = new CustomButton(ButtonTranslation.INSTANCE.copyFromGroupButton() + "…", ButtonTranslation.INSTANCE.copyMailsFromGroup(), SmallIcons.INSTANCE.copyIcon(), new ClickHandler() {

            public void onClick(ClickEvent event) {
                session.getTabManager().addTabToCurrentTab(new CopyMailsTabItem(group.getVoId(), groupId));
            }
        });
    }
    menu.addWidget(copy);
    // TABLE
    CellTable<ApplicationMail> table = mailsRequest.getTable(new FieldUpdater<ApplicationMail, String>() {

        public void update(int index, ApplicationMail appMail, String value) {
            session.getTabManager().addTabToCurrentTab(new EditMailTabItem(appMail));
        }
    });
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    removeButton.setEnabled(false);
    enableButton.setEnabled(false);
    disableButton.setEnabled(false);
    JsonUtils.addTableManagedButton(mailsRequest, table, removeButton);
    JsonUtils.addTableManagedButton(mailsRequest, table, enableButton);
    JsonUtils.addTableManagedButton(mailsRequest, table, disableButton);
    session.getUiElements().resizePerunTable(sp, 100);
    firstTabPanel.add(sp);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) SetSendingEnabled(cz.metacentrum.perun.webgui.json.registrarManager.SetSendingEnabled) GetApplicationMails(cz.metacentrum.perun.webgui.json.registrarManager.GetApplicationMails) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) DeleteApplicationMail(cz.metacentrum.perun.webgui.json.registrarManager.DeleteApplicationMail) ApplicationMail(cz.metacentrum.perun.webgui.model.ApplicationMail) DeleteApplicationMail(cz.metacentrum.perun.webgui.json.registrarManager.DeleteApplicationMail)

Example 39 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.

the class PreviewFormTabItem method prepareApplicationForm.

/**
	 * Prepares the widgets from the items as A DISPLAY FOR THE USER
	 *
	 * @param sp scroll panel
	 */
public void prepareApplicationForm(ScrollPanel sp) {
    FlexTable ft = new FlexTable();
    ft.setSize("100%", "100%");
    ft.setCellPadding(10);
    FlexCellFormatter fcf = ft.getFlexCellFormatter();
    int i = 0;
    for (final ApplicationFormItem item : formItems) {
        // skip items not from correct app type
        ArrayList<String> itemApplicationTypes = JsonUtils.listFromJsArrayString(item.getApplicationTypes());
        if (!itemApplicationTypes.contains(appType))
            continue;
        // generate correct items
        RegistrarFormItemGenerator gen = new RegistrarFormItemGenerator(item, locale);
        this.applFormGenerators.add(gen);
        gen.addValidationTrigger(new FormValidator() {

            public void triggerValidation() {
                validateFormValues(false);
            }
        });
        // if button, add onclick
        if (item.getType().equals("SUBMIT_BUTTON")) {
            this.sendButton = (Button) gen.getWidget();
            sendButton.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    // revalidate again, with force validation
                    if (!validateFormValues(true)) {
                        return;
                    }
                    // sending is disabled
                    Confirm c = new Confirm("Sending disabled", new Label("Sending form is disabled in preview mode, but form items value validation works."), true);
                    c.show();
                }
            });
        }
        // get localized texts
        ItemTexts itemTexts = item.getItemTexts(locale);
        if (!gen.isVisible()) {
            continue;
        }
        // WITH LABEL (input box ...)
        if (gen.isLabelShown()) {
            // 0 = label
            if (item.isRequired() == true) {
                // required
                ft.setHTML(i, 0, "<strong>" + gen.getLabelOrShortname() + "*</strong>");
            } else {
                // optional
                ft.setHTML(i, 0, "<strong>" + gen.getLabelOrShortname() + "</strong>");
            }
            // 1 = widget
            Widget w = gen.getWidget();
            w.setTitle(itemTexts.getHelp());
            ft.setWidget(i, 1, w);
            // 2 = status
            ft.setWidget(i, 2, gen.getStatusWidget());
            // 3 = HELP
            if (itemTexts.getHelp() != null && itemTexts.getHelp().length() > 0) {
                Label help = new Label(itemTexts.getHelp());
                ft.setWidget(i, 3, help);
            }
            // format
            fcf.setStyleName(i, 0, "applicationFormLabel");
            fcf.setStyleName(i, 1, "applicationFormWidget");
            fcf.setStyleName(i, 2, "applicationFormCheck");
            fcf.setStyleName(i, 3, "applicationFormHelp");
            ft.setWidth("100%");
        // ELSE HTML COMMENT
        } else {
            ft.setWidget(i, 0, gen.getWidget());
            // colspan = 2
            fcf.setColSpan(i, 0, 4);
            fcf.setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_LEFT);
            fcf.setVerticalAlignment(i, 0, HasVerticalAlignment.ALIGN_MIDDLE);
        }
        i++;
    }
    sp.setWidget(ft);
}
Also used : FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) FormValidator(cz.metacentrum.perun.webgui.client.applicationresources.FormValidator) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) RegistrarFormItemGenerator(cz.metacentrum.perun.webgui.client.applicationresources.RegistrarFormItemGenerator)

Example 40 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.

the class PreviewFormTabItem method draw.

public Widget draw() {
    if (form.getGroup() != null) {
        titleWidget.setText(Utils.getStrippedStringWithEllipsis(form.getGroup().getShortName()) + ": form preview");
    } else {
        titleWidget.setText(Utils.getStrippedStringWithEllipsis(form.getVo().getName()) + ": form preview");
    }
    final TabItem tab = this;
    final VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    TabMenu menu = new TabMenu();
    final ScrollPanel sp = new ScrollPanel();
    final CustomButton switchType = new CustomButton(ButtonTranslation.INSTANCE.switchToExtensionButton(), ButtonTranslation.INSTANCE.switchBetweenInitialAndExtension(), SmallIcons.INSTANCE.applicationFormIcon());
    switchType.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            // switch type
            if (appType.equalsIgnoreCase("EXTENSION")) {
                appType = "INITIAL";
                switchType.setText(ButtonTranslation.INSTANCE.switchToExtensionButton());
            } else {
                appType = "EXTENSION";
                switchType.setText(ButtonTranslation.INSTANCE.switchToInitialButton());
            }
            // prepare new
            prepareApplicationForm(sp);
        }
    });
    menu.addWidget(switchType);
    if (!Utils.getNativeLanguage().isEmpty()) {
        final CustomButton switchLocale = new CustomButton(ButtonTranslation.INSTANCE.switchToCzechButton(Utils.getNativeLanguage().get(1)), ButtonTranslation.INSTANCE.switchBetweenCzechAndEnglish(), SmallIcons.INSTANCE.locateIcon());
        menu.addWidget(switchLocale);
        switchLocale.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                // switch type
                if (locale.equalsIgnoreCase("en")) {
                    locale = Utils.getNativeLanguage().get(0);
                    switchLocale.setText(ButtonTranslation.INSTANCE.switchToEnglishButton());
                } else {
                    locale = "en";
                    switchLocale.setText(ButtonTranslation.INSTANCE.switchToCzechButton(Utils.getNativeLanguage().get(1)));
                }
                // prepare new
                prepareApplicationForm(sp);
            }
        });
    }
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    vp.add(sp);
    vp.setCellHeight(sp, "100%");
    prepareApplicationForm(sp);
    session.getUiElements().resizeSmallTabPanel(sp, 350, tab);
    contentWidget.setWidget(vp);
    return getWidget();
}
Also used : TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu)

Aggregations

ClickEvent (com.google.gwt.event.dom.client.ClickEvent)385 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)382 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)161 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)135 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)124 ArrayList (java.util.ArrayList)117 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)105 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)76 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)42 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)41 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)40 PerunError (cz.metacentrum.perun.webgui.model.PerunError)36 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)32 HashMap (java.util.HashMap)32 Button (com.google.gwt.user.client.ui.Button)30 Image (com.google.gwt.user.client.ui.Image)28 HTML (com.google.gwt.user.client.ui.HTML)26 Button (org.gwtbootstrap3.client.ui.Button)26 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)25 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)23