[vcs-log] refresh is enabled only if there is data manager and log ui in context

This commit is contained in:
Julia Beliaeva
2016-02-25 21:34:05 +03:00
parent 579c34be31
commit dfa80366c4
@@ -20,11 +20,13 @@ import com.intellij.ide.actions.RefreshAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.vcs.log.VcsLogDataKeys;
import com.intellij.vcs.log.data.VcsLogDataManager;
import com.intellij.vcs.log.impl.VcsLogManager;
public class RefreshLogAction extends RefreshAction {
public RefreshLogAction() {
super("Refresh", "Refresh", AllIcons.Actions.Refresh);
super("Refresh", "Re-read Commits From Disk for All VCS Roots and Rebuild Log", AllIcons.Actions.Refresh);
}
@Override
@@ -35,6 +37,12 @@ public class RefreshLogAction extends RefreshAction {
@Override
public void update(AnActionEvent e) {
e.getPresentation().setEnabledAndVisible(e.getProject() != null);
Project project = e.getProject();
if (project == null) {
e.getPresentation().setEnabledAndVisible(false);
} else {
VcsLogDataManager dataManager = VcsLogManager.getInstance(project).getDataManager();
e.getPresentation().setEnabledAndVisible(dataManager != null && e.getData(VcsLogDataKeys.VCS_LOG_UI) != null);
}
}
}