use of org.eclipse.che.api.promises.client.Operation in project che by eclipse.
the class DebuggerPresenter method updateStackFrameDump.
private void updateStackFrameDump() {
Debugger debugger = debuggerManager.getActiveDebugger();
if (debugger != null && executionPoint != null) {
Promise<StackFrameDump> promise = debugger.dumpStackFrame();
promise.then(new Operation<StackFrameDump>() {
@Override
public void apply(StackFrameDump arg) throws OperationException {
variables = new ArrayList<>();
variables.addAll(arg.getFields());
variables.addAll(arg.getVariables());
view.setVariables(variables);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
Log.error(DebuggerPresenter.class, arg.getCause());
}
});
}
}
use of org.eclipse.che.api.promises.client.Operation in project che by eclipse.
the class DocumentStorageImpl method saveDocument.
@Override
public void saveDocument(final EditorInput editorInput, @NotNull final Document document, final boolean overwrite, @NotNull final AsyncCallback<EditorInput> callback) {
final VirtualFile file = editorInput.getFile();
file.updateContent(document.getContents()).then(new Operation<Void>() {
@Override
public void apply(Void arg) throws OperationException {
Log.debug(DocumentStorageImpl.class, "Document saved (" + file.getLocation() + ").");
DocumentStorageImpl.this.eventBus.fireEvent(FileEvent.createSaveFileEvent(file));
try {
callback.onSuccess(editorInput);
} catch (final Exception e) {
Log.warn(DocumentStorageImpl.class, "Exception during save success callback: ", e);
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
Log.error(DocumentStorageImpl.class, "Document save failed (" + file.getLocation() + ").", arg.getCause());
try {
callback.onFailure(arg.getCause());
} catch (final Exception e) {
Log.warn(DocumentStorageImpl.class, "Exception during save failure callback: ", e);
}
}
});
}
use of org.eclipse.che.api.promises.client.Operation in project che by eclipse.
the class AddRemoteRepositoryPresenter method onOkClicked.
/** {@inheritDoc} */
@Override
public void onOkClicked() {
final String name = view.getName();
final String url = view.getUrl().trim();
final Project project = appContext.getRootProject();
service.remoteAdd(appContext.getDevMachine(), project.getLocation(), name, url).then(new Operation<Void>() {
@Override
public void apply(Void arg) throws OperationException {
callback.onSuccess(null);
view.close();
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
callback.onFailure(error.getCause());
}
});
}
use of org.eclipse.che.api.promises.client.Operation in project che by eclipse.
the class RemoveFromIndexPresenter method onRemoveClicked.
/** {@inheritDoc} */
@Override
public void onRemoveClicked() {
final GitOutputConsole console = gitOutputConsoleFactory.create(REMOVE_FROM_INDEX_COMMAND_NAME);
final Resource[] resources = appContext.getResources();
checkState(!isNullOrEmpty(resources));
service.remove(appContext.getDevMachine(), project.getLocation(), toRelativePaths(resources), view.isRemoved()).then(new Operation<Void>() {
@Override
public void apply(Void ignored) throws OperationException {
console.print(constant.removeFilesSuccessfull());
consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
notificationManager.notify(constant.removeFilesSuccessfull());
project.synchronize();
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
handleError(error.getCause(), console);
consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
}
});
view.close();
}
use of org.eclipse.che.api.promises.client.Operation in project che by eclipse.
the class ResetToCommitPresenter method reset.
/**
* Reset current HEAD to the specified state and refresh project in the success case.
*/
private void reset() {
ResetRequest.ResetType type = view.isMixMode() ? ResetRequest.ResetType.MIXED : null;
type = (type == null && view.isSoftMode()) ? ResetRequest.ResetType.SOFT : type;
type = (type == null && view.isHardMode()) ? ResetRequest.ResetType.HARD : type;
final GitOutputConsole console = gitOutputConsoleFactory.create(RESET_COMMAND_NAME);
service.reset(appContext.getDevMachine(), project.getLocation(), selectedRevision.getId(), type, null).then(new Operation<Void>() {
@Override
public void apply(Void ignored) throws OperationException {
console.print(constant.resetSuccessfully());
consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
notificationManager.notify(constant.resetSuccessfully());
project.synchronize();
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
String errorMessage = (error.getMessage() != null) ? error.getMessage() : constant.resetFail();
console.printError(errorMessage);
consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
notificationManager.notify(constant.resetFail(), FAIL, FLOAT_MODE);
}
});
}
Aggregations