mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
non-prefix matching in goto... actions
This commit is contained in:
+6
@@ -17,6 +17,7 @@ package com.intellij.codeInspection.actions;
|
||||
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
|
||||
import com.intellij.ide.util.gotoByName.ChooseByNameBase;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.fileTypes.UnknownFileType;
|
||||
@@ -82,6 +83,11 @@ public class InspectionListCellRenderer extends DefaultListCellRenderer implemen
|
||||
right.add(icon, BorderLayout.EAST);
|
||||
panel.add(right, BorderLayout.EAST);
|
||||
}
|
||||
else {
|
||||
// E.g. "..." item
|
||||
Component component = super.getListCellRendererComponent(list, value, index, sel, focus);
|
||||
return value == ChooseByNameBase.NON_PREFIX_SEPARATOR ? ChooseByNameBase.renderNonPrefixSeparatorComponent(component) : component;
|
||||
}
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
@@ -410,8 +410,9 @@ public abstract class ChooseByNameBase {
|
||||
curElements.add(psi);
|
||||
}
|
||||
}
|
||||
else if (object == NON_PREFIX_SEPARATOR)
|
||||
else if (object == NON_PREFIX_SEPARATOR) {
|
||||
curElements = nonPrefixMatchElements;
|
||||
}
|
||||
}
|
||||
return new PsiElement[][]{PsiUtilCore.toPsiElementArray(prefixMatchElements), PsiUtilCore.toPsiElementArray(nonPrefixMatchElements)};
|
||||
}
|
||||
@@ -1398,7 +1399,12 @@ public abstract class ChooseByNameBase {
|
||||
}
|
||||
|
||||
private static final String EXTRA_ELEM = "...";
|
||||
static final String NON_PREFIX_SEPARATOR = "non-prefix matches:";
|
||||
public static final String NON_PREFIX_SEPARATOR = "non-prefix matches:";
|
||||
|
||||
public static Component renderNonPrefixSeparatorComponent(Component component) {
|
||||
component.setFont(component.getFont().deriveFont(Font.PLAIN, component.getFont().getSize() - 2));
|
||||
return component;
|
||||
}
|
||||
|
||||
private class CalcElementsThread implements Runnable {
|
||||
private final String myPattern;
|
||||
|
||||
+1
-6
@@ -58,12 +58,7 @@ public abstract class ContributorsBasedGotoByModel implements ChooseByNameModel
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
|
||||
if (value == ChooseByNameBase.NON_PREFIX_SEPARATOR) {
|
||||
component.setFont(component.getFont().deriveFont(Font.BOLD, component.getFont().getSize() - 2));
|
||||
}
|
||||
|
||||
return component;
|
||||
return value == ChooseByNameBase.NON_PREFIX_SEPARATOR ? ChooseByNameBase.renderNonPrefixSeparatorComponent(component) : component;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -42,15 +42,21 @@ public class GotoFileCellRenderer extends PsiElementListCellRenderer<PsiFile> {
|
||||
|
||||
public GotoFileCellRenderer(int maxSize) {
|
||||
myMaxWidth = maxSize;
|
||||
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
|
||||
Font editorFont = new Font(scheme.getEditorFontName(), Font.PLAIN, scheme.getEditorFontSize());
|
||||
setFont(editorFont);
|
||||
}
|
||||
|
||||
public String getElementText(PsiFile element) {
|
||||
return element.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
|
||||
Font editorFont = new Font(scheme.getEditorFontName(), Font.PLAIN, scheme.getEditorFontSize());
|
||||
setFont(editorFont);
|
||||
return value == ChooseByNameBase.NON_PREFIX_SEPARATOR ? ChooseByNameBase.renderNonPrefixSeparatorComponent(component) : component;
|
||||
}
|
||||
|
||||
protected String getContainerText(PsiFile element, String name) {
|
||||
final PsiDirectory psiDirectory = element.getContainingDirectory();
|
||||
if (psiDirectory == null) return null;
|
||||
|
||||
Reference in New Issue
Block a user