mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
faster lookup element painting
This commit is contained in:
+15
-11
@@ -28,6 +28,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.codeStyle.MinusculeMatcher;
|
||||
import com.intellij.psi.codeStyle.NameUtil;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.speedSearch.SpeedSearchUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.FList;
|
||||
@@ -172,17 +173,20 @@ public class LookupCellRenderer implements ListCellRenderer {
|
||||
myTailComponent.getPreferredSize().getWidth() +
|
||||
myTypeLabel.getPreferredSize().getWidth();
|
||||
|
||||
myPanel.removeAll();
|
||||
if (isSelected && w > list.getWidth()) {
|
||||
myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.X_AXIS));
|
||||
myPanel.add(myNameComponent);
|
||||
myPanel.add(myTailComponent);
|
||||
myPanel.add(myTypeLabel);
|
||||
} else {
|
||||
myPanel.setLayout(new BorderLayout());
|
||||
myPanel.add(myNameComponent, BorderLayout.WEST);
|
||||
myPanel.add(myTailComponent, BorderLayout.CENTER);
|
||||
myPanel.add(myTypeLabel, BorderLayout.EAST);
|
||||
boolean useBoxLayout = isSelected && w > list.getWidth() && ((JBList)list).getExpandableItemsHandler().isEnabled();
|
||||
if (useBoxLayout != myPanel.getLayout() instanceof BoxLayout) {
|
||||
myPanel.removeAll();
|
||||
if (useBoxLayout) {
|
||||
myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.X_AXIS));
|
||||
myPanel.add(myNameComponent);
|
||||
myPanel.add(myTailComponent);
|
||||
myPanel.add(myTypeLabel);
|
||||
} else {
|
||||
myPanel.setLayout(new BorderLayout());
|
||||
myPanel.add(myNameComponent, BorderLayout.WEST);
|
||||
myPanel.add(myTailComponent, BorderLayout.CENTER);
|
||||
myPanel.add(myTypeLabel, BorderLayout.EAST);
|
||||
}
|
||||
}
|
||||
|
||||
return myPanel;
|
||||
|
||||
@@ -21,6 +21,8 @@ import java.util.Collection;
|
||||
|
||||
public interface ExpandableItemsHandler<T> {
|
||||
void setEnabled(boolean enabled);
|
||||
|
||||
boolean isEnabled();
|
||||
|
||||
@NotNull
|
||||
Collection<T> getExpandedItems();
|
||||
|
||||
@@ -58,6 +58,11 @@ public abstract class ExpandableItemsHandlerFactory {
|
||||
public void setEnabled(boolean enabled) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<Object> getExpandedItems() {
|
||||
|
||||
@@ -159,6 +159,11 @@ public abstract class AbstractExpandableItemsHandler<KeyType, ComponentType exte
|
||||
if (!myEnabled) hideHint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return myEnabled;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<KeyType> getExpandedItems() {
|
||||
|
||||
Reference in New Issue
Block a user