[r=anton] list/table tooltips speed optimization (IDEA-61033)

This commit is contained in:
Eugene Zhuravlev
2010-11-17 17:05:02 +03:00
parent 80a7cd7d4c
commit 37c5f578bb
2 changed files with 20 additions and 22 deletions
@@ -22,7 +22,6 @@ import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.util.Comparing;
import com.intellij.ui.ColoredListCellRenderer;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.ui.UIUtil;
import com.intellij.xdebugger.ui.DebuggerColors;
import com.sun.jdi.Method;
@@ -92,28 +91,11 @@ class FramesListRenderer extends ColoredListCellRenderer {
}
else {
append(label.substring(0, openingBrace - 1), attributes);
final StringBuilder builder = StringBuilderSpinAllocator.alloc();
try {
builder.append(" (");
builder.append(label.substring(openingBrace + 1, closingBrace));
builder.append(")");
append(builder.toString(), SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES);
}
finally {
StringBuilderSpinAllocator.dispose(builder);
}
append(" (" + label.substring(openingBrace + 1, closingBrace) + ")", SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES);
append(label.substring(closingBrace + 1, label.length()), attributes);
if (shouldHighlightAsRecursive && descriptor.isRecursiveCall()) {
final StringBuilder _builder = StringBuilderSpinAllocator.alloc();
try {
_builder.append(" [").append(descriptor.getOccurrenceIndex()).append("]");
append(_builder.toString(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
}
finally {
StringBuilderSpinAllocator.dispose(_builder);
}
append(" [" + descriptor.getOccurrenceIndex() + "]", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
}
}
}
@@ -18,6 +18,7 @@ package com.intellij.ui;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Pair;
import com.intellij.util.Alarm;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -167,7 +168,21 @@ abstract public class AbstractExpandableItemsHandler<KeyType, ComponentType exte
handleSelectionChange(selected, false);
}
protected void handleSelectionChange(KeyType selected, boolean processIfUnfocused) {
private final Alarm myUpdateAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
protected void handleSelectionChange(final KeyType selected, final boolean processIfUnfocused) {
if (!ApplicationManager.getApplication().isDispatchThread()) {
return;
}
myUpdateAlarm.cancelAllRequests();
myUpdateAlarm.addRequest(new Runnable() {
public void run() {
doHandleSelectionChange(selected, processIfUnfocused);
}
}, 150);
}
private void doHandleSelectionChange(KeyType selected, boolean processIfUnfocused) {
if (!isEnabled) return;
if (selected == null || !myComponent.isShowing() || (!myComponent.isFocusOwner() && !processIfUnfocused)) {
@@ -193,7 +208,8 @@ abstract public class AbstractExpandableItemsHandler<KeyType, ComponentType exte
}
}
protected final void hideHint() {
private void hideHint() {
myUpdateAlarm.cancelAllRequests();
if (myHint != null) {
myHint.hide();
myHint = null;