use of org.eclipse.che.ide.ext.git.client.BranchFilterByRemote 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);
}
});
}
Aggregations