Java Code Examples for com.google.gwt.core.client.Callback#onSuccess()

The following examples show how to use com.google.gwt.core.client.Callback#onSuccess() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SearchDataSource.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private void basicFetch(Criteria criteria, final Callback<ResultSet, Void> callback) {
        final ResultSet resultSet = new ResultSet(this);
        resultSet.setCriteria(criteria);
        resultSet.setFetchMode(FetchMode.BASIC);
//        resultSet.setCriteriaPolicy(CriteriaPolicy.DROPONCHANGE);
        // server resource returns full result in case of SearchType.PIDS query
        if (resultSet.lengthIsKnown()) {
            callback.onSuccess(resultSet);
        } else {
            final HandlerRegistration[] handler = new HandlerRegistration[1];
            handler[0] = resultSet.addDataArrivedHandler(new DataArrivedHandler() {

                @Override
                public void onDataArrived(DataArrivedEvent event) {
                    handler[0].removeHandler();
                    callback.onSuccess(resultSet);
                }
            });
            resultSet.get(0);
        }
    }
 
Example 2
Source File: MetaModelDataSource.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
public static void getModels(boolean reload, final Callback<ResultSet, Void> callback) {
    final ResultSet models = getModels(reload);
    if (models.lengthIsKnown()) {
        callback.onSuccess(models);
    } else {
        final HandlerRegistration[] handler = new HandlerRegistration[1];
        handler[0] = models.addDataArrivedHandler(new DataArrivedHandler() {

            @Override
            public void onDataArrived(DataArrivedEvent event) {
                handler[0].removeHandler();
                callback.onSuccess(models);
            }
        });
    }
}
 
Example 3
Source File: DiffProvider.java    From swellrt with Apache License 2.0 6 votes vote down vote up
@Override
public void getDiffs(WaveletId waveletId, String docId, HashedVersion version,
    Callback<DiffData, Exception> callback) {

  callback.onSuccess(new DiffData() {

    @Override
    public String getDocId() {
      return "";
    }

    @Override
    public Range[] getRanges() {
      return new Range[] {};
    }

  });

}
 
Example 4
Source File: ObjectPagingProxy.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void load(final PagingLoadConfig config,
		final Callback<PagingLoadResult<M>, Throwable> callback) {
	final ArrayList<M> temp = new ArrayList<M>();

	for (M model : data) {
		temp.add(model);
	}

	final ArrayList<M> sublist = new ArrayList<M>();
	int start = config.getOffset();
	int limit = temp.size();
	if (config.getLimit() > 0) {
		limit = Math.min(start + config.getLimit(), limit);
	}
	for (int i = config.getOffset(); i < limit; i++) {
		sublist.add(temp.get(i));
	}

	Timer t = new Timer() {

		@Override
		public void run() {
			callback.onSuccess(new PagingLoadResultBean<M>(sublist, temp
					.size(), config.getOffset()));
		}
	};
	t.schedule(delay);

}
 
Example 5
Source File: DiffProvider.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@Override
public void getDiffs(Callback<DiffData, Exception> callback) {
  callback.onSuccess(new DiffData() {

    @Override
    public String getDocId() {
      return "";
    }

    @Override
    public Range[] getRanges() {
      return new Range[] {};
    }
  });
}
 
Example 6
Source File: PatchManagementPresenter.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void launchRollbackWizard(final PatchInfo patchInfo) {
    // this callback is directly called from the standalone branch
    // or after the running server instances are retrieved in the domain branch
    final Callback<RollbackContext, Throwable> contextCallback = new Callback<RollbackContext, Throwable>() {
        @Override
        public void onFailure(final Throwable caught) {
            Log.error("Unable to launch apply patch wizard", caught);
            Console.error(Console.CONSTANTS.patch_manager_rollback_wizard_error(), caught.getMessage());
        }

        @Override
        public void onSuccess(final RollbackContext context) {
            window = new DefaultWindow(Console.CONSTANTS.patch_manager_rollback());
            window.setWidth(480);
            window.setHeight(NORMAL_WINDOW_HEIGHT);
            window.setWidget(new RollbackWizard(PatchManagementPresenter.this, context,
                    Console.CONSTANTS.patch_manager_rollback(), dispatcher, patchManager));
            window.setGlassEnabled(true);
            window.center();
        }
    };

    if (bootstrapContext.isStandalone()) {
        contextCallback
                .onSuccess(new RollbackContext(true, Patches.STANDALONE_HOST, Collections.<String>emptyList(),
                        patchManager.baseAddress(), patchInfo));
    } else {
        final String host = hostStore.getSelectedHost();
        dispatcher
                .execute(new DMRAction(getRunningServersOp(host)), new GetRunningServersCallback() {
                    @Override
                    protected void onServers(final List<String> runningServers) {
                        contextCallback.onSuccess(new RollbackContext(false, host, runningServers,
                                patchManager.baseAddress(), patchInfo));
                    }
                });
    }
}
 
Example 7
Source File: PatchManagementPresenter.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void launchApplyWizard() {
    if (!UploadHandler.verifySupport()) {
        Console.warning(Console.CONSTANTS.uploadsNotSupported(), Console.CONSTANTS.noUploadDueToSecurityReasons());
    }

    // this callback is directly called from the standalone branch
    // or after the running server instances are retrieved in the domain branch
    final Callback<ApplyContext, Throwable> contextCallback = new Callback<ApplyContext, Throwable>() {
        @Override
        public void onFailure(final Throwable caught) {
            Log.error("Unable to launch apply patch wizard", caught);
            Console.error(Console.CONSTANTS.patch_manager_apply_new_wizard_error(), caught.getMessage());
        }

        @Override
        public void onSuccess(final ApplyContext context) {
            window = new DefaultWindow(Console.CONSTANTS.patch_manager_apply_patch());
            window.setWidth(480);
            window.setHeight(NORMAL_WINDOW_HEIGHT);
            window.trapWidget(new ApplyWizard(PatchManagementPresenter.this, context,
                    Console.CONSTANTS.patch_manager_apply_patch(), dispatcher, patchManager).asWidget());
            window.setGlassEnabled(true);
            window.center();
        }
    };

    if (bootstrapContext.isStandalone()) {
        contextCallback
                .onSuccess(new ApplyContext(true, Patches.STANDALONE_HOST, Collections.<String>emptyList(),
                        patchManager.baseAddress(), bootstrapContext.getProperty(BootstrapContext.UPLOAD_API)));
    } else {
        final String host = hostStore.getSelectedHost();
        dispatcher
                .execute(new DMRAction(getRunningServersOp(host)), new GetRunningServersCallback() {
                    @Override
                    protected void onServers(final List<String> runningServers) {
                        contextCallback.onSuccess(new ApplyContext(false, host, runningServers,
                                patchManager.baseAddress(),
                                bootstrapContext.getProperty(BootstrapContext.UPLOAD_API)));
                    }
                });
    }
}
 
Example 8
Source File: BaseTestCase.java    From gwt-ol with Apache License 2.0 3 votes vote down vote up
/**
 * Load the list of scripts asynchronously only if they are not already loaded.
 *
 * @param urls URLs of the scripts to load
 * @param currentUrlIndex current url index
 * @param callback callback that gets invoked asynchronously
 */
private void loadScripts(List<String> urls, int currentUrlIndex, Callback<Void, Exception> callback) {

    if (currentUrlIndex < urls.size()) {

        String currentUrl = urls.get(currentUrlIndex);

        if (scriptAlreadyLoaded(currentUrl)) {

            loadScripts(urls, currentUrlIndex + 1, callback);

        } else {

            ScriptInjector.fromUrl(currentUrl).setWindow(ScriptInjector.TOP_WINDOW).setCallback(new Callback<Void, Exception>() {

                @Override
                public void onFailure(Exception reason) {
                    callback.onFailure(reason);
                }

                @Override
                public void onSuccess(Void result) {
                    loadedScriptUrls.add(currentUrl);
                    loadScripts(urls, currentUrlIndex + 1, callback);

                }

            }).inject();
        }

    } else {
        callback.onSuccess(null);
    }

}