Search in sources :

Example 96 with JavaScriptObject

use of com.google.gwt.core.client.JavaScriptObject in project perun by CESNET.

the class AddAdmin method addGroupAdminGroup.

/**
	 * Attempts to add a new admin group to Group, it first tests the values and then submits them.
	 *
	 * @param groupToAddAdminTo where we want to add admin
	 * @param group Group to be admin
	 */
public void addGroupAdminGroup(final Group groupToAddAdminTo, final Group group) {
    // store group id to user id to used unified check method
    this.userId = (group != null) ? group.getId() : 0;
    this.entityId = (groupToAddAdminTo != null) ? groupToAddAdminTo.getId() : 0;
    this.entity = PerunEntity.GROUP;
    // test arguments
    if (!this.testAdding()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Adding group " + group.getShortName() + " as manager failed.");
            // custom events
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Group " + group.getShortName() + " added as manager of " + groupToAddAdminTo.getName());
            events.onFinished(jso);
        }

        ;

        public void onLoadingStart() {
            events.onLoadingStart();
        }

        ;
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(GROUP_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 97 with JavaScriptObject

use of com.google.gwt.core.client.JavaScriptObject in project perun by CESNET.

the class AddExtSource method addGroupExtSource.

/**
	 * Attempts to add external source to Group in DB - make RPC call
	 *
	 * @param groupId ID of Group, where should be ext source added
	 * @param extSourceId ID of external source to be added
	 */
public void addGroupExtSource(final int groupId, final int extSourceId) {
    this.extSourceId = extSourceId;
    // create whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("source", new JSONNumber(extSourceId));
    jsonQuery.put("group", new JSONNumber(groupId));
    // local events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Adding external source: " + extSourceId + " to group: " + groupId + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("External source: " + extSourceId + " successfully added to group: " + groupId);
            events.onFinished(jso);
        }

        ;

        public void onLoadingStart() {
            events.onLoadingStart();
        }

        ;
    };
    // create request
    JsonPostClient request = new JsonPostClient(newEvents);
    request.sendData(JSON_URL, jsonQuery);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) JSONNumber(com.google.gwt.json.client.JSONNumber) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 98 with JavaScriptObject

use of com.google.gwt.core.client.JavaScriptObject in project perun by CESNET.

the class RemoveExtSource method removeVoExtSource.

/**
	 * Attempts to remove external source from VO
	 *
	 * @param voId ID of VO, where we should remove ext source
	 * @param extSourceId ID of external source to be removed
	 */
public void removeVoExtSource(final int voId, final int extSourceId) {
    this.voId = voId;
    this.extSourceId = extSourceId;
    // test arguments
    if (!this.testRemoving()) {
        return;
    }
    // json object
    JSONObject jsonQuery = prepareJSONObject();
    // local events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Removing external source: " + extSourceId + " from VO: " + voId + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("External source: " + extSourceId + " successfully removed from VO: " + voId);
            events.onFinished(jso);
        }

        ;

        public void onLoadingStart() {
            events.onLoadingStart();
        }

        ;
    };
    // create request
    JsonPostClient request = new JsonPostClient(newEvents);
    request.sendData(JSON_URL, jsonQuery);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) 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)

Example 99 with JavaScriptObject

use of com.google.gwt.core.client.JavaScriptObject in project perun by CESNET.

the class RemoveAttributes method removeAttributes.

/**
	 * Attempts to remove some attributes from entity
	 *
	 * @param ids defines which type of attribute will be removed (member, user, member_resource, etc.)
	 * @param attributes list of attributes to remove
	 */
public void removeAttributes(final Map<String, Integer> ids, final ArrayList<Attribute> attributes) {
    this.ids = ids;
    this.attributes = attributes;
    // test arguments
    if (!this.testRemoving()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

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

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Attributes successfully removed !");
            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 100 with JavaScriptObject

use of com.google.gwt.core.client.JavaScriptObject 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

JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)356 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)286 PerunError (cz.metacentrum.perun.webgui.model.PerunError)173 JsonPostClient (cz.metacentrum.perun.webgui.json.JsonPostClient)149 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)105 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)105 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)98 ArrayList (java.util.ArrayList)86 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)67 JSONObject (com.google.gwt.json.client.JSONObject)54 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)54 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)28 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)28 HashMap (java.util.HashMap)27 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)22 JSONNumber (com.google.gwt.json.client.JSONNumber)19 User (cz.metacentrum.perun.webgui.model.User)18 AjaxLoaderImage (cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage)18 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)18 Map (java.util.Map)18