Search in sources :

Example 6 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback 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 7 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project gerrit by GerritCodeReview.

the class StarredChanges method startRequest.

private static void startRequest() {
    busy = true;
    final Change.Id id = pending.keySet().iterator().next();
    final boolean starred = pending.remove(id);
    RestApi call = AccountApi.self().view("starred.changes").id(id.get());
    AsyncCallback<JavaScriptObject> cb = new AsyncCallback<JavaScriptObject>() {

        @Override
        public void onSuccess(JavaScriptObject none) {
            if (pending.isEmpty()) {
                busy = false;
            } else {
                startRequest();
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            if (!starred && RestApi.isStatus(caught, 404)) {
                onSuccess(null);
                return;
            }
            fireChangeStarEvent(id, !starred);
            for (Map.Entry<Change.Id, Boolean> e : pending.entrySet()) {
                fireChangeStarEvent(e.getKey(), !e.getValue());
            }
            pending.clear();
            busy = false;
        }
    };
    if (starred) {
        call.put(cb);
    } else {
        call.delete(cb);
    }
}
Also used : RestApi(com.google.gerrit.client.rpc.RestApi) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) Change(com.google.gerrit.reviewdb.client.Change) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 8 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project gerrit by GerritCodeReview.

the class Loader method initLibrary.

static void initLibrary(final AsyncCallback<Void> cb) {
    if (isLibLoaded()) {
        cb.onSuccess(null);
        return;
    }
    CallbackGroup group = new CallbackGroup();
    injectCss(Lib.I.css(), group.<Void>addEmpty());
    injectScript(Lib.I.js().getSafeUri(), group.add(new AsyncCallback<Void>() {

        @Override
        public void onSuccess(Void result) {
            Vim.initKeyMap();
        }

        @Override
        public void onFailure(Throwable caught) {
        }
    }));
    group.addListener(cb);
    group.done();
}
Also used : AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup)

Example 9 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project gwt-test-utils by gwt-test-utils.

the class MyBeautifulApp method onModuleLoad.

public void onModuleLoad() {
    FlowPanel panel = new FlowPanel();
    b1 = new Button("Button1's HTML");
    b1.getElement().setId("button-1");
    panel.add(b1);
    b2 = new Button("Button2's HTML");
    b2.getElement().setId("button-2");
    panel.add(b2);
    l = new Label();
    l.setText("init");
    panel.add(l);
    t = new TextBox();
    panel.add(t);
    historyLabel = new Label();
    panel.add(historyLabel);
    invisibleTB = new TextBox();
    invisibleTB.setVisible(false);
    panel.add(invisibleTB);
    lb = new ListBox();
    lb.addItem("lbText0");
    lb.addItem("lbText1");
    lb.addItem("lbText2");
    panel.add(lb);
    RootPanel.get().add(panel);
    b1.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            l.setText("click on b1");
        }
    });
    b2.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            l.setText("click on b2");
        }
    });
    b3 = new Button("Button3's HTML");
    panel.add(b3);
    b3.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            MyRemoteServiceAsync remoteServiceAsync = GWT.create(MyRemoteService.class);
            remoteServiceAsync.myMethod(l.getText(), new AsyncCallback<String>() {

                public void onFailure(Throwable arg0) {
                    l.setText("error");
                }

                public void onSuccess(String arg0) {
                    l.setText(arg0);
                }
            });
        }
    });
    b4 = new Button("Button4's HTML");
    panel.add(b4);
    b4.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            MyRemoteServiceAsync remoteServiceAsync = GWT.create(MyRemoteService.class);
            remoteServiceAsync.myMethod2(new MyCustomObject("toto"), new AsyncCallback<MyCustomObject>() {

                public void onFailure(Throwable t) {
                    throw new RuntimeException(t);
                }

                public void onSuccess(MyCustomObject object) {
                    l.setText(object.myField + " " + object.myTransientField);
                }
            });
        }
    });
    b5 = new Button("Button5's HTML");
    panel.add(b5);
    b5.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            MyRemoteServiceAsync remoteServiceAsync = GWT.create(MyRemoteService.class);
            remoteServiceAsync.myMethod3(new AsyncCallback<Void>() {

                public void onFailure(Throwable arg0) {
                    l.setText("error");
                }

                public void onSuccess(Void arg0) {
                    l.setText("success");
                }
            });
        }
    });
    t.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            historyLabel.setText("t was filled with value \"" + t.getText() + "\"");
        }
    });
    invisibleTB.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            historyLabel.setText("invisibleTB was filled with value \"" + invisibleTB.getText() + "\"");
        }
    });
    myComposite = new MyComposite("myComposite Label", "MyComposite Button");
    panel.add(myComposite);
}
Also used : ClickEvent(com.google.gwt.event.dom.client.ClickEvent) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler)

Example 10 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.

the class GeneratedDownloadController method fetchGeneratedDownloads.

private void fetchGeneratedDownloads() {
    final GetGeneratedDownloadsRequest input = ApiHelper.setAccessCode(new GetGeneratedDownloadsRequest()).pager(pager);
    input.session(SessionController.get().sessionForApiCall());
    if (getGeneratedDownloadsRequest != null) {
        getGeneratedDownloadsRequest.cancel();
    }
    getGeneratedDownloadsRequest = ApiHelper.createDownloadClient().getGeneratedDownloads(input, new AsyncCallback<GetGeneratedDownloadsResponse>() {

        @Override
        public void onSuccess(GetGeneratedDownloadsResponse output) {
            getGeneratedDownloadsRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
                if (output.downloads != null && output.downloads.size() > 0) {
                    pager = output.pager;
                    updateRowCount(input.pager.count == null ? 0 : input.pager.count.intValue(), input.pager.count == null || input.pager.count.intValue() == 0);
                    updateRowData(input.pager.start.intValue(), output.downloads);
                } else {
                    updateRowCount(input.pager.start.intValue(), true);
                    updateRowData(input.pager.start.intValue(), Collections.<GeneratedDownload>emptyList());
                }
            }
            DefaultEventBus.get().fireEventFromSource(new GetGeneratedDownloadsSuccess(input, output), GeneratedDownloadController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            getGeneratedDownloadsRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetGeneratedDownloadsFailure(input, caught), GeneratedDownloadController.this);
        }
    });
}
Also used : GetGeneratedDownloadsResponse(com.willshex.blogwt.shared.api.download.call.GetGeneratedDownloadsResponse) GetGeneratedDownloadsSuccess(com.willshex.blogwt.client.api.download.event.GetGeneratedDownloadsEventHandler.GetGeneratedDownloadsSuccess) GetGeneratedDownloadsFailure(com.willshex.blogwt.client.api.download.event.GetGeneratedDownloadsEventHandler.GetGeneratedDownloadsFailure) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetGeneratedDownloadsRequest(com.willshex.blogwt.shared.api.download.call.GetGeneratedDownloadsRequest)

Aggregations

AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)64 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)8 Test (org.junit.Test)7 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)6 FormDialogCallback (org.activityinfo.ui.client.page.common.dialog.FormDialogCallback)6 CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)5 ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)4 FormDialogTether (org.activityinfo.ui.client.page.common.dialog.FormDialogTether)4 ChangeInfo (com.google.gerrit.client.info.ChangeInfo)3 Date (java.util.Date)3 GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)3 VoidResult (org.activityinfo.legacy.shared.command.result.VoidResult)3 MaskingAsyncMonitor (org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor)3 FormDialogImpl (org.activityinfo.ui.client.page.common.dialog.FormDialogImpl)3 Operation (org.eclipse.che.api.promises.client.Operation)3 OperationException (org.eclipse.che.api.promises.client.OperationException)3 PromiseError (org.eclipse.che.api.promises.client.PromiseError)3 Path (org.eclipse.che.ide.resource.Path)3 EditInfo (com.google.gerrit.client.info.ChangeInfo.EditInfo)2 RevisionInfo (com.google.gerrit.client.info.ChangeInfo.RevisionInfo)2