<commit_before>// Copyright 2000-2019 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.usages.actions;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.ui.Messages;
import com.intellij.usageView.UsageViewBundle;
import com.intellij.usages.UsageView;
import com.intellij.usages.impl.UsageViewImpl;
import org.jetbrains.annotations.NotNull;

/**
* @author gregsh
*/
public class RerunSearchAction extends DumbAwareAction {

  @Override
  public void actionPerformed(@NotNull AnActionEvent e) {
    UsageView usageView = e.getData(UsageView.USAGE_VIEW_KEY);
    if (usageView instanceof UsageViewImpl) {
      if (!((UsageViewImpl)usageView).canPerformReRun()) {
        Messages.showErrorDialog(e.getProject(), UsageViewBundle.message("dialog.message.targets.have.been.invalidated"),
                                 UsageViewBundle.message("dialog.title.cannot.re.run.search"));
        return;
      }
      ((UsageViewImpl)usageView).refreshUsages();
    }
  }

  @Override
  public void update(@NotNull AnActionEvent e) {
    UsageView usageView = e.getData(UsageView.USAGE_VIEW_KEY);
    boolean isEnabled = usageView instanceof UsageViewImpl;
    Presentation presentation = e.getPresentation();
    if (isEnabled) presentation.setVisible(((UsageViewImpl)usageView).canPerformReRun());
    presentation.setEnabled(isEnabled);
  }
}<commit_msg>Problems view: hide and disable re-run action if re-run disabled (IDEA-CR-62760)<commit_after>// Copyright 2000-2019 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.usages.actions;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.ui.Messages;
import com.intellij.usageView.UsageViewBundle;
import com.intellij.usages.UsageView;
import com.intellij.usages.impl.UsageViewImpl;
import org.jetbrains.annotations.NotNull;

/**
* @author gregsh
*/
public class RerunSearchAction extends DumbAwareAction {

  @Override
  public void actionPerformed(@NotNull AnActionEvent e) {
    UsageView usageView = e.getData(UsageView.USAGE_VIEW_KEY);
    if (usageView instanceof UsageViewImpl) {
      if (!((UsageViewImpl)usageView).canPerformReRun()) {
        Messages.showErrorDialog(e.getProject(), UsageViewBundle.message("dialog.message.targets.have.been.invalidated"),
                                 UsageViewBundle.message("dialog.title.cannot.re.run.search"));
        return;
      }
      ((UsageViewImpl)usageView).refreshUsages();
    }
  }

  @Override
  public void update(@NotNull AnActionEvent e) {
    UsageView usageView = e.getData(UsageView.USAGE_VIEW_KEY);
    e.getPresentation().setEnabledAndVisible(usageView instanceof UsageViewImpl && ((UsageViewImpl)usageView).canPerformReRun());
  }
}
{'fraction_non_alphanumeric': 0.10430038510911425, 'fraction_numerical': 0.008023106546854942, 'mean_word_length': 4.478031634446397, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5662216', 'n_tokens_mistral': 977, 'n_tokens_neox': 932, 'n_words': 184}