[file-history] introduce a data key for refresher

This commit is contained in:
Julia Beliaeva
2018-07-09 17:35:14 +03:00
parent 5864247fc5
commit 33f83a2373
4 changed files with 23 additions and 13 deletions
@@ -0,0 +1,9 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi;
import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.openapi.vcs.history.FileHistoryRefresherI;
public interface VcsInternalDataKeys {
DataKey<FileHistoryRefresherI> FILE_HISTORY_REFRESHER = DataKey.create("FILE_HISTORY_REFRESHER");
}
@@ -18,6 +18,7 @@ package com.intellij.openapi.vcs.history;
import com.intellij.CommonBundle;
import com.intellij.icons.AllIcons;
import com.intellij.ide.CopyProvider;
import com.intellij.openapi.VcsInternalDataKeys;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.colors.EditorColorsListener;
@@ -501,6 +502,9 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
return flatView.getRow(flatView.getSelectedRow() + 1).getRevision();
}
}
else if (VcsInternalDataKeys.FILE_HISTORY_REFRESHER.is(dataId)) {
return myRefresherI;
}
else {
return super.getData(dataId);
}
@@ -553,11 +557,6 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
myDualView.dispose();
}
@NotNull
public FileHistoryRefresherI getRefresher() {
return myRefresherI;
}
private void refreshRevisionsOrder() {
final List<VcsFileRevision> list = myHistorySession.getRevisionList();
myRevisionsOrder.clear();
@@ -15,6 +15,8 @@
*/
package com.intellij.openapi.vcs.history;
import com.intellij.openapi.VcsInternalDataKeys;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
@@ -88,7 +90,7 @@ public class FileHistorySessionPartner implements VcsHistorySessionConsumer {
JComponent component = ContentUtilEx.findContentComponent(getToolWindow(project).getContentManager(), comp ->
comp instanceof FileHistoryPanelImpl &&
sameHistories((FileHistoryPanelImpl)comp, path, startingRevisionNumber));
return component == null ? null : ((FileHistoryPanelImpl)component).getRefresher();
return component == null ? null : VcsInternalDataKeys.FILE_HISTORY_REFRESHER.getData((DataProvider)component);
}
public void acceptRevision(VcsFileRevision revision) {
@@ -3,11 +3,11 @@ package com.intellij.openapi.vcs.history.actions;
import com.intellij.icons.AllIcons;
import com.intellij.ide.actions.RefreshAction;
import com.intellij.openapi.VcsInternalDataKeys;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.VcsDataKeys;
import com.intellij.openapi.vcs.history.FileHistoryPanelImpl;
import com.intellij.openapi.vcs.history.FileHistoryRefresherI;
public class RefreshFileHistoryAction extends RefreshAction implements DumbAware {
public RefreshFileHistoryAction() {
@@ -15,19 +15,19 @@ public class RefreshFileHistoryAction extends RefreshAction implements DumbAware
}
public void actionPerformed(AnActionEvent e) {
FileHistoryPanelImpl panel = (FileHistoryPanelImpl)e.getRequiredData(VcsDataKeys.FILE_HISTORY_PANEL);
panel.getRefresher().refresh(false);
FileHistoryRefresherI refresher = e.getRequiredData(VcsInternalDataKeys.FILE_HISTORY_REFRESHER);
refresher.refresh(false);
}
@Override
public void update(AnActionEvent e) {
super.update(e);
FileHistoryPanelImpl panel = (FileHistoryPanelImpl)e.getData(VcsDataKeys.FILE_HISTORY_PANEL);
if (panel == null) {
FileHistoryRefresherI refresher = e.getData(VcsInternalDataKeys.FILE_HISTORY_REFRESHER);
if (refresher == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
e.getPresentation().setVisible(true);
e.getPresentation().setEnabled(!panel.getRefresher().isInRefresh());
e.getPresentation().setEnabled(!refresher.isInRefresh());
}
}