Search in sources :

Example 81 with JsonCallbackEvents

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

the class CreateMember method createMember.

/**
 * Attempts to create member in VO from candidate
 *
 * @param voId vo where member should be created
 * @param group where member should be created
 * @param candidate candidate to be member
 */
public void createMember(final int voId, Group group, final Candidate candidate) {
    this.voId = voId;
    this.group = group;
    this.candidate = candidate;
    // test arguments
    if (!this.testAdding()) {
        return;
    }
    if (!session.isVoAdmin(voId)) {
        // GROUP ADMIN HAVE OWN PROCESSING
        createMemberAsGroupAdmin(voId, group, candidate);
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Creating member: " + candidate.getDisplayName() + " failed.");
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Member " + candidate.getDisplayName() + " created !");
            // call validation asynchronously
            Member mem = jso.cast();
            ValidateMemberAsync request = new ValidateMemberAsync();
            request.validateMemberAsync(mem);
            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)

Example 82 with JsonCallbackEvents

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

the class DeleteMember method deleteMember.

/**
 * Attempts to delete member in VO
 *
 * @param memberId ID of member which should be deleted
 */
public void deleteMember(final int memberId) {
    this.memberId = memberId;
    // test arguments
    if (!this.testAdding()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

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

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Member: " + memberId + " 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 83 with JsonCallbackEvents

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

the class CreateOwner method createOwner.

/**
 * Attempts to create owner, it first tests the values and then submits them.
 *
 * @param ownerName name of future owner
 * @param ownerContact owners contact (mail, phone, vo etc.)
 * @param ownerType type of owner (administrative, technical)
 */
public void createOwner(final String ownerName, final String ownerContact, final String ownerType) {
    this.ownerName = ownerName;
    this.ownerContact = ownerContact;
    this.ownerType = ownerType;
    // test arguments
    if (!this.testCreating()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Creating owner: " + ownerName + " failed.");
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Owner " + ownerName + " created.");
            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 84 with JsonCallbackEvents

use of cz.metacentrum.perun.webgui.json.JsonCallbackEvents 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 85 with JsonCallbackEvents

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

the class CreateCategory method createCategory.

/**
 * Attempts to create a new Category, it first tests the values and then submits them.
 *
 * @param name Category name
 * @param rank Category ranking
 */
public void createCategory(final String name, double rank) {
    this.name = name;
    this.rank = rank;
    // test arguments
    if (!this.testCreating()) {
        return;
    }
    // json object
    JSONObject jsonQuery = prepareJSONObject();
    // local events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Creating category " + name + " failed.");
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Category " + name + " created.");
            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)

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