mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[file-history] make RefreshFileHistoryAction context-based
RefreshFileHistoryAction extracts FileHistoryRefresher from context and uses it to do refresh. In order to know whether refresh is already in progress, a method isInRefresh is added.
This commit is contained in:
@@ -24,6 +24,8 @@
|
||||
text="Com_pare with Specified Revision..." popup="true"/>
|
||||
<action id="Vcs.ShowHistoryForBlock" class="com.intellij.openapi.vcs.actions.SelectedBlockHistoryAction"/>
|
||||
<action id="Vcs.GetVersion" class="com.intellij.openapi.vcs.history.actions.GetVersionAction"/>
|
||||
<action id="Vcs.RefreshFileHistory" class="com.intellij.openapi.vcs.history.actions.RefreshFileHistoryAction"
|
||||
use-shortcut-of="Refresh"/>
|
||||
<action id="Vcs.ShowDiffWithLocal.Before" class="com.intellij.openapi.vcs.history.actions.ShowDiffBeforeWithLocalAction"
|
||||
text="Compare Before with Local" description="Compare version before selected revision with current version"/>
|
||||
<action id="Vcs.ShowDiffWithLocal" class="com.intellij.openapi.vcs.history.actions.ShowDiffAfterWithLocalAction"
|
||||
@@ -208,6 +210,7 @@
|
||||
<group id="VcsHistoryInternalGroup.Toolbar">
|
||||
<reference ref="Diff.ShowDiff"/>
|
||||
<reference ref="VcsHistoryActionsGroup.Toolbar"/>
|
||||
<reference ref="Vcs.RefreshFileHistory"/>
|
||||
</group>
|
||||
|
||||
<group id="CommittedChangesToolbar">
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.intellij.openapi.vcs.history;
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.CopyProvider;
|
||||
import com.intellij.ide.actions.RefreshAction;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsListener;
|
||||
@@ -195,7 +194,7 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
|
||||
|
||||
lastTask = ourExecutor.submit(() -> {
|
||||
if (!updateAlarm.isDisposed() && myHistorySession.shouldBeRefreshed()) {
|
||||
refreshUiAndScheduleDataRefresh(true);
|
||||
ApplicationManager.getApplication().invokeAndWait(() -> myRefresherI.refresh(true));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -402,15 +401,14 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
|
||||
|
||||
@NotNull
|
||||
private DefaultActionGroup fillActionGroup(boolean popup, DefaultActionGroup result) {
|
||||
result.add(new RefreshFileHistoryAction());
|
||||
|
||||
if (popup) {
|
||||
result.add(ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_SOURCE));
|
||||
}
|
||||
|
||||
AnAction actionGroup = ActionManager.getInstance().getAction(popup ? VCS_HISTORY_POPUP_ACTION_GROUP : VCS_HISTORY_TOOLBAR_ACTION_GROUP);
|
||||
result.add(actionGroup);
|
||||
AnAction[] additionalActions = myProvider.getAdditionalActions(() -> refreshUiAndScheduleDataRefresh(true));
|
||||
AnAction[] additionalActions =
|
||||
myProvider.getAdditionalActions(() -> ApplicationManager.getApplication().invokeAndWait(() -> myRefresherI.refresh(true)));
|
||||
if (additionalActions != null) {
|
||||
for (AnAction additionalAction : additionalActions) {
|
||||
if (popup || additionalAction.getTemplatePresentation().getIcon() != null) {
|
||||
@@ -429,12 +427,6 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
|
||||
return result;
|
||||
}
|
||||
|
||||
private void refreshUiAndScheduleDataRefresh(boolean canUseCache) {
|
||||
ApplicationManager.getApplication().invokeAndWait(() -> {
|
||||
myRefresherI.refresh(canUseCache);
|
||||
});
|
||||
}
|
||||
|
||||
public Object getData(String dataId) {
|
||||
if (CommonDataKeys.NAVIGATABLE.is(dataId)) {
|
||||
VcsFileRevision[] selectedRevisions = getSelectedRevisions();
|
||||
@@ -996,27 +988,6 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
|
||||
}
|
||||
}
|
||||
|
||||
private class RefreshFileHistoryAction extends RefreshAction implements DumbAware {
|
||||
public RefreshFileHistoryAction() {
|
||||
super(VcsBundle.message("action.name.refresh"), VcsBundle.message("action.description.refresh"), AllIcons.Actions.Refresh);
|
||||
registerShortcutOn(FileHistoryPanelImpl.this);
|
||||
}
|
||||
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
refreshUiAndScheduleDataRefresh(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
super.update(e);
|
||||
e.getPresentation().setEnabled(!isInRefresh());
|
||||
}
|
||||
|
||||
private boolean isInRefresh() {
|
||||
return VcsCachingHistory.getHistoryLock(myVcs, VcsBackgroundableActions.CREATE_HISTORY_SESSION, myFilePath, myStartingRevision).isLocked();
|
||||
}
|
||||
}
|
||||
|
||||
private class MyShowDetailsAction extends ToggleAction implements DumbAware {
|
||||
|
||||
public MyShowDetailsAction() {
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.openapi.vcs.history;
|
||||
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.impl.VcsBackgroundableActions;
|
||||
import com.intellij.vcs.history.VcsHistoryProviderEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -82,6 +83,12 @@ public class FileHistoryRefresher implements FileHistoryRefresherI {
|
||||
mySessionPartner.createOrSelectContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInRefresh() {
|
||||
return VcsCachingHistory.getHistoryLock(myVcs, VcsBackgroundableActions.CREATE_HISTORY_SESSION, myPath, myStartingRevisionNumber)
|
||||
.isLocked();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param canUseCache
|
||||
*/
|
||||
|
||||
@@ -19,4 +19,6 @@ public interface FileHistoryRefresherI {
|
||||
void refresh(boolean canUseCache);
|
||||
|
||||
void selectContent();
|
||||
|
||||
boolean isInRefresh();
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
// 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.vcs.history.actions;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.actions.RefreshAction;
|
||||
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;
|
||||
|
||||
public class RefreshFileHistoryAction extends RefreshAction implements DumbAware {
|
||||
public RefreshFileHistoryAction() {
|
||||
super(VcsBundle.message("action.name.refresh"), VcsBundle.message("action.description.refresh"), AllIcons.Actions.Refresh);
|
||||
}
|
||||
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
FileHistoryPanelImpl panel = (FileHistoryPanelImpl)e.getRequiredData(VcsDataKeys.FILE_HISTORY_PANEL);
|
||||
panel.getRefresher().refresh(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
super.update(e);
|
||||
FileHistoryPanelImpl panel = (FileHistoryPanelImpl)e.getData(VcsDataKeys.FILE_HISTORY_PANEL);
|
||||
if (panel == null) {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
return;
|
||||
}
|
||||
e.getPresentation().setVisible(true);
|
||||
e.getPresentation().setEnabled(!panel.getRefresher().isInRefresh());
|
||||
}
|
||||
}
|
||||
+5
@@ -528,6 +528,11 @@ public class TreeConflictRefreshablePanel implements Disposable {
|
||||
@Override
|
||||
public void selectContent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInRefresh() {
|
||||
return false;
|
||||
}
|
||||
}, true);
|
||||
myFileHistoryPanel.setBottomRevisionForShowDiff(last);
|
||||
myFileHistoryPanel.setBorder(BorderFactory.createLineBorder(UIUtil.getBorderColor()));
|
||||
|
||||
Reference in New Issue
Block a user