Search in sources :

Example 1 with ChangeScreen

use of com.google.gerrit.client.change.ChangeScreen in project gerrit by GerritCodeReview.

the class Dispatcher method change.

private static void change(final String token) {
    String rest = skip(token);
    int c = rest.lastIndexOf(',');
    String panel = null;
    if (0 <= c) {
        panel = rest.substring(c + 1);
        rest = rest.substring(0, c);
        int at = panel.lastIndexOf('@');
        if (at > 0) {
            rest += panel.substring(at);
            panel = panel.substring(0, at);
        }
    }
    Change.Id id;
    int s = rest.indexOf('/');
    if (0 <= s) {
        id = Change.Id.parse(rest.substring(0, s));
        rest = rest.substring(s + 1);
    } else {
        id = Change.Id.parse(rest);
        rest = "";
    }
    if (rest.isEmpty()) {
        FileTable.Mode mode = FileTable.Mode.REVIEW;
        if (panel != null && (panel.equals("edit") || panel.startsWith("edit/"))) {
            mode = FileTable.Mode.EDIT;
            panel = null;
        }
        Gerrit.display(token, panel == null ? new ChangeScreen(id, DiffObject.base(), null, false, mode) : new NotFoundScreen());
        return;
    }
    String psIdStr;
    s = rest.indexOf('/');
    if (0 <= s) {
        psIdStr = rest.substring(0, s);
        rest = rest.substring(s + 1);
    } else {
        psIdStr = rest;
        rest = "";
    }
    DiffObject base = DiffObject.base();
    PatchSet.Id ps;
    int dotdot = psIdStr.indexOf("..");
    if (1 <= dotdot) {
        base = DiffObject.parse(id, psIdStr.substring(0, dotdot));
        if (base == null) {
            Gerrit.display(token, new NotFoundScreen());
        }
        psIdStr = psIdStr.substring(dotdot + 2);
    }
    ps = toPsId(id, psIdStr);
    if (!rest.isEmpty()) {
        DisplaySide side = DisplaySide.B;
        int line = 0;
        int at = rest.lastIndexOf('@');
        if (at > 0) {
            String l = rest.substring(at + 1);
            if (l.startsWith("a")) {
                side = DisplaySide.A;
                l = l.substring(1);
            }
            line = Integer.parseInt(l);
            rest = rest.substring(0, at);
        }
        Patch.Key p = new Patch.Key(ps, KeyUtil.decode(rest));
        patch(token, base, p, side, line, panel);
    } else {
        if (panel == null) {
            Gerrit.display(token, new ChangeScreen(id, base, String.valueOf(ps.get()), false, FileTable.Mode.REVIEW));
        } else {
            Gerrit.display(token, new NotFoundScreen());
        }
    }
}
Also used : ChangeScreen(com.google.gerrit.client.change.ChangeScreen) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) Change(com.google.gerrit.reviewdb.client.Change) FileTable(com.google.gerrit.client.change.FileTable) DisplaySide(com.google.gerrit.client.diff.DisplaySide) Patch(com.google.gerrit.reviewdb.client.Patch)

Example 2 with ChangeScreen

use of com.google.gerrit.client.change.ChangeScreen in project gerrit by GerritCodeReview.

the class DiffScreen method upToChange.

private Runnable upToChange(boolean openReplyBox) {
    return () -> {
        CallbackGroup group = new CallbackGroup();
        getCommentManager().saveAllDrafts(group);
        group.done();
        group.addListener(new GerritCallback<Void>() {

            @Override
            public void onSuccess(Void result) {
                String rev = String.valueOf(revision.get());
                Gerrit.display(PageLinks.toChange(changeId, base.asString(), rev), new ChangeScreen(changeId, base, rev, openReplyBox, FileTable.Mode.REVIEW));
            }
        });
    };
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) ChangeScreen(com.google.gerrit.client.change.ChangeScreen) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup)

Aggregations

ChangeScreen (com.google.gerrit.client.change.ChangeScreen)2 FileTable (com.google.gerrit.client.change.FileTable)1 DisplaySide (com.google.gerrit.client.diff.DisplaySide)1 CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)1 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)1 Change (com.google.gerrit.reviewdb.client.Change)1 Patch (com.google.gerrit.reviewdb.client.Patch)1 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)1