• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java PromiseError类的典型用法和代码示例

java 3次浏览

本文整理汇总了Java中org.eclipse.che.api.promises.client.PromiseError的典型用法代码示例。如果您正苦于以下问题:Java PromiseError类的具体用法?Java PromiseError怎么用?Java PromiseError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

PromiseError类属于org.eclipse.che.api.promises.client包,在下文中一共展示了PromiseError类的36个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: refreshKeys

点赞 4

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
/** Refresh ssh keys. */
private void refreshKeys() {
  service
      .getPairs(VCS_SSH_SERVICE)
      .then(
          new Operation<List<SshPairDto>>() {
            @Override
            public void apply(List<SshPairDto> result) throws OperationException {
              view.setPairs(result);
            }
          })
      .catchError(
          new Operation<PromiseError>() {
            @Override
            public void apply(PromiseError arg) throws OperationException {
              notificationManager.notify(constant.failedToLoadSshKeys(), FAIL, FLOAT_MODE);
            }
          });
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:20,
代码来源:SshKeyManagerPresenter.java

示例2: catchErrorPromise

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
@Override
public final native <B> Promise<B> catchErrorPromise(
    Function<PromiseError, Promise<B>> onRejected) /*-{
      return this.then(undefined, function (reason) {
          return @org.eclipse.che.api.promises.client.js.JsPromise::applyFunctionToError(*)(onRejected, reason);
      });
  }-*/;
 

开发者ID:eclipse,
项目名称:che,
代码行数:8,
代码来源:JsPromise.java

示例3: testGetStackFrameDump

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
@Test
public void testGetStackFrameDump() throws Exception {
  Promise<StackFrameDumpDto> promiseStackFrameDump = mock(Promise.class);
  StackFrameDumpDto mockStackFrameDumpDto = mock(StackFrameDumpDto.class);
  final String json = "json";
  doReturn(json).when(dtoFactory).toJson(mockStackFrameDumpDto);

  doReturn(promiseStackFrameDump)
      .when(service)
      .getStackFrameDump(SESSION_ID, THREAD_ID, FRAME_INDEX);
  doReturn(promiseStackFrameDump)
      .when(promiseStackFrameDump)
      .then((Function<StackFrameDumpDto, Object>) any());
  doReturn(promiseStackFrameDump)
      .when(promiseStackFrameDump)
      .catchError((Operation<PromiseError>) any());

  Promise<? extends StackFrameDump> result = debugger.getStackFrameDump(THREAD_ID, FRAME_INDEX);
  assertEquals(promiseStackFrameDump, result);
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:21,
代码来源:DebuggerTest.java

示例4: fork

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
private Promise<BitbucketRepositoryFork> fork(
    final String owner, final String repository, final int number, final boolean isForkPrivate) {
  final String forkName = number == 0 ? repository : (repository + "-" + number);
  return bitbucketClientService
      .forkRepository(owner, repository, forkName, isForkPrivate)
      .catchErrorPromise(
          new Function<PromiseError, Promise<BitbucketRepositoryFork>>() {
            @Override
            public Promise<BitbucketRepositoryFork> apply(PromiseError exception)
                throws FunctionException {
              if (number < MAX_FORK_CREATION_ATTEMPT && exception instanceof ServerException) {
                final ServerException serverException = (ServerException) exception;
                final String exceptionMessage = serverException.getMessage();

                if (serverException.getHTTPStatus() == BAD_REQUEST
                    && exceptionMessage != null
                    && containsIgnoreCase(exceptionMessage, REPOSITORY_EXISTS_ERROR_MESSAGE)) {

                  return fork(owner, repository, number + 1, isForkPrivate);
                }
              }
              return reject(exception);
            }
          });
}
 

开发者ID:codenvy,
项目名称:codenvy,
代码行数:26,
代码来源:BitbucketHostingService.java

示例5: removeFailedKey

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
/** Need to remove failed uploaded keys from local storage if they can't be uploaded */
private void removeFailedKey(final String host) {
  service
      .getPairs(VCS_SSH_SERVICE)
      .then(
          new Operation<List<SshPairDto>>() {
            @Override
            public void apply(List<SshPairDto> result) throws OperationException {
              for (SshPairDto key : result) {
                if (key.getName().equals(host)) {
                  removeFailedKey(key);
                  return;
                }
              }
              refreshKeys();
            }
          })
      .catchError(
          new Operation<PromiseError>() {
            @Override
            public void apply(PromiseError arg) throws OperationException {
              refreshKeys();
              notificationManager.notify(constant.failedToLoadSshKeys(), FAIL, FLOAT_MODE);
            }
          });
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:27,
代码来源:SshKeyManagerPresenter.java

示例6: startImport

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
/**
 * Starts project importing. This method should be called when we want mark project as importing.
 *
 * @param sourceStorage information about project location and repository type
 * @return returns instance of Promise
 */
protected Promise<Project> startImport(final Path path, SourceStorage sourceStorage) {
  appContext.addProjectToImporting(path.toString());

  return importProject(path, sourceStorage)
      .then(
          new Function<Project, Project>() {
            @Override
            public Project apply(Project project) throws FunctionException {
              appContext.removeProjectFromImporting(project.getLocation().toString());

              return project;
            }
          })
      .catchErrorPromise(
          new Function<PromiseError, Promise<Project>>() {
            @Override
            public Promise<Project> apply(PromiseError error) throws FunctionException {
              appContext.removeProjectFromImporting(path.toString());

              throw new IllegalStateException(error.getCause());
            }
          });
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:30,
代码来源:AbstractImporter.java

示例7: handleStartRecompilationError

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
private Operation<PromiseError> handleStartRecompilationError(String codeServerURL) {
  boolean isLocalhost = codeServerURL.equals(LOCAL_CODE_SERVER_ADDRESS);

  return err -> {
    if (!isLocalhost) {
      setUpSuperDevModeWithUI(LOCAL_CODE_SERVER_ADDRESS);
    } else {
      dialogFactory
          .createMessageDialog(
              messages.gwtRecompileDialogTitle(),
              messages.gwtRecompileDialogNoServerMessage(),
              null)
          .show();
    }
  };
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:17,
代码来源:GWTDevMode.java

示例8: init

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
@Override
public Promise<Void> init() {
  return userInitializer
      .init()
      .catchError(
          (Operation<PromiseError>)
              err -> {
                // Fail to initialize the current user.
                // Since we can't get theme ID from the user's preferences
                // try to inject CSS styles with a default theme at least
                // in order to be able to use a minimal UI (dialogs)
                // for displaying an error information to the user.
                styleInjector.inject();

                // Prevent further initialization steps.
                throw new OperationException(err.getMessage(), err.getCause());
              })
      .then(initUI())
      .thenPromise(aVoid -> initAppContext())
      .then(showUI())
      .then(
          arg -> {
            eventBus.fireEvent(new BasicIDEInitializedEvent());
          });
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:26,
代码来源:DefaultIdeInitializationStrategy.java

示例9: initAppContext

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
protected Promise<Void> initAppContext() {
  return getWorkspaceToStart()
      .then(
          (Function<WorkspaceImpl, Void>)
              workspace -> {
                ((AppContextImpl) appContext).setWorkspace(workspace);
                ((AppContextImpl) appContext).setStartAppActions(getStartUpActions());

                return null;
              })
      .catchError(
          (Operation<PromiseError>)
              err -> {
                throw new OperationException("Can not get workspace: " + err.getCause());
              });
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:17,
代码来源:DefaultIdeInitializationStrategy.java

示例10: initAppContext

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
@Override
protected Promise<Void> initAppContext() {
  return super.initAppContext()
      .thenPromise(
          aVoid ->
              getFactory()
                  .then(
                      (Function<FactoryDto, Void>)
                          factory -> {
                            ((AppContextImpl) appContext).setFactory(factory);
                            return null;
                          })
                  .catchError(
                      (Operation<PromiseError>)
                          err -> {
                            throw new OperationException(
                                "Unable to load Factory: " + err.getMessage(), err.getCause());
                          })
                  .then(
                      arg -> {
                        if (RUNNING != appContext.getWorkspace().getStatus()) {
                          throw new OperationException(
                              "Can't load Factory. Workspace is not running.");
                        }
                      }));
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:27,
代码来源:FactoryIdeInitializationStrategy.java

示例11: getFailedKey

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
/** Need to remove failed uploaded pair from local storage if they can't be uploaded to github */
private void getFailedKey() {
  sshServiceClient
      .getPairs(SshKeyManagerPresenter.VCS_SSH_SERVICE)
      .then(
          new Operation<List<SshPairDto>>() {
            @Override
            public void apply(List<SshPairDto> result) throws OperationException {
              for (SshPairDto key : result) {
                if (key.getName().equals(GITHUB_HOST)) {
                  removeFailedKey(key);
                  return;
                }
              }
            }
          })
      .catchError(
          new Operation<PromiseError>() {
            @Override
            public void apply(PromiseError arg) throws OperationException {
              Log.error(OAuth2Authenticator.class, arg.getCause());
            }
          });
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:25,
代码来源:GitHubAuthenticatorImpl.java

示例12: shouldNotifyOnFailedRevert

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
@Test
public void shouldNotifyOnFailedRevert() throws Exception {
  RevertResult revertResult = mock(RevertResult.class);
  when(revertResult.getNewHead()).thenReturn("1234");
  when(revertResult.getRevertedCommits()).thenReturn(Collections.emptyList());
  when(revertResult.getConflicts()).thenReturn(Collections.emptyMap());

  Revision selectedRevision = mock(Revision.class);
  when(selectedRevision.getId()).thenReturn("1234");

  presenter.show(project);
  presenter.onRevisionSelected(selectedRevision);
  presenter.onRevertClicked();
  verify(revertPromise).catchError(promiseErrorCaptor.capture());
  promiseErrorCaptor.getValue().apply(mock(PromiseError.class));

  verify(notificationManager).notify(eq(constant.revertCommitFailed()), eq(FAIL), eq(FLOAT_MODE));
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:19,
代码来源:RevertCommitPresenterTest.java

示例13: shouldShowDialogOnInitCommitError

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
@Test
public void shouldShowDialogOnInitCommitError() throws Exception {
  PromiseError error = mock(PromiseError.class);
  ServerException exception = mock(ServerException.class);
  when(exception.getErrorCode()).thenReturn(ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED);
  when(error.getCause()).thenReturn(exception);
  when(constant.initCommitWasNotPerformed()).thenReturn("error message");
  MessageDialog dialog = mock(MessageDialog.class);
  when(dialogFactory.createMessageDialog(
          eq("title"), eq("error message"), any(ConfirmCallback.class)))
      .thenReturn(dialog);

  presenter.show();
  verify(logPromise).catchError(promiseErrorCaptor.capture());
  promiseErrorCaptor.getValue().apply(error);

  verify(dialog).show();
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:19,
代码来源:HistoryPresenterTest.java

示例14: generateSSHAndPushBranch

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
private void generateSSHAndPushBranch(
    final WorkflowExecutor executor, final Context context, String host) {
  sshService
      .generatePair("vcs", host)
      .then(
          new Operation<SshPairDto>() {
            @Override
            public void apply(SshPairDto arg) throws OperationException {
              pushBranch(executor, context);
            }
          })
      .catchError(
          new Operation<PromiseError>() {
            @Override
            public void apply(PromiseError err) throws OperationException {
              executor.fail(delegate, context, err.getMessage());
            }
          });
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:20,
代码来源:PushBranchStep.java

示例15: authenticate

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
private void authenticate(final WorkflowExecutor executor, final Context context) {
  context
      .getVcsHostingService()
      .authenticate(appContext.getCurrentUser())
      .then(authSuccessOp(executor, context))
      .catchError(
          new Operation<PromiseError>() {
            @Override
            public void apply(PromiseError err) throws OperationException {
              try {
                throw err.getCause();
              } catch (UnauthorizedException unEx) {
                notificationManager.notify(
                    messages.stepAuthorizeCodenvyOnVCSHostErrorCannotAccessVCSHostTitle(),
                    messages.stepAuthorizeCodenvyOnVCSHostErrorCannotAccessVCSHostContent(),
                    FAIL,
                    FLOAT_MODE);
                executor.fail(
                    AuthorizeCodenvyOnVCSHostStep.this, context, unEx.getLocalizedMessage());
              } catch (Throwable thr) {
                handleThrowable(thr, executor, context);
              }
            }
          });
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:26,
代码来源:AuthorizeCodenvyOnVCSHostStep.java

示例16: show

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
/**
 * The method gets method parameters via {@link JavaNavigationService} and then call special
 * method on view to display them.
 *
 * @param activeEditor active editor which contains method or constructor for which parameters
 *     will be displayed
 */
public void show(final TextEditor activeEditor) {
  final int offset = activeEditor.getCursorOffset();

  if (!isCursorInRightPlace(activeEditor, offset)) {
    return;
  }

  VirtualFile file = activeEditor.getEditorInput().getFile();

  if (file instanceof Resource) {
    final Optional<Project> project = ((Resource) file).getRelatedProject();
    final int lineStartOffset = getLineStartOffset(activeEditor, offset);

    navigationService
        .getMethodParametersHints(
            project.get().getLocation(), JavaUtil.resolveFQN(file), offset, lineStartOffset)
        .then(
            new Operation<List<MethodParameters>>() {
              @Override
              public void apply(List<MethodParameters> parameters) throws OperationException {
                if (parameters.isEmpty()) {
                  return;
                }

                PositionConverter.PixelCoordinates coordinates =
                    activeEditor.getPositionConverter().offsetToPixel(offset);

                view.show(parameters, coordinates.getX(), coordinates.getY());
              }
            })
        .catchError(
            new Operation<PromiseError>() {
              @Override
              public void apply(PromiseError error) throws OperationException {
                Log.error(getClass(), error.getMessage());
              }
            });
  }
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:47,
代码来源:ParametersHintsPresenter.java

示例17: onAccepted

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
private void onAccepted(String value) {
  final Resource resource = appContext.getResource();

  checkState(resource instanceof Container, "Parent should be a container");

  ((Container) resource)
      .newFolder(value.replace('.', '/'))
      .then(
          new Operation<Folder>() {
            @Override
            public void apply(Folder pkg) throws OperationException {
              eventBus.fireEvent(new RevealResourceEvent(pkg));
            }
          })
      .catchError(
          new Operation<PromiseError>() {
            @Override
            public void apply(PromiseError error) throws OperationException {
              dialogFactory
                  .createMessageDialog(
                      coreLocalizationConstant.invalidName(), error.getMessage(), null)
                  .show();
            }
          });
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:26,
代码来源:NewPackageAction.java

示例18: show

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
/**
 * Show Rename window with the special information.
 *
 * @param refactorInfo information about the rename operation
 */
public void show(RefactorInfo refactorInfo) {
  this.refactorInfo = refactorInfo;
  final CreateRenameRefactoring createRenameRefactoring =
      createRenameRefactoringDto(refactorInfo);

  Promise<RenameRefactoringSession> createRenamePromise =
      refactorService.createRenameRefactoring(createRenameRefactoring);
  createRenamePromise
      .then(
          new Operation<RenameRefactoringSession>() {
            @Override
            public void apply(RenameRefactoringSession session) throws OperationException {
              show(session);
            }
          })
      .catchError(
          new Operation<PromiseError>() {
            @Override
            public void apply(PromiseError arg) throws OperationException {
              notificationManager.notify(
                  locale.failedToRename(), arg.getMessage(), FAIL, FLOAT_MODE);
            }
          });
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:30,
代码来源:RenamePresenter.java

示例19: createRenameSession

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
private void createRenameSession() {
  final CreateRenameRefactoring refactoringSession =
      createRenameRefactoringDto(textEditor, false);

  Promise<RenameRefactoringSession> createRenamePromise =
      refactoringServiceClient.createRenameRefactoring(refactoringSession);
  createRenamePromise
      .then(
          new Operation<RenameRefactoringSession>() {
            @Override
            public void apply(RenameRefactoringSession session) throws OperationException {
              renamePresenter.show(session);
              if (mode != null) {
                mode.exitLinkedMode(false);
              }
            }
          })
      .catchError(
          new Operation<PromiseError>() {
            @Override
            public void apply(PromiseError arg) throws OperationException {
              showError();
            }
          });
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:26,
代码来源:JavaRefactoringRename.java

示例20: showProjectsAndPackages

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
private void showProjectsAndPackages() {
  Promise<List<JavaProject>> projectsPromise = navigationService.getProjectsAndPackages(true);

  projectsPromise
      .then(
          new Operation<List<JavaProject>>() {
            @Override
            public void apply(List<JavaProject> projects) throws OperationException {
              List<JavaProject> currentProject = new ArrayList<>();
              for (JavaProject project : projects) {
                currentProject.add(project);
              }
              view.setTreeOfDestinations(refactorInfo, currentProject);
              view.show(refactorInfo);
            }
          })
      .catchError(
          new Operation<PromiseError>() {
            @Override
            public void apply(PromiseError error) throws OperationException {
              notificationManager.notify(
                  locale.showPackagesError(), error.getMessage(), Status.FAIL, FLOAT_MODE);
            }
          });
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:26,
代码来源:MovePresenter.java

示例21: setUp

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  when(editor.getEditorInput()).thenReturn(editorInput);
  when(editor.getDocument()).thenReturn(document);
  when(editorInput.getFile()).thenReturn(file);
  when(editor.getCursorOffset()).thenReturn(0);
  when(file.getRelatedProject()).thenReturn(Optional.of(relatedProject));
  when(file.getParentWithMarker(eq(SourceFolderMarker.ID))).thenReturn(Optional.of(srcFolder));
  when(file.getName()).thenReturn("A.java");
  when(file.getExtension()).thenReturn("java");
  when(file.getResourceType()).thenReturn(Resource.FILE);
  when(file.getLocation()).thenReturn(Path.valueOf("/project/src/a/b/c/A.java"));
  when(srcFolder.getLocation()).thenReturn(Path.valueOf("/project/src"));
  when(relatedProject.getLocation()).thenReturn(Path.valueOf("/project"));
  when(javaNavigationService.getCompilationUnit(any(Path.class), anyString(), anyBoolean()))
      .thenReturn(promise);
  when(promise.then(org.mockito.ArgumentMatchers.<Operation<CompilationUnit>>anyObject()))
      .thenReturn(promise);
  when(promise.catchError(org.mockito.ArgumentMatchers.<Operation<PromiseError>>anyObject()))
      .thenReturn(promise);
  when(loaderFactory.newLoader()).thenReturn(loader);

  presenter =
      new FileStructurePresenter(
          view, javaNavigationService, context, editorAgent, loaderFactory);
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:27,
代码来源:FileStructurePresenterTest.java

示例22: propertiesShouldBeDisplayedFailed

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
@Test
public void propertiesShouldBeDisplayedFailed() throws OperationException {
  PromiseError promiseError = mock(PromiseError.class);
  NotificationManager notificationManager = mock(NotificationManager.class);

  when(notificationManagerProvider.get()).thenReturn(notificationManager);

  presenter.onWorkspaceRunning(workspaceRunningEvent);
  presenter.go(container);

  verify(mapPromise).catchError(errorOperationCaptor.capture());

  errorOperationCaptor.getValue().apply(promiseError);

  verify(preferencesManager).loadPreferences();
  verify(notificationManager).notify(nullable(String.class), eq(FAIL), eq(FLOAT_MODE));
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:18,
代码来源:JavaCompilerPreferencePresenterTest.java

示例23: testGetValue

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
@Test
public void testGetValue() throws Exception {
  final VariableDto variableDto = mock(VariableDto.class);
  final Variable variable = mock(Variable.class);
  final Promise<SimpleValueDto> promiseValue = mock(Promise.class);

  SimpleValueDto simpleValueDto = mock(SimpleValueDto.class);
  doReturn(simpleValueDto).when(dtoFactory).createDto(SimpleValueDto.class);
  doReturn(simpleValueDto).when(simpleValueDto).withString(nullable(String.class));

  SimpleValue simpleValue = mock(SimpleValue.class);
  doReturn(simpleValue).when(variable).getValue();

  doReturn(simpleValue).when(variable).getValue();
  doReturn(variableDto).when(dtoFactory).createDto(VariableDto.class);
  doReturn(mock(VariablePathDto.class)).when(dtoFactory).createDto(VariablePathDto.class);
  doReturn(mock(VariablePathDto.class)).when(variable).getVariablePath();

  doReturn(promiseValue).when(service).getValue(SESSION_ID, variableDto, THREAD_ID, FRAME_INDEX);
  doReturn(promiseValue).when(promiseValue).then((Function<SimpleValueDto, Object>) any());
  doReturn(promiseValue).when(promiseValue).catchError((Operation<PromiseError>) any());

  Promise<? extends SimpleValue> result = debugger.getValue(variable, THREAD_ID, FRAME_INDEX);
  assertEquals(promiseValue, result);
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:26,
代码来源:DebuggerTest.java

示例24: renameRefactoringShouldBeShowErrorWindow

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
@Test
public void renameRefactoringShouldBeShowErrorWindow() throws OperationException {
  PromiseError arg = Mockito.mock(PromiseError.class);
  MessageDialog dialog = Mockito.mock(MessageDialog.class);

  when(locale.renameRename()).thenReturn("renameTitle");
  when(locale.renameOperationUnavailable()).thenReturn("renameBody");
  when(dialogFactory.createMessageDialog(anyString(), anyString(), anyObject()))
      .thenReturn(dialog);

  refactoringRename.refactor(textEditor);

  verify(createRenamePromise).then(renameRefCaptor.capture());
  renameRefCaptor.getValue().apply(session);
  verify(createRenamePromise).catchError(refactoringErrorCaptor.capture());
  refactoringErrorCaptor.getValue().apply(arg);

  verify(dialogFactory).createMessageDialog("renameTitle", "renameBody", null);
  verify(dialog).show();
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:21,
代码来源:JavaRefactoringRenameTest.java

示例25: actionPerformed

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
  mavenServerServiceClient
      .reImportProjects(getPathsToSelectedMavenProject())
      .catchError(
          new Operation<PromiseError>() {
            @Override
            public void apply(PromiseError arg) throws OperationException {
              notificationManager.notify(
                  "Problem with reimporting maven dependencies",
                  arg.getMessage(),
                  FAIL,
                  EMERGE_MODE);
            }
          });
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:17,
代码来源:ReimportMavenDependenciesAction.java

示例26: testEvaluateExpressionRequestIsFailed

点赞 3

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
@Test
public void testEvaluateExpressionRequestIsFailed() throws Exception {
  when(view.getExpression()).thenReturn(EXPRESSION);
  when(debugger.evaluate(view.getExpression(), THREAD_ID, FRAME_INDEX)).thenReturn(promise);
  when(promise.then((Operation) anyObject())).thenReturn(promise);
  when(promise.catchError(org.mockito.ArgumentMatchers.<Operation<PromiseError>>anyObject()))
      .thenReturn(promise);
  when(debuggerManager.getActiveDebugger()).thenReturn(debugger);
  when(promiseError.getMessage()).thenReturn(FAIL_REASON);

  presenter.showDialog();
  presenter.onEvaluateClicked();

  verify(view, atLeastOnce()).setEnableEvaluateButton(eq(DISABLE_BUTTON));
  verify(debugger).evaluate(EXPRESSION, THREAD_ID, FRAME_INDEX);
  verify(promise).catchError(errorCaptor.capture());

  errorCaptor.getValue().apply(promiseError);

  verify(view).setEnableEvaluateButton(eq(!DISABLE_BUTTON));
  verify(constants).evaluateExpressionFailed(FAIL_REASON);
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:23,
代码来源:EvaluateExpressionTest.java

示例27: actionPerformed

点赞 2

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
  // This calls the service in the workspace.
  // This method is in our org.eclipse.che.plugin.serverservice.ide.MyServiceClient class
  // This is a Promise, so the .then() method is invoked after the response is made
  serviceClient
      .getHello("CheTheAllPowerful!")
      .then(
          new Operation<String>() {
            @Override
            public void apply(String response) throws OperationException {
              // This passes the response String to the notification manager.
              notificationManager.notify(
                  response,
                  StatusNotification.Status.SUCCESS,
                  StatusNotification.DisplayMode.FLOAT_MODE);
            }
          })
      .catchError(
          new Operation<PromiseError>() {
            @Override
            public void apply(PromiseError error) throws OperationException {
              notificationManager.notify(
                  "Fail",
                  StatusNotification.Status.FAIL,
                  StatusNotification.DisplayMode.FLOAT_MODE);
            }
          });
}
 

开发者ID:eclipse,
项目名称:che-archetypes,
代码行数:30,
代码来源:MyAction.java

示例28: applyOperationToError

点赞 2

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
private static final native void applyOperationToError(
  Operation<PromiseError> onRejected, JavaScriptObject reason) /*-{
    var reasonString = reason.toString();
    if (reasonString.indexOf("org.eclipse.che.api.promises.client.OperationException:") == 0
        || reasonString.indexOf("org.eclipse.che.api.promises.client.FunctionException:") == 0) {
        var promiseError = @org.eclipse.che.api.promises.client.js.JsPromiseError::create(Ljava/lang/Throwable;)(reason)
        [email protected]::apply(*)(promiseError);
    } else {
        [email protected]::apply(*)(reason);
    }
}-*/;
 

开发者ID:eclipse,
项目名称:che,
代码行数:12,
代码来源:JsPromise.java

示例29: applyFunctionToError

点赞 2

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
private static final native <V> V applyFunctionToError(
  Function<PromiseError, V> onRejected, JavaScriptObject reason) /*-{
    var reasonString = reason.toString();
    if (reasonString.indexOf("org.eclipse.che.api.promises.client.OperationException:") == 0
        || reasonString.indexOf("org.eclipse.che.api.promises.client.FunctionException:") == 0) {
        var promiseError = @org.eclipse.che.api.promises.client.js.JsPromiseError::create(Ljava/lang/Throwable;)(reason)
        return [email protected]::apply(*)(promiseError);
    } else {
        return [email protected]::apply(*)(reason);
    }
}-*/;
 

开发者ID:eclipse,
项目名称:che,
代码行数:12,
代码来源:JsPromise.java

示例30: then

点赞 2

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
@Override
public final <B> Promise<B> then(
    Function<V, B> onFulfilled, Function<PromiseError, B> onRejected) {
  if (onFulfilled != null) {
    return this.internalThen(onFulfilled, onRejected);
  } else {
    return this.catchError(onRejected);
  }
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:10,
代码来源:JsPromise.java

示例31: internalThen

点赞 2

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
private final native <B> Promise<B> internalThen(
  Function<V, B> onFulfilled, Function<PromiseError, B> onRejected) /*-{
    return this.then(function (value) {
        return [email protected]::apply(*)(value);
    }, function (reason) {
        return @org.eclipse.che.api.promises.client.js.JsPromise::applyFunctionToError(*)(onRejected, reason);
    });
}-*/;
 

开发者ID:eclipse,
项目名称:che,
代码行数:9,
代码来源:JsPromise.java

示例32: TreeResourceRevealer

点赞 2

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
@Inject
public TreeResourceRevealer(
    ProjectExplorerView projectExplorer, EventBus eventBus, PromiseProvider promises) {
  this.tree = projectExplorer.getTree();

  queue = promises.resolve(null);

  eventBus.addHandler(
      RevealResourceEvent.getType(),
      new RevealResourceHandler() {
        @Override
        public void onRevealResource(final RevealResourceEvent event) {
          queue.thenPromise(
              new Function<Void, Promise<Void>>() {
                @Override
                public Promise<Void> apply(Void ignored) throws FunctionException {
                  return reveal(
                          event.getLocation(),
                          event.isSelectionRequired(),
                          event.isFocusRequired())
                      .catchError(
                          new Function<PromiseError, Void>() {
                            @Override
                            public Void apply(PromiseError arg) throws FunctionException {
                              return null;
                            }
                          });
                }
              });
        }
      });
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:33,
代码来源:TreeResourceRevealer.java

示例33: showErrorNotification

点赞 2

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
/** Returns an operation which shows an error notification with the given title. */
private Operation<PromiseError> showErrorNotification(String title) {
  return err -> {
    notificationManager.notify(title, err.getMessage(), FAIL, EMERGE_MODE);
    throw new OperationException(err.getMessage());
  };
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:8,
代码来源:CommandsExplorerPresenter.java

示例34: doSave

点赞 2

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
@Override
public void doSave(AsyncCallback<EditorInput> callback) {
  commandManager
      .updateCommand(initialCommandName, editedCommand)
      .then(
          arg -> {
            // according to the CommandManager#updateCommand contract
            // command's name after updating may differ from the proposed name
            // in order to prevent name duplication
            editedCommand.setName(arg.getName());

            if (!initialCommandName.equals(editedCommand.getName())) {
              input.setFile(nodeFactory.newCommandFileNode(editedCommand));
              initialCommandName = editedCommand.getName();
              firePropertyChange(PROP_INPUT);
            }

            updateDirtyState(false);

            view.setSaveEnabled(false);

            callback.onSuccess(getEditorInput());
          })
      .catchError(
          (Operation<PromiseError>)
              arg -> {
                notificationManager.notify(
                    messages.editorMessageUnableToSave(), arg.getMessage(), WARNING, EMERGE_MODE);

                callback.onFailure(arg.getCause());

                throw new OperationException(arg.getMessage());
              });
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:35,
代码来源:CommandEditor.java

示例35: createFolder

点赞 2

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
final void createFolder(String name) {
  Resource resource = appContext.getResource();

  if (!(resource instanceof Container)) {
    final Container parent = resource.getParent();

    checkState(parent != null, "Parent should be a container");

    resource = parent;
  }

  ((Container) resource)
      .newFolder(name)
      .then(
          new Operation<Folder>() {
            @Override
            public void apply(Folder folder) throws OperationException {
              eventBus.fireEvent(new RevealResourceEvent(folder));
            }
          })
      .catchError(
          new Operation<PromiseError>() {
            @Override
            public void apply(PromiseError error) throws OperationException {
              dialogFactory.createMessageDialog("Error", error.getMessage(), null).show();
            }
          });
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:29,
代码来源:NewFolderAction.java

示例36: loadProfile

点赞 2

import org.eclipse.che.api.promises.client.PromiseError; //导入依赖的package包/类
private Promise<ProfileDto> loadProfile() {
  return getUserProfile()
      .catchError(
          (Operation<PromiseError>)
              arg -> {
                throw new OperationException("Unable to load user's profile: " + arg.getCause());
              });
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:9,
代码来源:CurrentUserInitializer.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)