mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
remember the resized lookup size
This commit is contained in:
+1
-1
@@ -35,7 +35,7 @@ public class RealLookupElementPresentation extends LookupElementPresentation {
|
||||
result += getStringWidth(presentation.getTailText(), normalMetrics);
|
||||
final String typeText = presentation.getTypeText();
|
||||
if (StringUtil.isNotEmpty(typeText)) {
|
||||
result += getStringWidth("XXX", normalMetrics); //3 spaces for nice tail-type separation
|
||||
result += getStringWidth("W", normalMetrics); // nice tail-type separation
|
||||
result += getStringWidth(typeText, normalMetrics);
|
||||
}
|
||||
result += getStringWidth("W", boldMetrics); //for unforeseen Swing size adjustments
|
||||
|
||||
@@ -45,7 +45,6 @@ public class LookupCellRenderer implements ListCellRenderer {
|
||||
private final Font myBoldFont;
|
||||
private final FontMetrics myNormalMetrics;
|
||||
private final FontMetrics myBoldMetrics;
|
||||
private final int myMaxWidth;
|
||||
|
||||
public static final Color BACKGROUND_COLOR = new Color(235, 244, 254);
|
||||
static final Color FOREGROUND_COLOR = Color.black;
|
||||
@@ -98,7 +97,6 @@ public class LookupCellRenderer implements ListCellRenderer {
|
||||
|
||||
myNormalMetrics = myLookup.getEditor().getComponent().getFontMetrics(myNormalFont);
|
||||
myBoldMetrics = myLookup.getEditor().getComponent().getFontMetrics(myBoldFont);
|
||||
myMaxWidth = myNormalMetrics.stringWidth(StringUtil.repeatSymbol('W', MAX_LENGTH));
|
||||
|
||||
UIUtil.removeQuaquaVisualMarginsIn(myPanel);
|
||||
}
|
||||
@@ -266,7 +264,7 @@ public class LookupCellRenderer implements ListCellRenderer {
|
||||
int allowedWidth,
|
||||
boolean selected) {
|
||||
final String givenText = presentation.getTypeText();
|
||||
final String labelText = trimLabelText(StringUtil.isEmpty(givenText) ? "" : " " + givenText, allowedWidth, myNormalMetrics);
|
||||
final String labelText = trimLabelText(StringUtil.isEmpty(givenText) ? "" : " " + givenText, allowedWidth, myNormalMetrics);
|
||||
|
||||
int used = RealLookupElementPresentation.getStringWidth(labelText, myNormalMetrics);
|
||||
|
||||
@@ -320,8 +318,7 @@ public class LookupCellRenderer implements ListCellRenderer {
|
||||
myEmptyIcon = new EmptyIcon(Math.max(icon.getIconWidth(), myEmptyIcon.getIconWidth()), Math.max(icon.getIconHeight(), myEmptyIcon.getIconHeight()));
|
||||
}
|
||||
|
||||
int maxWidth = Math.min(RealLookupElementPresentation.calculateWidth(p, myNormalMetrics, myBoldMetrics), myMaxWidth);
|
||||
return maxWidth + getCommonGapsWidth();
|
||||
return RealLookupElementPresentation.calculateWidth(p, myNormalMetrics, myBoldMetrics) + getCommonGapsWidth();
|
||||
}
|
||||
|
||||
private int getCommonGapsWidth() {
|
||||
|
||||
@@ -90,7 +90,6 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable
|
||||
private static final int MAX_PREFERRED_COUNT = 5;
|
||||
|
||||
private static final LookupItem EMPTY_LOOKUP_ITEM = LookupItem.fromString("preselect");
|
||||
private static final int LOOKUP_HEIGHT = Integer.getInteger("idea.lookup.height", 11).intValue();
|
||||
private static final Icon relevanceSortIcon = IconLoader.getIcon("/ide/lookupRelevance.png");
|
||||
private static final Icon lexiSortIcon = IconLoader.getIcon("/ide/lookupAlphanumeric.png");
|
||||
|
||||
@@ -442,7 +441,8 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable
|
||||
updateListHeight(listModel);
|
||||
|
||||
if (!model.isEmpty()) {
|
||||
myList.setFixedCellWidth(Math.max(myLookupTextWidth + myCellRenderer.getIconIndent(), myAdComponent.getAdComponent().getPreferredSize().width));
|
||||
int listWidth = Math.min(myLookupTextWidth + myCellRenderer.getIconIndent(), UISettings.getInstance().MAX_LOOKUP_LIST_WIDTH);
|
||||
myList.setFixedCellWidth(Math.max(listWidth, myAdComponent.getAdComponent().getPreferredSize().width));
|
||||
|
||||
LookupElement first = model.iterator().next();
|
||||
if (isFocused() && (!(isExactPrefixItem(first, true) || isExactPrefixItem(first, false)) || mySelectionTouched)) {
|
||||
@@ -528,7 +528,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable
|
||||
private void updateListHeight(ListModel model) {
|
||||
myList.setFixedCellHeight(myCellRenderer.getListCellRendererComponent(myList, model.getElementAt(0), 0, false, false).getPreferredSize().height);
|
||||
|
||||
myList.setVisibleRowCount(Math.min(model.getSize(), LOOKUP_HEIGHT));
|
||||
myList.setVisibleRowCount(Math.min(model.getSize(), UISettings.getInstance().MAX_LOOKUP_ITEM_COUNT));
|
||||
}
|
||||
|
||||
private void addEmptyItem(DefaultListModel model) {
|
||||
@@ -1356,8 +1356,16 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable
|
||||
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
mainPanel.setSize(getSize());
|
||||
Dimension size = getSize();
|
||||
mainPanel.setSize(size);
|
||||
mainPanel.validate();
|
||||
|
||||
UISettings.getInstance().MAX_LOOKUP_LIST_WIDTH = Math.max(300, myScrollPane.getViewport().getWidth());
|
||||
int visibleRowCount = myList.getLastVisibleIndex() - myList.getFirstVisibleIndex() + 1;
|
||||
if (visibleRowCount != myList.getModel().getSize()) {
|
||||
UISettings.getInstance().MAX_LOOKUP_ITEM_COUNT = Math.max(5, visibleRowCount);
|
||||
}
|
||||
|
||||
layoutStatusIcons();
|
||||
layoutHint();
|
||||
|
||||
|
||||
@@ -87,6 +87,8 @@ public class UISettings implements PersistentStateComponent<UISettings>, Exporta
|
||||
public boolean SHOW_ICONS_IN_MENUS = true;
|
||||
public boolean DISABLE_MNEMONICS = SystemInfo.isMac; // IDEADEV-33409, should be disabled by default on MacOS
|
||||
public boolean SORT_LOOKUP_ELEMENTS_LEXICOGRAPHICALLY = false;
|
||||
public int MAX_LOOKUP_LIST_WIDTH = 500;
|
||||
public int MAX_LOOKUP_ITEM_COUNT = 11;
|
||||
|
||||
/**
|
||||
* Defines whether asterisk is shown on modified editor tab or not
|
||||
|
||||
Reference in New Issue
Block a user