Search in sources :

Example 21 with JavaScriptObject

use of com.google.gwt.core.client.JavaScriptObject in project gerrit by GerritCodeReview.

the class ProjectGlue method onAction.

public static void onAction(Project.NameKey project, ActionInfo action, ActionButton button) {
    RestApi api = ProjectApi.project(project).view(action.id());
    JavaScriptObject f = projectAction(action.id());
    if (f != null) {
        ActionContext c = ActionContext.create(api);
        c.set(action);
        c.set(project);
        c.button(button);
        ApiGlue.invoke(f, c);
    } else {
        DefaultActions.invoke(project, action, api);
    }
}
Also used : RestApi(com.google.gerrit.client.rpc.RestApi) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject)

Example 22 with JavaScriptObject

use of com.google.gwt.core.client.JavaScriptObject in project gerrit by GerritCodeReview.

the class RevisionGlue method onAction.

public static void onAction(ChangeInfo change, RevisionInfo revision, ActionInfo action, ActionButton button) {
    RestApi api = ChangeApi.revision(change.legacyId().get(), revision.name()).view(action.id());
    JavaScriptObject f = get(action.id());
    if (f != null) {
        ActionContext c = ActionContext.create(api);
        c.set(action);
        c.set(change);
        c.set(revision);
        c.button(button);
        ApiGlue.invoke(f, c);
    } else {
        DefaultActions.invoke(change, action, api);
    }
}
Also used : RestApi(com.google.gerrit.client.rpc.RestApi) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject)

Example 23 with JavaScriptObject

use of com.google.gwt.core.client.JavaScriptObject in project gerrit by GerritCodeReview.

the class DraftBox method onDiscard.

@UiHandler({ "discard1", "discard2" })
void onDiscard(ClickEvent e) {
    e.stopPropagation();
    if (isNew()) {
        removeUI();
        restoreSelection();
    } else {
        setEdit(false);
        pendingGroup = new CallbackGroup();
        CommentApi.deleteDraft(psId, comment.id(), pendingGroup.addFinal(new GerritCallback<JavaScriptObject>() {

            @Override
            public void onSuccess(JavaScriptObject result) {
                pendingGroup = null;
                removeUI();
            }
        }));
    }
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup) UiHandler(com.google.gwt.uibinder.client.UiHandler)

Example 24 with JavaScriptObject

use of com.google.gwt.core.client.JavaScriptObject in project gerrit by GerritCodeReview.

the class Edit_JsonSerializer method fromJson.

@Override
public Edit fromJson(Object jso) {
    if (jso == null) {
        return null;
    }
    final JavaScriptObject o = (JavaScriptObject) jso;
    final int cnt = length(o);
    if (4 == cnt) {
        return new Edit(get(o, 0), get(o, 1), get(o, 2), get(o, 3));
    }
    List<Edit> l = new ArrayList<>((cnt / 4) - 1);
    for (int i = 4; i < cnt; ) {
        int as = get(o, i++);
        int ae = get(o, i++);
        int bs = get(o, i++);
        int be = get(o, i++);
        l.add(new Edit(as, ae, bs, be));
    }
    return new ReplaceEdit(get(o, 0), get(o, 1), get(o, 2), get(o, 3), l);
}
Also used : JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) ArrayList(java.util.ArrayList)

Example 25 with JavaScriptObject

use of com.google.gwt.core.client.JavaScriptObject in project gerrit by GerritCodeReview.

the class StarredChanges method startRequest.

private static void startRequest() {
    busy = true;
    final Change.Id id = pending.keySet().iterator().next();
    final boolean starred = pending.remove(id);
    RestApi call = AccountApi.self().view("starred.changes").id(id.get());
    AsyncCallback<JavaScriptObject> cb = new AsyncCallback<JavaScriptObject>() {

        @Override
        public void onSuccess(JavaScriptObject none) {
            if (pending.isEmpty()) {
                busy = false;
            } else {
                startRequest();
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            if (!starred && RestApi.isStatus(caught, 404)) {
                onSuccess(null);
                return;
            }
            fireChangeStarEvent(id, !starred);
            for (Map.Entry<Change.Id, Boolean> e : pending.entrySet()) {
                fireChangeStarEvent(e.getKey(), !e.getValue());
            }
            pending.clear();
            busy = false;
        }
    };
    if (starred) {
        call.put(cb);
    } else {
        call.delete(cb);
    }
}
Also used : RestApi(com.google.gerrit.client.rpc.RestApi) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) Change(com.google.gerrit.reviewdb.client.Change) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)436 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)333 PerunError (cz.metacentrum.perun.webgui.model.PerunError)212 JsonPostClient (cz.metacentrum.perun.webgui.json.JsonPostClient)181 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)110 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)110 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)104 ArrayList (java.util.ArrayList)95 JSONObject (com.google.gwt.json.client.JSONObject)79 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)73 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)58 HashMap (java.util.HashMap)34 JSONNumber (com.google.gwt.json.client.JSONNumber)32 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)31 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)31 Map (java.util.Map)25 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)24 JSONString (com.google.gwt.json.client.JSONString)22 Attribute (cz.metacentrum.perun.webgui.model.Attribute)20 Group (cz.metacentrum.perun.webgui.model.Group)19