Search in sources :

Example 81 with ClickHandler

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

the class WebGui method showCurrentGDPRApproval.

private void showCurrentGDPRApproval(Map<String, Integer> ids, Attribute a, Map<String, String> approvedAdminGDPR, String currentVersion, JsonCallbackEvents finishEvents) {
    String gdprApprovalText = session.getConfiguration().getGDPRproperty("text");
    String agreeButtonText = session.getConfiguration().getGDPRproperty("agree");
    String disagreeButtonText = session.getConfiguration().getGDPRproperty("disagree");
    String disagreeResult = session.getConfiguration().getGDPRproperty("disagree_result");
    String title = session.getConfiguration().getGDPRproperty("title");
    String backToGdprConfirm = session.getConfiguration().getGDPRproperty("disagree_back");
    HTML html = new HTML("<div height=\"500\" width=\"420\">" + gdprApprovalText + "</div>");
    Confirm gdprConfirm = new Confirm(title, html, new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            SetAttribute setAttribute = new SetAttribute(new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    // approved finish loading UI
                    finishEvents.onFinished(null);
                }

                @Override
                public void onError(PerunError error) {
                    error.setErrorInfo("Failed to store your GDPR approval for version: " + currentVersion);
                    finishEvents.onError(error);
                }
            });
            approvedAdminGDPR.put(currentVersion, JsonUtils.getCurrentDateAsString());
            a.setValueAsMap(approvedAdminGDPR);
            setAttribute.setAttribute(ids, a);
        }
    }, new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            Confirm disagreeConfirm = new Confirm(title, new HTML(disagreeResult), false);
            disagreeConfirm.setNonScrollable(true);
            disagreeConfirm.setAutoHide(false);
            disagreeConfirm.setOkButtonText(backToGdprConfirm);
            disagreeConfirm.setOkClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    finishEvents.onError(null);
                    Window.Location.reload();
                }
            });
            disagreeConfirm.show();
        }
    }, agreeButtonText, disagreeButtonText, true);
    gdprConfirm.setNonScrollable(true);
    gdprConfirm.setAutoHide(false);
    gdprConfirm.show();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) PerunError(cz.metacentrum.perun.webgui.model.PerunError) SetAttribute(cz.metacentrum.perun.webgui.json.attributesManager.SetAttribute)

Example 82 with ClickHandler

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

the class MainMenuSection method addAdvancedLink.

public void addAdvancedLink(boolean active) {
    if (!JsonUtils.isExtendedInfoVisible()) {
        if (active) {
            final Anchor a = new Anchor("");
            if (displayAdvanced) {
                a.setHTML("<i>&lt;&lt; hide advanced</i>");
            } else {
                a.setHTML("<i>show advanced &gt;&gt;</i>");
            }
            a.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    displayAdvanced = !displayAdvanced;
                    // rebuild this menu
                    PerunWebSession.getInstance().getUiElements().getMenu().saveAdvancedStateToBrowser(role + "", displayAdvanced);
                    PerunWebSession.getInstance().getUiElements().getMenu().updateLinks(role);
                }
            });
            this.sectionPanel.setWidget(rowCounter, 0, a);
            this.sectionPanel.getFlexCellFormatter().setColSpan(rowCounter, 0, 2);
        } else {
            HTML a = new HTML();
            a.addStyleName("mainMenuNotActive");
            if (displayAdvanced) {
                a.setHTML("<i>&lt;&lt; hide advanced</i>");
            } else {
                a.setHTML("<i>show advanced &gt;&gt;</i>");
            }
            this.sectionPanel.setWidget(rowCounter, 0, a);
            this.sectionPanel.getFlexCellFormatter().setColSpan(rowCounter, 0, 2);
        }
        rowCounter++;
    }
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent)

Example 83 with ClickHandler

use of com.google.gwt.event.dom.client.ClickHandler 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)

Example 84 with ClickHandler

use of com.google.gwt.event.dom.client.ClickHandler 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 (item.getHidden().equals("ALWAYS")) {
            continue;
        }
        // WITH LABEL (input box ...)
        if (gen.isLabelShown()) {
            // 0 = label
            if (item.isRequired() == true) {
                // required
                ft.setHTML(i, 0, "<strong>" + SafeHtmlUtils.fromString(gen.getLabelOrShortname()).asString() + "*</strong>");
            } else {
                // optional
                ft.setHTML(i, 0, "<strong>" + SafeHtmlUtils.fromString(gen.getLabelOrShortname()).asString() + "</strong>");
            }
            // 1 = widget with icons
            HorizontalPanel hp = new HorizontalPanel();
            hp.setSpacing(10);
            Widget w = gen.getWidget();
            w.setTitle(itemTexts.getHelp());
            if (item.getDisabled().equals("ALWAYS")) {
                w.getElement().setAttribute("disabled", "disabled");
            }
            hp.add(w);
            // lock icon
            if (item.getDisabled() != "NEVER") {
                Image lockIcon = new Image(SmallIcons.INSTANCE.lockIcon());
                lockIcon.setStyleName("pointer");
                String dependency = item.getDisabledDependencyItemId() == 0 ? "it" : formItems.stream().filter(it -> it.getId() == item.getDisabledDependencyItemId()).collect(Collectors.toList()).get(0).getShortname();
                switch(item.getDisabled()) {
                    case "ALWAYS":
                        lockIcon.setTitle("Always disabled");
                        break;
                    case "IF_EMPTY":
                        lockIcon.setTitle("Disabled when " + dependency + " is empty");
                        break;
                    case "IF_PREFILLED":
                        lockIcon.setTitle("Disabled when " + dependency + " is prefilled");
                        break;
                }
                hp.add(lockIcon);
            }
            // eye icon
            if (item.getHidden() != "NEVER") {
                Image eyeIcon = new Image(SmallIcons.INSTANCE.hiddenIcon());
                eyeIcon.setStyleName("pointer");
                String dependency = item.getHiddenDependencyItemId() == 0 ? "it" : formItems.stream().filter(it -> it.getId() == item.getHiddenDependencyItemId()).collect(Collectors.toList()).get(0).getShortname();
                switch(item.getHidden()) {
                    case "ALWAYS":
                        eyeIcon.setTitle("Always hidden");
                        break;
                    case "IF_EMPTY":
                        eyeIcon.setTitle("Hidden when " + dependency + " is empty");
                        break;
                    case "IF_PREFILLED":
                        eyeIcon.setTitle("Hidden when " + dependency + " is prefilled");
                        break;
                }
                hp.add(eyeIcon);
            }
            ft.setWidget(i, 1, hp);
            // 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 85 with ClickHandler

use of com.google.gwt.event.dom.client.ClickHandler 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

ClickHandler (com.google.gwt.event.dom.client.ClickHandler)447 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)437 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)168 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)143 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)129 ArrayList (java.util.ArrayList)128 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)110 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)79 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)48 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)47 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)41 PerunError (cz.metacentrum.perun.webgui.model.PerunError)38 HashMap (java.util.HashMap)37 Button (com.google.gwt.user.client.ui.Button)35 HTML (com.google.gwt.user.client.ui.HTML)34 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)33 Button (org.gwtbootstrap3.client.ui.Button)33 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)31 Image (com.google.gwt.user.client.ui.Image)30 Map (java.util.Map)27