use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.
the class ExportPresenter method onExportClicked.
/** {@inheritDoc} */
@Override
public void onExportClicked() {
final Project project = appContext.getRootProject();
checkState(project != null);
final Resource[] resources = appContext.getResources();
checkState(!Arrays.isNullOrEmpty(resources));
checkState(resources.length == 1);
final String givenRevision = view.isRevisionSpecified() ? view.getRevision() : null;
final StatusNotification notification = new StatusNotification(constants.exportStarted(resources[0].getLocation().toString()), PROGRESS, FLOAT_MODE);
notificationManager.notify(notification);
view.onClose();
if (!isNullOrEmpty(givenRevision)) {
service.getRevisions(project.getLocation(), toRelative(project, resources[0]), "1:HEAD").then(new Operation<GetRevisionsResponse>() {
@Override
public void apply(GetRevisionsResponse response) throws OperationException {
final List<String> pathRevisions = response.getRevisions();
if (pathRevisions.size() > 0) {
final String pathFirstRevision = pathRevisions.get(0);
final String pathLastRevision = pathRevisions.get(pathRevisions.size() - 1);
final int givenRevisionNb = Integer.valueOf(givenRevision);
final int pathFirstRevisionNb = Integer.valueOf(pathFirstRevision.substring(1));
final int pathLastRevisionNb = Integer.valueOf(pathLastRevision.substring(1));
final List<String> errOutput = response.getErrOutput();
if (errOutput != null && !errOutput.isEmpty()) {
printErrors(errOutput, constants.commandInfo());
notification.setTitle(constants.exportCommandExecutionError());
notification.setStatus(FAIL);
} else if (givenRevisionNb < pathFirstRevisionNb || givenRevisionNb > pathLastRevisionNb) {
notification.setTitle(constants.exportRevisionDoNotExistForPath(givenRevision, toRelative(project, resources[0]).toString()));
notification.setStatus(FAIL);
} else {
openExportPopup(project.getLocation(), toRelative(project, resources[0]), givenRevision, notification);
}
} else {
notification.setTitle(constants.exportNoRevisionForPath(toRelative(project, resources[0]).toString()));
notification.setStatus(FAIL);
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notification.setTitle(constants.exportCommandExecutionError() + "\n" + error.getMessage());
notification.setStatus(FAIL);
}
});
} else {
openExportPopup(project.getLocation(), toRelative(project, resources[0]), null, notification);
}
}
use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.
the class LockUnlockPresenter method doUnlockAction.
private void doUnlockAction(final boolean force, final Path[] paths) {
final Project project = appContext.getRootProject();
checkState(project != null);
performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputResponse>() {
@Override
public Promise<CLIOutputResponse> perform(Credentials credentials) {
return service.unlock(project.getLocation(), paths, force, credentials);
}
}, null).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandUnlock());
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
}
});
}
use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.
the class CleanupPresenter method cleanup.
public void cleanup() {
final Project project = appContext.getRootProject();
checkState(project != null);
final Resource[] resources = appContext.getResources();
checkState(!Arrays.isNullOrEmpty(resources));
service.cleanup(project.getLocation(), toRelative(project, resources)).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse result) throws OperationException {
printResponse(result.getCommand(), result.getOutput(), result.getErrOutput(), constants.commandCleanup());
notificationManager.notify(constants.cleanupSuccessful());
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(constants.cleanupFailed() + ": " + error.getMessage(), FAIL, FLOAT_MODE);
}
});
}
use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.
the class CommitPresenter method loadAllChanges.
private void loadAllChanges() {
final Project project = appContext.getRootProject();
checkState(project != null);
service.status(project.getLocation(), new Path[0], null, false, false, false, true, false, null).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
List<StatusItem> statusItems = parseChangesList(response);
view.setChangesList(statusItems);
view.onShow();
cache.put(Changes.ALL, statusItems);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
Log.error(CommitPresenter.class, error.getMessage());
}
});
}
use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.
the class CommitPresenter method showDiff.
/** {@inheritDoc} */
@Override
public void showDiff(final String path) {
final Project project = appContext.getRootProject();
checkState(project != null);
performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputResponse>() {
@Override
public Promise<CLIOutputResponse> perform(Credentials credentials) {
return service.showDiff(project.getLocation(), new Path[] { valueOf(path) }, "HEAD", credentials);
}
}, null).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
String content = Joiner.on('\n').join(response.getOutput());
diffViewerPresenter.showDiff(content);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
}
});
}
Aggregations