use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.
the class BranchPresenter method onCheckoutClicked.
/** {@inheritDoc} */
@Override
public void onCheckoutClicked() {
final CheckoutRequest checkoutRequest = dtoFactory.createDto(CheckoutRequest.class);
if (selectedBranch.isRemote()) {
checkoutRequest.setTrackBranch(selectedBranch.getDisplayName());
} else {
checkoutRequest.setName(selectedBranch.getDisplayName());
}
service.checkout(appContext.getDevMachine(), project.getLocation(), checkoutRequest).then(new Operation<Void>() {
@Override
public void apply(Void ignored) throws OperationException {
getBranches();
project.synchronize();
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
handleError(error.getCause(), BRANCH_CHECKOUT_COMMAND_NAME);
}
});
}
use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.
the class CommitPresenter method setAmendCommitMessage.
/** {@inheritDoc} */
@Override
public void setAmendCommitMessage() {
service.log(appContext.getDevMachine(), project.getLocation(), null, false).then(new Operation<LogResponse>() {
@Override
public void apply(LogResponse log) throws OperationException {
final List<Revision> commits = log.getCommits();
String message = "";
if (commits != null && (!commits.isEmpty())) {
final Revision tip = commits.get(0);
if (tip != null) {
message = tip.getMessage();
}
}
CommitPresenter.this.view.setMessage(message);
CommitPresenter.this.view.setEnableCommitButton(!message.isEmpty());
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
if (getErrorCode(error.getCause()) == ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED) {
dialogFactory.createMessageDialog(constant.commitTitle(), constant.initCommitWasNotPerformed(), null).show();
} else {
CommitPresenter.this.view.setMessage("");
notificationManager.notify(constant.logFailed(), FAIL, NOT_EMERGE_MODE);
}
}
});
}
use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.
the class ComparePresenter method showCompareBetweenRevisions.
/**
*
* @param file
* path of the file
* @param status
* status of the file
* @param revisionA
* hash of the first revision or branch.
* If it is set to {@code null}, compare with empty repository state will be performed
* @param revisionB
* hash of the second revision or branch.
* If it is set to {@code null}, compare with latest repository state will be performed
*/
public void showCompareBetweenRevisions(final Path file, final Status status, @Nullable final String revisionA, @Nullable final String revisionB) {
this.compareWithLatest = false;
final DevMachine devMachine = appContext.getDevMachine();
final Path projectLocation = appContext.getRootProject().getLocation();
view.setTitle(file.toString());
if (status == Status.ADDED) {
service.showFileContent(devMachine, projectLocation, file, revisionB).then(new Operation<ShowFileContentResponse>() {
@Override
public void apply(ShowFileContentResponse response) throws OperationException {
view.setColumnTitles(revisionB + locale.compareReadOnlyTitle(), revisionA == null ? "" : revisionA + locale.compareReadOnlyTitle());
view.show("", response.getContent(), file.toString(), true);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, NOT_EMERGE_MODE);
}
});
} else if (status == Status.DELETED) {
service.showFileContent(devMachine, projectLocation, file, revisionA).then(new Operation<ShowFileContentResponse>() {
@Override
public void apply(ShowFileContentResponse response) throws OperationException {
view.setColumnTitles(revisionB + locale.compareReadOnlyTitle(), revisionA + locale.compareReadOnlyTitle());
view.show(response.getContent(), "", file.toString(), true);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, NOT_EMERGE_MODE);
}
});
} else {
service.showFileContent(devMachine, projectLocation, file, revisionA).then(new Operation<ShowFileContentResponse>() {
@Override
public void apply(final ShowFileContentResponse contentAResponse) throws OperationException {
service.showFileContent(devMachine, projectLocation, file, revisionB).then(new Operation<ShowFileContentResponse>() {
@Override
public void apply(ShowFileContentResponse contentBResponse) throws OperationException {
view.setColumnTitles(revisionB + locale.compareReadOnlyTitle(), revisionA + locale.compareReadOnlyTitle());
view.show(contentAResponse.getContent(), contentBResponse.getContent(), file.toString(), true);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, NOT_EMERGE_MODE);
}
});
}
});
}
}
use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.
the class PullPresenter method updateBranches.
/**
* Update the list of branches.
*
* @param remoteMode
* is a remote mode
*/
private void updateBranches(@NotNull final BranchListMode remoteMode) {
service.branchList(appContext.getDevMachine(), project.getLocation(), remoteMode).then(new Operation<List<Branch>>() {
@Override
public void apply(List<Branch> branches) throws OperationException {
if (LIST_REMOTE.equals(remoteMode)) {
view.setRemoteBranches(branchSearcher.getRemoteBranchesToDisplay(view.getRepositoryName(), branches));
updateBranches(LIST_LOCAL);
} else {
view.setLocalBranches(branchSearcher.getLocalBranchesToDisplay(branches));
for (Branch branch : branches) {
if (branch.isActive()) {
view.selectRemoteBranch(branch.getDisplayName());
break;
}
}
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
handleError(error.getCause(), BRANCH_LIST_COMMAND_NAME);
view.setEnablePullButton(false);
}
});
}
use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.
the class PushToRemotePresenter method onPushClicked.
/** {@inheritDoc} */
@Override
public void onPushClicked() {
final StatusNotification notification = notificationManager.notify(constant.pushProcess(), PROGRESS, FLOAT_MODE);
final String repository = view.getRepository();
final GitOutputConsole console = gitOutputConsoleFactory.create(PUSH_COMMAND_NAME);
service.push(appContext.getDevMachine(), project.getLocation(), getRefs(), repository, false).then(new Operation<PushResponse>() {
@Override
public void apply(PushResponse response) throws OperationException {
console.print(response.getCommandOutput());
processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
notification.setStatus(SUCCESS);
if (response.getCommandOutput().contains("Everything up-to-date")) {
notification.setTitle(constant.pushUpToDate());
} else {
notification.setTitle(constant.pushSuccess(repository));
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
handleError(error.getCause(), notification, console);
processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
}
});
view.close();
}
Aggregations