當前位置: 首頁>>代碼示例>>Java>>正文


Java Callback類代碼示例

本文整理匯總了Java中com.google.gwt.core.client.Callback的典型用法代碼示例。如果您正苦於以下問題:Java Callback類的具體用法?Java Callback怎麽用?Java Callback使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Callback類屬於com.google.gwt.core.client包,在下文中一共展示了Callback類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: HelloWorldViewPresenter

import com.google.gwt.core.client.Callback; //導入依賴的package包/類
@Inject
public HelloWorldViewPresenter(final HelloWorldView helloWorldView) {
  this.helloWorldView = helloWorldView;

  ScriptInjector.fromUrl(GWT.getModuleBaseURL() + Constants.JAVASCRIPT_FILE_ID)
      .setWindow(ScriptInjector.TOP_WINDOW)
      .setCallback(
          new Callback<Void, Exception>() {
            @Override
            public void onSuccess(final Void result) {
              Log.info(HelloWorldViewPresenter.class, Constants.JAVASCRIPT_FILE_ID + " loaded.");
              sayHello("Hello from Java Script!");
            }

            @Override
            public void onFailure(final Exception e) {
              Log.error(
                  HelloWorldViewPresenter.class,
                  "Unable to load " + Constants.JAVASCRIPT_FILE_ID,
                  e);
            }
          })
      .inject();
}
 
開發者ID:eclipse,項目名稱:che-archetypes,代碼行數:25,代碼來源:HelloWorldViewPresenter.java

示例2: onModuleLoad

import com.google.gwt.core.client.Callback; //導入依賴的package包/類
public void onModuleLoad() {
	ScriptInjector.fromUrl(GWT.getModuleBaseURL()+"bower_components/webcomponents-lite.min.js").setWindow(ScriptInjector.TOP_WINDOW).setCallback(
               new Callback<Void, Exception>() {
                   @Override
                   public void onSuccess(Void result) {
					LOGGER.info("injection success");
					importPolymer();
				}

				@Override
				public void onFailure(Exception reason) {

				}
			}).inject();


	LOGGER.info("Initializing Layout client UI module ...");
	new ModuleConfigurator().configureModule(new LayoutUIModuleConfiguration());
}
 
開發者ID:GwtDomino,項目名稱:domino-todolist,代碼行數:20,代碼來源:LayoutUIClientModule.java

示例3: injectDocReadyAndC8OCoreScripts

import com.google.gwt.core.client.Callback; //導入依賴的package包/類
private void injectDocReadyAndC8OCoreScripts(final String convertigoMachineUrl) {
    final String convertigoStudioJsUrl = convertigoMachineUrl + "/convertigo/studio/js/";

    // First, inject docready.js = $(document).ready() (but native JS function)
    final String docReadyJsUrl = convertigoStudioJsUrl + "libs/docready.js";
    ScriptInjector
        .fromUrl(docReadyJsUrl)
        .setWindow(ScriptInjector.TOP_WINDOW)
        .setCallback(new Callback<Void, Exception>() {
            @Override
            public void onSuccess(Void result) {
                // ... then convertigo.js and main.js
                injectC8OCoreScripts(convertigoStudioJsUrl);
            }

            @Override
            public void onFailure(Exception reason) {
                Window.alert(formatScriptInjectFailure(docReadyJsUrl, convertigoMachineUrl));
            }
        })
        .inject();
}
 
開發者ID:convertigo,項目名稱:convertigo-che-assembly,代碼行數:23,代碼來源:MainViewPresenter.java

示例4: init

import com.google.gwt.core.client.Callback; //導入依賴的package包/類
public static void init()
{
	if(init)
		return;
	init = true;
	
	String javaScript = "ammo.js";
	
	final String js = GWT.getModuleBaseForStaticFiles() + javaScript;

	ScriptInjector.fromUrl(js).setCallback(new Callback<Void, Exception>()
	{
		@Override
		public void onFailure(Exception e)
		{
			GWT.log("inject " + js + " failure " + e);
		}

		@Override
		public void onSuccess(Void ok)
		{
			Bullet.initVariables();
		}
	}).setWindow(ScriptInjector.TOP_WINDOW).inject();
}
 
開發者ID:xpenatan,項目名稱:gdx-bullet-gwt,代碼行數:26,代碼來源:GwtBullet.java

示例5: injectJqueryScript

import com.google.gwt.core.client.Callback; //導入依賴的package包/類
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();
}
 
開發者ID:interseroh,項目名稱:demo-gwt-springboot,代碼行數:18,代碼來源:DemoGwtWebApp.java

示例6: setCurrentLocationIfSupported

import com.google.gwt.core.client.Callback; //導入依賴的package包/類
public void setCurrentLocationIfSupported() {
    Geolocation.getIfSupported().getCurrentPosition(
        new Callback<Position, PositionError>() {

            @Override
            public void onSuccess(Position result) {
                Position.Coordinates coordinates = result.getCoordinates();
                LatLng center = LatLng.newInstance(coordinates.getLatitude(), coordinates.getLongitude());
                getMapWidget().setCenter(center);
            }

            @Override
            public void onFailure(PositionError reason) {
                Window.alert(Texts.MSG_LOCATION_NOT_SUPPORTED);
            }
        });
}
 
開發者ID:baldram,項目名稱:tristar-eye,代碼行數:18,代碼來源:ClassicMapService.java

示例7: login

import com.google.gwt.core.client.Callback; //導入依賴的package包/類
/**
 * Request an access token from an OAuth 2.0 provider.
 *
 * <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>
 * 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<String, 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.expires == 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.accessToken);
      }
    });
  }
}
 
開發者ID:chetsmartboy,項目名稱:gwt-oauth2,代碼行數:45,代碼來源:Auth.java

示例8: addFoursquareAuth

import com.google.gwt.core.client.Callback; //導入依賴的package包/類
private void addFoursquareAuth() {
  // Since the auth flow requires opening a popup window, it must be started
  // as a direct result of a user action, such as clicking a button or link.
  // Otherwise, a browser's popup blocker may block the popup.
  Button button = new Button("Authenticate with Foursquare");
  button.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      final AuthRequest req = new AuthRequest(FOURSQUARE_AUTH_URL, FOURSQUARE_CLIENT_ID);
      AUTH.login(req, new Callback<String, Throwable>() {
        @Override
        public void onSuccess(String token) {
          Window.alert("Got an OAuth token:\n" + token + "\n"
              + "Token expires in " + AUTH.expiresIn(req) + " ms\n");
        }

        @Override
        public void onFailure(Throwable caught) {
          Window.alert("Error:\n" + caught.getMessage());
        }
      });
    }
  });
  RootPanel.get().add(button);
}
 
開發者ID:chetsmartboy,項目名稱:gwt-oauth2,代碼行數:26,代碼來源:OAuth2SampleEntryPoint.java

示例9: addDailymotionAuth

import com.google.gwt.core.client.Callback; //導入依賴的package包/類
private void addDailymotionAuth() {
  // Since the auth flow requires opening a popup window, it must be started
  // as a direct result of a user action, such as clicking a button or link.
  // Otherwise, a browser's popup blocker may block the popup.
  Button button = new Button("Authenticate with Dailymotion");
  button.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      final AuthRequest req = new AuthRequest(DAILYMOTION_AUTH_URL, DAILYMOTION_CLIENT_ID);
      AUTH.login(req, new Callback<String, Throwable>() {
        @Override
        public void onSuccess(String token) {
          Window.alert("Got an OAuth token:\n" + token + "\n"
              + "Token expires in " + AUTH.expiresIn(req) + " ms\n");
        }

        @Override
        public void onFailure(Throwable caught) {
          Window.alert("Error:\n" + caught.getMessage());
        }
      });
    }
  });
  RootPanel.get().add(button);
}
 
開發者ID:chetsmartboy,項目名稱:gwt-oauth2,代碼行數:26,代碼來源:OAuth2SampleEntryPoint.java

示例10: addWindowsLiveAuth

import com.google.gwt.core.client.Callback; //導入依賴的package包/類
private void addWindowsLiveAuth() {
  // Since the auth flow requires opening a popup window, it must be started
  // as a direct result of a user action, such as clicking a button or link.
  // Otherwise, a browser's popup blocker may block the popup.
  Button button = new Button("Authenticate with Windows Live");
  button.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      final AuthRequest req = new AuthRequest(WINDOWS_LIVE_AUTH_URL, WINDOWS_LIVE_CLIENT_ID)
          .withScopes(WINDOWS_LIVE_BASIC_SCOPE);
      AUTH.login(req, new Callback<String, Throwable>() {
        @Override
        public void onSuccess(String token) {
          Window.alert("Got an OAuth token:\n" + token + "\n"
              + "Token expires in " + AUTH.expiresIn(req) + " ms\n");
        }

        @Override
        public void onFailure(Throwable caught) {
          Window.alert("Error:\n" + caught.getMessage());
        }
      });
    }
  });
  RootPanel.get().add(button);
}
 
開發者ID:chetsmartboy,項目名稱:gwt-oauth2,代碼行數:27,代碼來源:OAuth2SampleEntryPoint.java

示例11: addPremiumSupportHelpAction

import com.google.gwt.core.client.Callback; //導入依賴的package包/類
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();
}
 
開發者ID:codenvy,項目名稱:codenvy,代碼行數:24,代碼來源:HelpExtension.java

示例12: inject

import com.google.gwt.core.client.Callback; //導入依賴的package包/類
@Override
public void inject (final OnCompletion oc) {
	final String js = GWT.getModuleBaseForStaticFiles() + "freetype.js";
	ScriptInjector.fromUrl(js).setCallback(new Callback<Void, Exception>() {

		@Override
		public void onFailure (Exception reason) {
			error = true;
			GWT.log("Exception injecting " + js, reason);
			oc.run();
		}

		@Override
		public void onSuccess (Void result) {
			success = true;
			GWT.log("Success injecting js.");
			oc.run();
		}

	}).setWindow(ScriptInjector.TOP_WINDOW).inject();
}
 
開發者ID:intrigus,項目名稱:gdx-freetype-gwt,代碼行數:22,代碼來源:FreetypeInjector.java

示例13: injectScriptOneAfterAnother

import com.google.gwt.core.client.Callback; //導入依賴的package包/類
private static void injectScriptOneAfterAnother(final List<String> pathAsList) {
    ScriptInjector.fromUrl(pathAsList.remove(0))
                  .setWindow(ScriptInjector.TOP_WINDOW)
                  .setCallback(new Callback<Void, Exception>() {
                      @Override
                      public void onFailure(Exception reason) {
                      }

                      @Override
                      public void onSuccess(Void result) {
                          if (!pathAsList.isEmpty()) {
                              injectScriptOneAfterAnother(pathAsList);
                          }
                      }
                  })
                  .inject();
}
 
開發者ID:ow2-proactive,項目名稱:scheduling-portal,代碼行數:18,代碼來源:JSUtil.java

示例14: executeScript

import com.google.gwt.core.client.Callback; //導入依賴的package包/類
public void executeScript(final String script, final String engine, final String nodeUrl,
        final Callback<String, String> syncCallBack) {
    rm.executeNodeScript(LoginModel.getInstance().getSessionId(),
                         script,
                         engine,
                         nodeUrl,
                         new AsyncCallback<String>() {
                             public void onFailure(Throwable caught) {
                                 LogModel.getInstance()
                                         .logImportantMessage("Failed to execute a script " + script + " on " +
                                                              nodeUrl + " : " +
                                                              JSONUtils.getJsonErrorMessage(caught));
                                 syncCallBack.onFailure(JSONUtils.getJsonErrorMessage(caught));
                             }

                             public void onSuccess(String result) {
                                 syncCallBack.onSuccess(parseScriptResult(result));
                             }
                         });
}
 
開發者ID:ow2-proactive,項目名稱:scheduling-portal,代碼行數:21,代碼來源:RMController.java

示例15: send

import com.google.gwt.core.client.Callback; //導入依賴的package包/類
@Override
public <R> Promise<R> send(final Unmarshallable<R> unmarshaller) {
  return CallbackPromiseHelper.createFromCallback(
      new CallbackPromiseHelper.Call<R, Throwable>() {
        @Override
        public void makeCall(final Callback<R, Throwable> callback) {
          send(
              new AsyncRequestCallback<R>(unmarshaller) {
                @Override
                protected void onSuccess(R result) {
                  callback.onSuccess(result);
                }

                @Override
                protected void onFailure(Throwable exception) {
                  callback.onFailure(exception);
                }
              });
        }
      });
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:22,代碼來源:MachineAsyncRequest.java


注:本文中的com.google.gwt.core.client.Callback類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。