diff options
author | Chris Goldthorpe | 2009-04-22 18:07:19 +0000 |
---|---|---|
committer | Chris Goldthorpe | 2009-04-22 18:07:19 +0000 |
commit | ae3cc98e75e91841e85a0e0e1baeeb3a514c783a (patch) | |
tree | 8cd0e0b0502c2aef2445fbc786688dcc427d56ca /org.eclipse.ui.intro | |
parent | d105b7ce9239a889acd08cf3b56c7e8a9ec30c95 (diff) | |
download | eclipse.platform.ua-ae3cc98e75e91841e85a0e0e1baeeb3a514c783a.tar.gz eclipse.platform.ua-ae3cc98e75e91841e85a0e0e1baeeb3a514c783a.tar.xz eclipse.platform.ua-ae3cc98e75e91841e85a0e0e1baeeb3a514c783a.zip |
Bug 273241 [Intro] The text of item is't trim on Welcome page:
Diffstat (limited to 'org.eclipse.ui.intro')
-rw-r--r-- | org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageWidgetFactory.java | 4 | ||||
-rw-r--r-- | org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/util/StringUtil.java | 31 |
2 files changed, 32 insertions, 3 deletions
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageWidgetFactory.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageWidgetFactory.java index de330ad8c..12d96f061 100644 --- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageWidgetFactory.java +++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageWidgetFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. + * Copyright (c) 2004, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -319,7 +319,7 @@ public class PageWidgetFactory { if (isBold) return createFormText(parent, generateBoldFormText(text.getText()), fg); - return createText(parent, text.getText(), fg); + return createText(parent, StringUtil.normalizeWhiteSpace(text.getText()), fg); } private Control createFormText(Composite parent, String text, Color fg) { diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/util/StringUtil.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/util/StringUtil.java index c99248f1a..c03a01ea5 100644 --- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/util/StringUtil.java +++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/util/StringUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. + * Copyright (c) 2004, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -87,5 +87,34 @@ public class StringUtil { } } } + + // Removes leading and trailing whitespace and replaces other + // occurrences with a single space. + + public static String normalizeWhiteSpace(String input) { + if (input == null) { + return null; + } + StringBuffer result = new StringBuffer(); + boolean atStart = true; + boolean whitespaceToInsert = false; + for (int i = 0; i < input.length(); i++) { + char next = input.charAt(i); + if (Character.isWhitespace(next)) { + if (!atStart) { + whitespaceToInsert = true; + } + } else { + if (whitespaceToInsert) { + result.append(' '); + whitespaceToInsert = false; + } + atStart = false; + result.append(next); + } + } + String resString = result.toString(); + return resString; + } } |