Search in sources :

Example 76 with JsonCallbackEvents

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

the class DeleteMembers method deleteMembers.

/**
 * Attempts to delete members from VO
 *
 * @param members Members which should be deleted
 */
public void deleteMembers(final ArrayList<RichMember> members) {
    this.members = members;
    // test arguments
    if (!this.testAdding()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Deleting " + members.size() + " members failed.");
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText(members.size() + " members deleted!");
            events.onFinished(jso);
        }

        public void onLoadingStart() {
            events.onLoadingStart();
        }
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, prepareJSONObject());
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 77 with JsonCallbackEvents

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

the class SendPasswordResetLinkEmail method sendEmail.

/**
 * Send password reset gui link to member's email
 *
 * @param member
 */
public void sendEmail(final RichMember member, String namespace, String attribute, String language) {
    this.member = member;
    this.namespace = namespace;
    this.mailAttributeURN = attribute;
    this.language = language;
    // test arguments
    if (!this.testAdding()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            events.onFinished(jso);
        }

        public void onLoadingStart() {
            events.onLoadingStart();
        }
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, prepareJSONObject());
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 78 with JsonCallbackEvents

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

the class GetFormItems method prepareErrorSettings.

private void prepareErrorSettings(PerunError error) {
    FlexTable ft = new FlexTable();
    ft.setWidth("100%");
    ft.setCellPadding(8);
    FlexCellFormatter fcf = ft.getFlexCellFormatter();
    ft.addStyleName("borderTable");
    ft.setHTML(0, 0, "<strong>Short name</strong>");
    ft.setHTML(0, 1, "<strong>Type</strong>");
    ft.setHTML(0, 2, "<strong>Disabled</strong>");
    ft.setHTML(0, 3, "<strong>Hidden</strong>");
    ft.setHTML(0, 4, "<strong>Preview</strong>");
    ft.setHTML(0, 5, "<strong>Edit</strong>");
    fcf.setStyleName(0, 0, "header");
    fcf.setStyleName(0, 1, "header");
    fcf.setStyleName(0, 2, "header");
    fcf.setStyleName(0, 3, "header");
    fcf.setStyleName(0, 4, "header");
    fcf.setStyleName(0, 5, "header");
    if (error != null && error.getName().equalsIgnoreCase("FormNotExistsException")) {
        // no form, add create button
        final CustomButton create = new CustomButton("Create empty form", ButtonTranslation.INSTANCE.createEmptyApplicationForm(), SmallIcons.INSTANCE.addIcon());
        create.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                // disable button event with refresh page on finished
                CreateApplicationForm request = new CreateApplicationForm(entity, id, JsonCallbackEvents.disableButtonEvents(create, new JsonCallbackEvents() {

                    private TabItem item = null;

                    @Override
                    public void onFinished(JavaScriptObject jso) {
                        if (item != null) {
                            item.draw();
                        }
                    }

                    @Override
                    public void onLoadingStart() {
                        item = session.getTabManager().getActiveTab();
                    }
                }));
                request.createApplicationForm();
            }
        });
        if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && !session.isVoAdmin(id)) {
            create.setEnabled(false);
        } else if (PerunEntity.GROUP.equals(entity) && !session.isGroupAdmin(id) && !session.isVoAdmin(group.getVoId())) {
            create.setEnabled(false);
        }
        loaderImage.setEmptyResultMessage("Application form doesn't exists.");
        loaderImage.loadingFinished();
        ft.setWidget(1, 0, loaderImage);
        ft.getFlexCellFormatter().addStyleName(1, 0, "noBorder");
        ft.getFlexCellFormatter().setColSpan(1, 0, 6);
        ft.setWidget(2, 0, create);
        ft.getFlexCellFormatter().addStyleName(2, 0, "noBorder");
        ft.getFlexCellFormatter().setColSpan(2, 0, 6);
        ft.getFlexCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
        ft.getFlexCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_MIDDLE);
        ft.getFlexCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_CENTER);
        ft.getFlexCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_MIDDLE);
    } else {
        // standard error
        ft.setWidget(1, 0, loaderImage);
        fcf.setColSpan(1, 0, 6);
    }
    contents.setWidget(ft);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) CreateFormItemTabItem(cz.metacentrum.perun.webgui.tabs.registrartabs.CreateFormItemTabItem) EditFormItemTabItem(cz.metacentrum.perun.webgui.tabs.registrartabs.EditFormItemTabItem) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ClickEvent(com.google.gwt.event.dom.client.ClickEvent)

Example 79 with JsonCallbackEvents

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

the class UpdateFormItems method updateFormItems.

/**
 * Updates form items in DB by passed list of them
 *
 * @param formItems
 */
public void updateFormItems(ArrayList<ApplicationFormItem> formItems) {
    this.formItems = formItems;
    ;
    // test arguments
    if (!this.testCreating()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Updating form items failed.");
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Form items updated.");
            events.onFinished(jso);
        }

        public void onLoadingStart() {
            events.onLoadingStart();
        }
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, prepareJSONObject());
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 80 with JsonCallbackEvents

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

the class UpdateGroup method updateGroup.

/**
 * Updates group details
 * @param group Group with updated details
 */
public void updateGroup(Group group) {
    if (group == null) {
        Window.alert("Group can't be null");
        return;
    }
    // GROUP OBJECT
    JSONObject oldGroup = new JSONObject(group);
    // RECONSTRUCT OBJECT
    JSONObject newGroup = new JSONObject();
    newGroup.put("id", oldGroup.get("id"));
    // fake new group short name as name in order to update
    newGroup.put("name", oldGroup.get("shortName"));
    newGroup.put("description", oldGroup.get("description"));
    newGroup.put("voId", oldGroup.get("voId"));
    newGroup.put("parentGroupId", oldGroup.get("parentGroupId"));
    newGroup.put("beanName", oldGroup.get("beanName"));
    newGroup.put("createdAt", oldGroup.get("createdAt"));
    newGroup.put("createdBy", oldGroup.get("createdBy"));
    newGroup.put("modifiedAt", oldGroup.get("modifiedAt"));
    newGroup.put("modifiedBy", oldGroup.get("modifiedBy"));
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("group", newGroup);
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Updating group failed.");
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            Group gp = jso.cast();
            session.getUiElements().setLogSuccessText("Group " + gp.getName() + " successfully updated!");
            events.onFinished(jso);
        }

        public void onLoadingStart() {
            events.onLoadingStart();
        }
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, jsonQuery);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Group(cz.metacentrum.perun.webgui.model.Group) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Aggregations

JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)380 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)333 PerunError (cz.metacentrum.perun.webgui.model.PerunError)206 JsonPostClient (cz.metacentrum.perun.webgui.json.JsonPostClient)181 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)143 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)143 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)142 ArrayList (java.util.ArrayList)125 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)108 JSONObject (com.google.gwt.json.client.JSONObject)69 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)60 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)41 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)34 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)34 HashMap (java.util.HashMap)33 JSONNumber (com.google.gwt.json.client.JSONNumber)30 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)24 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)24 Group (cz.metacentrum.perun.webgui.model.Group)23 Map (java.util.Map)23