Search in sources :

Example 1 with CommentInfo

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

the class PublishedBox method addReplyBox.

void addReplyBox(boolean quote) {
    CommentInfo commentReply = CommentInfo.createReply(comment);
    if (quote) {
        commentReply.message(ReplyBox.quote(comment.message()));
    }
    getCommentManager().addDraftBox(displaySide, commentReply).setEdit(true);
}
Also used : CommentInfo(com.google.gerrit.client.changes.CommentInfo)

Example 2 with CommentInfo

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

the class Message method renderComments.

private void renderComments(List<CommentInfo> list) {
    CommentLinkProcessor clp = history.getCommentLinkProcessor();
    PatchSet.Id ps = new PatchSet.Id(history.getChangeId(), info._revisionNumber());
    TreeMap<String, List<CommentInfo>> m = byPath(list);
    List<CommentInfo> l = m.remove(Patch.COMMIT_MSG);
    if (l != null) {
        comments.add(new FileComments(clp, ps, Util.C.commitMessage(), l));
    }
    l = m.remove(Patch.MERGE_LIST);
    if (l != null) {
        comments.add(new FileComments(clp, ps, Util.C.mergeList(), l));
    }
    for (Map.Entry<String, List<CommentInfo>> e : m.entrySet()) {
        comments.add(new FileComments(clp, ps, e.getKey(), e.getValue()));
    }
}
Also used : CommentLinkProcessor(com.google.gerrit.client.ui.CommentLinkProcessor) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) ArrayList(java.util.ArrayList) List(java.util.List) CommentInfo(com.google.gerrit.client.changes.CommentInfo) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 3 with CommentInfo

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

the class History method comments.

private List<CommentInfo> comments(MessageInfo msg) {
    if (msg.author() == null) {
        return Collections.emptyList();
    }
    int authorId = msg.author()._accountId();
    List<CommentInfo> list = byAuthor.get(authorId);
    if (list == null) {
        return Collections.emptyList();
    }
    Timestamp when = msg.date();
    List<CommentInfo> match = new ArrayList<>();
    List<CommentInfo> other = new ArrayList<>();
    for (CommentInfo c : list) {
        if (c.updated().compareTo(when) <= 0) {
            match.add(c);
        } else {
            other.add(c);
        }
    }
    if (match.isEmpty()) {
        return Collections.emptyList();
    } else if (other.isEmpty()) {
        byAuthor.remove(authorId);
    } else {
        byAuthor.put(authorId, other);
    }
    return match;
}
Also used : ArrayList(java.util.ArrayList) CommentInfo(com.google.gerrit.client.changes.CommentInfo) Timestamp(java.sql.Timestamp)

Example 4 with CommentInfo

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

the class History method addComments.

void addComments(NativeMap<JsArray<CommentInfo>> map) {
    for (String path : map.keySet()) {
        for (CommentInfo c : Natives.asList(map.get(path))) {
            c.path(path);
            if (c.author() != null) {
                int authorId = c.author()._accountId();
                List<CommentInfo> l = byAuthor.get(authorId);
                if (l == null) {
                    l = new ArrayList<>();
                    byAuthor.put(authorId, l);
                }
                l.add(c);
            }
        }
    }
}
Also used : CommentInfo(com.google.gerrit.client.changes.CommentInfo)

Example 5 with CommentInfo

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

the class LocalComments method getInlineComment.

private static InlineComment getInlineComment(String key) {
    String path;
    Side side = Side.PARENT;
    int line = 0;
    CommentRange range;
    StorageBackend storage = new StorageBackend();
    String[] elements = key.split("-");
    int offset = 1;
    if (key.startsWith("patchReply-") || key.startsWith("patchCommentEdit-")) {
        offset = 2;
    }
    Change.Id changeId = new Change.Id(Integer.parseInt(elements[offset + 0]));
    PatchSet.Id psId = new PatchSet.Id(changeId, Integer.parseInt(elements[offset + 1]));
    path = atob(elements[offset + 2]);
    side = (Side.PARENT.toString().equals(elements[offset + 3])) ? Side.PARENT : Side.REVISION;
    range = null;
    if (elements[offset + 4].startsWith("R")) {
        String rangeStart = elements[offset + 4].substring(1);
        String rangeEnd = elements[offset + 5];
        String[] split = rangeStart.split(",");
        int sl = Integer.parseInt(split[0]);
        int sc = Integer.parseInt(split[1]);
        split = rangeEnd.split(",");
        int el = Integer.parseInt(split[0]);
        int ec = Integer.parseInt(split[1]);
        range = CommentRange.create(sl, sc, el, ec);
        line = sl;
    } else {
        line = Integer.parseInt(elements[offset + 4]);
    }
    CommentInfo info = CommentInfo.create(path, side, line, range, false);
    info.message(storage.getItem(key));
    if (key.startsWith("patchReply-")) {
        info.inReplyTo(elements[1]);
    } else if (key.startsWith("patchCommentEdit-")) {
        info.id(elements[1]);
    }
    InlineComment inlineComment = new InlineComment(psId, info);
    return inlineComment;
}
Also used : CommentRange(com.google.gerrit.client.diff.CommentRange) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) Change(com.google.gerrit.reviewdb.client.Change) CommentInfo(com.google.gerrit.client.changes.CommentInfo) Side(com.google.gerrit.extensions.client.Side)

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