use of org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole in project che by eclipse.
the class AddToIndexAction method addToIndex.
private void addToIndex(final GitOutputConsole console) {
Resource[] resources = appContext.getResources();
Path[] paths = new Path[resources.length];
for (int i = 0; i < resources.length; i++) {
Path path = resources[i].getLocation().removeFirstSegments(1);
paths[i] = path.segmentCount() == 0 ? Path.EMPTY : path;
}
service.add(appContext.getDevMachine(), appContext.getRootProject().getLocation(), false, paths).then(voidArg -> {
console.print(constant.addSuccess());
notificationManager.notify(constant.addSuccess());
}).catchError(error -> {
console.printError(constant.addFailed());
notificationManager.notify(constant.addFailed(), FAIL, FLOAT_MODE);
});
}
use of org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole in project che by eclipse.
the class PullPresenter method handleError.
/**
* Handler some action whether some exception happened.
*
* @param exception
* exception that happened
* @param commandName
* name of the command
*/
private void handleError(@NotNull Throwable exception, @NotNull String commandName) {
int errorCode = getErrorCode(exception);
if (errorCode == ErrorCodes.NO_COMMITTER_NAME_OR_EMAIL_DEFINED) {
dialogFactory.createMessageDialog(constant.pullTitle(), constant.committerIdentityInfoEmpty(), null).show();
return;
} else if (errorCode == ErrorCodes.UNABLE_GET_PRIVATE_SSH_KEY) {
dialogFactory.createMessageDialog(constant.pullTitle(), constant.messagesUnableGetSshKey(), null).show();
return;
}
String errorMessage = exception.getMessage();
if (errorMessage == null) {
switch(commandName) {
case REMOTE_REPO_COMMAND_NAME:
errorMessage = constant.remoteListFailed();
break;
case BRANCH_LIST_COMMAND_NAME:
errorMessage = constant.branchesListFailed();
break;
case PULL_COMMAND_NAME:
errorMessage = constant.pullFail(view.getRepositoryUrl());
break;
}
}
GitOutputConsole console = gitOutputConsoleFactory.create(commandName);
console.printError(errorMessage);
consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
notificationManager.notify(errorMessage, FAIL, FLOAT_MODE);
}
use of org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole in project che by eclipse.
the class PushToRemotePresenter method updateRemoteBranches.
/**
* Update list of remote branches on view.
*/
void updateRemoteBranches() {
getBranchesForCurrentProject(LIST_REMOTE, new AsyncCallback<List<Branch>>() {
@Override
public void onSuccess(final List<Branch> result) {
// Need to add the upstream of local branch in the list of remote branches
// to be able to push changes to the remote upstream branch
getUpstreamBranch(new AsyncCallback<Branch>() {
@Override
public void onSuccess(Branch upstream) {
BranchFilterByRemote remoteRefsHandler = new BranchFilterByRemote(view.getRepository());
final List<String> remoteBranches = branchSearcher.getRemoteBranchesToDisplay(remoteRefsHandler, result);
String selectedRemoteBranch = null;
if (upstream != null && upstream.isRemote() && remoteRefsHandler.isLinkedTo(upstream)) {
String simpleUpstreamName = remoteRefsHandler.getBranchNameWithoutRefs(upstream);
if (!remoteBranches.contains(simpleUpstreamName)) {
remoteBranches.add(simpleUpstreamName);
}
selectedRemoteBranch = simpleUpstreamName;
}
// Need to add the current local branch in the list of remote branches
// to be able to push changes to the remote branch with same name
final String currentBranch = view.getLocalBranch();
if (!remoteBranches.contains(currentBranch)) {
remoteBranches.add(currentBranch);
}
if (selectedRemoteBranch == null) {
selectedRemoteBranch = currentBranch;
}
view.setRemoteBranches(remoteBranches);
view.selectRemoteBranch(selectedRemoteBranch);
}
@Override
public void onFailure(Throwable caught) {
GitOutputConsole console = gitOutputConsoleFactory.create(CONFIG_COMMAND_NAME);
console.printError(constant.failedGettingConfig());
processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
notificationManager.notify(constant.failedGettingConfig(), FAIL, FLOAT_MODE);
}
});
}
@Override
public void onFailure(Throwable exception) {
String errorMessage = exception.getMessage() != null ? exception.getMessage() : constant.remoteBranchesListFailed();
GitOutputConsole console = gitOutputConsoleFactory.create(BRANCH_LIST_COMMAND_NAME);
console.printError(errorMessage);
processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
notificationManager.notify(constant.remoteBranchesListFailed(), FAIL, FLOAT_MODE);
view.setEnablePushButton(false);
}
});
}
use of org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole 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.ide.ext.git.client.outputconsole.GitOutputConsole 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