CHE-5862: Set right handler on double click in Git Compare window (#5885)

Set right handler on double click in Git Compare window
6.19.x
Mykola Morhun 2017-08-03 16:17:25 +03:00 committed by GitHub
parent 5661a37563
commit 307491c349
2 changed files with 30 additions and 17 deletions

View File

@ -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 -> {

View File

@ -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<String, Status> 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);
}
}