From 307491c349de2eca95014afa78f17beb1e1cf86e Mon Sep 17 00:00:00 2001 From: Mykola Morhun Date: Thu, 3 Aug 2017 16:17:25 +0300 Subject: [PATCH] CHE-5862: Set right handler on double click in Git Compare window (#5885) Set right handler on double click in Git Compare window --- .../changeslist/ChangesListPresenter.java | 1 + .../changespanel/ChangesPanelPresenter.java | 46 ++++++++++++------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/compare/changeslist/ChangesListPresenter.java b/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/compare/changeslist/ChangesListPresenter.java index 926135d231..37cdacad22 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/compare/changeslist/ChangesListPresenter.java +++ b/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/compare/changeslist/ChangesListPresenter.java @@ -60,6 +60,7 @@ public class ChangesListPresenter implements ChangesListView.ActionDelegate { this.view = view; this.notificationManager = notificationManager; this.changesPanelPresenter = changesPanelPresenter; + this.changesPanelPresenter.setFileNodeDoubleClickHandler((path, status) -> this.onCompareClicked()); this.view.setDelegate(this); SelectionChangedHandler handler = event -> { diff --git a/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/compare/changespanel/ChangesPanelPresenter.java b/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/compare/changespanel/ChangesPanelPresenter.java index c96d0444f2..f7afb4bef1 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/compare/changespanel/ChangesPanelPresenter.java +++ b/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/compare/changespanel/ChangesPanelPresenter.java @@ -26,7 +26,7 @@ import static org.eclipse.che.ide.ext.git.client.compare.changespanel.ViewMode.L import static org.eclipse.che.ide.ext.git.client.compare.changespanel.ViewMode.TREE; /** - * Presenter for displaying list of changed files. + * Presenter for displaying window with list of changed files. * * @author Igor Vinokur * @author Vlad Zhukovskyi @@ -34,14 +34,13 @@ import static org.eclipse.che.ide.ext.git.client.compare.changespanel.ViewMode.T public class ChangesPanelPresenter implements ChangesPanelView.ActionDelegate { private final ChangesPanelView view; - private final AppContext appContext; - private final NotificationManager notificationManager; - private final ComparePresenter comparePresenter; private final GitLocalizationConstant locale; private Map changedFiles; private ViewMode viewMode; + private FileNodeDoubleClickHandler fileNodeDoubleClickHandler; + @Inject public ChangesPanelPresenter(GitLocalizationConstant locale, ChangesPanelView view, @@ -50,11 +49,21 @@ public class ChangesPanelPresenter implements ChangesPanelView.ActionDelegate { ComparePresenter comparePresenter) { this.locale = locale; this.view = view; - this.appContext = appContext; - this.notificationManager = notificationManager; - this.comparePresenter = comparePresenter; this.view.setDelegate(this); this.viewMode = TREE; + + this.fileNodeDoubleClickHandler = (path, status) -> { + appContext.getRootProject() + .getFile(path) + .then(file -> { + if (file.isPresent()) { + comparePresenter.showCompareWithLatest(file.get(), status, "HEAD"); + } + }) + .catchError(error -> { + notificationManager.notify(error.getMessage(), FAIL, NOT_EMERGE_MODE); + }); + }; } /** @@ -83,16 +92,7 @@ public class ChangesPanelPresenter implements ChangesPanelView.ActionDelegate { @Override public void onFileNodeDoubleClicked(String path, final Status status) { - appContext.getRootProject() - .getFile(path) - .then(file -> { - if (file.isPresent()) { - comparePresenter.showCompareWithLatest(file.get(), status, "HEAD"); - } - }) - .catchError(error -> { - notificationManager.notify(error.getMessage(), FAIL, NOT_EMERGE_MODE); - }); + fileNodeDoubleClickHandler.onFileNodeDoubleClicked(path, status); } @Override @@ -117,4 +117,16 @@ public class ChangesPanelPresenter implements ChangesPanelView.ActionDelegate { view.setTextToChangeViewModeButton(viewMode == TREE ? locale.changeListRowListViewButtonText() : locale.changeListGroupByDirectoryButtonText()); } + + public void setFileNodeDoubleClickHandler(FileNodeDoubleClickHandler fileNodeDoubleClickHandler) { + this.fileNodeDoubleClickHandler = fileNodeDoubleClickHandler; + } + + /** + * Describes behaviour on double click action on a selected path. + */ + public interface FileNodeDoubleClickHandler { + void onFileNodeDoubleClicked(String path, final Status status); + } + }