Search in sources :

Example 11 with CommentInfo

use of com.google.gerrit.client.changes.CommentInfo in project gerrit by GerritCodeReview.

the class ChangeScreen method filterForRevision.

private static NativeMap<JsArray<CommentInfo>> filterForRevision(NativeMap<JsArray<CommentInfo>> comments, int id) {
    NativeMap<JsArray<CommentInfo>> filtered = NativeMap.create();
    for (String k : comments.keySet()) {
        JsArray<CommentInfo> allRevisions = comments.get(k);
        JsArray<CommentInfo> thisRevision = JsArray.createArray().cast();
        for (int i = 0; i < allRevisions.length(); i++) {
            CommentInfo c = allRevisions.get(i);
            if (c.patchSet() == id) {
                thisRevision.push(c);
            }
        }
        filtered.put(k, thisRevision);
    }
    return filtered;
}
Also used : JsArray(com.google.gwt.core.client.JsArray) JsArrayString(com.google.gwt.core.client.JsArrayString) CommentInfo(com.google.gerrit.client.changes.CommentInfo) GerritUiExtensionPoint(com.google.gerrit.client.GerritUiExtensionPoint)

Example 12 with CommentInfo

use of com.google.gerrit.client.changes.CommentInfo in project gerrit by GerritCodeReview.

the class DraftBox method save.

void save(CallbackGroup group) {
    if (pendingGroup != null) {
        pendingGroup.addListener(group);
        return;
    }
    String message = editArea.getValue().trim();
    if (message.length() == 0) {
        return;
    }
    CommentInfo input = CommentInfo.copy(comment);
    input.message(message);
    enableEdit(false);
    pendingGroup = group;
    final LocalComments lc = new LocalComments(psId);
    GerritCallback<CommentInfo> cb = new GerritCallback<CommentInfo>() {

        @Override
        public void onSuccess(CommentInfo result) {
            enableEdit(true);
            pendingGroup = null;
            set(result);
            setEdit(false);
            if (autoClosed) {
                setOpen(false);
            }
            getCommentManager().setUnsaved(DraftBox.this, false);
        }

        @Override
        public void onFailure(Throwable e) {
            enableEdit(true);
            pendingGroup = null;
            if (RestApi.isNotSignedIn(e)) {
                CommentInfo saved = CommentInfo.copy(comment);
                saved.message(editArea.getValue().trim());
                lc.setInlineComment(saved);
            }
            super.onFailure(e);
        }
    };
    if (input.id() == null) {
        CommentApi.createDraft(psId, input, group.add(cb));
    } else {
        CommentApi.updateDraft(psId, input.id(), input, group.add(cb));
    }
    CodeMirror cm = getCm();
    cm.vim().handleKey("<Esc>");
    cm.focus();
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) CommentInfo(com.google.gerrit.client.changes.CommentInfo) LocalComments(com.google.gerrit.client.change.LocalComments) CodeMirror(net.codemirror.lib.CodeMirror)

Aggregations

CommentInfo (com.google.gerrit.client.changes.CommentInfo)12 ArrayList (java.util.ArrayList)4 JsArrayString (com.google.gwt.core.client.JsArrayString)3 NativeMap (com.google.gerrit.client.rpc.NativeMap)2 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)2 JsArray (com.google.gwt.core.client.JsArray)2 Timestamp (java.sql.Timestamp)2 List (java.util.List)2 TreeMap (java.util.TreeMap)2 GerritUiExtensionPoint (com.google.gerrit.client.GerritUiExtensionPoint)1 NotFoundScreen (com.google.gerrit.client.NotFoundScreen)1 LocalComments (com.google.gerrit.client.change.LocalComments)1 CommentRange (com.google.gerrit.client.diff.CommentRange)1 RevisionInfo (com.google.gerrit.client.info.ChangeInfo.RevisionInfo)1 CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)1 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)1 CommentLinkProcessor (com.google.gerrit.client.ui.CommentLinkProcessor)1 Side (com.google.gerrit.extensions.client.Side)1 Change (com.google.gerrit.reviewdb.client.Change)1 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)1