Search in sources :

Example 51 with JsonCallbackEvents

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

the class GetResources method retrieveData.

/**
 * Retrieves data from RPC
 */
public void retrieveData() {
    // empty
    if (this.attributesToSearchBy.size() == 0) {
        session.getUiElements().setLogText("No keywords.");
        return;
    }
    // ok, start
    loaderImage.loadingStart();
    // build request
    JSONObject attributesWithSearchingValues = new JSONObject();
    for (Map.Entry<String, String> entry : attributesToSearchBy.entrySet()) {
        String name = entry.getKey();
        String value = entry.getValue();
        attributesWithSearchingValues.put(name, new JSONString(value));
    }
    JSONObject req = new JSONObject();
    req.put("attributesWithSearchingValues", attributesWithSearchingValues);
    // send request
    JsonPostClient js = new JsonPostClient(new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Error while loading resources.");
            loaderImage.loadingError(error);
            events.onError(error);
        }

        public void onLoadingStart() {
            loaderImage.loadingStart();
            session.getUiElements().setLogText("Loading resources started.");
            events.onLoadingStart();
        }

        public void onFinished(JavaScriptObject jso) {
            loaderImage.loadingFinished();
            setList(JsonUtils.<Resource>jsoAsList(jso));
            sortTable();
            session.getUiElements().setLogText("Resources loaded: " + list.size());
            events.onFinished(jso);
        }
    });
    js.sendData(JSON_URL, req);
    return;
}
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) Resource(cz.metacentrum.perun.webgui.model.Resource) JSONString(com.google.gwt.json.client.JSONString) PerunError(cz.metacentrum.perun.webgui.model.PerunError) HashMap(java.util.HashMap) Map(java.util.Map) JSONString(com.google.gwt.json.client.JSONString)

Example 52 with JsonCallbackEvents

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

the class DeleteSecurityTeam method deleteSecurityTeam.

/**
 * Attempts to delete Security Team, it first tests the values and then submits them.
 *
 * @param securityTeamId ID of SecurityTeam to be deleted
 * @param force true for force delete
 */
public void deleteSecurityTeam(final int securityTeamId, final boolean force) {
    this.securityTeamId = securityTeamId;
    this.force = force;
    // test arguments
    if (!this.testDeleting()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Deleting Security Team: " + securityTeamId + " failed.");
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Security Team " + securityTeamId + " 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 53 with JsonCallbackEvents

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

the class AssignServices method assignService.

/**
 * Attempts to assign Services to Resource
 *
 * @param resourceId ID of resource where should be assigned
 * @param services IDs of services to assign
 */
public void assignService(final int resourceId, final ArrayList<Service> services) {
    this.resourceId = resourceId;
    for (int i = 0; i < services.size(); i++) {
        serviceIds[i] = services.get(i).getId();
    }
    // test arguments
    if (!this.testAssigning()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Assigning services to resource: " + resourceId + " failed.");
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Services successfully assigned to resource: " + resourceId);
            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 54 with JsonCallbackEvents

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

the class AssignServices method assignService.

/**
 * Attempts to assign service to resource
 *
 * @param serviceId ID of service which should be assigned
 * @param resourceId ID of resource where should be assigned
 */
public void assignService(final int serviceId, final int resourceId) {
    this.resourceId = resourceId;
    this.serviceIds[0] = serviceId;
    // test arguments
    if (!this.testAssigning()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Assigning service: " + serviceId + " to resource: " + resourceId + " failed.");
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Service: " + serviceId + " successfully assigned to resource: " + resourceId);
            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 55 with JsonCallbackEvents

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

the class AssignResourceTag method assignResourceTag.

/**
 * Attempts to assign resource tag to Resource, it first tests the values and then submits them
 *
 * @param tag ResourceTag to assign
 */
public void assignResourceTag(ResourceTag tag) {
    this.resourceTag = tag;
    // test arguments
    if (!this.testAdding()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Assigning tag to resource failed.");
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Tag assigned to resource.");
            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