From fa53d89041ac7eba2b7c1dadf65f61197f63b850 Mon Sep 17 00:00:00 2001 From: "peter.gromov" Date: Mon, 8 Nov 2010 19:16:36 +0300 Subject: [PATCH 1/2] lookup progress which doesn't lead to size jumping --- .../codeInsight/lookup/impl/LookupImpl.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java index 55cdba73dde1..c3d1ec195f9e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java @@ -97,6 +97,7 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable { private boolean myFocused = true; private String myAdditionalPrefix = ""; private final AsyncProcessIcon myProcessIcon = new AsyncProcessIcon("Completion progress"); + private final JPanel myIconPanel = new JPanel(new BorderLayout()); private volatile boolean myCalculating; private final JLabel myAdComponent; private volatile String myAdText; @@ -112,7 +113,7 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable { myProject = project; myEditor = editor; - myProcessIcon.setVisible(false); + myIconPanel.setVisible(false); myCellRenderer = new LookupCellRenderer(this); myList.setCellRenderer(myCellRenderer); @@ -127,14 +128,13 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable { getComponent().add(scrollPane, BorderLayout.NORTH); scrollPane.setBorder(null); - JPanel bottomPanel = new JPanel(new BorderLayout()); - - bottomPanel.add(myProcessIcon, BorderLayout.EAST); myAdComponent = HintUtil.createAdComponent(null); - bottomPanel.add(myAdComponent, BorderLayout.CENTER); - getComponent().add(bottomPanel, BorderLayout.SOUTH); + getComponent().add(myAdComponent, BorderLayout.SOUTH); getComponent().setBorder(new BegPopupMenuBorder()); + myIconPanel.setBackground(Color.LIGHT_GRAY); + myIconPanel.add(myProcessIcon); + final ListModel model = myList.getModel(); addEmptyItem((DefaultListModel)model); updateListHeight(model); @@ -164,7 +164,7 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable { public void setCalculating(final boolean calculating) { myCalculating = calculating; - myProcessIcon.setVisible(calculating); + myIconPanel.setVisible(calculating); if (calculating) { myProcessIcon.resume(); } else { @@ -306,11 +306,7 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable { updateListHeight(model); - myAdComponent.setPreferredSize(null); myAdComponent.setText(myAdText); - if (myAdText != null) { - myAdComponent.setPreferredSize(new Dimension(myAdComponent.getPreferredSize().width, myProcessIcon.getPreferredSize().height)); - } if (hasItems) { myList.setFixedCellWidth(Math.max(myLookupTextWidth + myCellRenderer.getIconIndent(), myAdComponent.getPreferredSize().width)); @@ -584,6 +580,8 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable { HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl(); hintManager.showEditorHint(this, myEditor, p, HintManagerImpl.HIDE_BY_ESCAPE | HintManagerImpl.UPDATE_BY_SCROLLING, 0, false); + getComponent().getRootPane().getLayeredPane().add(myIconPanel, 42, 0); + myShownStamp = System.currentTimeMillis(); } @@ -976,6 +974,9 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable { Point point = calculatePosition(); updateBounds(point.x,point.y); + final Dimension size = myProcessIcon.getPreferredSize(); + myIconPanel.setBounds(getComponent().getRootPane().getLayeredPane().getWidth() - size.width, 0, size.width, size.height); + HintManagerImpl.adjustEditorHintPosition(this, myEditor, point); } } From 487b0edba89ca90a08a14d099eb22dca6622dd38 Mon Sep 17 00:00:00 2001 From: "peter.gromov" Date: Mon, 8 Nov 2010 19:22:50 +0300 Subject: [PATCH 2/2] more interruptibility in class name completion --- .../impl/search/AllClassesSearchExecutor.java | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/java/java-impl/src/com/intellij/psi/impl/search/AllClassesSearchExecutor.java b/java/java-impl/src/com/intellij/psi/impl/search/AllClassesSearchExecutor.java index 817c937cf562..e2fcbcec8acd 100644 --- a/java/java-impl/src/com/intellij/psi/impl/search/AllClassesSearchExecutor.java +++ b/java/java-impl/src/com/intellij/psi/impl/search/AllClassesSearchExecutor.java @@ -20,6 +20,7 @@ package com.intellij.psi.impl.search; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.util.Computable; import com.intellij.psi.*; @@ -32,8 +33,10 @@ import com.intellij.util.Processor; import com.intellij.util.QueryExecutor; import org.jetbrains.annotations.NotNull; -import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collections; import java.util.Comparator; +import java.util.List; public class AllClassesSearchExecutor implements QueryExecutor { public boolean execute(@NotNull final AllClassesSearch.SearchParameters queryParameters, @NotNull final Processor consumer) { @@ -61,16 +64,34 @@ public class AllClassesSearchExecutor implements QueryExecutor() { + + final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); + if (indicator != null) { + indicator.checkCanceled(); + } + + List sorted = new ArrayList(names.length); + for (int i = 0; i < names.length; i++) { + String name = names[i]; + if (parameters.nameMatches(name)) { + sorted.add(name); + } + if (indicator != null && i % 512 == 0) { + indicator.checkCanceled(); + } + } + + if (indicator != null) { + indicator.checkCanceled(); + } + + Collections.sort(sorted, new Comparator() { public int compare(final String o1, final String o2) { return o1.compareToIgnoreCase(o2); } }); - for (final String name : names) { - if (!parameters.nameMatches(name)) continue; - + for (final String name : sorted) { ProgressManager.checkCanceled(); final PsiClass[] classes = ApplicationManager.getApplication().runReadAction(new Computable() { public PsiClass[] compute() {