Search in sources :

Example 6 with CommentInfo

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

the class CommentManager method renderPublished.

void renderPublished(DisplaySide forSide, JsArray<CommentInfo> in) {
    for (CommentInfo info : Natives.asList(in)) {
        DisplaySide side = displaySide(info, forSide);
        if (side != null) {
            int cmLinePlusOne = host.getCmLine(info.line() - 1, side) + 1;
            CommentGroup group = group(side, cmLinePlusOne);
            PublishedBox box = new PublishedBox(group, getCommentLinkProcessor(), getPatchSetIdFromSide(side), info, side, isOpen());
            group.add(box);
            box.setAnnotation(host.getDiffTable().scrollbar.comment(host.getCmFromSide(side), cmLinePlusOne - 1));
            getPublished().put(info.id(), box);
        }
    }
}
Also used : CommentInfo(com.google.gerrit.client.changes.CommentInfo)

Example 7 with CommentInfo

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

the class ReplyBox method onLoad.

@Override
protected void onLoad() {
    commentsPanel.setVisible(false);
    post.setEnabled(false);
    if (lc.hasReplyComment()) {
        message.setText(lc.getReplyComment());
        lc.removeReplyComment();
    }
    ChangeApi.drafts(psId.getParentKey().get()).get(new AsyncCallback<NativeMap<JsArray<CommentInfo>>>() {

        @Override
        public void onSuccess(NativeMap<JsArray<CommentInfo>> result) {
            displayComments(result);
            post.setEnabled(true);
        }

        @Override
        public void onFailure(Throwable caught) {
            post.setEnabled(true);
        }
    });
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            message.setFocus(true);
        }
    });
    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

        @Override
        public boolean execute() {
            String t = message.getText();
            if (t != null) {
                message.setCursorPos(t.length());
            }
            return false;
        }
    }, 0);
}
Also used : JsArray(com.google.gwt.core.client.JsArray) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) CommentInfo(com.google.gerrit.client.changes.CommentInfo) JsArrayString(com.google.gwt.core.client.JsArrayString) NativeMap(com.google.gerrit.client.rpc.NativeMap)

Example 8 with CommentInfo

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

the class ReplyBox method displayComments.

private void displayComments(NativeMap<JsArray<CommentInfo>> m) {
    comments.clear();
    JsArray<CommentInfo> l = m.get(Patch.COMMIT_MSG);
    if (l != null) {
        comments.add(new FileComments(clp, psId, Util.C.commitMessage(), copyPath(Patch.COMMIT_MSG, l)));
    }
    l = m.get(Patch.MERGE_LIST);
    if (l != null) {
        comments.add(new FileComments(clp, psId, Util.C.commitMessage(), copyPath(Patch.MERGE_LIST, l)));
    }
    List<String> paths = new ArrayList<>(m.keySet());
    Collections.sort(paths);
    for (String path : paths) {
        if (!Patch.isMagic(path)) {
            comments.add(new FileComments(clp, psId, path, copyPath(path, m.get(path))));
        }
    }
    commentsPanel.setVisible(comments.getWidgetCount() > 0);
}
Also used : ArrayList(java.util.ArrayList) CommentInfo(com.google.gerrit.client.changes.CommentInfo) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 9 with CommentInfo

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

the class Message method byPath.

private static TreeMap<String, List<CommentInfo>> byPath(List<CommentInfo> list) {
    TreeMap<String, List<CommentInfo>> m = new TreeMap<>();
    for (CommentInfo c : list) {
        List<CommentInfo> l = m.get(c.path());
        if (l == null) {
            l = new ArrayList<>();
            m.put(c.path(), l);
        }
        l.add(c);
    }
    return m;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) CommentInfo(com.google.gerrit.client.changes.CommentInfo) TreeMap(java.util.TreeMap)

Example 10 with CommentInfo

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

the class ChangeScreen method loadConfigInfo.

private void loadConfigInfo(final ChangeInfo info, DiffObject base) {
    final RevisionInfo rev = info.revision(revision);
    if (base.isAutoMerge() && !initCurrentRevision(info).isMerge()) {
        Gerrit.display(getToken(), new NotFoundScreen());
    }
    updateToken(info, base, rev);
    RevisionInfo baseRev = resolveRevisionOrPatchSetId(info, base.asString(), null);
    CallbackGroup group = new CallbackGroup();
    Timestamp lastReply = myLastReply(info);
    if (rev.isEdit()) {
        // Comments are filtered for the current revision. Use parent
        // patch set for edits, as edits themself can never have comments.
        RevisionInfo p = RevisionInfo.findEditParentRevision(info.revisions().values());
        List<NativeMap<JsArray<CommentInfo>>> comments = loadComments(p, group);
        loadFileList(base, baseRev, rev, lastReply, group, comments, null);
    } else {
        loadDiff(base, baseRev, rev, lastReply, group);
    }
    group.addListener(new AsyncCallback<Void>() {

        @Override
        public void onSuccess(Void result) {
            loadConfigInfo(info, rev);
        }

        @Override
        public void onFailure(Throwable caught) {
            logger.log(Level.SEVERE, "Loading file list and inline comments failed: " + caught.getMessage());
            loadConfigInfo(info, rev);
        }
    });
    group.done();
}
Also used : RevisionInfo(com.google.gerrit.client.info.ChangeInfo.RevisionInfo) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup) CommentInfo(com.google.gerrit.client.changes.CommentInfo) NativeMap(com.google.gerrit.client.rpc.NativeMap) Timestamp(java.sql.Timestamp) NotFoundScreen(com.google.gerrit.client.NotFoundScreen)

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