mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-119606 Find in Path settings icon has issues
This commit is contained in:
@@ -683,8 +683,8 @@ public class FindInProjectUtil {
|
||||
}
|
||||
|
||||
public static class StringUsageTarget implements ConfigurableUsageTarget, ItemPresentation {
|
||||
@NotNull private final Project myProject;
|
||||
@NotNull private final FindModel myFindModel;
|
||||
@NotNull protected final Project myProject;
|
||||
@NotNull protected final FindModel myFindModel;
|
||||
|
||||
public StringUsageTarget(@NotNull Project project, @NotNull FindModel findModel) {
|
||||
myProject = project;
|
||||
|
||||
+33
-2
@@ -20,9 +20,12 @@ import com.intellij.find.*;
|
||||
import com.intellij.find.actions.FindInPathAction;
|
||||
import com.intellij.find.findInProject.FindInProjectManager;
|
||||
import com.intellij.find.impl.FindInProjectUtil;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.KeyboardShortcut;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
@@ -44,8 +47,10 @@ import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.usageView.*;
|
||||
import com.intellij.usages.*;
|
||||
import com.intellij.usages.UsageViewManager;
|
||||
import com.intellij.usages.impl.UsageViewImpl;
|
||||
import com.intellij.usages.rules.UsageInFile;
|
||||
import com.intellij.util.AdapterProcessor;
|
||||
@@ -154,6 +159,32 @@ public class ReplaceInProjectManager {
|
||||
searchAndShowUsages(manager, usageSearcherFactory, findModelCopy, presentation, processPresentation, findManager);
|
||||
}
|
||||
|
||||
private static class ReplaceInProjectTarget extends FindInProjectUtil.StringUsageTarget {
|
||||
public ReplaceInProjectTarget(@NotNull Project project, @NotNull FindModel findModel) {
|
||||
super(project, findModel);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getLongDescriptiveName() {
|
||||
UsageViewPresentation presentation = FindInProjectUtil.setupViewPresentation(false, myFindModel);
|
||||
return "Replace "+presentation.getToolwindowTitle()+" with '"+ myFindModel.getStringToReplace()+"'";
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyboardShortcut getShortcut() {
|
||||
return ActionManager.getInstance().getKeyboardShortcut("ReplaceInPath");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showSettings() {
|
||||
Content selectedContent = com.intellij.usageView.UsageViewManager.getInstance(myProject).getSelectedContent(true);
|
||||
JComponent component = selectedContent == null ? null : selectedContent.getComponent();
|
||||
ReplaceInProjectManager findInProjectManager = getInstance(myProject);
|
||||
findInProjectManager.replaceInProject(DataManager.getInstance().getDataContext(component));
|
||||
}
|
||||
}
|
||||
|
||||
public void searchAndShowUsages(@NotNull UsageViewManager manager,
|
||||
@NotNull Factory<UsageSearcher> usageSearcherFactory,
|
||||
@NotNull final FindModel findModelCopy,
|
||||
@@ -162,7 +193,7 @@ public class ReplaceInProjectManager {
|
||||
final FindManager findManager) {
|
||||
presentation.setMergeDupLinesAvailable(false);
|
||||
final ReplaceContext[] context = new ReplaceContext[1];
|
||||
manager.searchAndShowUsages(new UsageTarget[]{new FindInProjectUtil.StringUsageTarget(myProject, findModelCopy)},
|
||||
manager.searchAndShowUsages(new UsageTarget[]{new ReplaceInProjectTarget(myProject, findModelCopy)},
|
||||
usageSearcherFactory, processPresentation, presentation, new UsageViewManager.UsageViewStateListener() {
|
||||
@Override
|
||||
public void usageViewCreated(@NotNull UsageView usageView) {
|
||||
|
||||
@@ -477,7 +477,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
|
||||
UsageViewTreeCellRenderer coloredRenderer = (UsageViewTreeCellRenderer)renderer;
|
||||
return coloredRenderer.getPlainTextForNode(value);
|
||||
}
|
||||
return value == null? null : value.toString();
|
||||
return value == null ? null : value.toString();
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
@@ -617,9 +617,11 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
|
||||
|
||||
@NotNull
|
||||
private AnAction showSettings() {
|
||||
return new AnAction("Settings...", "Show find usages settings dialog", AllIcons.General.ProjectSettings) {
|
||||
final ConfigurableUsageTarget configurableUsageTarget = getConfigurableTarget(myTargets);
|
||||
String description = configurableUsageTarget == null ? "Show find usages settings dialog" : "Show settings for "+configurableUsageTarget.getLongDescriptiveName();
|
||||
return new AnAction("Settings...", description, AllIcons.General.ProjectSettings) {
|
||||
{
|
||||
KeyboardShortcut shortcut = getShowUsagesWithSettingsShortcut(myTargets);
|
||||
KeyboardShortcut shortcut = configurableUsageTarget == null ? getShowUsagesWithSettingsShortcut() : configurableUsageTarget.getShortcut();
|
||||
if (shortcut != null) {
|
||||
registerCustomShortcutSet(new CustomShortcutSet(shortcut), getComponent());
|
||||
}
|
||||
@@ -631,6 +633,17 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
|
||||
};
|
||||
}
|
||||
|
||||
private static ConfigurableUsageTarget getConfigurableTarget(@NotNull UsageTarget[] targets) {
|
||||
ConfigurableUsageTarget configurableUsageTarget = null;
|
||||
if (targets.length != 0) {
|
||||
NavigationItem target = targets[0];
|
||||
if (target instanceof ConfigurableUsageTarget) {
|
||||
configurableUsageTarget = (ConfigurableUsageTarget)target;
|
||||
}
|
||||
}
|
||||
return configurableUsageTarget;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private AnAction createRecentFindUsagesAction() {
|
||||
AnAction action = ActionManager.getInstance().getAction(SHOW_RECENT_FIND_USAGES_ACTION_ID);
|
||||
@@ -756,13 +769,8 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
|
||||
}
|
||||
|
||||
static KeyboardShortcut getShowUsagesWithSettingsShortcut(@NotNull UsageTarget[] targets) {
|
||||
if (targets.length != 0) {
|
||||
NavigationItem target = targets[0];
|
||||
if (target instanceof ConfigurableUsageTarget) {
|
||||
return ((ConfigurableUsageTarget)target).getShortcut();
|
||||
}
|
||||
}
|
||||
return getShowUsagesWithSettingsShortcut();
|
||||
ConfigurableUsageTarget configurableTarget = getConfigurableTarget(targets);
|
||||
return configurableTarget == null ? getShowUsagesWithSettingsShortcut() : configurableTarget.getShortcut();
|
||||
}
|
||||
|
||||
void associateProgress(ProgressIndicator indicator) {
|
||||
|
||||
Reference in New Issue
Block a user