mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Align location string to the right in goto* popups, when there's no module renderer.
This commit is contained in:
@@ -29,4 +29,8 @@ public abstract class ModuleRendererFactory {
|
||||
}
|
||||
|
||||
public abstract DefaultListCellRenderer getModuleRenderer();
|
||||
|
||||
public boolean rendersLocationString() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,12 +55,18 @@ public class NavigationItemListCellRenderer extends JPanel implements ListCellRe
|
||||
Font editorFont = new Font(scheme.getEditorFontName(), Font.PLAIN, scheme.getEditorFontSize());
|
||||
setFont(editorFont);
|
||||
removeAll();
|
||||
final Component leftCellRendererComponent =
|
||||
new LeftRenderer().getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
|
||||
final boolean hasRightRenderer = UISettings.getInstance().SHOW_ICONS_IN_QUICK_NAVIGATION;
|
||||
final ModuleRendererFactory factory = ModuleRendererFactory.getInstance();
|
||||
|
||||
final LeftRenderer left = new LeftRenderer(!hasRightRenderer || !factory.rendersLocationString());
|
||||
final Component leftCellRendererComponent = left.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
final Color listBg = leftCellRendererComponent.getBackground();
|
||||
add(leftCellRendererComponent, BorderLayout.WEST);
|
||||
if (UISettings.getInstance().SHOW_ICONS_IN_QUICK_NAVIGATION){
|
||||
final DefaultListCellRenderer moduleRenderer = ModuleRendererFactory.getInstance().getModuleRenderer();
|
||||
|
||||
if (hasRightRenderer){
|
||||
final DefaultListCellRenderer moduleRenderer = factory.getModuleRenderer();
|
||||
|
||||
final Component rightCellRendererComponent =
|
||||
moduleRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
rightCellRendererComponent.setBackground(listBg);
|
||||
@@ -76,6 +82,12 @@ public class NavigationItemListCellRenderer extends JPanel implements ListCellRe
|
||||
}
|
||||
|
||||
private static class LeftRenderer extends ColoredListCellRenderer {
|
||||
public final boolean myRenderLocation;
|
||||
|
||||
public LeftRenderer(boolean renderLocation) {
|
||||
myRenderLocation = renderLocation;
|
||||
}
|
||||
|
||||
protected void customizeCellRenderer(
|
||||
JList list,
|
||||
Object value,
|
||||
@@ -129,10 +141,12 @@ public class NavigationItemListCellRenderer extends JPanel implements ListCellRe
|
||||
append(name, nameAttributes);
|
||||
setIcon(presentation.getIcon(false));
|
||||
|
||||
String containerText = presentation.getLocationString();
|
||||
if (myRenderLocation) {
|
||||
String containerText = presentation.getLocationString();
|
||||
|
||||
if (containerText != null && containerText.length() > 0) {
|
||||
append(" " + containerText, new SimpleTextAttributes(Font.PLAIN, Color.GRAY));
|
||||
if (containerText != null && containerText.length() > 0) {
|
||||
append(" " + containerText, new SimpleTextAttributes(Font.PLAIN, Color.GRAY));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.intellij.ide.util;
|
||||
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.navigation.NavigationItem;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -33,7 +35,20 @@ public class PlatformModuleRendererFactory extends ModuleRendererFactory {
|
||||
final boolean isSelected,
|
||||
final boolean cellHasFocus) {
|
||||
final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
setText("");
|
||||
|
||||
String text = "";
|
||||
if (value instanceof NavigationItem) {
|
||||
final ItemPresentation presentation = ((NavigationItem)value).getPresentation();
|
||||
if (presentation != null) {
|
||||
String containerText = presentation.getLocationString();
|
||||
if (containerText != null && containerText.length() > 0) {
|
||||
text = " " + containerText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setText(text);
|
||||
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
|
||||
setHorizontalTextPosition(SwingConstants.LEFT);
|
||||
setBackground(isSelected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground());
|
||||
@@ -42,4 +57,9 @@ public class PlatformModuleRendererFactory extends ModuleRendererFactory {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rendersLocationString() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user