示例#1
0
  /**
   * 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>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.
   *
   * @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);
            }
          });
    }
  }
示例#2
0
 protected void clickLoadHistory() {
   showBusyIcon();
   Scheduler scheduler = Scheduler.get();
   scheduler.scheduleDeferred(
       new Command() {
         public void execute() {
           loadHistoryData();
         }
       });
 }
示例#3
0
  private void doBuild(
      final Panel buildResults,
      final String statusOperator,
      final String statusValue,
      final boolean enableStatusSelector,
      final String categoryOperator,
      final String category,
      final boolean enableCategorySelector,
      final String customSelector) {
    buildResults.clear();

    final HorizontalPanel busy = new HorizontalPanel();
    busy.add(new Label(constants.ValidatingAndBuildingPackagePleaseWait()));
    busy.add(new Image(images.redAnime()));

    buildResults.add(busy);

    Scheduler scheduler = Scheduler.get();
    scheduler.scheduleDeferred(
        new Command() {
          public void execute() {
            RepositoryServiceFactory.getPackageService()
                .buildPackage(
                    conf.getUuid(),
                    true,
                    buildMode,
                    statusOperator,
                    statusValue,
                    enableStatusSelector,
                    categoryOperator,
                    category,
                    enableCategorySelector,
                    customSelector,
                    new GenericCallback<BuilderResult>() {
                      public void onSuccess(BuilderResult result) {
                        LoadingPopup.close();
                        if (result == null || !result.hasLines()) {
                          showSuccessfulBuild(buildResults);
                        } else {
                          showBuilderErrors(result, buildResults, clientFactory);
                        }
                      }

                      public void onFailure(Throwable t) {
                        buildResults.clear();
                        super.onFailure(t);
                      }
                    });
          }
        });
  }
示例#4
0
  public RulePackageSelector(boolean loadGlobalArea) {
    this.loadGlobalArea = loadGlobalArea;

    packageList = new ListBox();

    Scheduler scheduler = Scheduler.get();

    scheduler.scheduleDeferred(
        new ScheduledCommand() {
          public void execute() {
            loadPackageList();
          }
        });

    initWidget(packageList);
  }
示例#5
0
  /** Actually build the source, and display it. */
  public static void doBuildSource(final String uuid, final String name) {
    LoadingPopup.showMessage(constants.AssemblingPackageSource());

    Scheduler scheduler = Scheduler.get();
    scheduler.scheduleDeferred(
        new Command() {
          public void execute() {
            RepositoryServiceFactory.getPackageService()
                .buildPackageSource(
                    uuid,
                    new GenericCallback<java.lang.String>() {
                      public void onSuccess(String content) {
                        showSource(content, name);
                      }
                    });
          }
        });
  }