From 05eab6a32eed8104efca1a2e3b9ca6e88b71cdcf Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 13 Oct 2009 13:49:12 +0100 Subject: [PATCH] IDEADEV-40837 Completion popup: tail type cut off --- .../lookup/impl/LookupCellRenderer.java | 1 - .../intellij/ui/SimpleColoredComponent.java | 73 +++++++++++++------ 2 files changed, 51 insertions(+), 23 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupCellRenderer.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupCellRenderer.java index 2b040a356eee..f752b376ba5e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupCellRenderer.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupCellRenderer.java @@ -243,7 +243,6 @@ public class LookupCellRenderer implements ListCellRenderer { myTypeLabel.append(labelText); } - myTypeLabel.setBackground(Color.YELLOW); myTypeLabel.setBackground(sampleBackground); myTypeLabel.setForeground(item instanceof EmptyLookupItem ? EMPTY_ITEM_FOREGROUND_COLOR : foreground); return used; diff --git a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java index 2c235d6014f3..203faa8d5f8f 100644 --- a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java +++ b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java @@ -101,23 +101,31 @@ public class SimpleColoredComponent extends JComponent { * Appends string fragments to existing ones. Appended string * will have specified attributes. */ - public synchronized void append(@NotNull final String fragment, @NotNull final SimpleTextAttributes attributes, boolean isMainText) { - myFragments.add(fragment); - myAttributes.add(attributes); - if (isMainText) { - myMainTextLastIndex = myFragments.size() - 1; + public void append(@NotNull final String fragment, @NotNull final SimpleTextAttributes attributes, boolean isMainText) { + synchronized (this) { + myFragments.add(fragment); + myAttributes.add(attributes); + if (isMainText) { + myMainTextLastIndex = myFragments.size() - 1; + } } + revalidate(); + repaint(); } - public synchronized void append(@NotNull final String fragment, @NotNull final SimpleTextAttributes attributes, Object tag) { - append(fragment, attributes); - if (myFragmentTags == null) { - myFragmentTags = new ArrayList(); + public void append(@NotNull final String fragment, @NotNull final SimpleTextAttributes attributes, Object tag) { + synchronized (this) { + append(fragment, attributes); + if (myFragmentTags == null) { + myFragmentTags = new ArrayList(); + } + while(myFragmentTags.size() < myFragments.size()-1) { + myFragmentTags.add(null); + } + myFragmentTags.add(tag); } - while(myFragmentTags.size() < myFragments.size()-1) { - myFragmentTags.add(null); - } - myFragmentTags.add(tag); + revalidate(); + repaint(); } public synchronized void appendAlign(int alignWidth) { @@ -129,15 +137,19 @@ public class SimpleColoredComponent extends JComponent { * Clear all special attributes of SimpleColoredComponent. * They are icon, text fragments and their attributes, "paint focus border". */ - public synchronized void clear() { - myIcon = null; - myPaintFocusBorder = false; - myFragments.clear(); - myAttributes.clear(); - myFragmentTags = null; - myMainTextLastIndex = -1; - myAlignIndex = -1; - myAlignWidth = -1; + public void clear() { + synchronized (this) { + myIcon = null; + myPaintFocusBorder = false; + myFragments.clear(); + myAttributes.clear(); + myFragmentTags = null; + myMainTextLastIndex = -1; + myAlignIndex = -1; + myAlignWidth = -1; + } + revalidate(); + repaint(); } /** @@ -153,6 +165,8 @@ public class SimpleColoredComponent extends JComponent { */ public final void setIcon(final Icon icon) { myIcon = icon; + revalidate(); + repaint(); } /** @@ -167,6 +181,9 @@ public class SimpleColoredComponent extends JComponent { */ public void setIpad(final Insets ipad) { myIpad = ipad; + + revalidate(); + repaint(); } /** @@ -188,6 +205,9 @@ public class SimpleColoredComponent extends JComponent { throw new IllegalArgumentException("wrong iconTextGap: " + iconTextGap); } myIconTextGap = iconTextGap; + + revalidate(); + repaint(); } /** @@ -195,6 +215,8 @@ public class SimpleColoredComponent extends JComponent { */ protected final void setPaintFocusBorder(final boolean paintFocusBorder) { myPaintFocusBorder = paintFocusBorder; + + repaint(); } /** @@ -203,6 +225,8 @@ public class SimpleColoredComponent extends JComponent { */ protected final void setFocusBorderAroundIcon(final boolean focusBorderAroundIcon) { myFocusBorderAroundIcon = focusBorderAroundIcon; + + repaint(); } public boolean isIconOpaque() { @@ -211,6 +235,8 @@ public class SimpleColoredComponent extends JComponent { public void setIconOpaque(final boolean iconOpaque) { myIconOpaque = iconOpaque; + + repaint(); } public Dimension getPreferredSize() { @@ -457,6 +483,9 @@ public class SimpleColoredComponent extends JComponent { protected void setBorderInsets(Insets insets) { myBorder.setInsets(insets); + + revalidate(); + repaint(); } private static final class MyBorder implements Border {