List of usage examples for com.google.gwt.chrome.def BackgroundJsCallback BackgroundJsCallback
BackgroundJsCallback
From source file:org.rest.client.activity.RequestActivity.java
License:Apache License
private void fromGoogleDriveAction(final String entryId) { requestView.reset();// ww w . ja va 2s . c om clientFactory.getChromeMessagePassing().postMessage(ExternalEventsFactory.EXT_GET_EXTERNAL_REQUEST_DATA, entryId, new BackgroundJsCallback() { @Override public void onSuccess(JavaScriptObject message) { ExternalDriveCreateResponse response; try { response = message.cast(); } catch (Exception e) { StatusNotification.notify("Unable to read response from background page", StatusNotification.TYPE_ERROR, StatusNotification.TIME_MEDIUM); return; } if (response.isError()) { StatusNotification.notify(response.getErrorMessage(), StatusNotification.TYPE_ERROR, StatusNotification.TIME_MEDIUM); return; } ExternalDriveCreateData data = response.getData(); if (data == null) { StatusNotification.notify("No data passed to application.", StatusNotification.TYPE_ERROR, StatusNotification.TIME_MEDIUM); return; } Storage store = Storage.getSessionStorageIfSupported(); store.setItem(LocalStore.GOOGLE_DRIVE_CREATE_FOLDER_ID, data.getFolderId()); store.setItem(LocalStore.GOOGLE_DRIVE_CREATE_USER_ID, data.getUserId()); tutorialFactory = new TutorialFactory("gdriveCreate", true); requestView.setUpDriveTutorial(tutorialFactory); } @Override public void onError(String message) { Log.error("Error get gdrive data", message); } }); }