Search in sources :

Example 1 with GetGuiConfiguration

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

the class WebGui method loadPerunPrincipal.

/**
	 * Performs a login into the RPC, loads user and his roles into session and enables GUI.
	 */
private void loadPerunPrincipal() {
    // WEB PAGE SPLITTER
    final DockLayoutPanel bodySplitter = new DockLayoutPanel(Unit.PX);
    body.add(bodySplitter);
    // MAIN CONTENT WRAPPER - make content resize-able
    final ResizeLayoutPanel contentWrapper = new ResizeLayoutPanel();
    contentWrapper.setSize("100%", "100%");
    // MAIN CONTENT
    AbsolutePanel contentPanel = new AbsolutePanel();
    contentPanel.setSize("100%", "100%");
    // put content into wrapper
    contentWrapper.setWidget(contentPanel);
    // SETUP SESSION
    // store handler for main contetn's elements (tabs etc.) into session
    session.setUiElements(new UiElements(contentPanel));
    // Store TabManager into session for handling tabs (add/remove/close...)
    session.setTabManager(new TabManager());
    // Store this class into session
    session.setWebGui(webgui);
    // Set this class as browser's History handler
    History.addValueChangeHandler(webgui);
    // show loading box
    final PopupPanel loadingBox = session.getUiElements().perunLoadingBox();
    loadingBox.show();
    // events after getting PerunPrincipal from RPC
    final JsonCallbackEvents events = new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // store perun principal into session for future use
            final PerunPrincipal pp = (PerunPrincipal) jso;
            session.setPerunPrincipal(pp);
            GetGuiConfiguration getConfig = new GetGuiConfiguration(new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    session.setConfiguration((BasicOverlayType) jso.cast());
                    // check if user exists
                    if (session.getUser() == null && !pp.getRoles().hasAnyRole()) {
                        // if not and no role, redraw page body
                        RootLayoutPanel body = RootLayoutPanel.get();
                        loadingBox.hide();
                        body.clear();
                        body.add(new NotUserOfPerunWidget());
                        return;
                    }
                    // check if user exists
                    if (session.getUser().isServiceUser()) {
                        // if not and no role, redraw page body
                        RootLayoutPanel body = RootLayoutPanel.get();
                        loadingBox.hide();
                        body.clear();
                        body.add(new CantLogAsServiceUserWidget());
                        return;
                    }
                    // Sets URL mapper for loading proper tabs
                    urlMapper = new UrlMapper();
                    // MENU WRAPPER
                    VerticalPanel menuWrapper = new VerticalPanel();
                    menuWrapper.setHeight("100%");
                    // add menu
                    menuWrapper.add(session.getUiElements().getMenu().getWidget());
                    menuWrapper.setCellVerticalAlignment(session.getUiElements().getMenu().getWidget(), HasVerticalAlignment.ALIGN_TOP);
                    // Put all panels into web page splitter
                    //	bodySplitter.addNorth(session.getUiElements().getHeader(), 78);
                    bodySplitter.addNorth(session.getUiElements().getHeader(), 64);
                    bodySplitter.addSouth(session.getUiElements().getFooter(), 30);
                    bodySplitter.addWest(menuWrapper, 202);
                    // content must be added as last !!
                    bodySplitter.add(contentWrapper);
                    // Append more GUI elements from UiElements class which are not part of splitted design
                    if ("true".equalsIgnoreCase(Location.getParameter("log"))) {
                        // log
                        bodySplitter.getElement().appendChild(session.getUiElements().getLog().getElement());
                    }
                    // status
                    bodySplitter.getElement().appendChild(session.getUiElements().getStatus().getElement());
                    // keep alive
                    VerticalPanel vp = new VerticalPanel();
                    vp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
                    vp.add(new HTML("<h2>Connection to Perun has been lost.</h2><strong>Please check your internet connection.</strong>"));
                    final FlexTable layout = new FlexTable();
                    layout.setVisible(false);
                    layout.setHTML(0, 0, "<p>You can also try to <strong>refresh the browser window</strong>. However, all <strong>unsaved changes will be lost</strong>.");
                    layout.getFlexCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_TOP);
                    vp.add(layout);
                    vp.setSpacing(10);
                    final Confirm c = new Confirm("", vp, true);
                    c.setAutoHide(false);
                    c.setHideOnButtonClick(false);
                    c.setOkIcon(SmallIcons.INSTANCE.arrowRefreshIcon());
                    c.setOkButtonText("Re-connect");
                    c.setNonScrollable(true);
                    c.setOkClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {
                            KeepAlive call = new KeepAlive(JsonCallbackEvents.disableButtonEvents(c.getOkButton(), new JsonCallbackEvents() {

                                @Override
                                public void onLoadingStart() {
                                    checkPending = true;
                                }

                                @Override
                                public void onFinished(JavaScriptObject jso) {
                                    BasicOverlayType type = jso.cast();
                                    checkPending = false;
                                    connected = true;
                                    if (type.getString().equals("OK")) {
                                        if (c.isShowing()) {
                                            c.hide();
                                        }
                                    }
                                    // If ok, append new keepalive checker
                                    appendKeepAliveChecker(c);
                                }

                                @Override
                                public void onError(PerunError error) {
                                    checkPending = false;
                                    // connection lost only IF TIMEOUT
                                    if (error != null && error.getErrorId().equals("0")) {
                                        connected = false;
                                        if (!c.isShowing()) {
                                            c.show();
                                        }
                                        layout.setVisible(true);
                                        c.getOkButton().setText("Reload");
                                        c.getOkButton().addClickHandler(new ClickHandler() {

                                            @Override
                                            public void onClick(ClickEvent event) {
                                                Window.Location.reload();
                                            }
                                        });
                                    }
                                }
                            }));
                            call.retrieveData();
                        }
                    });
                    appendKeepAliveChecker(c);
                    // store users roles and editable entities into session
                    session.setRoles(pp.getRoles());
                    // display logged user
                    session.getUiElements().setLoggedUserInfo(pp);
                    session.getUiElements().setLogText("Welcome " + pp.getUser().getFullNameWithTitles());
                    // show extended info ?
                    boolean showExtendedInfo = false;
                    // is perun admin ?
                    if (session.isPerunAdmin()) {
                        showExtendedInfo = true;
                    }
                    // replace by local storage if possible
                    Storage localStorage = Storage.getLocalStorageIfSupported();
                    if (localStorage != null) {
                        String value = localStorage.getItem("urn:perun:gui:preferences:extendedInfo");
                        if (value != null) {
                            showExtendedInfo = Boolean.parseBoolean(value);
                        }
                    }
                    // finally set it
                    JsonUtils.setExtendedInfoVisible(showExtendedInfo);
                    // set extended info button
                    session.getUiElements().getExtendedInfoButtonWidget().setDown(showExtendedInfo);
                    // perun loaded = true
                    perunLoaded = true;
                    // loads the page based on URL or default
                    loadPage();
                    // hides the loading box
                    loadingBox.hide();
                    // load proper parts of menu (based on roles)
                    session.getUiElements().getMenu().prepare();
                }

                @Override
                public void onError(PerunError error) {
                    // hides the loading box
                    loadingBox.hide();
                    // shows error box
                    PopupPanel loadingFailedBox;
                    if (error != null) {
                        loadingFailedBox = session.getUiElements().perunLoadingFailedBox("Request timeout exceeded.");
                    } else {
                        if (error.getName().contains("UserNotExistsException")) {
                            loadingFailedBox = session.getUiElements().perunLoadingFailedBox("You are not registered to any Virtual Organization.</br></br>" + error.getErrorInfo());
                        } else {
                            loadingFailedBox = session.getUiElements().perunLoadingFailedBox(error.getErrorInfo());
                        }
                    }
                    if (!error.getErrorId().equals("0")) {
                        loadingFailedBox.show();
                    }
                }
            });
            getConfig.retrieveData();
        }

        @Override
        public void onError(PerunError error) {
            // hides the loading box
            loadingBox.hide();
            // shows error box
            PopupPanel loadingFailedBox;
            if (error == null) {
                loadingFailedBox = session.getUiElements().perunLoadingFailedBox("Request timeout exceeded.");
            } else {
                if (error.getName().contains("UserNotExistsException")) {
                    loadingFailedBox = session.getUiElements().perunLoadingFailedBox("You are not registered to any Virtual Organization.</br></br>" + error.getErrorInfo());
                } else {
                    loadingFailedBox = session.getUiElements().perunLoadingFailedBox(error.getErrorInfo());
                }
            }
            loadingFailedBox.show();
        }
    };
    GetPerunPrincipal loggedUserRequst = new GetPerunPrincipal(events);
    loggedUserRequst.retrieveData();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) TabManager(cz.metacentrum.perun.webgui.tabs.TabManager) BasicOverlayType(cz.metacentrum.perun.webgui.model.BasicOverlayType) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) CantLogAsServiceUserWidget(cz.metacentrum.perun.webgui.widgets.CantLogAsServiceUserWidget) GetPerunPrincipal(cz.metacentrum.perun.webgui.json.authzResolver.GetPerunPrincipal) PerunPrincipal(cz.metacentrum.perun.webgui.model.PerunPrincipal) GetPerunPrincipal(cz.metacentrum.perun.webgui.json.authzResolver.GetPerunPrincipal) GetGuiConfiguration(cz.metacentrum.perun.webgui.json.GetGuiConfiguration) UrlMapper(cz.metacentrum.perun.webgui.tabs.UrlMapper) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Storage(com.google.gwt.storage.client.Storage) NotUserOfPerunWidget(cz.metacentrum.perun.webgui.widgets.NotUserOfPerunWidget) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) KeepAlive(cz.metacentrum.perun.webgui.json.authzResolver.KeepAlive) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 2 with GetGuiConfiguration

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

the class ApplicationFormGui method loadPerunPrincipal.

/**
	 * Performs a login into the RPC, loads user and his roles into session and enables GUI.
	 */
private void loadPerunPrincipal(final JsonCallbackEvents externalEvents) {
    // events after getting PerunPrincipal from RPC
    GetPerunPrincipal principal = new GetPerunPrincipal(new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // store perun principal into session for future use
            PerunPrincipal pp = (PerunPrincipal) jso;
            session.setPerunPrincipal(pp);
            // store users roles and editable entities into session
            if (pp.getRoles().hasAnyRole()) {
                session.setRoles(pp.getRoles());
            }
            // proceed after GUI configuration is loaded
            GetGuiConfiguration getConf = new GetGuiConfiguration(new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    // store configuration
                    session.setConfiguration((BasicOverlayType) jso.cast());
                    if (Utils.getVosToSkipCaptchaFor().contains(vo.getShortName())) {
                        // skip captcha
                        final GetApplicationsForUser request;
                        if (session.getUser() == null) {
                            // if not yet user in perun, search by actor / extSourceName
                            request = new GetApplicationsForUser(0, externalEvents);
                        } else {
                            // if user in perun
                            request = new GetApplicationsForUser(session.getUser().getId(), externalEvents);
                        }
                        request.retrieveData();
                        // finish loading GUI
                        loadingBox.hide();
                        bodySplitter.clear();
                        bodySplitter.add(ft);
                    // challange captcha only for default URL (non)
                    } else if (session.getRpcUrl().startsWith("/non/rpc")) {
                        if (Location.getParameterMap().keySet().contains("m") && Location.getParameterMap().keySet().contains("i")) {
                            // passed params doesn't matter, different UI is loaded.
                            final GetApplicationsForUser request;
                            if (session.getUser() == null) {
                                // if not yet user in perun, search by actor / extSourceName
                                request = new GetApplicationsForUser(0, externalEvents);
                            } else {
                                // if user in perun
                                request = new GetApplicationsForUser(session.getUser().getId(), externalEvents);
                            }
                            request.retrieveData();
                            // finish loading GUI
                            loadingBox.hide();
                            bodySplitter.clear();
                            bodySplitter.add(ft);
                        } else {
                            // CHALLENGE WITH CAPTCHA
                            FlexTable ft = new FlexTable();
                            ft.setSize("100%", "500px");
                            // captcha with public key
                            String key = Utils.getReCaptchaPublicKey();
                            if (key == null) {
                                PerunError error = new JSONObject().getJavaScriptObject().cast();
                                error.setErrorId("0");
                                error.setName("Missing public key");
                                error.setErrorInfo("Public key for Re-Captcha service is missing. Please add public key to GUIs configuration file.");
                                error.setRequestURL("");
                                UiElements.generateError(error, "Missing public key", "Public key for Re-Captcha service is missing.<br />Accessing application form without authorization is not possible.");
                                loadingBox.hide();
                                return;
                            }
                            final RecaptchaWidget captcha = new RecaptchaWidget(key, LocaleInfo.getCurrentLocale().getLocaleName(), "clean");
                            final CustomButton cb = new CustomButton();
                            cb.setIcon(SmallIcons.INSTANCE.arrowRightIcon());
                            cb.setText(ApplicationMessages.INSTANCE.captchaSendButton());
                            cb.setImageAlign(true);
                            final TextBox response = new TextBox();
                            captcha.setOwnTextBox(response);
                            Scheduler.get().scheduleDeferred(new Command() {

                                @Override
                                public void execute() {
                                    response.setFocus(true);
                                }
                            });
                            response.addKeyDownHandler(new KeyDownHandler() {

                                @Override
                                public void onKeyDown(KeyDownEvent event) {
                                    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                                        cb.click();
                                    }
                                }
                            });
                            cb.addClickHandler(new ClickHandler() {

                                @Override
                                public void onClick(ClickEvent clickEvent) {
                                    VerifyCaptcha req = new VerifyCaptcha(captcha.getChallenge(), captcha.getResponse(), JsonCallbackEvents.disableButtonEvents(cb, new JsonCallbackEvents() {

                                        public void onFinished(JavaScriptObject jso) {
                                            BasicOverlayType bt = jso.cast();
                                            if (bt.getBoolean()) {
                                                // OK captcha answer - load GUI
                                                // Authorized anonymous user
                                                session.getUiElements().setLogText("Auth OK");
                                                final GetApplicationsForUser request;
                                                if (session.getUser() == null) {
                                                    // if not yet user in perun, search by actor / extSourceName
                                                    request = new GetApplicationsForUser(0, externalEvents);
                                                } else {
                                                    // if user in perun
                                                    request = new GetApplicationsForUser(session.getUser().getId(), externalEvents);
                                                }
                                                request.retrieveData();
                                            } else {
                                                // wrong captcha answer
                                                UiElements.generateAlert(ApplicationMessages.INSTANCE.captchaErrorHeader(), ApplicationMessages.INSTANCE.captchaErrorMessage());
                                            }
                                        }
                                    }));
                                    req.retrieveData();
                                }
                            });
                            // set layout
                            int row = 0;
                            // display VO logo if present in attribute
                            for (int i = 0; i < vo.getAttributes().length(); i++) {
                                if (vo.getAttributes().get(i).getFriendlyName().equalsIgnoreCase("voLogoURL")) {
                                    ft.setWidget(row, 0, new Image(vo.getAttributes().get(i).getValue()));
                                    ft.getFlexCellFormatter().setAlignment(row, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);
                                    row++;
                                }
                            }
                            ft.getFlexCellFormatter().setAlignment(row, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);
                            ft.setHTML(row, 0, ApplicationMessages.INSTANCE.captchaDescription());
                            ft.setWidget(row + 1, 0, captcha);
                            ft.getFlexCellFormatter().setHorizontalAlignment(row + 1, 0, HasHorizontalAlignment.ALIGN_CENTER);
                            ft.getFlexCellFormatter().setVerticalAlignment(row + 1, 0, HasVerticalAlignment.ALIGN_BOTTOM);
                            FlexTable sendFt = new FlexTable();
                            sendFt.setStyleName("inputFormFlexTable");
                            sendFt.setWidget(0, 0, response);
                            sendFt.setWidget(0, 1, cb);
                            ft.setWidget(row + 2, 0, sendFt);
                            ft.getFlexCellFormatter().setHorizontalAlignment(row + 2, 0, HasHorizontalAlignment.ALIGN_CENTER);
                            ft.getFlexCellFormatter().setVerticalAlignment(row + 2, 0, HasVerticalAlignment.ALIGN_TOP);
                            ft.setHeight("100%");
                            ft.getFlexCellFormatter().setHeight(row, 0, "50%");
                            ft.getFlexCellFormatter().setHeight(row + 2, 0, "50%");
                            // finish loading GUI
                            loadingBox.hide();
                            bodySplitter.clear();
                            bodySplitter.add(ft);
                        }
                    } else {
                        // Authorized known user
                        session.getUiElements().setLogText("Auth OK");
                        final GetApplicationsForUser req;
                        if (session.getUser() == null) {
                            // if not yet user in perun, search by actor / extSourceName
                            req = new GetApplicationsForUser(0, externalEvents);
                        } else {
                            // if user in perun
                            req = new GetApplicationsForUser(session.getUser().getId(), externalEvents);
                        }
                        req.retrieveData();
                    }
                }
            });
            getConf.retrieveData();
        }
    });
    principal.retrieveData();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) GetApplicationsForUser(cz.metacentrum.perun.webgui.json.registrarManager.GetApplicationsForUser) VerifyCaptcha(cz.metacentrum.perun.webgui.json.registrarManager.VerifyCaptcha) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage) JSONObject(com.google.gwt.json.client.JSONObject) Command(com.google.gwt.user.client.Command) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) GetPerunPrincipal(cz.metacentrum.perun.webgui.json.authzResolver.GetPerunPrincipal) RecaptchaWidget(cz.metacentrum.perun.webgui.widgets.recaptcha.RecaptchaWidget) GetPerunPrincipal(cz.metacentrum.perun.webgui.json.authzResolver.GetPerunPrincipal) GetGuiConfiguration(cz.metacentrum.perun.webgui.json.GetGuiConfiguration)

Example 3 with GetGuiConfiguration

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

the class PasswordResetGui method loadPerunPrincipal.

/**
	 * Performs a login into the RPC, loads user and his roles into session and enables GUI.
	 */
private void loadPerunPrincipal() {
    // show loading box
    final PopupPanel loadingBox = session.getUiElements().perunLoadingBox();
    loadingBox.show();
    // events after getting PerunPrincipal from RPC
    final JsonCallbackEvents events = new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // store perun principal into session for future use
            PerunPrincipal pp = (PerunPrincipal) jso;
            session.setPerunPrincipal(pp);
            // check if user exists
            if (session.getUser() != null && !pp.getRoles().hasAnyRole() && !session.getRpcUrl().startsWith("/non/rpc")) {
                // if not and no role, redraw page body
                RootLayoutPanel body = RootLayoutPanel.get();
                loadingBox.hide();
                body.clear();
                body.add(new NotUserOfPerunWidget());
                return;
            }
            if (session.getUser() != null && !pp.getRoles().hasAnyRole()) {
                // store users roles and editable entities into session
                session.setRoles(pp.getRoles());
                // display logged user
                session.getUiElements().setLoggedUserInfo(pp);
            }
            GetGuiConfiguration getConf = new GetGuiConfiguration(new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    session.setConfiguration((BasicOverlayType) jso.cast());
                    // hides the loading box
                    loadingBox.hide();
                    if (session.getRpcUrl().startsWith("/non/rpc")) {
                        // CHALLENGE WITH CAPTCHA
                        FlexTable ft = new FlexTable();
                        ft.setSize("100%", "500px");
                        // captcha with public key
                        String key = Utils.getReCaptchaPublicKey();
                        if (key == null) {
                            PerunError error = new JSONObject().getJavaScriptObject().cast();
                            error.setErrorId("0");
                            error.setName("Missing public key");
                            error.setErrorInfo("Public key for Re-Captcha service is missing. Please add public key to GUIs configuration file.");
                            error.setRequestURL("");
                            UiElements.generateError(error, "Missing public key", "Public key for Re-Captcha service is missing.<br />Accessing password reset without authorization is not possible.");
                            loadingBox.hide();
                            return;
                        }
                        final RecaptchaWidget captcha = new RecaptchaWidget(key, LocaleInfo.getCurrentLocale().getLocaleName(), "clean");
                        final CustomButton cb = new CustomButton();
                        cb.setIcon(SmallIcons.INSTANCE.arrowRightIcon());
                        cb.setText(ApplicationMessages.INSTANCE.captchaSendButton());
                        cb.setImageAlign(true);
                        final TextBox response = new TextBox();
                        captcha.setOwnTextBox(response);
                        Scheduler.get().scheduleDeferred(new Command() {

                            @Override
                            public void execute() {
                                response.setFocus(true);
                            }
                        });
                        response.addKeyDownHandler(new KeyDownHandler() {

                            @Override
                            public void onKeyDown(KeyDownEvent event) {
                                if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                                    cb.click();
                                }
                            }
                        });
                        cb.addClickHandler(new ClickHandler() {

                            @Override
                            public void onClick(ClickEvent clickEvent) {
                                VerifyCaptcha req = new VerifyCaptcha(captcha.getChallenge(), captcha.getResponse(), JsonCallbackEvents.disableButtonEvents(cb, new JsonCallbackEvents() {

                                    public void onFinished(JavaScriptObject jso) {
                                        BasicOverlayType bt = jso.cast();
                                        if (bt.getBoolean()) {
                                            // OK captcha answer - load GUI
                                            // add menu item and load content
                                            contentPanel.setWidget(new PasswordResetFormPage().getContent());
                                        //Anchor a = leftMenu.addMenuContents("Password reset", SmallIcons.INSTANCE.keyIcon(), new PasswordResetFormPage().getContent());
                                        //a.fireEvent(new ClickEvent(){});
                                        } else {
                                            // wrong captcha answer
                                            UiElements.generateAlert(ApplicationMessages.INSTANCE.captchaErrorHeader(), ApplicationMessages.INSTANCE.captchaErrorMessage());
                                        }
                                    }
                                }));
                                req.retrieveData();
                            }
                        });
                        // set layout
                        int row = 0;
                        ft.getFlexCellFormatter().setAlignment(row, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);
                        ft.setHTML(row, 0, "<h2>In order to continue to the password reset page, please, use CAPTCHA below.</h2>");
                        ft.setWidget(row + 1, 0, captcha);
                        ft.getFlexCellFormatter().setHorizontalAlignment(row + 1, 0, HasHorizontalAlignment.ALIGN_CENTER);
                        ft.getFlexCellFormatter().setVerticalAlignment(row + 1, 0, HasVerticalAlignment.ALIGN_BOTTOM);
                        FlexTable sendFt = new FlexTable();
                        sendFt.setStyleName("inputFormFlexTable");
                        sendFt.setWidget(0, 0, response);
                        sendFt.setWidget(0, 1, cb);
                        ft.setWidget(row + 2, 0, sendFt);
                        ft.getFlexCellFormatter().setHorizontalAlignment(row + 2, 0, HasHorizontalAlignment.ALIGN_CENTER);
                        ft.getFlexCellFormatter().setVerticalAlignment(row + 2, 0, HasVerticalAlignment.ALIGN_TOP);
                        ft.setHeight("100%");
                        ft.getFlexCellFormatter().setHeight(row, 0, "50%");
                        ft.getFlexCellFormatter().setHeight(row + 2, 0, "50%");
                        // finish loading GUI
                        loadingBox.hide();
                        contentPanel.setWidget(ft);
                    } else {
                        // add menu item and load content
                        contentPanel.setWidget(new PasswordResetFormPage().getContent());
                    //Anchor a = leftMenu.addMenuContents("Password reset", SmallIcons.INSTANCE.keyIcon(), new PasswordResetFormPage().getContent());
                    //a.fireEvent(new ClickEvent(){});
                    }
                }

                @Override
                public void onError(PerunError error) {
                    // hides the loading box
                    loadingBox.hide();
                    // shows error box
                    PopupPanel loadingFailedBox;
                    if (error == null) {
                        loadingFailedBox = session.getUiElements().perunLoadingFailedBox("Request timeout exceeded.");
                    } else {
                        if (error.getName().contains("UserNotExistsException")) {
                            loadingFailedBox = session.getUiElements().perunLoadingFailedBox("You are not registered to any Virtual Organization.</br></br>" + error.getErrorInfo());
                        } else {
                            loadingFailedBox = session.getUiElements().perunLoadingFailedBox(error.getErrorInfo());
                        }
                    }
                    loadingFailedBox.show();
                    leftMenu.addItem("Password reset", SmallIcons.INSTANCE.keyIcon(), null);
                }
            });
            getConf.retrieveData();
        }

        @Override
        public void onError(PerunError error) {
            // hides the loading box
            loadingBox.hide();
            // shows error box
            PopupPanel loadingFailedBox;
            if (error == null) {
                loadingFailedBox = session.getUiElements().perunLoadingFailedBox("Request timeout exceeded.");
            } else {
                if (error.getName().contains("UserNotExistsException")) {
                    loadingFailedBox = session.getUiElements().perunLoadingFailedBox("You are not registered to any Virtual Organization.</br></br>" + error.getErrorInfo());
                } else {
                    loadingFailedBox = session.getUiElements().perunLoadingFailedBox(error.getErrorInfo());
                }
            }
            loadingFailedBox.show();
            leftMenu.addItem("Password reset", SmallIcons.INSTANCE.keyIcon(), null);
        }
    };
    GetPerunPrincipal loggedUserRequest = new GetPerunPrincipal(events);
    loggedUserRequest.retrieveData();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) BasicOverlayType(cz.metacentrum.perun.webgui.model.BasicOverlayType) VerifyCaptcha(cz.metacentrum.perun.webgui.json.registrarManager.VerifyCaptcha) JSONObject(com.google.gwt.json.client.JSONObject) Command(com.google.gwt.user.client.Command) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) RecaptchaWidget(cz.metacentrum.perun.webgui.widgets.recaptcha.RecaptchaWidget) GetPerunPrincipal(cz.metacentrum.perun.webgui.json.authzResolver.GetPerunPrincipal) PerunPrincipal(cz.metacentrum.perun.webgui.model.PerunPrincipal) GetPerunPrincipal(cz.metacentrum.perun.webgui.json.authzResolver.GetPerunPrincipal) PerunError(cz.metacentrum.perun.webgui.model.PerunError) PasswordResetFormPage(cz.metacentrum.perun.webgui.client.passwordresetresources.PasswordResetFormPage) GetGuiConfiguration(cz.metacentrum.perun.webgui.json.GetGuiConfiguration)

Aggregations

GetGuiConfiguration (cz.metacentrum.perun.webgui.json.GetGuiConfiguration)3 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)3 GetPerunPrincipal (cz.metacentrum.perun.webgui.json.authzResolver.GetPerunPrincipal)3 JSONObject (com.google.gwt.json.client.JSONObject)2 Command (com.google.gwt.user.client.Command)2 VerifyCaptcha (cz.metacentrum.perun.webgui.json.registrarManager.VerifyCaptcha)2 BasicOverlayType (cz.metacentrum.perun.webgui.model.BasicOverlayType)2 PerunError (cz.metacentrum.perun.webgui.model.PerunError)2 PerunPrincipal (cz.metacentrum.perun.webgui.model.PerunPrincipal)2 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)2 RecaptchaWidget (cz.metacentrum.perun.webgui.widgets.recaptcha.RecaptchaWidget)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 Storage (com.google.gwt.storage.client.Storage)1 PasswordResetFormPage (cz.metacentrum.perun.webgui.client.passwordresetresources.PasswordResetFormPage)1 KeepAlive (cz.metacentrum.perun.webgui.json.authzResolver.KeepAlive)1 GetApplicationsForUser (cz.metacentrum.perun.webgui.json.registrarManager.GetApplicationsForUser)1 TabManager (cz.metacentrum.perun.webgui.tabs.TabManager)1 UrlMapper (cz.metacentrum.perun.webgui.tabs.UrlMapper)1