Merge branch 'master' of git@git.labs.intellij.net:idea/community

This commit is contained in:
Kirill Kalishev
2010-11-08 19:39:42 +03:00
2 changed files with 39 additions and 17 deletions
@@ -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<PsiClass, AllClassesSearch.SearchParameters> {
public boolean execute(@NotNull final AllClassesSearch.SearchParameters queryParameters, @NotNull final Processor<PsiClass> consumer) {
@@ -61,16 +64,34 @@ public class AllClassesSearchExecutor implements QueryExecutor<PsiClass, AllClas
return cache.getAllClassNames();
}
});
ProgressManager.checkCanceled();
Arrays.sort(names, new Comparator<String>() {
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
if (indicator != null) {
indicator.checkCanceled();
}
List<String> sorted = new ArrayList<String>(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<String>() {
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<PsiClass[]>() {
public PsiClass[] compute() {
@@ -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);
}
}