From f21ccdf26d4dbd51a746154e87f97438d02307ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Thu, 27 Apr 2017 11:22:33 +0200 Subject: [PATCH] FinderRecursivePanel: optimize layout performance via #hasFixedSizeListElements --- .../com/intellij/ui/FinderRecursivePanel.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ui/FinderRecursivePanel.java b/platform/platform-impl/src/com/intellij/ui/FinderRecursivePanel.java index a775244f5f4f..bc9569a97d7e 100644 --- a/platform/platform-impl/src/com/intellij/ui/FinderRecursivePanel.java +++ b/platform/platform-impl/src/com/intellij/ui/FinderRecursivePanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,7 @@ import com.intellij.ui.components.JBPanelWithEmptyText; import com.intellij.ui.speedSearch.ListWithFilter; import com.intellij.util.ArrayUtil; import com.intellij.util.Function; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.update.MergingUpdateQueue; import com.intellij.util.ui.update.Update; @@ -158,7 +159,7 @@ public abstract class FinderRecursivePanel extends OnePixelSplitter implement /** * Returns tooltip text for the given list item or null if no tooltip is available. - * + *

*

This method is invoked by panel's list cell render in order to set a tooltip text for the list cell render component. * It is invoked before {@link #doCustomizeCellRenderer(SimpleColoredComponent, JList, Object, int, boolean, boolean)}, * thus the tooltip may still be reset in {@code doCustomizeCellRenderer}. @@ -215,6 +216,11 @@ public abstract class FinderRecursivePanel extends OnePixelSplitter implement list.setEmptyText(getListEmptyText()); list.setCellRenderer(createListCellRenderer()); + if (hasFixedSizeListElements()) { + list.setFixedCellHeight(JBUI.scale(UIUtil.LIST_FIXED_CELL_HEIGHT)); + list.setFixedCellWidth(list.getWidth()); + } + installListActions(list); list.addListSelectionListener(new ListSelectionListener() { @Override @@ -406,6 +412,16 @@ public abstract class FinderRecursivePanel extends OnePixelSplitter implement protected void doCustomizeCellRenderer(SimpleColoredComponent comp, JList list, T value, int index, boolean selected, boolean hasFocus) { } + /** + * Whether this list contains "fixed size" elements. + * + * @return true. + * @since 2017.2 + */ + protected boolean hasFixedSizeListElements() { + return true; + } + @Nullable @Override public Object getData(@NonNls String dataId) {