コード例 #1
0
  @Override
  public Promise<Void> promise(final ActionEvent event) {
    final CurrentProject currentProject = appContext.getCurrentProject();

    if (currentProject == null) {
      return Promises.reject(JsPromiseError.create(localization.noOpenedProject()));
    }

    final Call<Void, Throwable> call =
        new Call<Void, Throwable>() {

          private HandlerRegistration handlerRegistration;

          @Override
          public void makeCall(final Callback<Void, Throwable> callback) {
            actionCompletedCallBack = callback;

            handlerRegistration =
                eventBus.addHandler(
                    NodeExpandedEvent.TYPE,
                    new NodeExpandedEventHandler() {
                      @Override
                      public void onNodeExpanded() {
                        handlerRegistration.removeHandler();
                        callback.onSuccess(null);
                      }
                    });

            actionPerformed(event);
          }
        };

    return createFromCallback(call);
  }
コード例 #2
0
  @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);
  }