Search in sources :

Example 1 with NativeMap

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

the class ProjectAccessScreen method onLoad.

@Override
protected void onLoad() {
    super.onLoad();
    CallbackGroup cbs = new CallbackGroup();
    ConfigServerApi.capabilities(cbs.add(new AsyncCallback<NativeMap<CapabilityInfo>>() {

        @Override
        public void onSuccess(NativeMap<CapabilityInfo> result) {
            capabilityMap = result;
        }

        @Override
        public void onFailure(Throwable caught) {
        // Handled by ScreenLoadCallback.onFailure().
        }
    }));
    Util.PROJECT_SVC.projectAccess(getProjectKey(), cbs.addFinal(new ScreenLoadCallback<ProjectAccess>(this) {

        @Override
        public void preDisplay(ProjectAccess access) {
            displayReadOnly(access);
        }
    }));
    savedPanel = ACCESS;
}
Also used : AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup) ScreenLoadCallback(com.google.gerrit.client.rpc.ScreenLoadCallback) NativeMap(com.google.gerrit.client.rpc.NativeMap) CapabilityInfo(com.google.gerrit.client.config.CapabilityInfo) ProjectAccess(com.google.gerrit.common.data.ProjectAccess)

Example 2 with NativeMap

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

the class ChangeScreen method loadRevisionInfo.

void loadRevisionInfo() {
    RestApi call = ChangeApi.actions(changeId.get(), revision);
    call.background();
    call.get(new GerritCallback<NativeMap<ActionInfo>>() {

        @Override
        public void onSuccess(NativeMap<ActionInfo> actionMap) {
            actionMap.copyKeysIntoChildren("id");
            renderRevisionInfo(changeInfo, actionMap);
        }
    });
}
Also used : RestApi(com.google.gerrit.client.rpc.RestApi) ActionInfo(com.google.gerrit.client.info.ActionInfo) NativeMap(com.google.gerrit.client.rpc.NativeMap)

Example 3 with NativeMap

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

the class GroupSuggestOracle method requestSuggestions.

@Override
public void requestSuggestions(final Request req, final Callback done) {
    if (req.getQuery().length() < chars) {
        responseEmptySuggestion(req, done);
        return;
    }
    RestApi rest = new RestApi("/groups/").addParameter("suggest", req.getQuery());
    if (req.getLimit() > 0) {
        rest.addParameter("n", req.getLimit());
    }
    rest.get(new AsyncCallback<NativeMap<JavaScriptObject>>() {

        @Override
        public void onSuccess(NativeMap<JavaScriptObject> result) {
            List<String> keys = result.sortedKeys();
            List<Suggestion> suggestions = new ArrayList<>(keys.size());
            for (String g : keys) {
                suggestions.add(new HighlightSuggestion(req.getQuery(), g));
            }
            done.onSuggestionsReady(req, new Response(suggestions));
        }

        @Override
        public void onFailure(Throwable caught) {
            responseEmptySuggestion(req, done);
        }
    });
}
Also used : RestApi(com.google.gerrit.plugin.client.rpc.RestApi) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) HighlightSuggestion(com.google.gerrit.client.ui.HighlightSuggestion) List(java.util.List) ArrayList(java.util.ArrayList) NativeMap(com.google.gerrit.client.rpc.NativeMap)

Example 4 with NativeMap

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

Example 5 with NativeMap

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

the class MyGpgKeysScreen method refreshKeys.

private void refreshKeys() {
    AccountApi.self().view("gpgkeys").get(NativeMap.copyKeysIntoChildren("id", new GerritCallback<NativeMap<GpgKeyInfo>>() {

        @Override
        public void onSuccess(NativeMap<GpgKeyInfo> result) {
            List<GpgKeyInfo> list = Natives.asList(result.values());
            // TODO(dborowitz): Sort on something more meaningful, like
            // created date?
            Collections.sort(list, new Comparator<GpgKeyInfo>() {

                @Override
                public int compare(GpgKeyInfo a, GpgKeyInfo b) {
                    return a.id().compareTo(b.id());
                }
            });
            keys.clear();
            keyText.setText("");
            errorPanel.setVisible(false);
            addButton.setEnabled(true);
            if (!list.isEmpty()) {
                keys.setVisible(true);
                for (GpgKeyInfo k : list) {
                    keys.addOneKey(k);
                }
                showKeyTable(true);
                showAddKeyBlock(false);
            } else {
                keys.setVisible(false);
                showAddKeyBlock(true);
                showKeyTable(false);
            }
            display();
        }
    }));
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) NativeMap(com.google.gerrit.client.rpc.NativeMap) GpgKeyInfo(com.google.gerrit.client.info.GpgKeyInfo)

Aggregations

NativeMap (com.google.gerrit.client.rpc.NativeMap)6 CommentInfo (com.google.gerrit.client.changes.CommentInfo)2 CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)2 NotFoundScreen (com.google.gerrit.client.NotFoundScreen)1 CapabilityInfo (com.google.gerrit.client.config.CapabilityInfo)1 ActionInfo (com.google.gerrit.client.info.ActionInfo)1 RevisionInfo (com.google.gerrit.client.info.ChangeInfo.RevisionInfo)1 GpgKeyInfo (com.google.gerrit.client.info.GpgKeyInfo)1 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)1 RestApi (com.google.gerrit.client.rpc.RestApi)1 ScreenLoadCallback (com.google.gerrit.client.rpc.ScreenLoadCallback)1 HighlightSuggestion (com.google.gerrit.client.ui.HighlightSuggestion)1 ProjectAccess (com.google.gerrit.common.data.ProjectAccess)1 RestApi (com.google.gerrit.plugin.client.rpc.RestApi)1 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 JsArray (com.google.gwt.core.client.JsArray)1 JsArrayString (com.google.gwt.core.client.JsArrayString)1 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)1 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1