use of org.eclipse.che.ide.api.subversion.Credentials 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.ide.api.subversion.Credentials 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);
}
});
}
use of org.eclipse.che.ide.api.subversion.Credentials in project che by eclipse.
the class CopyPresenter method onCopyClicked.
/** {@inheritDoc} */
@Override
public void onCopyClicked() {
final Project project = appContext.getRootProject();
Preconditions.checkState(project != null);
final Path src = view.isSourceCheckBoxSelected() ? Path.valueOf(view.getSourcePath()) : toRelative(project, sourceNode);
final Path target = view.isTargetCheckBoxSelected() ? Path.valueOf(view.getTargetUrl()) : toRelative(project, this.target);
final String comment = view.isTargetCheckBoxSelected() ? view.getComment() : null;
final StatusNotification notification = new StatusNotification(constants.copyNotificationStarted(src.toString()), PROGRESS, FLOAT_MODE);
notificationManager.notify(notification);
view.hide();
performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputResponse>() {
@Override
public Promise<CLIOutputResponse> perform(Credentials credentials) {
notification.setStatus(PROGRESS);
notification.setTitle(constants.copyNotificationStarted(src.toString()));
return service.copy(project.getLocation(), src, target, comment, credentials);
}
}, notification).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandCopy());
notification.setTitle(constants.copyNotificationSuccessful());
notification.setStatus(SUCCESS);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notification.setTitle(constants.copyNotificationFailed());
notification.setStatus(FAIL);
}
});
}
use of org.eclipse.che.ide.api.subversion.Credentials in project che by eclipse.
the class LockUnlockPresenter method doLockAction.
private void doLockAction(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.lock(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.commandLock());
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
}
});
}
use of org.eclipse.che.ide.api.subversion.Credentials in project che by eclipse.
the class MergePresenter method merge.
/**
* Prepares to merging and opens Merge dialog.
*/
public void merge() {
view.enableMergeButton(false);
view.sourceCheckBox().setValue(false);
final Project project = appContext.getRootProject();
checkState(project != null);
final Resource[] resources = appContext.getResources();
checkState(resources != null && resources.length == 1);
performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<InfoResponse>() {
@Override
public Promise<InfoResponse> perform(Credentials credentials) {
return service.info(project.getLocation(), toRelative(project, resources[0]).toString(), "HEAD", false, credentials);
}
}, null).then(new Operation<InfoResponse>() {
@Override
public void apply(InfoResponse response) throws OperationException {
if (response.getErrorOutput() != null && !response.getErrorOutput().isEmpty()) {
printErrors(response.getErrorOutput(), constants.commandInfo());
notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE);
return;
}
mergeTarget = response.getItems().get(0);
view.targetTextBox().setValue(mergeTarget.getRelativeURL());
String repositoryRoot = mergeTarget.getRepositoryRoot();
service.info(project.getLocation(), repositoryRoot, "HEAD", true).then(new Operation<InfoResponse>() {
@Override
public void apply(InfoResponse response) throws OperationException {
if (!response.getErrorOutput().isEmpty()) {
printErrors(response.getErrorOutput(), constants.commandInfo());
notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE);
return;
}
sourceURL = response.getItems().get(0).getURL();
SubversionItemNode subversionTreeNode = new SubversionItemNode(response.getItems().get(0));
List<Node> children = new ArrayList<>();
if (response.getItems().size() > 1) {
for (int i = 1; i < response.getItems().size(); i++) {
SubversionItem item = response.getItems().get(i);
if (!"file".equals(item.getNodeKind())) {
children.add(new SubversionItemNode(item));
}
}
}
subversionTreeNode.setChildren(children);
view.setRootNode(subversionTreeNode);
view.show();
validateSourceURL();
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
}
});
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
}
});
}
Aggregations