com.google.gwt.core.client.Callback Java Examples
The following examples show how to use
com.google.gwt.core.client.Callback.
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: AppTest.java From gdx-fireapp with Apache License 2.0 | 6 votes |
@Test public void configure() throws Exception { // Given App app = new App(); FirebaseConfigParser configParser = PowerMockito.mock(FirebaseConfigParser.class); PowerMockito.whenNew(FirebaseConfigParser.class).withAnyArguments().thenReturn(configParser); ScriptInjector.FromUrl fromUrl = PowerMockito.mock(ScriptInjector.FromUrl.class); Mockito.when(ScriptInjector.fromUrl(Mockito.nullable(String.class))).thenReturn(fromUrl); Mockito.when(fromUrl.setCallback(Mockito.nullable(Callback.class))).thenReturn(fromUrl); Mockito.when(fromUrl.setRemoveTag(Mockito.anyBoolean())).thenReturn(fromUrl); Mockito.when(fromUrl.setWindow(Mockito.nullable(JavaScriptObject.class))).thenReturn(fromUrl); // When app.configure(); // Then PowerMockito.verifyNew(FirebaseConfigParser.class, VerificationModeFactory.times(1)).withArguments(Mockito.anyString()); Mockito.verify(configParser, VerificationModeFactory.times(1)).getFirebaseScriptSrc(); }
Example #2
Source File: ImportParentChooser.java From proarc with GNU General Public License v3.0 | 6 votes |
private void loadParentSelection(final String pid, String batchId) { if (pid == null && batchId == null) { selectionView.setSelection(null); return ; } SearchDataSource.getInstance().findParent(pid, batchId, new Callback<ResultSet, Void>() { @Override public void onFailure(Void reason) { } @Override public void onSuccess(ResultSet result) { if (result.isEmpty()) { selectionView.setSelection(null); } else { newParent = oldParent = result.first(); selectionView.setSelection(newParent); } loadFailed = false; } }); }
Example #3
Source File: DesaExportAction.java From proarc with GNU General Public License v3.0 | 6 votes |
private void askForExportOptions(String[] pids) { if (pids == null || pids.length == 0) { return ; } Record export = new Record(); export.setAttribute(ExportResourceApi.DESA_PID_PARAM, pids); ExportOptionsWidget.showOptions(export, new Callback<Record, Void>() { @Override public void onFailure(Void reason) { // no-op } @Override public void onSuccess(Record result) { exportOrValidate(result); } }); }
Example #4
Source File: DigitalObjectFormValidateAction.java From proarc with GNU General Public License v3.0 | 6 votes |
private void validate(final Validatable validable, final Record[] digitalObjects) { if (digitalObjects != null && digitalObjects.length > 0) { // ensure models are fetched MetaModelDataSource.getModels(false, new Callback<ResultSet, Void>() { @Override public void onFailure(Void reason) { } @Override public void onSuccess(ResultSet result) { new ValidateTask(validable, digitalObjects).execute(); } }); } else { // no-op } }
Example #5
Source File: DigitalObjectNavigateAction.java From proarc with GNU General Public License v3.0 | 6 votes |
private void fetchSiblings(final String pid) { SearchDataSource.getInstance().findParent(pid, null, new Callback<ResultSet, Void>() { @Override public void onFailure(Void reason) { } @Override public void onSuccess(ResultSet result) { if (result.isEmpty()) { SC.warn(i18n.DigitalObjectNavigateAction_NoParent_Msg()); } else { Record parent = result.first(); DigitalObject parentObj = DigitalObject.createOrNull(parent); if (parentObj != null) { scheduleFetchSiblings(parentObj.getPid(), pid); } } } }); }
Example #6
Source File: MetaModelDataSource.java From proarc with GNU General Public License v3.0 | 6 votes |
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 #7
Source File: SearchDataSource.java From proarc with GNU General Public License v3.0 | 6 votes |
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 #8
Source File: RecaptchaView.java From gwt-material-demo with Apache License 2.0 | 6 votes |
@Inject RecaptchaView(Binder uiBinder) { initWidget(uiBinder.createAndBindUi(this)); // Load the Api RecaptchaApi recaptchaApi = new RecaptchaApi("6LeZSRIUAAAAAE3JdZpdi6shhA87ZUG4U2ICsGlJ"); ApiRegistry.register(recaptchaApi, new Callback<Void, Exception>() { @Override public void onFailure(Exception reason) { MaterialToast.fireToast(reason.getMessage()); } @Override public void onSuccess(Void result) { recaptcha.load(recaptchaApi); } }); }
Example #9
Source File: GoogleMap.java From unitime with Apache License 2.0 | 6 votes |
@Override public void setup() { ScriptInjector.fromUrl("https://maps.googleapis.com/maps/api/js?" + (iApiKey != null && !iApiKey.isEmpty() ? "key=" + iApiKey + "&" : "") + "sensor=false&callback=setupGoogleMap").setWindow(ScriptInjector.TOP_WINDOW).setCallback( new Callback<Void, Exception>() { @Override public void onSuccess(Void result) { } @Override public void onFailure(Exception e) { UniTimeNotifications.error(e.getMessage(), e); setVisible(false); iMapControl = null; } }).inject(); }
Example #10
Source File: LeafletMap.java From unitime with Apache License 2.0 | 6 votes |
public void setup() { loadCss(GWT.getHostPageBaseURL() + "leaflet/leaflet.css"); ScriptInjector.fromUrl(GWT.getHostPageBaseURL() + "leaflet/leaflet.js").setWindow(ScriptInjector.TOP_WINDOW).setCallback( new Callback<Void, Exception>() { @Override public void onSuccess(Void result) { setupLeafletMap(iTileUrl, iTileAttribution); setLeafletMarker(); leafletReverseGeocode(); } @Override public void onFailure(Exception e) { UniTimeNotifications.error(e.getMessage(), e); setVisible(false); iMapControl = null; } }).inject(); }
Example #11
Source File: WorkflowNewJobEditor.java From proarc with GNU General Public License v3.0 | 6 votes |
public void open(WorkflowManaging.WorkflowNewJobEditPlace place) { MetaModelDataSource.getModels(false, new Callback<ResultSet, Void>() { @Override public void onFailure(Void reason) { } @Override public void onSuccess(ResultSet result) { Record modelRecord = MetaModelDataSource.getModels().findByKey(place.getModelPid()); MetaModelDataSource.MetaModelRecord.get(modelRecord); MetaModelDataSource.MetaModelRecord metaModel = new MetaModelDataSource.MetaModelRecord(modelRecord); Record record = new Record(); record.setAttribute(WorkflowModelConsts.JOB_ID, place.getJobId()); record.setAttribute(DigitalObjectDataSource.FIELD_MODEL, place.getModelPid()); record.setAttributeAsJavaObject(MetaModelDataSource.FIELD_MODELOBJECT, metaModel); editor.edit(DigitalObjectDataSource.DigitalObject.create(record)); } }); }
Example #12
Source File: DigitalObjectEditor.java From proarc with GNU General Public License v3.0 | 6 votes |
private void initSearchList(String[] pids) { expect(); SearchDataSource.getInstance().find(pids, new Callback<ResultSet, Void>() { @Override public void onFailure(Void reason) { searchList = new RecordList(); release(); } @Override public void onSuccess(ResultSet result) { searchList = result; release(); } }); }
Example #13
Source File: ModsBatchEditor.java From proarc with GNU General Public License v3.0 | 6 votes |
private void prepareTemplate(DigitalObject templateObj, DescriptionMetadata templateDesc) { if (templateDesc != null) { prepareDescription(getCurrent(), templateDesc); return ; } ModsCustomDataSource.getInstance().fetchDescription(templateObj, new Callback<DescriptionMetadata, String>() { @Override public void onFailure(String reason) { stop(reason); } @Override public void onSuccess(DescriptionMetadata result) { templateDescriptions[getTemplateIndex()] = result; prepareDescription(getCurrent(), result); } }, false); }
Example #14
Source File: DiffProvider.java From swellrt with Apache License 2.0 | 6 votes |
@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 #15
Source File: ApiRegistry.java From gwt-material with Apache License 2.0 | 6 votes |
/** * Will register the {@link ApiFeature} to the list of features providing also the Javascript Script element object * for later removal / update. */ public static void register(ApiFeature apiFeature, Callback<Void, Exception> callback) { if (apiFeature != null && apiFeature.getApiKey() != null && !apiFeature.getApiKey().isEmpty()) { JavaScriptObject scriptObject = ScriptInjector.fromUrl(apiFeature.constructApiUrl()) .setWindow(ScriptInjector.TOP_WINDOW) .setCallback(new Callback<Void, Exception>() { @Override public void onFailure(Exception e) { callback.onFailure(e); } @Override public void onSuccess(Void aVoid) { callback.onSuccess(aVoid); } }).inject(); features.put(apiFeature, scriptObject); } }
Example #16
Source File: HelpExtension.java From codenvy with Eclipse Public License 1.0 | 6 votes |
private void addPremiumSupportHelpAction() { // userVoice init ScriptInjector.fromUrl(resources.userVoice().getSafeUri().asString()) .setWindow(ScriptInjector.TOP_WINDOW) .setCallback( new Callback<Void, Exception>() { @Override public void onSuccess(Void aVoid) { // add action actionManager.registerAction( localizationConstant.createSupportTicketAction(), createSupportTicketAction); helpGroup.addSeparator(); helpGroup.add(createSupportTicketAction); } @Override public void onFailure(Exception e) { Log.error(getClass(), "Unable to inject UserVoice", e); } }) .inject(); }
Example #17
Source File: DemoGwtWebApp.java From demo-gwt-springboot with Apache License 2.0 | 6 votes |
private void injectJqueryScript() { // Workaround: https://goo.gl/1OrFqj ScriptInjector.fromUrl(JQUERY_UI_URL).setCallback(new Callback<Void, Exception>() { @Override public void onFailure(Exception reason) { logger.info("Script load failed Info: " + reason); } @Override public void onSuccess(Void result) { logger.info("JQuery for Select loaded successful!"); init(); } }).setRemoveTag(true).setWindow(ScriptInjector.TOP_WINDOW).inject(); }
Example #18
Source File: BaseTestCase.java From gwt-ol with Apache License 2.0 | 6 votes |
/** * Method for tests which need injected scripts. */ protected void injectUrlAndTest(final TestWithInjection testWithInjection) { this.delayTestFinish(this.testDelay); this.loadScripts(this.scriptUrls, 0, new Callback<Void, Exception>() { @Override public void onSuccess(Void result) { testWithInjection.test(); finishTest(); } @Override public void onFailure(Exception reason) { assertNotNull(reason); fail("Injection failed: " + reason.toString()); } }); }
Example #19
Source File: CollectionWebApp.java From gwt-boot-samples with Apache License 2.0 | 6 votes |
private void injectTomatoScript() { logger.info("Inject tomato.js"); ScriptInjector.fromUrl(TOMATO_JS_URL) .setCallback(new Callback<Void, Exception>() { @Override public void onFailure(Exception reason) { logger.info("Script load failed Info: " + reason); } @Override public void onSuccess(Void result) { logger.info( "tomato.js loaded successfully and executed!"); } }).setRemoveTag(true).setWindow(ScriptInjector.TOP_WINDOW) .inject(); }
Example #20
Source File: Auth.java From requestor with Apache License 2.0 | 6 votes |
/** * Request an access token from an OAuth 2.0 provider. * <p/> * <p> If it can be determined that the user has already granted access, and the token has not yet expired, and that * the token will not expire soon, the existing token will be passed to the callback. </p> * <p/> * <p> Otherwise, a popup window will be displayed which may prompt the user to grant access. If the user has * already granted access the popup will immediately close and the token will be passed to the callback. If access * hasn't been granted, the user will be prompted, and when they grant, the token will be passed to the callback. * </p> * * @param req Request for authentication. * @param callback Callback to pass the token to when access has been granted. */ public void login(AuthRequest req, final Callback<TokenInfo, Throwable> callback) { lastRequest = req; lastCallback = callback; String authUrl = req.toUrl(urlCodex) + "&redirect_uri=" + urlCodex.encode(oauthWindowUrl); // Try to look up the token we have stored. final TokenInfo info = getToken(req); if (info == null || info.getExpires() == null || expiringSoon(info)) { // Token wasn't found, or doesn't have an expiration, or is expired or // expiring soon. Requesting access will refresh the token. doLogin(authUrl, callback); } else { // Token was found and is good, immediately execute the callback with the // access token. scheduler.scheduleDeferred(new ScheduledCommand() { @Override public void execute() { callback.onSuccess(info); } }); } }
Example #21
Source File: OAuth2Base.java From requestor with Apache License 2.0 | 5 votes |
@Override public void auth(final PreparedRequest preparedRequest) { AUTH.login(authRequest, new Callback<TokenInfo, Throwable>() { @Override public void onFailure(Throwable reason) { preparedRequest.abort(new RequestException("Unable to authorize the request using OAuth2.", reason)); } @Override public void onSuccess(TokenInfo tokenInfo) { doAuth(preparedRequest, tokenInfo); preparedRequest.send(); } }); }
Example #22
Source File: ImportBatchItemEditor.java From proarc with GNU General Public License v3.0 | 5 votes |
@Override public void delete(Object[] items) { if (items != null && items.length > 0) { Record[] records = (Record[]) items; String[] pids = ClientUtils.toFieldValues(records, ImportBatchItemDataSource.FIELD_PID); String batchId = records[0].getAttribute(ImportBatchItemDataSource.FIELD_BATCHID); ImportBatchItemDataSource.getInstance().delete(new Callback<Record[], String>() { @Override public void onFailure(String reason) { } @Override public void onSuccess(Record[] result) { DigitalObjectCopyMetadataAction.removeSelection(result); RecordList rl = thumbViewer.getRecordList(); for (Record record : result) { int index = rl.findIndex(ImportBatchItemDataSource.FIELD_PID, record.getAttribute(ImportBatchItemDataSource.FIELD_PID)); if (index >= 0) { rl.removeAt(index); } } int visibleFirstRows = batchItemGrid.getVisibleRows()[0]; if (visibleFirstRows >= 0) { ClientUtils.scrollToTile(thumbViewer, visibleFirstRows); } batchItemGrid.deselectAllRecords(); } }, batchId, pids); } }
Example #23
Source File: WorkflowJobView.java From proarc with GNU General Public License v3.0 | 5 votes |
private void saveNewDigitalObject(String modelId, Long jobId) { if (modelId == null || jobId == null) { return; } DigitalObjectDataSource ds = DigitalObjectDataSource.getInstance(); ds.saveNewDigitalObject(modelId, null, null, jobId, new Callback<String, DigitalObjectDataSource.ErrorSavingDigitalObject>() { @Override public void onFailure(DigitalObjectDataSource.ErrorSavingDigitalObject reason) { switch (reason) { case CONCURRENT_MODIFICATION: SC.ask(i18n.SaveAction_ConcurrentErrorAskReload_Msg(), aBoolean -> { if (aBoolean!= null && aBoolean) { refresh(); }}); default: SC.warn("Failed to create digital object!"); } } @Override public void onSuccess(String result) { SC.say(i18n.DigitalObjectCreator_FinishedStep_CreateNewObjectButton_Title(), i18n.DigitalObjectCreator_FinishedStep_Done_Msg()); } }); }
Example #24
Source File: ImportParentChooser.java From proarc with GNU General Public License v3.0 | 5 votes |
private void fetchModels(final boolean reload) { MetaModelDataSource.getModels(reload, new Callback<ResultSet, Void>() { @Override public void onFailure(Void reason) { } @Override public void onSuccess(ResultSet modelResultSet) { LinkedHashMap<?, ?> valueMap = ClientUtils.getValueMap(modelResultSet, MetaModelDataSource.FIELD_PID, MetaModelDataSource.FIELD_DISPLAY_NAME); treeView.setModels(valueMap); foundView.setModels(valueMap); selectionView.setModels(valueMap); if (firstShowParentFetch) { //issue #499 Object previousId = Offline.get(LAST_SELECTED_MODEL_TAG); if (previousId != null) { foundView.setFilterModel(previousId); } else if (!valueMap.isEmpty()) { // init the view filter with the first modelId on first show Object firstModel = valueMap.keySet().iterator().next(); foundView.setFilterModel(firstModel); } // issue 209: do not refresh the parent search on each show firstShowParentFetch = false; foundView.refresh(); } } }); }
Example #25
Source File: PatchManagementPresenter.java From core with GNU Lesser General Public License v2.1 | 5 votes |
public void restart() { ModelNode restartNode = new ModelNode(); if (!bootstrapContext.isStandalone()) { restartNode.get(ADDRESS).add("host", hostStore.getSelectedHost()); } restartNode.get(OP).set(SHUTDOWN); restartNode.get("restart").set(true); final RestartModal restartModal = new RestartModal(); restartModal.center(); RestartOp restartOp = new RestartOp(dispatcher); restartOp.start(dispatcher, restartNode, new TimeoutOperation.Callback() { @Override public void onSuccess() { // TODO Doesn't need a full reload if a non-dc host was patched Window.Location.reload(); } @Override public void onTimeout() { // TODO Is there another way out? restartModal.timeout(); } @Override public void onError(final Throwable caught) { // TODO Is there another way out? restartModal.error(); } }); }
Example #26
Source File: PatchManagementPresenter.java From core with GNU Lesser General Public License v2.1 | 5 votes |
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 #27
Source File: AuthImpl.java From requestor with Apache License 2.0 | 5 votes |
/** * Get the OAuth 2.0 token for which this application may not have already been granted access, by displaying a * popup to the user. */ @Override void doLogin(String authUrl, final Callback<TokenInfo, Throwable> callback) { if (window != null && window.isOpen()) { callback.onFailure(new IllegalStateException("Authentication in progress")); } else { window = openWindow(authUrl, height, width); if (window == null) { callback.onFailure(new RuntimeException( "The authentication popup window appears to have been blocked")); } // Workaround to check if the user has closed the auth window, // since neither the onclose and onunload events work the expected way in this scenario window.setFinished(false); new Timer() { @Override public void run() { if (window.hasFinished()) cancel(); if (!window.isOpen()) { window.setFinished(true); callback.onFailure(new RuntimeException("User has closed the authentication window.")); cancel(); } } }.scheduleRepeating(300); } }
Example #28
Source File: FeaturePagingProxy.java From geowe-core with GNU General Public License v3.0 | 5 votes |
@Override public void load(final PagingLoadConfig config, final Callback<PagingLoadResult<VectorFeature>, Throwable> callback) { //Execute ordering options if(config.getSortInfo() != null && !config.getSortInfo().isEmpty()) { String sortAttribute = config.getSortInfo().get(0).getSortField(); int order = config.getSortInfo().get(0).getSortDir().equals(SortDir.ASC) ? FeatureComparator.ORDER_ASC : FeatureComparator.ORDER_DESC; Collections.sort(data, new FeatureComparator(sortAttribute, order)); } super.load(config, callback); }
Example #29
Source File: LazyContentDocument.java From swellrt with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("rawtypes") public void startShowDiffs() { diffsSuppressed = false; diffProvider.getDiffs(new Callback<DiffData, Exception>() { @Override public void onSuccess(DiffData result) { // remove old diffs getTarget().clearDiffs(); DiffData.Range[] ranges = result.getRanges(); for (int i = 0; i < ranges.length; i++) { // show all diffs DiffData.Range diff = ranges[i]; ParticipantId author = null; try { author = ParticipantId.of(diff.getValues().getAuthor()); } catch (InvalidParticipantAddress e) { author = ParticipantId.VOID; } getTarget().setDiff(diff.getStart(), diff.getEnd(), author); } } @Override public void onFailure(Exception reason) { // Mute exception } }); }
Example #30
Source File: ObjectPagingProxy.java From geowe-core with GNU General Public License v3.0 | 5 votes |
@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); }