CHE-414: Display staged changes in green when status called

6.19.x
Igor Vinokur 2016-03-02 14:54:04 +02:00
parent 9b55d567c4
commit 2dd77ecf21
35 changed files with 255 additions and 212 deletions

View File

@ -88,8 +88,6 @@ import org.eclipse.che.git.impl.nativegit.ssh.GitSshScriptProvider;
import java.io.File;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Pattern;
@ -104,14 +102,19 @@ import static org.eclipse.che.api.git.shared.ProviderInfo.PROVIDER_NAME;
*/
public class NativeGitConnection implements GitConnection {
private static final Pattern authErrorPattern =
Pattern.compile(
".*fatal: could not read (Username|Password) for '.*': No such device or address.*|" +
".*fatal: could not read (Username|Password) for '.*': Input/output error.*|" +
".*fatal: Authentication failed for '.*'.*|.*fatal: Could not read from remote repository\\.\\n\\nPlease make sure " +
"you have the correct access rights\\nand the repository exists\\.\\n.*",
Pattern.MULTILINE);
private static final Pattern notInGitRepoErrorPattern = Pattern.compile("^fatal: Not a git repository.*(\\n.*)*$", Pattern.MULTILINE);
private static final Pattern authErrorPattern =
Pattern.compile(
".*fatal: could not read (Username|Password) for '.*': No such device or address.*|" +
".*fatal: could not read (Username|Password) for '.*': Input/output error.*|" +
".*fatal: Authentication failed for '.*'.*|.*fatal: Could not read from remote repository\\.\\n\\nPlease make sure " +
"you have the correct access rights\\nand the repository exists\\.\\n.*",
Pattern.MULTILINE);
private static final Pattern notInGitRepoErrorPattern =
Pattern.compile("^fatal: Not a git repository.*(\\n.*)*$", Pattern.MULTILINE);
private static final Pattern noInitCommitWhenBranchCreateErrorPattern = Pattern.compile("fatal: Not a valid object name: '.*'.\n");
private static final Pattern noInitCommitWhenLogErrorPattern =
Pattern.compile("fatal: your current branch '.*' does not have any commits yet\n");
private static final Pattern noInitCommitWhenPullErrorPattern = Pattern.compile("fatal: empty ident name .* not allowed\n");
private final NativeGit nativeGit;
private final CredentialsLoader credentialsLoader;
private final GitUserResolver userResolver;
@ -180,8 +183,7 @@ public class NativeGitConnection implements GitConnection {
try {
branchCreateCommand.execute();
} catch (ServerException exception) {
Pattern errorPattern = Pattern.compile("fatal: Not a valid object name: '.*'.\n");
if (errorPattern.matcher(exception.getMessage()).find()) {
if (noInitCommitWhenBranchCreateErrorPattern.matcher(exception.getMessage()).find()) {
throw new GitException(exception.getMessage(), ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED);
}
}
@ -373,8 +375,7 @@ public class NativeGitConnection implements GitConnection {
try {
return new LogPage(nativeGit.createLogCommand().setFileFilter(request.getFileFilter()).execute());
} catch (ServerException exception) {
Pattern errorPattern = Pattern.compile("fatal: your current branch '.*' does not have any commits yet\n");
if (errorPattern.matcher(exception.getMessage()).find()) {
if (noInitCommitWhenLogErrorPattern.matcher(exception.getMessage()).find()) {
throw new GitException(exception.getMessage(), ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED);
} else {
throw exception;
@ -422,7 +423,20 @@ public class NativeGitConnection implements GitConnection {
.setRemoteUri(remoteUri)
.setTimeout(request.getTimeout());
executeRemoteCommand(pullCommand);
try {
executeRemoteCommand(pullCommand);
} catch (GitException exception) {
if (noInitCommitWhenPullErrorPattern.matcher(exception.getMessage()).find()) {
throw new GitException(exception.getMessage(), ErrorCodes.NO_COMMITTER_NAME_OR_EMAIL_DEFINED);
} else if ("Unable get private ssh key".equals(exception.getMessage())) {
throw new GitException(exception.getMessage(), ErrorCodes.UNABLE_GET_PRIVATE_SSH_KEY);
} else if (("Auto-merging file\nCONFLICT (content): Merge conflict in file\n" +
"Automatic merge failed; fix conflicts and then commit the result.\n").equals(exception.getMessage())) {
throw new GitException(exception.getMessage(), ErrorCodes.MERGE_CONFLICT);
} else {
throw exception;
}
}
return pullCommand.getPullResponse();
}

View File

@ -564,4 +564,16 @@ public class Style {
return theme.getListBoxDropdownBackgroundColor();
}
public static String getGitConsoleStagedFilesColor() {
return theme.gitConsoleStagedFilesColor();
}
public static String getGitConsoleUnstagedFilesColor() {
return theme.gitConsoleUnstagedFilesColor();
}
public static String getGitConsoleErrorColor() {
return theme.gitConsoleErrorColor();
}
}

View File

@ -1457,4 +1457,12 @@ public interface Theme {
String toolButtonHoverBoxShadow();
String toolButtonActiveBoxShadow();
/********************************************************************************************
*
* Git output console
*
********************************************************************************************/
String gitConsoleStagedFilesColor();
String gitConsoleUnstagedFilesColor();
String gitConsoleErrorColor();
}

View File

@ -1439,4 +1439,19 @@ public class DarkTheme implements Theme {
public String toolButtonActiveBoxShadow() {
return "inset 1px 1px 0 0 #3c3c3c";
}
@Override
public String gitConsoleStagedFilesColor() {
return "lightgreen";
}
@Override
public String gitConsoleUnstagedFilesColor() {
return "#F62217";
}
@Override
public String gitConsoleErrorColor() {
return "#F62217";
}
}

View File

@ -1416,4 +1416,19 @@ public class LightTheme implements Theme {
public String toolButtonActiveBoxShadow() {
return "inset 1px 1px 0 0 #6F6E6E";
}
@Override
public String gitConsoleStagedFilesColor() {
return "green";
}
@Override
public String gitConsoleUnstagedFilesColor() {
return "red";
}
@Override
public String gitConsoleErrorColor() {
return "red";
}
}

View File

@ -22,6 +22,7 @@ public class ErrorCodes {
public static final int NO_COMMITTER_NAME_OR_EMAIL_DEFINED = 15216;
public static final int UNABLE_GET_PRIVATE_SSH_KEY = 32068;
public static final int UNAUTHORIZED_GIT_OPERATION = 32080;
public static final int MERGE_CONFLICT = 32062;
public static final int FAILED_CHECKOUT = 32063;
public static final int FAILED_CHECKOUT_WITH_START_POINT = 32064;
public static final int INIT_COMMIT_WAS_NOT_PERFORMED = 32082;

View File

@ -29,34 +29,59 @@ public interface Status {
void setBranchName(String branchName);
/**
* New files that are staged in index.
*/
List<String> getAdded();
void setAdded(List<String> added);
List<String> getChanged();
void setChanged(List<String> changed);
List<String> getRemoved();
void setRemoved(List<String> removed);
List<String> getMissing();
void setMissing(List<String> missing);
List<String> getModified();
void setModified(List<String> modified);
/**
* New files that are not staged in index.
*/
List<String> getUntracked();
void setUntracked(List<String> untracked);
/**
* Modified files that are staged in index.
*/
List<String> getChanged();
void setChanged(List<String> changed);
/**
* Modified files that are not staged in index.
*/
List<String> getModified();
void setModified(List<String> modified);
/**
* Deleted files that are staged in index.
*/
List<String> getRemoved();
void setRemoved(List<String> removed);
/**
* Deleted files that are not staged in index.
*/
List<String> getMissing();
void setMissing(List<String> missing);
/**
* Folders that contain only untracked files.
* @see #getUntracked()
*/
List<String> getUntrackedFolders();
void setUntrackedFolders(List<String> untrackedFolders);
/**
* Files that have conflicts.
*/
List<String> getConflicting();
void setConflicting(List<String> added);

View File

@ -115,7 +115,7 @@ public class AddToIndexPresenter implements AddToIndexView.ActionDelegate {
if (!result.isClean()) {
addSelection();
} else {
console.printInfo(constant.nothingAddToIndex());
console.print(constant.nothingAddToIndex());
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
notificationManager.notify(constant.nothingAddToIndex(), project.getRootProject());
}
@ -181,7 +181,7 @@ public class AddToIndexPresenter implements AddToIndexView.ActionDelegate {
@Override
protected void onSuccess(final Void result) {
console.printInfo(constant.addSuccess());
console.print(constant.addSuccess());
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
notificationManager.notify(constant.addSuccess(), project.getRootProject());
}

View File

@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.che.ide.ext.git.client.branch;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.web.bindery.event.shared.EventBus;

View File

@ -231,7 +231,7 @@ public class CommitPresenter implements CommitView.ActionDelegate {
message += " " + constant.commitUser(revision.getCommitter().getName());
}
GitOutputConsole console = gitOutputConsoleFactory.create(COMMIT_COMMAND_NAME);
console.printInfo(message);
console.print(message);
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
notificationManager.notify(message, appContext.getCurrentProject().getRootProject());
view.setMessage("");

View File

@ -88,7 +88,7 @@ public class DeleteRepositoryPresenter {
service.deleteRepository(workspaceId, project.getRootProject(), new AsyncRequestCallback<Void>() {
@Override
protected void onSuccess(Void result) {
console.printInfo(constant.deleteGitRepositorySuccess());
console.print(constant.deleteGitRepositorySuccess());
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
notificationManager.notify(constant.deleteGitRepositorySuccess(), project.getRootProject());
getRootProject(project.getRootProject());

View File

@ -178,7 +178,7 @@ public class FetchPresenter implements FetchView.ActionDelegate {
new RequestCallback<String>() {
@Override
protected void onSuccess(String result) {
console.printInfo(constant.fetchSuccess(remoteUrl));
console.print(constant.fetchSuccess(remoteUrl));
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
notification.setStatus(SUCCESS);
notification.setTitle(constant.fetchSuccess(remoteUrl));

View File

@ -92,7 +92,7 @@ public class InitRepositoryPresenter {
@Override
public void onSuccess(Void result) {
console.printInfo(constant.initSuccess());
console.print(constant.initSuccess());
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
notificationManager.notify(constant.initSuccess(), currentProject.getRootProject());
getRootProject(currentProject.getRootProject());

View File

@ -179,7 +179,7 @@ public class MergePresenter implements MergeView.ActionDelegate {
new AsyncRequestCallback<MergeResult>(dtoUnmarshallerFactory.newUnmarshaller(MergeResult.class)) {
@Override
protected void onSuccess(final MergeResult result) {
console.printInfo(formMergeMessage(result));
console.print(formMergeMessage(result));
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
notificationManager.notify(formMergeMessage(result), appContext.getCurrentProject().getRootProject());
refreshProject(openedEditors);

View File

@ -21,9 +21,8 @@ import javax.validation.constraints.NotNull;
* @author Roman Nikitenko
*/
public interface GitOutputConsole extends OutputConsole {
/**
* Print text on console.
* Print text in console.
*
* @param text
* text that need to be shown
@ -31,25 +30,22 @@ public interface GitOutputConsole extends OutputConsole {
void print(@NotNull String text);
/**
* [INFO] text
* Print colored text in console.
*
* @param text
* text that need to be shown
* @param color
* color of printed text
*/
void printInfo(String text);
void print(@NotNull String text, @NotNull String color);
/**
* [ERROR] text
* Print error in console.
*
* @param text
* text that need to be shown as error
*/
void printError(String text);
/**
* [WARNING] text
*
* @param text
*/
void printWarn(String text);
void printError(@NotNull String text);
/** Clear console. Remove all messages. */
void clear();

View File

@ -15,6 +15,7 @@ import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.theme.Style;
import org.eclipse.che.ide.ext.git.client.GitLocalizationConstant;
import org.eclipse.che.ide.ext.git.client.GitResources;
import org.vectomatic.dom.svg.ui.SVGResource;
@ -77,6 +78,21 @@ public class GitOutputConsolePresenter implements GitOutputPartView.ActionDelega
}
}
@Override
public void print(String text, String color) {
view.print(text, color);
view.scrollBottom();
for (ConsoleOutputListener outputListener : outputListeners) {
outputListener.onConsoleOutput(this);
}
}
@Override
public void printError(String text) {
print(text, Style.getGitConsoleErrorColor());
}
/** {@inheritDoc} */
public void clear() {
view.clear();
@ -93,33 +109,6 @@ public class GitOutputConsolePresenter implements GitOutputPartView.ActionDelega
view.scrollBottom();
}
public void printInfo(String text) {
view.printInfo(text);
view.scrollBottom();
for (ConsoleOutputListener outputListener : outputListeners) {
outputListener.onConsoleOutput(this);
}
}
public void printWarn(String text) {
view.printWarn(text);
view.scrollBottom();
for (ConsoleOutputListener outputListener : outputListeners) {
outputListener.onConsoleOutput(this);
}
}
public void printError(String text) {
view.printError(text);
view.scrollBottom();
for (ConsoleOutputListener outputListener : outputListeners) {
outputListener.onConsoleOutput(this);
}
}
@Override
public String getTitle() {
return title;

View File

@ -37,14 +37,17 @@ public interface GitOutputPartView extends View<GitOutputPartView.ActionDelegate
*/
void print(String text);
/**
* Print colored text in console area.
*
* @param text
* text that need to be shown
* @param color
* color of the text
*/
void print(String text, String color);
void printInfo(String text);
void printWarn(String text);
void printError(String text);
/**
* Set title of console part.
*

View File

@ -43,10 +43,6 @@ public class GitOutputPartViewImpl extends Composite implements GitOutputPartVie
interface GitOutputPartViewImplUiBinder extends UiBinder<Widget, GitOutputPartViewImpl> {
}
private static final String INFO_COLOR = "lightgreen";
private static final String WARNING_COLOR = "cyan";
private static final String ERROR_COLOR = "#F62217";
private ActionDelegate delegate;
@UiField
@ -89,25 +85,9 @@ public class GitOutputPartViewImpl extends Composite implements GitOutputPartVie
String preStyle = " style='margin:0px; font-size: 12px;' ";
HTML html = new HTML();
String TEXT = text.toUpperCase();
if (TEXT.startsWith("[INFO]")) {
html.setHTML("<pre" + preStyle + ">[<span style='color:" + INFO_COLOR + ";'><b>INFO</b></span>] " +
SimpleHtmlSanitizer.sanitizeHtml(text.substring(6)).asString() + "</pre>");
} else if (TEXT.startsWith("[ERROR]")) {
html.setHTML("<pre" + preStyle + ">[<span style='color:" + ERROR_COLOR + ";'><b>ERROR</b></span>] " +
SimpleHtmlSanitizer.sanitizeHtml(text.substring(7)).asString() + "</pre>");
} else if (TEXT.startsWith("[WARNING]")) {
html.setHTML("<pre" + preStyle + ">[<span style='color:" + WARNING_COLOR + ";'><b>WARNING</b></span>] " +
SimpleHtmlSanitizer.sanitizeHtml(text.substring(9)).asString() + "</pre>");
} else {
html.setHTML("<pre" + preStyle + ">" + SimpleHtmlSanitizer.sanitizeHtml(text).asString() + "</pre>");
}
html.setHTML("<pre" + preStyle + ">" + SimpleHtmlSanitizer.sanitizeHtml(text).asString() + "</pre>");
html.getElement().setAttribute("style", "padding-left: 2px;");
consoleArea.add(html);
}
@ -123,21 +103,6 @@ public class GitOutputPartViewImpl extends Composite implements GitOutputPartVie
consoleArea.add(html);
}
@Override
public void printInfo(String text) {
print(text, INFO_COLOR);
}
@Override
public void printWarn(String text) {
print(text, WARNING_COLOR);
}
@Override
public void printError(String text) {
print(text, ERROR_COLOR);
}
/** {@inheritDoc} */
@Override
public void clear() {

View File

@ -14,7 +14,7 @@ import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.web.bindery.event.shared.EventBus;
import org.eclipse.che.api.core.rest.shared.dto.ServiceError;
import org.eclipse.che.api.core.ErrorCodes;
import org.eclipse.che.api.git.gwt.client.GitServiceClient;
import org.eclipse.che.api.git.shared.Branch;
import org.eclipse.che.api.git.shared.PullResponse;
@ -27,7 +27,6 @@ import org.eclipse.che.ide.api.event.FileContentUpdateEvent;
import org.eclipse.che.ide.api.notification.NotificationManager;
import org.eclipse.che.ide.api.notification.StatusNotification;
import org.eclipse.che.ide.api.project.tree.VirtualFile;
import org.eclipse.che.ide.dto.DtoFactory;
import org.eclipse.che.ide.ext.git.client.BranchSearcher;
import org.eclipse.che.ide.ext.git.client.GitLocalizationConstant;
import org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole;
@ -36,11 +35,13 @@ import org.eclipse.che.ide.extension.machine.client.processes.ConsolesPanelPrese
import org.eclipse.che.ide.part.explorer.project.ProjectExplorerPresenter;
import org.eclipse.che.ide.rest.AsyncRequestCallback;
import org.eclipse.che.ide.rest.DtoUnmarshallerFactory;
import org.eclipse.che.ide.ui.dialogs.DialogFactory;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import static org.eclipse.che.ide.util.ExceptionUtils.getErrorCode;
import static org.eclipse.che.api.git.shared.BranchListRequest.LIST_LOCAL;
import static org.eclipse.che.api.git.shared.BranchListRequest.LIST_REMOTE;
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL;
@ -58,6 +59,8 @@ import static org.eclipse.che.ide.ext.git.client.compare.branchList.BranchListPr
public class PullPresenter implements PullView.ActionDelegate {
public static final String PULL_COMMAND_NAME = "Git pull";
private static final String GREEN_COLOR = "lightgreen";
private final PullView view;
private final GitServiceClient gitServiceClient;
private final EventBus eventBus;
@ -66,7 +69,7 @@ public class PullPresenter implements PullView.ActionDelegate {
private final AppContext appContext;
private final NotificationManager notificationManager;
private final DtoUnmarshallerFactory dtoUnmarshallerFactory;
private final DtoFactory dtoFactory;
private final DialogFactory dialogFactory;
private final BranchSearcher branchSearcher;
private final ProjectExplorerPresenter projectExplorer;
private final GitOutputConsoleFactory gitOutputConsoleFactory;
@ -84,13 +87,13 @@ public class PullPresenter implements PullView.ActionDelegate {
GitLocalizationConstant constant,
NotificationManager notificationManager,
DtoUnmarshallerFactory dtoUnmarshallerFactory,
DtoFactory dtoFactory,
DialogFactory dialogFactory,
BranchSearcher branchSearcher,
ProjectExplorerPresenter projectExplorer,
GitOutputConsoleFactory gitOutputConsoleFactory,
ConsolesPanelPresenter consolesPanelPresenter) {
this.view = view;
this.dtoFactory = dtoFactory;
this.dialogFactory = dialogFactory;
this.branchSearcher = branchSearcher;
this.projectExplorer = projectExplorer;
this.gitOutputConsoleFactory = gitOutputConsoleFactory;
@ -131,13 +134,7 @@ public class PullPresenter implements PullView.ActionDelegate {
@Override
protected void onFailure(Throwable exception) {
String errorMessage =
exception.getMessage() != null ? exception.getMessage()
: constant.remoteListFailed();
GitOutputConsole console = gitOutputConsoleFactory.create(REMOTE_REPO_COMMAND_NAME);
console.printError(errorMessage);
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
notificationManager.notify(constant.remoteListFailed(), FAIL, true, project.getRootProject());
handleError(exception, REMOTE_REPO_COMMAND_NAME);
view.setEnablePullButton(false);
}
}
@ -172,13 +169,7 @@ public class PullPresenter implements PullView.ActionDelegate {
@Override
protected void onFailure(Throwable exception) {
String errorMessage =
exception.getMessage() != null ? exception.getMessage()
: constant.branchesListFailed();
GitOutputConsole console = gitOutputConsoleFactory.create(BRANCH_LIST_COMMAND_NAME);
console.printError(errorMessage);
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
notificationManager.notify(constant.branchesListFailed(), FAIL, true, project.getRootProject());
handleError(exception, BRANCH_LIST_COMMAND_NAME);
view.setEnablePullButton(false);
}
}
@ -199,30 +190,30 @@ public class PullPresenter implements PullView.ActionDelegate {
final StatusNotification notification =
notificationManager.notify(constant.pullProcess(), PROGRESS, true, project.getRootProject());
final GitOutputConsole console = gitOutputConsoleFactory.create(PULL_COMMAND_NAME);
gitServiceClient.pull(workspaceId, project.getRootProject(), getRefs(), remoteName,
new AsyncRequestCallback<PullResponse>(dtoUnmarshallerFactory.newUnmarshaller(PullResponse.class)) {
@Override
protected void onSuccess(PullResponse result) {
console.printInfo(result.getCommandOutput());
GitOutputConsole console = gitOutputConsoleFactory.create(PULL_COMMAND_NAME);
console.print(result.getCommandOutput(), GREEN_COLOR);
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
notification.setStatus(SUCCESS);
if (result.getCommandOutput().contains("Already up-to-date")) {
notification.setTitle(constant.pullUpToDate());
} else {
refreshProject(openedEditors);
refreshProjectNodesAndEditors(openedEditors);
notification.setTitle(constant.pullSuccess(remoteUrl));
}
}
@Override
protected void onFailure(Throwable throwable) {
if (throwable.getMessage().contains("Merge conflict")) {
refreshProject(openedEditors);
protected void onFailure(Throwable exception) {
notification.setStatus(FAIL);
if (getErrorCode(exception) == ErrorCodes.MERGE_CONFLICT) {
refreshProjectNodesAndEditors(openedEditors);
}
handleError(throwable, remoteUrl, notification, console);
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
handleError(exception, PULL_COMMAND_NAME);
}
});
}
@ -233,7 +224,7 @@ public class PullPresenter implements PullView.ActionDelegate {
* @param openedEditors
* editors that corresponds to open files
*/
private void refreshProject(final List<EditorPartPresenter> openedEditors) {
private void refreshProjectNodesAndEditors(final List<EditorPartPresenter> openedEditors) {
projectExplorer.reloadChildren();
for (EditorPartPresenter partPresenter : openedEditors) {
final VirtualFile file = partPresenter.getEditorInput().getFile();
@ -255,32 +246,40 @@ public class PullPresenter implements PullView.ActionDelegate {
/**
* Handler some action whether some exception happened.
*
* @param throwable
* exception what happened
* @param exception
* exception that happened
* @param commandName
* name of the command
*/
private void handleError(@NotNull Throwable throwable, @NotNull String remoteUrl, StatusNotification notification,
GitOutputConsole console) {
String errorMessage = throwable.getMessage();
notification.setStatus(FAIL);
if (errorMessage == null) {
console.printError(constant.pullFail(remoteUrl));
notification.setTitle(constant.pullFail(remoteUrl));
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;
}
try {
errorMessage = dtoFactory.createDtoFromJson(errorMessage, ServiceError.class).getMessage();
if (errorMessage.equals("Unable get private ssh key")) {
console.printError(constant.messagesUnableGetSshKey());
notification.setTitle(constant.messagesUnableGetSshKey());
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;
}
console.printError(errorMessage);
notification.setTitle(errorMessage);
} catch (Exception e) {
console.printError(errorMessage);
notification.setTitle(errorMessage);
}
GitOutputConsole console = gitOutputConsoleFactory.create(commandName);
console.printError(errorMessage);
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
notificationManager.notify(errorMessage, FAIL, true, project.getRootProject());
}
/** {@inheritDoc} */

View File

@ -300,7 +300,7 @@ public class PushToRemotePresenter implements PushToRemoteView.ActionDelegate {
new AsyncRequestCallback<PushResponse>(dtoUnmarshallerFactory.newUnmarshaller(PushResponse.class)) {
@Override
protected void onSuccess(PushResponse result) {
console.printInfo(result.getCommandOutput());
console.print(result.getCommandOutput());
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
notification.setStatus(SUCCESS);
if (result.getCommandOutput().contains("Everything up-to-date")) {

View File

@ -160,7 +160,7 @@ public class RemoveFromIndexPresenter implements RemoveFromIndexView.ActionDeleg
new AsyncRequestCallback<String>() {
@Override
protected void onSuccess(String result) {
console.printInfo(constant.removeFilesSuccessfull());
console.print(constant.removeFilesSuccessfull());
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
notificationManager.notify(constant.removeFilesSuccessfull(), project.getRootProject());

View File

@ -180,7 +180,7 @@ public class ResetToCommitPresenter implements ResetToCommitView.ActionDelegate
//so we must repeat the logic which is performed when we open a project
eventBus.fireEvent(new OpenProjectEvent(project));
}
console.printInfo(constant.resetSuccessfully());
console.print(constant.resetSuccessfully());
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
notificationManager.notify(constant.resetSuccessfully(), project);

View File

@ -150,7 +150,7 @@ public class ResetFilesPresenter implements ResetFilesView.ActionDelegate {
final GitOutputConsole console = gitOutputConsoleFactory.create(RESET_COMMAND_NAME);
if (files.isEmpty()) {
view.close();
console.printInfo(constant.nothingToReset());
console.print(constant.nothingToReset());
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
notificationManager.notify(constant.nothingToReset(), project.getRootProject());
return;
@ -160,7 +160,7 @@ public class ResetFilesPresenter implements ResetFilesView.ActionDelegate {
service.reset(workspaceId, project.getRootProject(), "HEAD", ResetType.MIXED, files, new AsyncRequestCallback<Void>() {
@Override
protected void onSuccess(Void result) {
console.printInfo(constant.resetFilesSuccessfully());
console.print(constant.resetFilesSuccessfully());
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
notificationManager.notify(constant.resetFilesSuccessfully(), project.getRootProject());
}

View File

@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.che.ide.ext.git.client.status;
import org.eclipse.che.ide.api.theme.Style;
import org.eclipse.che.ide.ext.git.client.GitLocalizationConstant;
import org.eclipse.che.api.git.gwt.client.GitServiceClient;
import org.eclipse.che.ide.api.app.AppContext;
@ -24,6 +25,9 @@ import org.eclipse.che.ide.rest.StringUnmarshaller;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.Arrays;
import java.util.List;
import static org.eclipse.che.api.git.shared.StatusFormat.LONG;
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL;
@ -72,9 +76,7 @@ public class StatusCommandPresenter {
new AsyncRequestCallback<String>(new StringUnmarshaller()) {
@Override
protected void onSuccess(String result) {
final GitOutputConsole console = gitOutputConsoleFactory.create(STATUS_COMMAND_NAME);
printGitStatus(result, console);
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
printGitStatus(result);
}
@Override
@ -89,27 +91,28 @@ public class StatusCommandPresenter {
*
* @param statusText
* text to be printed
* @param console
* console for displaying status
*/
private void printGitStatus(String statusText, GitOutputConsole console) {
private void printGitStatus(String statusText) {
GitOutputConsole console = gitOutputConsoleFactory.create(STATUS_COMMAND_NAME);
console.print("");
String[] lines = statusText.split("\n");
for (String line : lines) {
if (line.startsWith("\tmodified:") || line.startsWith("#\tmodified:")) {
console.printError(line);
List<String> statusLines = Arrays.asList(statusText.split("\n"));
boolean containsStagedChanges = statusLines.contains("Changes to be committed:");
boolean stagedChangesAlreadyPrinted = false;
for (String line : statusLines) {
if ((line.startsWith("\t") || line.startsWith("#\t")) && containsStagedChanges && !stagedChangesAlreadyPrinted) {
console.print(line, Style.getGitConsoleStagedFilesColor());
if (statusLines.indexOf(line) == statusLines.size() - 1 || statusLines.get(statusLines.indexOf(line) + 1).equals("")) {
stagedChangesAlreadyPrinted = true;
}
continue;
} else if ((line.startsWith("\t") || line.startsWith("#\t"))) {
console.print(line, Style.getGitConsoleUnstagedFilesColor());
continue;
}
if (line.startsWith("\t") || line.startsWith("#\t")) {
console.printInfo(line);
continue;
}
console.print(line);
}
}
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
}
}

View File

@ -119,7 +119,7 @@ public class AddToIndexPresenterTest extends BaseTest {
onSuccess.invoke(callback, this.statusResponse);
verify(gitOutputConsoleFactory).create(ADD_TO_INDEX_COMMAND_NAME);
verify(console).printInfo(anyString());
verify(console).print(anyString());
verify(consolesPanelPresenter).addCommandOutput(anyString(), eq(console));
verify(notificationManager).notify(anyString(), eq(rootProjectConfig));
verify(view, never()).showDialog();
@ -281,7 +281,7 @@ public class AddToIndexPresenterTest extends BaseTest {
verify(service).add(anyString(), eq(rootProjectConfig), eq(NEED_UPDATING), (List<String>)anyObject(),
(RequestCallback<Void>)anyObject());
verify(gitOutputConsoleFactory, times(2)).create(ADD_TO_INDEX_COMMAND_NAME);
verify(console).printInfo(anyString());
verify(console).print(anyString());
verify(consolesPanelPresenter).addCommandOutput(anyString(), eq(console));
verify(notificationManager).notify(anyString(), eq(rootProjectConfig));
verify(constant, times(2)).addSuccess();

View File

@ -134,7 +134,7 @@ public class CommitPresenterTest extends BaseTest {
verify(service).commit(anyString(), eq(rootProjectConfig), eq(COMMIT_TEXT), eq(ALL_FILE_INCLUDES), eq(IS_OVERWRITTEN),
(AsyncRequestCallback<Revision>)anyObject());
verify(gitOutputConsoleFactory).create(COMMIT_COMMAND_NAME);
verify(console).printInfo(anyString());
verify(console).print(anyString());
verify(consolesPanelPresenter).addCommandOutput(anyString(), eq(console));
verify(notificationManager).notify(anyString(), rootProjectConfig);
}

View File

@ -82,7 +82,7 @@ public class DeleteRepositoryPresenterTest extends BaseTest {
verify(appContext).getCurrentProject();
verify(service).deleteRepository(anyString(), eq(rootProjectConfig), (AsyncRequestCallback<Void>)anyObject());
verify(gitOutputConsoleFactory).create(DELETE_REPO_COMMAND_NAME);
verify(console).printInfo(anyString());
verify(console).print(anyString());
verify(consolesPanelPresenter).addCommandOutput(anyString(), eq(console));
verify(notificationManager).notify(anyString(), rootProjectConfig);
}

View File

@ -228,7 +228,7 @@ public class FetchPresenterTest extends BaseTest {
eq(NO_REMOVE_DELETE_REFS), (RequestCallback<String>)anyObject());
verify(view).close();
verify(gitOutputConsoleFactory).create(FETCH_COMMAND_NAME);
verify(console).printInfo(anyString());
verify(console).print(anyString());
verify(consolesPanelPresenter).addCommandOutput(anyString(), eq(console));
verify(notificationManager).notify(anyString(), rootProjectConfig);
verify(constant, times(2)).fetchSuccess(eq(REMOTE_URI));

View File

@ -74,7 +74,7 @@ public class InitRepositoryPresenterTest extends BaseTest {
verify(gitRepositoryInitializer).initGitRepository(eq(rootProjectConfig), (AsyncCallback<Void>)anyObject());
verify(gitOutputConsoleFactory).create(INIT_COMMAND_NAME);
verify(console).printInfo(eq(constant.initSuccess()));
verify(console).print(eq(constant.initSuccess()));
verify(consolesPanelPresenter).addCommandOutput(anyString(), eq(console));
verify(notificationManager).notify(anyString(), rootProjectConfig);
}

View File

@ -184,7 +184,7 @@ public class MergePresenterTest extends BaseTest {
verify(partPresenter).getEditorInput();
verify(file).getPath();
verify(gitOutputConsoleFactory).create(MERGE_COMMAND_NAME);
verify(console).printInfo(anyString());
verify(console).print(anyString());
verify(consolesPanelPresenter).addCommandOutput(anyString(), eq(console));
verify(notificationManager).notify(anyString(), rootProjectConfig);
}

View File

@ -106,7 +106,7 @@ public class PullPresenterTest extends BaseTest {
constant,
notificationManager,
dtoUnmarshallerFactory,
dtoFactory,
dialogFactory,
branchSearcher,
projectExplorer,
gitOutputConsoleFactory,
@ -316,7 +316,7 @@ public class PullPresenterTest extends BaseTest {
verify(editorAgent).getOpenedEditors();
verify(service).pull(anyObject(), eq(rootProjectConfig), anyString(), eq(REPOSITORY_NAME), (AsyncRequestCallback)anyObject());
verify(gitOutputConsoleFactory).create(PULL_COMMAND_NAME);
verify(console).printInfo(anyString());
verify(console).print(anyString());
verify(consolesPanelPresenter).addCommandOutput(anyString(), eq(console));
verify(constant).pullSuccess(anyString());
verify(notificationManager).notify(anyString(), rootProjectConfig);
@ -350,7 +350,7 @@ public class PullPresenterTest extends BaseTest {
verify(editorAgent).getOpenedEditors();
verify(service).pull(anyObject(), eq(rootProjectConfig), anyString(), eq(REPOSITORY_NAME), (AsyncRequestCallback)anyObject());
verify(gitOutputConsoleFactory).create(PULL_COMMAND_NAME);
verify(console).printInfo(anyString());
verify(console).print(anyString());
verify(consolesPanelPresenter).addCommandOutput(anyString(), eq(console));
verify(constant).pullUpToDate();
verify(notificationManager).notify(anyString(), rootProjectConfig);
@ -438,7 +438,7 @@ public class PullPresenterTest extends BaseTest {
verify(view).close();
verify(gitOutputConsoleFactory).create(PULL_COMMAND_NAME);
verify(console).printInfo(anyString());
verify(console).print(anyString());
verify(consolesPanelPresenter).addCommandOutput(anyString(), eq(console));
verify(notificationManager).notify(anyString(), rootProjectConfig);
//check Refresh project is not called

View File

@ -321,7 +321,7 @@ public class PushToRemotePresenterTest extends BaseTest {
(AsyncRequestCallback<PushResponse>)anyObject());
verify(view).close();
verify(gitOutputConsoleFactory).create(PUSH_COMMAND_NAME);
verify(console).printInfo(anyString());
verify(console).print(anyString());
verify(constant).pushSuccess(anyString());
verify(consolesPanelPresenter).addCommandOutput(anyString(), eq(console));
verify(notificationManager).notify(anyString(), rootProjectConfig);
@ -344,7 +344,7 @@ public class PushToRemotePresenterTest extends BaseTest {
(AsyncRequestCallback<PushResponse>)anyObject());
verify(view).close();
verify(gitOutputConsoleFactory).create(PUSH_COMMAND_NAME);
verify(console).printInfo(anyString());
verify(console).print(anyString());
verify(consolesPanelPresenter).addCommandOutput(anyString(), eq(console));
verify(constant).pushUpToDate();
verify(notificationManager).notify(anyString(), rootProjectConfig);

View File

@ -165,7 +165,7 @@ public class RemoveFromIndexPresenterTest extends BaseTest {
verify(service).remove(anyString(), eq(rootProjectConfig), anyObject(), eq(REMOVED), anyObject());
verify(notificationManager).notify(anyString(), rootProjectConfig);
verify(gitOutputConsoleFactory).create(REMOVE_FROM_INDEX_COMMAND_NAME);
verify(console).printInfo(anyString());
verify(console).print(anyString());
verify(consolesPanelPresenter).addCommandOutput(anyString(), eq(console));
verify(constant, times(2)).removeFilesSuccessfull();
verify(view).close();

View File

@ -180,7 +180,7 @@ public class ResetToCommitPresenterTest extends BaseTest {
verify(service).reset(anyString(), anyObject(), eq(PROJECT_PATH), eq(HARD), (List<String>)anyObject(),
(AsyncRequestCallback<Void>)anyObject());
verify(eventBus).fireEvent(Matchers.<Event<OpenProjectEvent>>anyObject());
verify(console).printInfo(anyString());
verify(console).print(anyString());
verify(notificationManager).notify(anyString(), rootProjectConfig);
}
@ -214,7 +214,7 @@ public class ResetToCommitPresenterTest extends BaseTest {
verify(service).reset(anyString(), anyObject(), eq(PROJECT_PATH), eq(HARD), (List<String>)anyObject(),
(AsyncRequestCallback<Void>)anyObject());
verify(eventBus).fireEvent(Matchers.<Event<OpenProjectEvent>>anyObject());
verify(console).printInfo(anyString());
verify(console).print(anyString());
verify(notificationManager).notify(anyString(), rootProjectConfig);
}

View File

@ -184,7 +184,7 @@ public class ResetFilesPresenterTest extends BaseTest {
verify(view).close();
verify(service, never()).reset(anyString(), eq(projectConfig), anyString(), (ResetRequest.ResetType)anyObject(), (List<String>)anyObject(),
(AsyncRequestCallback<Void>)anyObject());
verify(console).printInfo(anyString());
verify(console).print(anyString());
verify(notificationManager).notify(anyString(), rootProjectConfig);
verify(constant, times(2)).nothingToReset();
}
@ -227,7 +227,7 @@ public class ResetFilesPresenterTest extends BaseTest {
verify(service).reset(anyString(), eq(rootProjectConfig), anyString(), (ResetRequest.ResetType)anyObject(), (List<String>)anyObject(),
(AsyncRequestCallback<Void>)anyObject());
verify(notificationManager).notify(anyString(), rootProjectConfig);
verify(console).printInfo(anyString());
verify(console).print(anyString());
verify(constant, times(2)).resetFilesSuccessfully();
}