Search in sources :

Example 36 with JsArray

use of com.google.gwt.core.client.JsArray in project gerrit by GerritCodeReview.

the class MyWatchesTable method addNotifyButton.

protected void addNotifyButton(final ProjectWatchInfo.Type type, final ProjectWatchInfo info, final int row, final int col) {
    final CheckBox cbox = new CheckBox();
    cbox.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            final Boolean oldVal = info.notify(type);
            info.notify(type, cbox.getValue());
            cbox.setEnabled(false);
            AccountApi.updateWatchedProject("self", info, new GerritCallback<JsArray<ProjectWatchInfo>>() {

                @Override
                public void onSuccess(JsArray<ProjectWatchInfo> watchedProjects) {
                    cbox.setEnabled(true);
                }

                @Override
                public void onFailure(Throwable caught) {
                    cbox.setEnabled(true);
                    info.notify(type, oldVal);
                    cbox.setValue(oldVal);
                    super.onFailure(caught);
                }
            });
        }
    });
    cbox.setValue(info.notify(type));
    table.setWidget(row, col, cbox);
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JsArray(com.google.gwt.core.client.JsArray) CheckBox(com.google.gwt.user.client.ui.CheckBox) ClickEvent(com.google.gwt.event.dom.client.ClickEvent)

Example 37 with JsArray

use of com.google.gwt.core.client.JsArray in project gerrit by GerritCodeReview.

the class ChangeScreen method onLoad.

@Override
protected void onLoad() {
    super.onLoad();
    CallbackGroup group = new CallbackGroup();
    if (Gerrit.isSignedIn()) {
        ChangeList.query("change:" + changeId.get() + " has:draft", Collections.<ListChangesOption>emptySet(), group.add(new AsyncCallback<ChangeList>() {

            @Override
            public void onSuccess(ChangeList result) {
                hasDraftComments = result.length() > 0;
            }

            @Override
            public void onFailure(Throwable caught) {
            }
        }));
        ChangeApi.editWithFiles(changeId.get(), group.add(new AsyncCallback<EditInfo>() {

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

            @Override
            public void onFailure(Throwable caught) {
            }
        }));
    }
    loadChangeInfo(true, group.addFinal(new GerritCallback<ChangeInfo>() {

        @Override
        public void onSuccess(final ChangeInfo info) {
            info.init();
            initCurrentRevision(info);
            final RevisionInfo rev = info.revision(revision);
            CallbackGroup group = new CallbackGroup();
            loadCommit(rev, group);
            group.addListener(new GerritCallback<Void>() {

                @Override
                public void onSuccess(Void result) {
                    if (base.isBase() && rev.isMerge()) {
                        base = DiffObject.parse(info.legacyId(), Gerrit.getUserPreferences().defaultBaseForMerges().getBase());
                    }
                    loadConfigInfo(info, base);
                    JsArray<MessageInfo> mAr = info.messages();
                    for (int i = 0; i < mAr.length(); i++) {
                        if (mAr.get(i).tag() != null) {
                            hideTaggedComments.setVisible(true);
                            break;
                        }
                    }
                }
            });
            group.done();
        }
    }));
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) JsArray(com.google.gwt.core.client.JsArray) ChangeInfo(com.google.gerrit.client.info.ChangeInfo) RevisionInfo(com.google.gerrit.client.info.ChangeInfo.RevisionInfo) ChangeList(com.google.gerrit.client.changes.ChangeList) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup) EditInfo(com.google.gerrit.client.info.ChangeInfo.EditInfo)

Example 38 with JsArray

use of com.google.gwt.core.client.JsArray 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 39 with JsArray

use of com.google.gwt.core.client.JsArray in project gerrit by GerritCodeReview.

the class ChangeScreen method filterForRevision.

private static NativeMap<JsArray<CommentInfo>> filterForRevision(NativeMap<JsArray<CommentInfo>> comments, int id) {
    NativeMap<JsArray<CommentInfo>> filtered = NativeMap.create();
    for (String k : comments.keySet()) {
        JsArray<CommentInfo> allRevisions = comments.get(k);
        JsArray<CommentInfo> thisRevision = JsArray.createArray().cast();
        for (int i = 0; i < allRevisions.length(); i++) {
            CommentInfo c = allRevisions.get(i);
            if (c.patchSet() == id) {
                thisRevision.push(c);
            }
        }
        filtered.put(k, thisRevision);
    }
    return filtered;
}
Also used : JsArray(com.google.gwt.core.client.JsArray) JsArrayString(com.google.gwt.core.client.JsArrayString) CommentInfo(com.google.gerrit.client.changes.CommentInfo) GerritUiExtensionPoint(com.google.gerrit.client.GerritUiExtensionPoint)

Aggregations

JsArray (com.google.gwt.core.client.JsArray)39 ArrayList (java.util.ArrayList)14 ServerError (org.rstudio.studio.client.server.ServerError)12 JsArrayString (com.google.gwt.core.client.JsArrayString)7 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)6 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)6 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)6 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)5 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)4 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)4 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)4 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)4 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)4 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)4 HTML (com.google.gwt.user.client.ui.HTML)3 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)3 CommentInfo (com.google.gerrit.client.changes.CommentInfo)2 CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)2 NativeString (com.google.gerrit.client.rpc.NativeString)2 Context (com.google.gwt.cell.client.Cell.Context)2