@Override public Promise<Map<String, String>> loadPreferences() { return getPreferences() .then( (Function<Map<String, String>, Map<String, String>>) preferences -> { persistedPreferences.clear(); persistedPreferences.putAll(preferences); return preferences; }); }
/** Removes the command with the specified {@code commandName}. */ Promise<Void> removeCommand(String commandName) { return workspaceServiceClient .deleteCommand(appContext.getWorkspaceId(), commandName) .thenPromise( arg -> workspaceServiceClient .getWorkspace(appContext.getWorkspaceId()) .then(updateWorkspace())); }
private void updateErrorWarningsPanel() { preferencesManager .loadPreferences() .then( properties -> { options.forEach(this::provideWidget); }); }
private void updateProjectConfig(String project) { appContext .getWorkspaceRoot() .getContainer(project) .then( container -> { if (container.isPresent()) { container.get().synchronize(); } }); }
/** {@inheritDoc} */ @NotNull @Override public final Promise<List<Node>> getChildren(boolean forceUpdate) { if (children == null || children.isEmpty() || forceUpdate) { return getChildrenImpl().then(setParentAndSaveState()); } return Promises.resolve(children); }
private void onProjectUpdated(String projectPath) { appContext .getWorkspaceRoot() .getContainer(projectPath) .then( container -> { if (container.isPresent()) { container.get().synchronize(); } }); }
@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()); } })
/** Shows the guide of creating a command of the specified {@code goal}. */ public void guide(CommandGoal goal) { workspaceAgentProvider.get().setActivePart(commandsExplorerPresenterProvider.get()); commandManager .createCommand(goal.getId(), "custom") .then( command -> { editorAgentProvider.get().openEditor(nodeFactory.newCommandFileNode(command)); }); } }
@Override public void onFileSelected(Path path) { view.hidePopup(); appContext .getWorkspaceRoot() .getFile(path) .then( optFile -> { if (optFile.isPresent()) { editorAgent.openEditor(optFile.get()); } }); }
/** {@inheritDoc} */ @Override public void actionPerformed(ActionEvent event) { checkNotNull(appContext.getWorkspace().getId(), "Workspace id should not be null"); appStateManager .persistState() .then( arg -> { workspaceManager.stopWorkspace(); }); } }
/** * Creates new command of the specified type. * * <p><b>Note</b> that command's name will be generated by {@link CommandManager} and command line * will be provided by an appropriate {@link CommandType}. */ Promise<Void> createCommand(final CommandImpl command) { return workspaceServiceClient .addCommand(appContext.getWorkspaceId(), command) .then(updateWorkspace()); }
@Override public void onCommandAdd(int left, int top) { commandTypeChooser.show(left, top).then(createCommand(getDefaultContext())); }
private void updateResource(String path) { appContext .getWorkspaceRoot() .getResource(Path.valueOf(path)) .then( resource -> { if (resource.isPresent()) { resource.get().getProject().synchronize(); resource.get().getParent().synchronize(); } }); }
@Override public Promise<CommandImpl> createCommand(CommandImpl command) { return doCreateCommand(command) .then( (Function<CommandImpl, CommandImpl>) newCommand -> { // postpone the notification because // listeners should be notified after returning from #createCommand method Scheduler.get().scheduleDeferred(() -> notifyCommandAdded(newCommand)); return newCommand; }); }
private Promise<Void> deleteCallback(Project project) { return project .delete() .then( deletedProject -> { notificationManager.notify( locale.projectRemoved(project.getName()), SUCCESS, EMERGE_MODE); }); }
/** * Updates the command with the specified {@code name} by replacing it with the given {@code * command}. * * <p><b>Note</b> that name of the updated command may differ from the name provided by the given * {@code command} in order to prevent name duplication. */ Promise<Void> updateCommand(final CommandImpl command) { return workspaceServiceClient .updateCommand(appContext.getWorkspaceId(), command.getName(), command) .then(updateWorkspace()); }
/** * 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)); }
@Override public void onCommandDuplicate(CommandImpl command) { commandManager .createCommand(command) .then(this::refreshViewAndSelectCommand) .catchError(showErrorNotification(messages.unableDuplicate())); }
private void importForWorkspace(StatusNotification notification) { javaFormatterServiceClient .updateRootFormatter(view.getFileContent()) .then( content -> { onSuccessImported(notification); }) .catchError( error -> { onFailedImported(notification); }); }
/** {@inheritDoc} */ @Override public Promise<String> getContent() { ExternalLibrariesParameters params = dtoFactory.createDto(ExternalLibrariesParameters.class); params.setProjectUri(project.toString()); params.setNodePath(getData().getPath()); params.setNodeId(libId); return service .getFileContent(getData().getUri()) .then((Function<String, String>) result -> result); }