private void onFailure(PromiseError error) { if (actionCompletedCallBack != null) { actionCompletedCallBack.onFailure(error.getCause()); } } }
/** * Called when children haven't been successfully loaded. Also fire {@link * org.eclipse.che.ide.ui.smartTree.event.LoadExceptionEvent} event. * * @param parent parent node, children which haven't been loaded * @return instance of {@link org.eclipse.che.api.promises.client.Operation} which contains * promise with error */ @NotNull private Operation<PromiseError> onLoadFailure(@NotNull final Node parent) { return error -> { childRequested.remove(parent); fireEvent(new LoadExceptionEvent(parent, error.getCause())); }; }
@Inject private void registerAllTemplates() { fetchTemplates() .then( templateDescriptors -> { templateDescriptors.forEach(this::register); }) .catchError( error -> { Log.error( ProjectTemplateRegistryImpl.this.getClass(), "Can't load project templates: " + error.getCause()); }); }
private Promise<ProfileDto> loadProfile() { return getUserProfile() .catchError( (Operation<PromiseError>) arg -> { throw new OperationException("Unable to load user's profile: " + arg.getCause()); }); }
private void registerProjectTypes() { fetchProjectTypes() .then( typeDescriptors -> { typeDescriptors.forEach( projectTypeDto -> projectTypes.put(projectTypeDto.getId(), projectTypeDto)); eventBus.fireEvent(new ProjectTypesLoadedEvent()); }) .catchError( error -> { Log.error( ProjectTypeRegistryImpl.this.getClass(), "Can't load project types: " + error.getCause()); }); }
private Promise<Map<String, String>> loadPreferences() { return preferencesManager .loadPreferences() .catchError( (Operation<PromiseError>) arg -> { throw new OperationException( messages.unableToLoadPreference() + ": " + arg.getCause()); }); }
private Promise<Project> recallSubversionImportWithCredentials( final Path path, final SourceStorage sourceStorage) { return askCredentialsDialog .askCredentials() .thenPromise( new Function<Credentials, Promise<Project>>() { @Override public Promise<Project> apply(Credentials credentials) throws FunctionException { sourceStorage.getParameters().put("username", credentials.getUsername()); sourceStorage.getParameters().put("password", credentials.getPassword()); return doImport(path, sourceStorage); } }) .catchError( error -> { callback.onFailure(error.getCause()); }); }
private void initResourceManager() { clearProjects(); resourceManager = resourceManagerFactory.newResourceManager(); resourceManager .getWorkspaceProjects() .then( projects -> { rootProjects.clear(); addAll(rootProjects, projects); rootProjects.sort(ResourcePathComparator.getInstance()); eventBus.fireEvent(new WorkspaceReadyEvent(projects)); }) .catchError( error -> { Log.error(AppContextImpl.class, error.getCause()); }); }
/** * Get the list of branches. * * @param remoteMode is a remote mode */ void getBranchesForCurrentProject( @NotNull final BranchListMode remoteMode, final AsyncCallback<List<Branch>> asyncResult) { service .branchList(project.getLocation(), remoteMode) .then( branches -> { asyncResult.onSuccess(branches); }) .catchError( error -> { asyncResult.onFailure(error.getCause()); }); }
private Promise<Project> recallSubversionImportWithCredentials( Path path, SourceStorage sourceStorage) { return askCredentialsDialog .askCredentials() .thenPromise( credentials -> { sourceStorage.getParameters().put("username", credentials.getUsername()); sourceStorage.getParameters().put("password", credentials.getPassword()); return doImport(path, sourceStorage); }) .catchError( caught -> { callback.onFailure(caught.getCause()); }); } }
protected void refreshVariables(long threadId, int frameIndex) { view.removeAllVariables(); Debugger debugger = debuggerManager.getActiveDebugger(); if (debugger != null && debugger.isSuspended()) { Promise<? extends StackFrameDump> promise = debugger.getStackFrameDump(threadId, frameIndex); promise .then( stackFrameDump -> { if (isSameSelection(threadId, frameIndex) || view.getSelectedThreadId() == -1) { variables = new LinkedList<>(); variables.addAll(stackFrameDump.getFields()); variables.addAll(stackFrameDump.getVariables()); view.setVariables(variables); } }) .catchError( error -> { Log.error(DebuggerPresenter.class, error.getCause()); }); } }
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()); }); }
/** {@inheritDoc} */ @Override public void onOkClicked() { final String name = view.getName(); final String url = view.getUrl().trim(); final Project project = appContext.getRootProject(); service .remoteAdd(project.getLocation(), name, url) .then( arg -> { callback.onSuccess(null); view.close(); }) .catchError( error -> { callback.onFailure(error.getCause()); }); }
public void showDialog(Project project) { this.project = project; view.setEnablePullButton(false); service .remoteList(project.getLocation(), null, true) .then( remotes -> { updateBranches(LIST_REMOTE); view.setRepositories(remotes); view.setEnablePullButton(!remotes.isEmpty()); view.showDialog(); }) .catchError( error -> { handleError(error.getCause(), REMOTE_REPO_COMMAND_NAME); view.setEnablePullButton(false); }); }
private void renameBranch(String newName) { service .branchRename(project.getLocation(), selectedBranch.getDisplayName(), newName) .then( ignored -> { getBranches(); view.setFocus(); }) .catchError( error -> { handleError(error.getCause(), BRANCH_RENAME_COMMAND_NAME); getBranches(); // rename of remote branch occurs in three stages, so needs update list // of branches on view }); }
@Override public void resume() { if (isConnected()) { for (DebuggerObserver observer : observers) { observer.onPreResume(); } ResumeActionDto action = dtoFactory.createDto(ResumeActionDto.class); action.setType(Action.TYPE.RESUME); removeCurrentLocation(); preserveDebuggerState(); Promise<Void> promise = service.resume(debugSessionDto.getId(), action); promise.catchError( error -> { Log.error(AbstractDebugger.class, error.getCause()); }); } }
@Override public void stepInto() { if (isConnected()) { for (DebuggerObserver observer : observers) { observer.onPreStepInto(); } StepIntoActionDto action = dtoFactory.createDto(StepIntoActionDto.class); action.setType(Action.TYPE.STEP_INTO); action.setSuspendPolicy(suspendEventDto.getSuspendPolicy()); removeCurrentLocation(); preserveDebuggerState(); Promise<Void> promise = service.stepInto(debugSessionDto.getId(), action); promise.catchError( error -> { Log.error(AbstractDebugger.class, error.getCause()); }); } }
@Override public void onCheckoutClicked() { final CheckoutRequest checkoutRequest = dtoFactory.createDto(CheckoutRequest.class); if (selectedBranch.isRemote()) { checkoutRequest.setTrackBranch(selectedBranch.getDisplayName()); } else { checkoutRequest.setName(selectedBranch.getDisplayName()); } service .checkout(project.getLocation(), checkoutRequest) .then( ignored -> { view.closeDialogIfShowing(); }) .catchError( error -> { handleError(error.getCause(), BRANCH_CHECKOUT_COMMAND_NAME); }); }
public void initRepository(final Project project) { final GitOutputConsole console = gitOutputConsoleFactory.create(INIT_COMMAND_NAME); service .init(project.getLocation(), false) .then( ignored -> { console.print(constant.initSuccess()); consolesPanelPresenter.addCommandOutput(console); notificationManager.notify(constant.initSuccess()); project.synchronize(); }) .catchError( error -> { handleError(error.getCause(), console); consolesPanelPresenter.addCommandOutput(console); }); }
/** Get list of revisions. */ private void getRevisions() { service .log(project.getLocation(), new Path[] {selectedFilePath}, -1, -1, false) .then( log -> { view.setRevisions(log.getCommits()); view.showDialog(); }) .catchError( error -> { if (getErrorCode(error.getCause()) == ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED) { dialogFactory .createMessageDialog( locale.compareWithRevisionTitle(), locale.initCommitWasNotPerformed(), null) .show(); } else { notificationManager.notify(locale.logFailed(), FAIL, NOT_EMERGE_MODE); } }); }