本文整理匯總了Java中com.google.gwt.core.client.Callback.onSuccess方法的典型用法代碼示例。如果您正苦於以下問題:Java Callback.onSuccess方法的具體用法?Java Callback.onSuccess怎麽用?Java Callback.onSuccess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.core.client.Callback
的用法示例。
在下文中一共展示了Callback.onSuccess方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: promise
import com.google.gwt.core.client.Callback; //導入方法依賴的package包/類
@Override
public Promise<Void> promise(final ActionEvent event) {
if (event.getParameters() == null
|| event.getParameters().get(SHOW_HIDDEN_FILES_PARAM_ID) == null) {
return Promises.reject(
JsPromiseError.create(
"Mandatory parameter" + SHOW_HIDDEN_FILES_PARAM_ID + " is not specified"));
}
final String showHiddenFilesKey = event.getParameters().get(SHOW_HIDDEN_FILES_PARAM_ID);
final boolean isShowHiddenFiles = Boolean.valueOf(showHiddenFilesKey);
final CallbackPromiseHelper.Call<Void, Throwable> call =
new CallbackPromiseHelper.Call<Void, Throwable>() {
@Override
public void makeCall(final Callback<Void, Throwable> callback) {
projectExplorerPresenter.showHiddenFiles(isShowHiddenFiles);
callback.onSuccess(null);
}
};
return createFromCallback(call);
}
示例2: basicFetch
import com.google.gwt.core.client.Callback; //導入方法依賴的package包/類
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);
}
}
示例3: getModels
import com.google.gwt.core.client.Callback; //導入方法依賴的package包/類
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);
}
});
}
}
示例4: load
import com.google.gwt.core.client.Callback; //導入方法依賴的package包/類
/**
* Load the specified script.
*
* @param script Path to script.
* @param callback {@code Callback} called when ready.
*/
public static void load(
String script, Callback<Void, Exception> callback) {
if (loadedScripts.contains(script)) {
callback.onSuccess(null);
return;
}
ScriptInjector.fromUrl(script)
.setWindow(ScriptInjector.TOP_WINDOW)
.setCallback(callback)
.inject();
loadedScripts.add(script);
}
示例5: testVersionSelected_cached
import com.google.gwt.core.client.Callback; //導入方法依賴的package包/類
/**
* Test that we don't call our dependency when we should have a cached version.
*/
public void testVersionSelected_cached() {
RestApiService service = EasyMock.createControl().createMock(RestApiService.class);
// Populate the cache with the service we'll request later.
loader.cache.put(ServiceLoader.generateCacheKey("service", "version", CallStyle.REST), service);
@SuppressWarnings("unchecked")
Callback<ApiService, String> mockCallback = EasyMock.createMock(Callback.class);
mockCallback.onSuccess(service);
EasyMock.expectLastCall();
EasyMock.replay(mockCallback);
loader.loadService("service", "version", mockCallback);
EasyMock.verify(mockCallback);
assertEquals(0, googleApi.invocations);
}
示例6: load
import com.google.gwt.core.client.Callback; //導入方法依賴的package包/類
@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);
}
示例7: getScriptInjectionCallback
import com.google.gwt.core.client.Callback; //導入方法依賴的package包/類
private static Callback<Void, Exception> getScriptInjectionCallback(
Callback<Void, Throwable> promiseCallback) {
return new Callback<Void, Exception>() {
@Override
public void onSuccess(Void result) {
promiseCallback.onSuccess(result);
}
@Override
public void onFailure(Exception reason) {
promiseCallback.onFailure(reason);
}
};
}
示例8: testVersionSelected
import com.google.gwt.core.client.Callback; //導入方法依賴的package包/類
/**
* Test that the callback gets invoked properly when a service is requested.
*/
public void testVersionSelected() {
googleApi.service = EasyMock.createControl().createMock(RestApiService.class);
@SuppressWarnings("unchecked")
Callback<ApiService, String> mockCallback = EasyMock.createMock(Callback.class);
mockCallback.onSuccess(googleApi.service);
EasyMock.replay(mockCallback);
loader.loadService("service", "version", mockCallback);
EasyMock.verify(mockCallback);
assertEquals(1, googleApi.invocations);
}
示例9: loadServiceDefinitions
import com.google.gwt.core.client.Callback; //導入方法依賴的package包/類
/**
* Load the directory document from either cache or the wire and notify the specified callback
* when done.
*/
public void loadServiceDefinitions(final Callback<Set<ServiceDefinition>, String> callback) {
if (directoryCache == null) {
googleApi.loadApiDirectory(new AsyncCallback<Set<ServiceDefinition>>() {
@Override
public void onSuccess(Set<ServiceDefinition> unfiltered) {
// Filter the list of services according to the blacklist.
directoryCache = Sets.filter(unfiltered, new Predicate<ServiceDefinition>() {
@Override
public boolean apply(ServiceDefinition service) {
return !SERVICE_NAME_BLACKLIST.contains(service.getName())
&& !SERVICE_ID_BLACKLIST.contains(service.getId());
}
});
callback.onSuccess(directoryCache);
delegate.directoryLoaded(directoryCache);
}
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught.getMessage());
}
});
} else {
callback.onSuccess(directoryCache);
}
}