@Override public void apply(String arg) throws OperationException { Map<String, String> connectionProperties = prepareConnectionProperties(debugConfiguration, arg); debugger .connect(connectionProperties) .catchError( new Operation<PromiseError>() { @Override public void apply(PromiseError arg) throws OperationException { debuggerManager.setActiveDebugger(null); } }); } });
@Override public void apply(final FactoryDto factory) throws OperationException { factoryService .findFactory( null, null, Collections.singletonList(Pair.of("name", factoryName))) .then(saveFactory(factory, factoryName)) .catchError(logError()); } })
@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()); }); }
@Override public void actionPerformed(ActionEvent e) { final Resource[] resources = appContext.getResources(); Set<String> pathsToRemove = stream(resources).map(resource -> resource.getLocation().toString()).collect(toSet()); fileWatcherExcludesOperation .removeFromFileWatcherExcludes(pathsToRemove) .catchError( error -> { notificationManager.notify(error.getMessage(), FAIL, EMERGE_MODE); }); }
@Override public void actionPerformed(ActionEvent e) { final Resource[] resources = appContext.getResources(); Set<String> pathsToExclude = stream(resources).map(resource -> resource.getLocation().toString()).collect(toSet()); fileWatcherExcludesOperation .addToFileWatcherExcludes(pathsToExclude) .catchError( error -> { notificationManager.notify(error.getMessage(), FAIL, EMERGE_MODE); }); }
private Promise<ProfileDto> loadProfile() { return getUserProfile() .catchError( (Operation<PromiseError>) arg -> { throw new OperationException("Unable to load user's profile: " + arg.getCause()); }); }
/** * Provide ability to write to preferences state for all workspaces. It's used to clean up user * preferences */ private Promise<Void> writeToPreferences(JsonObject state) { preferencesManager.setValue(APP_STATE, state.toJson()); return preferencesManager .flushPreferences() .catchError( error -> { LOG.error( "Failed to store app's state to user's preferences: {}", error.getMessage()); }); } }
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()); }); }
/** * Tries to set-up Super DevMode for the current IDE GWT app and shows an appropriate message to * the user. */ private void setUpSuperDevModeWithUI(String codeServerURL) { setUpSuperDevMode(codeServerURL) .then(showSuccessMessage(codeServerURL)) .catchError(handleStartRecompilationError(codeServerURL)); }
private Promise<Map<String, String>> loadPreferences() { return preferencesManager .loadPreferences() .catchError( (Operation<PromiseError>) arg -> { throw new OperationException( messages.unableToLoadPreference() + ": " + arg.getCause()); }); }
@Override public void onCommandDuplicate(CommandImpl command) { commandManager .createCommand(command) .then(this::refreshViewAndSelectCommand) .catchError(showErrorNotification(messages.unableDuplicate())); }
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()); }); }
private void importForWorkspace(StatusNotification notification) { javaFormatterServiceClient .updateRootFormatter(view.getFileContent()) .then( content -> { onSuccessImported(notification); }) .catchError( error -> { onFailedImported(notification); }); }
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()); }); } }
/** Show status. */ public void showStatus(Project project) { service .statusText(project.getLocation()) .then( status -> { printGitStatus(status); }) .catchError( error -> { notificationManager.notify(constant.statusFailed(), FAIL, FLOAT_MODE); }); }
private void showProjectsAndPackages() { extensionService .getDestinations() .then( projects -> { view.setTreeOfDestinations(refactorInfo, projects); view.show(refactorInfo); }) .catchError( error -> { notificationManager.notify( locale.showPackagesError(), error.getMessage(), Status.FAIL, FLOAT_MODE); }); }
@Override public void suspend() { if (!isConnected()) { return; } SuspendActionDto suspendAction = dtoFactory.createDto(SuspendActionDto.class); suspendAction.setType(Action.TYPE.SUSPEND); service .suspend(debugSessionDto.getId(), suspendAction) .catchError( error -> { notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE); }); }
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()); }); }
/** Saves given contents into file under edit. */ private void saveContent(final String content) { localContent = content; comparedFile .updateContent(content) .then( ignored -> { eventBus.fireEvent(new FileContentUpdateEvent(comparedFile.getLocation().toString())); }) .catchError( error -> { notificationManager.notify(error.getMessage(), FAIL, NOT_EMERGE_MODE); }); }
@Override public void onCommandRemove(CommandImpl command) { dialogFactory .createConfirmDialog( messages.removeCommandConfirmationTitle(), messages.removeCommandConfirmationMessage(command.getName()), () -> commandManager .removeCommand(command.getName()) .catchError(showErrorNotification(messages.unableRemove())), null) .show(); }