mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix renderer cosmetics (focus border) and popup width
This commit is contained in:
@@ -63,7 +63,7 @@ public class GotoRelatedFileAction extends AnAction {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
System.out.println(items);
|
||||
}
|
||||
createPopup(items, "Goto Related").showInBestPositionFor(context);
|
||||
createPopup(items, "Go to Related Files").showInBestPositionFor(context);
|
||||
}
|
||||
|
||||
public static JBPopup createPopup(final List<? extends GotoRelatedItem> items, final String title) {
|
||||
@@ -77,6 +77,10 @@ public class GotoRelatedFileAction extends AnAction {
|
||||
}
|
||||
|
||||
return getPsiElementPopup(elements, new DefaultPsiElementCellRenderer() {
|
||||
{
|
||||
setFocusBorderEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementText(PsiElement element) {
|
||||
String customName = itemsMap.get(element).getCustomName();
|
||||
@@ -92,7 +96,9 @@ public class GotoRelatedFileAction extends AnAction {
|
||||
@Override
|
||||
public String getContainerText(PsiElement element, String name) {
|
||||
PsiFile file = element.getContainingFile();
|
||||
return file != null && !getElementText(element).equals(file.getName()) ? "(" + file.getName() + ")" : null;
|
||||
return file != null && !getElementText(element).equals(file.getName())
|
||||
? "(" + file.getName() + ")"
|
||||
: null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -122,7 +128,8 @@ public class GotoRelatedFileAction extends AnAction {
|
||||
if (element instanceof PsiElement) {
|
||||
//noinspection SuspiciousMethodCalls
|
||||
itemsMap.get(element).navigate();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
((GotoRelatedItem)element).navigate();
|
||||
}
|
||||
return true;
|
||||
@@ -132,7 +139,7 @@ public class GotoRelatedFileAction extends AnAction {
|
||||
}
|
||||
|
||||
public static JBPopup getPsiElementPopup(final Object[] elements, final PsiElementListCellRenderer<PsiElement> renderer,
|
||||
final String title, final Processor<Object> processor) {
|
||||
final String title, final Processor<Object> processor) {
|
||||
final JList list = new JBList(elements);
|
||||
list.setCellRenderer(renderer);
|
||||
|
||||
@@ -153,7 +160,7 @@ public class GotoRelatedFileAction extends AnAction {
|
||||
builder.setTitle(title);
|
||||
}
|
||||
renderer.installSpeedSearch(builder, true);
|
||||
|
||||
builder.setMinSize(new Dimension(200, -1));
|
||||
return builder.setItemChoosenCallback(runnable).createPopup();
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ import java.util.Comparator;
|
||||
public abstract class PsiElementListCellRenderer<T extends PsiElement> extends JPanel implements ListCellRenderer, MatcherHolder {
|
||||
|
||||
private Matcher myMatcher;
|
||||
private boolean myFocusBorderEnabled = true;
|
||||
|
||||
protected PsiElementListCellRenderer() {
|
||||
super(new BorderLayout());
|
||||
@@ -118,7 +119,7 @@ public abstract class PsiElementListCellRenderer<T extends PsiElement> extends J
|
||||
setIcon(IconUtil.getEmptyIcon(false));
|
||||
append(value == null ? "" : value.toString(), new SimpleTextAttributes(Font.PLAIN, list.getForeground()));
|
||||
}
|
||||
setPaintFocusBorder(hasFocus && UIUtil.isToUseDottedCellBorder());
|
||||
setPaintFocusBorder(hasFocus && UIUtil.isToUseDottedCellBorder() && myFocusBorderEnabled);
|
||||
setBackground(selected ? UIUtil.getListSelectionBackground() : bgColor);
|
||||
}
|
||||
|
||||
@@ -160,6 +161,10 @@ public abstract class PsiElementListCellRenderer<T extends PsiElement> extends J
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void setFocusBorderEnabled(boolean enabled) {
|
||||
myFocusBorderEnabled = enabled;
|
||||
}
|
||||
|
||||
protected boolean customizeNonPsiElementLeftRenderer(ColoredListCellRenderer renderer,
|
||||
JList list,
|
||||
Object value,
|
||||
|
||||
Reference in New Issue
Block a user