mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[file-history] introduce a data key for refresher
This commit is contained in:
@@ -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();
|
||||
|
||||
+3
-1
@@ -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) {
|
||||
|
||||
+7
-7
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user