use of com.google.gwt.user.client.rpc.AsyncCallback in project che by eclipse.
the class PushToRemotePresenter method updateRemoteBranches.
/**
* Update list of remote branches on view.
*/
void updateRemoteBranches() {
getBranchesForCurrentProject(LIST_REMOTE, new AsyncCallback<List<Branch>>() {
@Override
public void onSuccess(final List<Branch> result) {
// Need to add the upstream of local branch in the list of remote branches
// to be able to push changes to the remote upstream branch
getUpstreamBranch(new AsyncCallback<Branch>() {
@Override
public void onSuccess(Branch upstream) {
BranchFilterByRemote remoteRefsHandler = new BranchFilterByRemote(view.getRepository());
final List<String> remoteBranches = branchSearcher.getRemoteBranchesToDisplay(remoteRefsHandler, result);
String selectedRemoteBranch = null;
if (upstream != null && upstream.isRemote() && remoteRefsHandler.isLinkedTo(upstream)) {
String simpleUpstreamName = remoteRefsHandler.getBranchNameWithoutRefs(upstream);
if (!remoteBranches.contains(simpleUpstreamName)) {
remoteBranches.add(simpleUpstreamName);
}
selectedRemoteBranch = simpleUpstreamName;
}
// Need to add the current local branch in the list of remote branches
// to be able to push changes to the remote branch with same name
final String currentBranch = view.getLocalBranch();
if (!remoteBranches.contains(currentBranch)) {
remoteBranches.add(currentBranch);
}
if (selectedRemoteBranch == null) {
selectedRemoteBranch = currentBranch;
}
view.setRemoteBranches(remoteBranches);
view.selectRemoteBranch(selectedRemoteBranch);
}
@Override
public void onFailure(Throwable caught) {
GitOutputConsole console = gitOutputConsoleFactory.create(CONFIG_COMMAND_NAME);
console.printError(constant.failedGettingConfig());
processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
notificationManager.notify(constant.failedGettingConfig(), FAIL, FLOAT_MODE);
}
});
}
@Override
public void onFailure(Throwable exception) {
String errorMessage = exception.getMessage() != null ? exception.getMessage() : constant.remoteBranchesListFailed();
GitOutputConsole console = gitOutputConsoleFactory.create(BRANCH_LIST_COMMAND_NAME);
console.printError(errorMessage);
processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
notificationManager.notify(constant.remoteBranchesListFailed(), FAIL, FLOAT_MODE);
view.setEnablePushButton(false);
}
});
}
use of com.google.gwt.user.client.rpc.AsyncCallback in project gwt-test-utils by gwt-test-utils.
the class SchedulerTest method scheduledCommandOrderWithRpcCall.
@Test
public void scheduledCommandOrderWithRpcCall() {
// Given
final StringBuilder sb = new StringBuilder();
final MyRemoteServiceAsync service = GWT.create(MyRemoteService.class);
Scheduler.get().scheduleEntry(new ScheduledCommand() {
public void execute() {
sb.append("scheduleEntry1 ");
}
});
Scheduler.get().scheduleFinally(new ScheduledCommand() {
public void execute() {
sb.append("scheduleFinally1 ");
}
});
service.myMethod("service1", new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
}
public void onSuccess(String result) {
sb.append("onSuccess1 ");
}
});
service.myMethod("service2", new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
}
public void onSuccess(String result) {
sb.append("onSuccess2 ");
}
});
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
sb.append("scheduleDeferred1 ");
service.myMethod("service3", new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
}
public void onSuccess(String result) {
sb.append("onSuccess3 ");
}
});
Scheduler.get().scheduleEntry(new ScheduledCommand() {
public void execute() {
sb.append("scheduleEntry2 ");
Scheduler.get().scheduleEntry(new ScheduledCommand() {
public void execute() {
sb.append("scheduleEntry3 ");
}
});
}
});
Scheduler.get().scheduleFinally(new ScheduledCommand() {
public void execute() {
sb.append("scheduleFinally2 ");
Scheduler.get().scheduleFinally(new ScheduledCommand() {
public void execute() {
sb.append("scheduleFinally3 ");
}
});
}
});
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
sb.append("scheduleDeferred2 ");
}
});
}
});
// When
getBrowserSimulator().fireLoopEnd();
// Then
assertThat(sb.toString()).isEqualTo("scheduleFinally1 scheduleEntry1 scheduleDeferred1 onSuccess1 onSuccess2 scheduleFinally2 scheduleFinally3 scheduleEntry2 scheduleEntry3 scheduleDeferred2 onSuccess3 ");
}
use of com.google.gwt.user.client.rpc.AsyncCallback in project che by eclipse.
the class ProjectImporter method authUserAndRecallImport.
private Promise<Project> authUserAndRecallImport(final String providerName, final String authenticateUrl, final Path path, final SourceStorage sourceStorage, final ProjectNotificationSubscriber subscriber) {
return createFromAsyncRequest(new RequestCall<Project>() {
@Override
public void makeCall(final AsyncCallback<Project> callback) {
OAuth2Authenticator authenticator = oAuth2AuthenticatorRegistry.getAuthenticator(providerName);
if (authenticator == null) {
authenticator = oAuth2AuthenticatorRegistry.getAuthenticator("default");
}
authenticator.authenticate(OAuth2AuthenticatorUrlProvider.get(appContext.getMasterEndpoint(), authenticateUrl), new AsyncCallback<OAuthStatus>() {
@Override
public void onFailure(Throwable caught) {
callback.onFailure(new Exception(caught.getMessage()));
}
@Override
public void onSuccess(OAuthStatus result) {
if (!result.equals(OAuthStatus.NOT_PERFORMED)) {
doImport(path, sourceStorage).then(new Operation<Project>() {
@Override
public void apply(Project project) throws OperationException {
callback.onSuccess(project);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
callback.onFailure(error.getCause());
}
});
} else {
subscriber.onFailure("Authentication cancelled");
callback.onFailure(new IllegalStateException("Authentication cancelled"));
}
}
});
}
});
}
use of com.google.gwt.user.client.rpc.AsyncCallback 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();
}
}));
}
use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.
the class PageController method fetchPages.
private void fetchPages() {
final GetPagesRequest input = ApiHelper.setAccessCode(new GetPagesRequest());
input.pager = pager;
input.session = SessionController.get().sessionForApiCall();
input.includePosts = Boolean.FALSE;
if (getPagesRequest != null) {
getPagesRequest.cancel();
}
getPagesRequest = ApiHelper.createPageClient().getPages(input, new AsyncCallback<GetPagesResponse>() {
@Override
public void onSuccess(GetPagesResponse output) {
getPagesRequest = null;
if (output.status == StatusType.StatusTypeSuccess) {
if (output.pages != null && output.pages.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.pages);
} else {
updateRowCount(input.pager.start.intValue(), true);
updateRowData(input.pager.start.intValue(), Collections.<Page>emptyList());
}
}
DefaultEventBus.get().fireEventFromSource(new GetPagesSuccess(input, output), PageController.this);
}
@Override
public void onFailure(Throwable caught) {
getPagesRequest = null;
DefaultEventBus.get().fireEventFromSource(new GetPagesFailure(input, caught), PageController.this);
}
});
}
Aggregations