Search in sources :

Example 26 with PerunError

use of cz.metacentrum.perun.webgui.model.PerunError in project perun by CESNET.

the class DeleteResource method deleteResource.

/**
	 * Attempts to delete resource, it first tests the values and then submits them
	 *
	 * @param resourceId ID of resource to be deleted
	 */
public void deleteResource(final int resourceId) {
    this.resourceId = resourceId;
    // test arguments
    if (!this.testDeleting()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

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

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Resource " + resourceId + " 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 27 with PerunError

use of cz.metacentrum.perun.webgui.model.PerunError 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 28 with PerunError

use of cz.metacentrum.perun.webgui.model.PerunError in project perun by CESNET.

the class SendInvitation method inviteUser.

/**
	 * Send request to invite user
	 */
public void inviteUser(String email, String name, String language) {
    if (email == null || email.isEmpty()) {
        UiElements.generateAlert("Input error", "Email address to send invitation to is empty.");
        return;
    }
    if (!JsonUtils.isValidEmail(email)) {
        UiElements.generateAlert("Input error", "Email address format is not valid.");
        return;
    }
    /*
		if (name == null || name.isEmpty()) {
			UiElements.generateAlert("Input error", "Name of user to invite can't be empty.");
			return;
		}
		*/
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

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

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("User invited.");
            events.onFinished(jso);
        }

        public void onLoadingStart() {
            events.onLoadingStart();
        }
    };
    // query
    JSONObject query = new JSONObject();
    query.put("voId", new JSONNumber(voId));
    if (groupId != 0) {
        query.put("groupId", new JSONNumber(groupId));
    }
    if (name != null && !name.isEmpty())
        query.put("name", new JSONString(name));
    query.put("email", new JSONString(email));
    if (language != null && !language.isEmpty()) {
        query.put("language", new JSONString(language));
    } else {
        query.put("language", new JSONObject(null));
    }
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, query);
}
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) JSONString(com.google.gwt.json.client.JSONString)

Example 29 with PerunError

use of cz.metacentrum.perun.webgui.model.PerunError 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 30 with PerunError

use of cz.metacentrum.perun.webgui.model.PerunError in project perun by CESNET.

the class GetUsers 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 users.");
            loaderImage.loadingError(error);
            events.onError(error);
        }

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

        public void onFinished(JavaScriptObject jso) {
            loaderImage.loadingFinished();
            setList(JsonUtils.<User>jsoAsList(jso));
            sortTable();
            session.getUiElements().setLogText("Users loaded: " + list.size());
            events.onFinished(jso);
        }
    });
    js.sendData(JSON_URL, req);
    return;
}
Also used : User(cz.metacentrum.perun.webgui.model.User) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) 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)

Aggregations

PerunError (cz.metacentrum.perun.webgui.model.PerunError)177 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)173 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)167 JsonPostClient (cz.metacentrum.perun.webgui.json.JsonPostClient)126 JSONObject (com.google.gwt.json.client.JSONObject)55 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)36 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)36 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)30 ArrayList (java.util.ArrayList)30 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)27 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)21 JSONNumber (com.google.gwt.json.client.JSONNumber)17 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)16 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)16 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)15 AjaxLoaderImage (cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage)11 Attribute (cz.metacentrum.perun.webgui.model.Attribute)10 HashMap (java.util.HashMap)10 JSONString (com.google.gwt.json.client.JSONString)8 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)8