Search in sources :

Example 31 with JsonCallbackEvents

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

the class RemoveAdmin method removeVoAdmin.

/**
 * Attempts to remove admin from VO, it first tests the values and then submits them.
 *
 * @param vo where we want to remove admin from
 * @param user User to be removed from admins
 */
public void removeVoAdmin(final VirtualOrganization vo, final User user) {
    this.userId = (user != null) ? user.getId() : 0;
    this.entityId = (vo != null) ? vo.getId() : 0;
    this.entity = PerunEntity.VIRTUAL_ORGANIZATION;
    // test arguments
    if (!this.testRemoving()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Removing " + user.getFullName() + " from managers failed.");
            // custom events
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("User " + user.getFullName() + " removed from managers of " + vo.getName());
            events.onFinished(jso);
        }

        public void onLoadingStart() {
            events.onLoadingStart();
        }
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(VO_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)

Example 32 with JsonCallbackEvents

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

the class RemoveAdmin method removeGroupAdmin.

/**
 * Attempts to remove admin from Group, it first tests the values and then submits them.
 *
 * @param group where we want to remove admin
 * @param user User to be removed from admin
 */
public void removeGroupAdmin(final Group group, final User user) {
    this.userId = (user != null) ? user.getId() : 0;
    this.entityId = (group != null) ? group.getId() : 0;
    this.entity = PerunEntity.GROUP;
    // test arguments
    if (!this.testRemoving()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Removing " + user.getFullName() + " from managers failed.");
            // custom events
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("User " + user.getFullName() + " removed from managers of " + group.getName());
            events.onFinished(jso);
        }

        public void onLoadingStart() {
            events.onLoadingStart();
        }
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(GROUP_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)

Example 33 with JsonCallbackEvents

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

the class RemoveAdmin method removeVoAdminGroup.

/**
 * Attempts to remove admin group from VO, it first tests the values and then submits them.
 *
 * @param vo where we want to remove admin from
 * @param group Group to be removed from admins
 */
public void removeVoAdminGroup(final VirtualOrganization vo, final Group group) {
    // store group id to user id to used unified check method
    this.userId = (group != null) ? group.getId() : 0;
    this.entityId = (vo != null) ? vo.getId() : 0;
    this.entity = PerunEntity.VIRTUAL_ORGANIZATION;
    // test arguments
    if (!this.testRemoving()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Removing group " + group.getShortName() + " from managers failed.");
            // custom events
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Group " + group.getShortName() + " removed from managers of " + vo.getName());
            events.onFinished(jso);
        }

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

Example 34 with JsonCallbackEvents

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

the class RemoveAdmin method removeFacilityAdmin.

/**
 * Attempts to remove admin from Facility, it first tests the values and then submits them.
 *
 * @param facility where we want to remove admin from
 * @param user User to be removed from admins
 */
public void removeFacilityAdmin(final Facility facility, final User user) {
    this.userId = (user != null) ? user.getId() : 0;
    this.entityId = (facility != null) ? facility.getId() : 0;
    this.entity = PerunEntity.FACILITY;
    // test arguments
    if (!this.testRemoving()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Removing " + user.getFullName() + " from managers failed.");
            // custom events
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("User " + user.getFullName() + " removed form managers of " + facility.getName());
            events.onFinished(jso);
        }

        public void onLoadingStart() {
            events.onLoadingStart();
        }
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(FACILITY_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)

Example 35 with JsonCallbackEvents

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

the class SetAttribute method setAttribute.

/**
 * Attempts to set new value for some attribute
 *
 * @param ids defines which type of attribute will be set (member, user, member_resource, etc.)
 * @param attribute attribute object with a new value
 */
public void setAttribute(final Map<String, Integer> ids, final Attribute attribute) {
    this.ids = ids;
    this.attribute = attribute;
    // test arguments
    if (!this.testSetting()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Setting new value for attribute: " + attribute.getId() + " failed.");
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("New value for attribute: " + attribute.getId() + " successfully updated in DB !");
            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)

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