Search in sources :

Example 41 with PerunError

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

the class DeleteService method deleteService.

/**
	 * Attempts to delete a service, tests values first
	 *
	 * @param serviceId id of service to be deleted
	 */
public void deleteService(final int serviceId) {
    this.serviceId = serviceId;
    // test arguments
    if (!this.testDeleting()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

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

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Service : " + serviceId + " 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 42 with PerunError

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

the class DeleteServicePackage method deleteServicePackage.

/**
	 * Attempts to delete a service, tests values first
	 *
	 * @param packageId id of service to be deleted
	 */
public void deleteServicePackage(final int packageId) {
    this.packageId = packageId;
    // test arguments
    if (!this.testDeleting()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

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

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Service package: " + packageId + " 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 43 with PerunError

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

the class RequestPreferredEmailChange method requestChange.

/**
	 * Request change of preferred email
	 *
	 * @param user
	 * @param email
	 */
public void requestChange(final User user, final String email) {
    this.user = user;
    this.email = email;
    // test arguments
    if (!this.testRemoving()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Requesting change of preferred email failed.");
            // custom events
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Request to change preferred email was submitted.");
            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 44 with PerunError

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

the class SetLogin method setLogin.

/**
	 * Set new login for user
	 *
	 * @param user
	 * @param namespace
	 * @param login
	 */
public void setLogin(final User user, final String namespace, final String login) {
    this.user = user;
    this.userId = user.getId();
    this.login = login;
    this.namespace = namespace;
    // test arguments
    if (!this.testAdding()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Adding login to user: " + user.getFullName() + " failed.");
            // custom events
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Login successfully added to user: " + user.getFullName());
            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 45 with PerunError

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

the class UpdateNameTitles method updateUserTitles.

/**
	 * Updates user details
	 * @param user User with updated details
	 */
public void updateUserTitles(User user) {
    if (user == null) {
        UiElements.generateAlert("Parameter error", "User to update can't be null");
        return;
    }
    // OBJECT
    JSONObject oldUser = new JSONObject(user);
    // RECONSTRUCT OBJECT
    JSONObject newUser = new JSONObject();
    newUser.put("id", oldUser.get("id"));
    newUser.put("firstName", oldUser.get("firstName"));
    newUser.put("middleName", oldUser.get("middleName"));
    newUser.put("lastName", oldUser.get("lastName"));
    newUser.put("titleBefore", oldUser.get("titleBefore"));
    newUser.put("titleAfter", oldUser.get("titleAfter"));
    newUser.put("serviceUser", oldUser.get("serviceUser"));
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("user", newUser);
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

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

        ;

        public void onFinished(JavaScriptObject jso) {
            User u = jso.cast();
            session.getUiElements().setLogSuccessText("User " + u.getFullNameWithTitles() + " 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) User(cz.metacentrum.perun.webgui.model.User) 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

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