From 1c93db5d03f2b39390ccf511218e396afeb91086 Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Mon, 12 Nov 2012 13:26:36 +0400 Subject: [PATCH] IDEA-90146 --- .../designSurface/DesignerEditorPanel.java | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java index 27bfe58e5ce5..e4d787faff60 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java @@ -42,6 +42,7 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.VerticalFlowLayout; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.HyperlinkLabel; import com.intellij.ui.IdeBorderFactory; @@ -970,7 +971,7 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider message.myQuickFix.run(); } }; - popupAction.getTemplatePresentation().setText(message.myLinkText + message.myAfterLinkText); + popupAction.getTemplatePresentation().setText(cleanText(message.myLinkText + message.myAfterLinkText)); popupGroup.add(popupAction); defaultAction[0] = popupAction; } @@ -982,7 +983,7 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider pair.second.run(); } }; - popupAction.getTemplatePresentation().setText(pair.first); + popupAction.getTemplatePresentation().setText(cleanText(pair.first)); popupGroup.add(popupAction); if (defaultAction[0] == null) { defaultAction[0] = popupAction; @@ -1002,13 +1003,42 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider @Override protected void update(FixableMessageInfo item, Presentation presentation, boolean popup) { if (popup) { - presentation.setText(item.myBeforeLinkText); + presentation.setText(cleanText(item.myBeforeLinkText)); } else { presentation.setText(myTitle); } } + private String cleanText(String text) { + if (text != null) { + text = text.trim(); + text = StringUtil.replace(text, " ", " "); + text = StringUtil.replace(text, "\n", " "); + + StringBuilder builder = new StringBuilder(); + int length = text.length(); + boolean whitespace = false; + + for (int i = 0; i < length; i++) { + char ch = text.charAt(i); + if (ch == ' ') { + if (!whitespace) { + whitespace = true; + builder.append(ch); + } + } + else { + whitespace = false; + builder.append(ch); + } + } + + text = builder.toString(); + } + return text; + } + @Override protected boolean selectionChanged(FixableMessageInfo item) { return false;