use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class EditCommandsPresenter method createNewCommand.
private void createNewCommand(final String type, final String commandLine, final String name, final Map<String, String> attributes) {
if (!isViewModified()) {
createCommand(type, commandLine, name, attributes);
return;
}
final ConfirmCallback saveCallback = new ConfirmCallback() {
@Override
public void accepted() {
updateCommand(editedCommand).then(new Operation<CommandImpl>() {
@Override
public void apply(CommandImpl arg) throws OperationException {
createCommand(type, commandLine, name, attributes);
}
});
}
};
final ConfirmCallback discardCallback = new ConfirmCallback() {
@Override
public void accepted() {
refreshView();
createCommand(type, commandLine, name, attributes);
}
};
ChoiceDialog dialog = dialogFactory.createChoiceDialog(machineLocale.editCommandsSaveChangesTitle(), machineLocale.editCommandsSaveChangesConfirmation(editedCommand.getName()), coreLocale.save(), machineLocale.editCommandsSaveChangesDiscard(), saveCallback, discardCallback);
dialog.show();
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class TestServiceClient method runTestsAfterCompilation.
Promise<TestResult> runTestsAfterCompilation(String projectPath, String testFramework, Map<String, String> parameters, StatusNotification statusNotification, Promise<CommandImpl> compileCommand) {
return compileCommand.thenPromise(command -> {
final Machine machine;
if (command == null) {
machine = null;
} else {
machine = appContext.getDevMachine().getDescriptor();
}
if (machine == null) {
if (statusNotification != null) {
statusNotification.setContent("Executing the tests without preliminary compilation.");
}
return sendTests(projectPath, testFramework, parameters);
}
if (statusNotification != null) {
statusNotification.setContent("Compiling the project before starting the test session.");
}
return promiseFromExecutorBody(new ExecutorBody<TestResult>() {
boolean compiled = false;
@Override
public void apply(final ResolveFunction<TestResult> resolve, RejectFunction reject) {
macroProcessor.expandMacros(command.getCommandLine()).then(new Operation<String>() {
@Override
public void apply(String expandedCommandLine) throws OperationException {
CommandImpl expandedCommand = new CommandImpl(command.getName(), expandedCommandLine, command.getType(), command.getAttributes());
final CommandOutputConsole console = commandConsoleFactory.create(expandedCommand, machine);
final String machineId = machine.getId();
processesPanelPresenter.addCommandOutput(machineId, console);
execAgentCommandManager.startProcess(machineId, expandedCommand).then(startResonse -> {
if (!startResonse.getAlive()) {
reject.apply(promiseFromThrowable(new Throwable(PROJECT_BUILD_NOT_STARTED_MESSAGE)));
}
}).thenIfProcessStartedEvent(console.getProcessStartedOperation()).thenIfProcessStdErrEvent(evt -> {
if (evt.getText().contains("BUILD SUCCESS")) {
compiled = true;
}
console.getStdErrOperation().apply(evt);
}).thenIfProcessStdOutEvent(evt -> {
if (evt.getText().contains("BUILD SUCCESS")) {
compiled = true;
}
console.getStdOutOperation().apply(evt);
}).thenIfProcessDiedEvent(evt -> {
console.getProcessDiedOperation().apply(evt);
if (compiled) {
if (statusNotification != null) {
statusNotification.setContent(EXECUTING_TESTS_MESSAGE);
}
sendTests(projectPath, testFramework, parameters).then(new Operation<TestResult>() {
@Override
public void apply(TestResult result) throws OperationException {
resolve.apply(result);
}
});
} else {
reject.apply(promiseFromThrowable(new Throwable(PROJECT_BUILD_FAILED_MESSAGE)));
}
});
}
});
}
});
});
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class TestResultViewImpl method gotoClass.
@Override
public void gotoClass(String packagePath, int line) {
lastWentLine = line;
final Project project = appContext.getRootProject();
String testSrcPath = project.getPath() + "/" + DEFAULT_TEST_SOURCE_FOLDER;
appContext.getWorkspaceRoot().getFile(testSrcPath + packagePath).then(new Operation<Optional<File>>() {
@Override
public void apply(Optional<File> file) throws OperationException {
if (file.isPresent()) {
eventBus.fireEvent(FileEvent.createOpenFileEvent(file.get()));
Timer t = new Timer() {
@Override
public void run() {
EditorPartPresenter editorPart = editorAgent.getActiveEditor();
Document doc = ((TextEditor) editorPart).getDocument();
doc.setCursorPosition(new TextPosition(lastWentLine - 1, 0));
}
};
t.schedule(500);
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
Log.info(TestResultViewImpl.class, error);
}
});
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class RemovePresenter method showRemove.
public void showRemove() {
final Project project = appContext.getRootProject();
checkState(project != null);
final Resource[] resources = appContext.getResources();
checkState(!Arrays.isNullOrEmpty(resources));
final StatusNotification notification = new StatusNotification(constants.removeStarted(resources.length), PROGRESS, FLOAT_MODE);
notificationManager.notify(notification);
service.remove(project.getLocation(), toRelative(project, resources)).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandRemove());
notification.setTitle(constants.removeSuccessful());
notification.setStatus(SUCCESS);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
notification.setTitle(constants.removeFailed());
notification.setStatus(FAIL);
}
});
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class ResolvePresenter method onResolveClicked.
@Override
public void onResolveClicked() {
final Project project = appContext.getRootProject();
checkState(project != null);
HashMap<String, String> filesConflictResolutionActions = new HashMap<String, String>();
Iterator<String> iterConflicts = conflictsList.iterator();
while (iterConflicts.hasNext()) {
String path = iterConflicts.next();
String resolutionActionText = view.getConflictResolutionAction(path);
if (!resolutionActionText.equals(ConflictResolutionAction.POSTPONE.getText())) {
filesConflictResolutionActions.put(path, resolutionActionText);
iterConflicts.remove();
}
}
if (filesConflictResolutionActions.size() > 0) {
service.resolve(project.getLocation(), filesConflictResolutionActions, "infinity").then(new Operation<CLIOutputResponseList>() {
@Override
public void apply(CLIOutputResponseList response) throws OperationException {
for (CLIOutputResponse outputResponse : response.getCLIOutputResponses()) {
printResponse(outputResponse.getCommand(), outputResponse.getOutput(), null, constants.commandResolve());
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
}
});
}
view.close();
}
Aggregations