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);
}
}
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);
}
}
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();
}
}));
}
}
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);
}
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);
}
}
Aggregations