From 33f83a237357bc29062f02fffaff7e7596619d1e Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Tue, 24 Apr 2018 22:11:34 +0300 Subject: [PATCH] [file-history] introduce a data key for refresher --- .../com/intellij/openapi/VcsInternalDataKeys.java | 9 +++++++++ .../openapi/vcs/history/FileHistoryPanelImpl.java | 9 ++++----- .../vcs/history/FileHistorySessionPartner.java | 4 +++- .../history/actions/RefreshFileHistoryAction.java | 14 +++++++------- 4 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 platform/vcs-impl/src/com/intellij/openapi/VcsInternalDataKeys.java diff --git a/platform/vcs-impl/src/com/intellij/openapi/VcsInternalDataKeys.java b/platform/vcs-impl/src/com/intellij/openapi/VcsInternalDataKeys.java new file mode 100644 index 000000000000..f476bcaad274 --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/openapi/VcsInternalDataKeys.java @@ -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 FILE_HISTORY_REFRESHER = DataKey.create("FILE_HISTORY_REFRESHER"); +} diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java index b4ffbf49d940..f1fa256ccf09 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java @@ -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 list = myHistorySession.getRevisionList(); myRevisionsOrder.clear(); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistorySessionPartner.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistorySessionPartner.java index 01a0414e9691..d7d8e85ba11a 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistorySessionPartner.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistorySessionPartner.java @@ -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) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/actions/RefreshFileHistoryAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/actions/RefreshFileHistoryAction.java index 0f4728d02078..ca47d46dd238 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/actions/RefreshFileHistoryAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/actions/RefreshFileHistoryAction.java @@ -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()); } }