Search in sources :

Example 1 with GerritCallback

use of com.google.gerrit.client.rpc.GerritCallback in project gerrit by GerritCodeReview.

the class PatchSetSelectBox method setUpBlame.

void setUpBlame(final CodeMirror cm, final boolean isBase, final PatchSet.Id rev, final String path) {
    if (!Patch.isMagic(path) && Gerrit.isSignedIn() && Gerrit.info().change().allowBlame()) {
        Anchor blameIcon = createBlameIcon();
        blameIcon.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent clickEvent) {
                if (cm.extras().getBlameInfo() != null) {
                    cm.extras().toggleAnnotation();
                } else {
                    ChangeApi.blame(rev, path, isBase).get(new GerritCallback<JsArray<BlameInfo>>() {

                        @Override
                        public void onSuccess(JsArray<BlameInfo> lines) {
                            cm.extras().toggleAnnotation(lines);
                        }
                    });
                }
            }
        });
        linkPanel.add(blameIcon);
    }
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) Anchor(com.google.gwt.user.client.ui.Anchor) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JsArray(com.google.gwt.core.client.JsArray) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) BlameInfo(com.google.gerrit.client.blame.BlameInfo)

Example 2 with GerritCallback

use of com.google.gerrit.client.rpc.GerritCallback 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();
            }
        }));
    }
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup) UiHandler(com.google.gwt.uibinder.client.UiHandler)

Example 3 with GerritCallback

use of com.google.gerrit.client.rpc.GerritCallback in project gerrit by GerritCodeReview.

the class DiffScreen method onLoad.

@Override
protected void onLoad() {
    super.onLoad();
    CallbackGroup group1 = new CallbackGroup();
    final CallbackGroup group2 = new CallbackGroup();
    CodeMirror.initLibrary(group1.add(new AsyncCallback<Void>() {

        final AsyncCallback<Void> themeCallback = group2.addEmpty();

        @Override
        public void onSuccess(Void result) {
            // Load theme after CM library to ensure theme can override CSS.
            ThemeLoader.loadTheme(prefs.theme(), themeCallback);
        }

        @Override
        public void onFailure(Throwable caught) {
        }
    }));
    DiffApi.diff(revision, path).base(base.asPatchSetId()).wholeFile().intraline(prefs.intralineDifference()).ignoreWhitespace(prefs.ignoreWhitespace()).get(group1.addFinal(new GerritCallback<DiffInfo>() {

        final AsyncCallback<Void> modeInjectorCb = group2.addEmpty();

        @Override
        public void onSuccess(DiffInfo diffInfo) {
            diff = diffInfo;
            fileSize = bucketFileSize(diffInfo);
            if (prefs.syntaxHighlighting()) {
                if (fileSize.compareTo(FileSize.SMALL) > 0) {
                    modeInjectorCb.onSuccess(null);
                } else {
                    injectMode(diffInfo, modeInjectorCb);
                }
            } else {
                modeInjectorCb.onSuccess(null);
            }
        }
    }));
    if (Gerrit.isSignedIn()) {
        ChangeApi.edit(changeId.get(), group2.add(new AsyncCallback<EditInfo>() {

            @Override
            public void onSuccess(EditInfo result) {
                edit = result;
            }

            @Override
            public void onFailure(Throwable caught) {
            }
        }));
    }
    final CommentsCollections comments = new CommentsCollections(base, revision, path);
    comments.load(group2);
    countParents(group2);
    RestApi call = ChangeApi.detail(changeId.get());
    ChangeList.addOptions(call, EnumSet.of(ListChangesOption.ALL_REVISIONS));
    call.get(group2.add(new AsyncCallback<ChangeInfo>() {

        @Override
        public void onSuccess(ChangeInfo info) {
            changeStatus = info.status();
            info.revisions().copyKeysIntoChildren("name");
            if (edit != null) {
                edit.setName(edit.commit().commit());
                info.setEdit(edit);
                info.revisions().put(edit.name(), RevisionInfo.fromEdit(edit));
            }
            String currentRevision = info.currentRevision();
            boolean current = currentRevision != null && revision.get() == info.revision(currentRevision)._number();
            JsArray<RevisionInfo> list = info.revisions().values();
            RevisionInfo.sortRevisionInfoByNumber(list);
            getDiffTable().set(prefs, list, parents, diff, edit != null, current, changeStatus.isOpen(), diff.binary());
            header.setChangeInfo(info);
        }

        @Override
        public void onFailure(Throwable caught) {
        }
    }));
    ConfigInfoCache.get(changeId, group2.addFinal(getScreenLoadCallback(comments)));
}
Also used : RestApi(com.google.gerrit.client.rpc.RestApi) ChangeInfo(com.google.gerrit.client.info.ChangeInfo) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup) EditInfo(com.google.gerrit.client.info.ChangeInfo.EditInfo) GerritCallback(com.google.gerrit.client.rpc.GerritCallback) RevisionInfo(com.google.gerrit.client.info.ChangeInfo.RevisionInfo)

Example 4 with GerritCallback

use of com.google.gerrit.client.rpc.GerritCallback 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)

Example 5 with GerritCallback

use of com.google.gerrit.client.rpc.GerritCallback in project gerrit by GerritCodeReview.

the class Dispatcher method admin.

private static void admin(String token) {
    GWT.runAsync(new AsyncSplit(token) {

        @Override
        public void onSuccess() {
            if (matchExact(ADMIN_GROUPS, token) || matchExact("/admin/groups", token)) {
                Gerrit.display(token, new GroupListScreen());
            } else if (matchPrefix(ADMIN_GROUPS, token)) {
                String rest = skip(token);
                if (rest.startsWith("?")) {
                    Gerrit.display(token, new GroupListScreen(rest.substring(1)));
                } else {
                    group();
                }
            } else if (matchPrefix("/admin/groups", token)) {
                String rest = skip(token);
                if (rest.startsWith("?")) {
                    Gerrit.display(token, new GroupListScreen(rest.substring(1)));
                }
            } else if (matchExact(ADMIN_PROJECTS, token) || matchExact("/admin/projects", token)) {
                Gerrit.display(token, new ProjectListScreen());
            } else if (matchPrefix(ADMIN_PROJECTS, token)) {
                String rest = skip(token);
                if (rest.startsWith("?")) {
                    Gerrit.display(token, new ProjectListScreen(rest.substring(1)));
                } else {
                    Gerrit.display(token, selectProject());
                }
            } else if (matchPrefix("/admin/projects", token)) {
                String rest = skip(token);
                if (rest.startsWith("?")) {
                    Gerrit.display(token, new ProjectListScreen(rest.substring(1)));
                }
            } else if (matchPrefix(ADMIN_PLUGINS, token) || matchExact("/admin/plugins", token)) {
                Gerrit.display(token, new PluginListScreen());
            } else if (matchExact(ADMIN_CREATE_PROJECT, token) || matchExact("/admin/create-project", token)) {
                Gerrit.display(token, new CreateProjectScreen());
            } else if (matchExact(ADMIN_CREATE_GROUP, token) || matchExact("/admin/create-group", token)) {
                Gerrit.display(token, new CreateGroupScreen());
            } else {
                Gerrit.display(token, new NotFoundScreen());
            }
        }

        private void group() {
            final String panel;
            final String group;
            if (matchPrefix("/admin/groups/uuid-", token)) {
                String p = skip(token);
                int c = p.indexOf(',');
                if (c < 0) {
                    group = p;
                    panel = null;
                } else {
                    group = p.substring(0, c);
                    panel = p.substring(c + 1);
                }
            } else if (matchPrefix(ADMIN_GROUPS, token)) {
                String p = skip(token);
                int c = p.indexOf(',');
                if (c < 0) {
                    group = p;
                    panel = null;
                } else {
                    group = p.substring(0, c);
                    panel = p.substring(c + 1);
                }
            } else {
                Gerrit.display(token, new NotFoundScreen());
                return;
            }
            GroupApi.getGroupDetail(group, new GerritCallback<GroupInfo>() {

                @Override
                public void onSuccess(GroupInfo group) {
                    if (panel == null || panel.isEmpty()) {
                        //
                        if (AccountGroup.isInternalGroup(group.getGroupUUID())) {
                            String newToken = toGroup(group.getGroupId(), AccountGroupScreen.MEMBERS);
                            Gerrit.display(newToken, new AccountGroupMembersScreen(group, newToken));
                        } else {
                            String newToken = toGroup(group.getGroupId(), AccountGroupScreen.INFO);
                            Gerrit.display(newToken, new AccountGroupInfoScreen(group, newToken));
                        }
                    } else if (AccountGroupScreen.INFO.equals(panel)) {
                        Gerrit.display(token, new AccountGroupInfoScreen(group, token));
                    } else if (AccountGroupScreen.MEMBERS.equals(panel)) {
                        Gerrit.display(token, new AccountGroupMembersScreen(group, token));
                    } else if (AccountGroupScreen.AUDIT_LOG.equals(panel)) {
                        Gerrit.display(token, new AccountGroupAuditLogScreen(group, token));
                    } else {
                        Gerrit.display(token, new NotFoundScreen());
                    }
                }
            });
        }

        private Screen selectProject() {
            if (matchPrefix(ADMIN_PROJECTS, token)) {
                String rest = skip(token);
                int c = rest.lastIndexOf(',');
                if (c < 0) {
                    return new ProjectInfoScreen(Project.NameKey.parse(rest));
                } else if (c == 0) {
                    return new NotFoundScreen();
                }
                int q = rest.lastIndexOf('?');
                if (q > 0 && rest.lastIndexOf(',', q) > 0) {
                    c = rest.substring(0, q - 1).lastIndexOf(',');
                }
                Project.NameKey k = Project.NameKey.parse(rest.substring(0, c));
                String panel = rest.substring(c + 1);
                if (ProjectScreen.INFO.equals(panel)) {
                    return new ProjectInfoScreen(k);
                }
                if (ProjectScreen.BRANCHES.equals(panel) || matchPrefix(ProjectScreen.BRANCHES, panel)) {
                    return new ProjectBranchesScreen(k);
                }
                if (ProjectScreen.TAGS.equals(panel) || matchPrefix(ProjectScreen.TAGS, panel)) {
                    return new ProjectTagsScreen(k);
                }
                if (ProjectScreen.ACCESS.equals(panel)) {
                    return new ProjectAccessScreen(k);
                }
                if (ProjectScreen.DASHBOARDS.equals(panel)) {
                    return new ProjectDashboardsScreen(k);
                }
            }
            return new NotFoundScreen();
        }
    });
}
Also used : ProjectTagsScreen(com.google.gerrit.client.admin.ProjectTagsScreen) ProjectAccessScreen(com.google.gerrit.client.admin.ProjectAccessScreen) AccountGroupMembersScreen(com.google.gerrit.client.admin.AccountGroupMembersScreen) AccountGroupInfoScreen(com.google.gerrit.client.admin.AccountGroupInfoScreen) ProjectInfoScreen(com.google.gerrit.client.admin.ProjectInfoScreen) GroupInfo(com.google.gerrit.client.info.GroupInfo) ProjectDashboardsScreen(com.google.gerrit.client.admin.ProjectDashboardsScreen) EditScreen(com.google.gerrit.client.editor.EditScreen) AccountGroupAuditLogScreen(com.google.gerrit.client.admin.AccountGroupAuditLogScreen) ProjectScreen(com.google.gerrit.client.admin.ProjectScreen) MyWatchedProjectsScreen(com.google.gerrit.client.account.MyWatchedProjectsScreen) MyEditPreferencesScreen(com.google.gerrit.client.account.MyEditPreferencesScreen) MyGroupsScreen(com.google.gerrit.client.account.MyGroupsScreen) MyProfileScreen(com.google.gerrit.client.account.MyProfileScreen) ProjectDashboardsScreen(com.google.gerrit.client.admin.ProjectDashboardsScreen) NewAgreementScreen(com.google.gerrit.client.account.NewAgreementScreen) CreateGroupScreen(com.google.gerrit.client.admin.CreateGroupScreen) MyContactInformationScreen(com.google.gerrit.client.account.MyContactInformationScreen) MyPasswordScreen(com.google.gerrit.client.account.MyPasswordScreen) ProjectInfoScreen(com.google.gerrit.client.admin.ProjectInfoScreen) MyOAuthTokenScreen(com.google.gerrit.client.account.MyOAuthTokenScreen) MyPreferencesScreen(com.google.gerrit.client.account.MyPreferencesScreen) MyAgreementsScreen(com.google.gerrit.client.account.MyAgreementsScreen) Screen(com.google.gerrit.client.ui.Screen) ProjectDashboardScreen(com.google.gerrit.client.changes.ProjectDashboardScreen) ExtensionSettingsScreen(com.google.gerrit.client.api.ExtensionSettingsScreen) ValidateEmailScreen(com.google.gerrit.client.account.ValidateEmailScreen) ProjectBranchesScreen(com.google.gerrit.client.admin.ProjectBranchesScreen) AccountGroupScreen(com.google.gerrit.client.admin.AccountGroupScreen) CustomDashboardScreen(com.google.gerrit.client.changes.CustomDashboardScreen) AccountDashboardScreen(com.google.gerrit.client.changes.AccountDashboardScreen) PluginListScreen(com.google.gerrit.client.admin.PluginListScreen) AccountGroupInfoScreen(com.google.gerrit.client.admin.AccountGroupInfoScreen) MyIdentitiesScreen(com.google.gerrit.client.account.MyIdentitiesScreen) QueryScreen(com.google.gerrit.client.changes.QueryScreen) ExtensionScreen(com.google.gerrit.client.api.ExtensionScreen) MyDiffPreferencesScreen(com.google.gerrit.client.account.MyDiffPreferencesScreen) RegisterScreen(com.google.gerrit.client.account.RegisterScreen) MySshKeysScreen(com.google.gerrit.client.account.MySshKeysScreen) ProjectListScreen(com.google.gerrit.client.admin.ProjectListScreen) DocScreen(com.google.gerrit.client.documentation.DocScreen) CreateProjectScreen(com.google.gerrit.client.admin.CreateProjectScreen) GroupListScreen(com.google.gerrit.client.admin.GroupListScreen) MyGpgKeysScreen(com.google.gerrit.client.account.MyGpgKeysScreen) ProjectTagsScreen(com.google.gerrit.client.admin.ProjectTagsScreen) AccountGroupMembersScreen(com.google.gerrit.client.admin.AccountGroupMembersScreen) ProjectAccessScreen(com.google.gerrit.client.admin.ProjectAccessScreen) ChangeScreen(com.google.gerrit.client.change.ChangeScreen) ProjectBranchesScreen(com.google.gerrit.client.admin.ProjectBranchesScreen) ProjectListScreen(com.google.gerrit.client.admin.ProjectListScreen) AccountGroupAuditLogScreen(com.google.gerrit.client.admin.AccountGroupAuditLogScreen) GerritCallback(com.google.gerrit.client.rpc.GerritCallback) GroupListScreen(com.google.gerrit.client.admin.GroupListScreen) CreateGroupScreen(com.google.gerrit.client.admin.CreateGroupScreen) PluginListScreen(com.google.gerrit.client.admin.PluginListScreen) CreateProjectScreen(com.google.gerrit.client.admin.CreateProjectScreen)

Aggregations

GerritCallback (com.google.gerrit.client.rpc.GerritCallback)25 CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)8 ChangeInfo (com.google.gerrit.client.info.ChangeInfo)7 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)7 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)7 Button (com.google.gwt.user.client.ui.Button)5 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)5 JsArray (com.google.gwt.core.client.JsArray)4 VoidResult (com.google.gerrit.client.VoidResult)3 NativeString (com.google.gerrit.client.rpc.NativeString)3 SmallHeading (com.google.gerrit.client.ui.SmallHeading)3 PopupPanel (com.google.gwt.user.client.ui.PopupPanel)3 ChangeScreen (com.google.gerrit.client.change.ChangeScreen)2 ProjectDashboardScreen (com.google.gerrit.client.changes.ProjectDashboardScreen)2 AccountInfo (com.google.gerrit.client.info.AccountInfo)2 GroupInfo (com.google.gerrit.client.info.GroupInfo)2 NpTextBox (com.google.gwtexpui.globalkey.client.NpTextBox)2 ErrorDialog (com.google.gerrit.client.ErrorDialog)1 ProjectAccessInfo (com.google.gerrit.client.access.ProjectAccessInfo)1 EditPreferences (com.google.gerrit.client.account.EditPreferences)1