Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 54006 Details for
Bug 164678
[Keys] KeysPreferencePage - remove use of 1.4 API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Replace text v02
keysReplaceAll-v02.txt (text/plain), 5.17 KB, created by
Paul Webster
on 2006-11-16 13:51:18 EST
(
hide
)
Description:
Replace text v02
Filename:
MIME Type:
Creator:
Paul Webster
Created:
2006-11-16 13:51:18 EST
Size:
5.17 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/util/Util.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/util/Util.java,v >retrieving revision 1.41 >diff -u -r1.41 Util.java >--- Eclipse UI/org/eclipse/ui/internal/util/Util.java 15 Nov 2006 17:27:09 -0000 1.41 >+++ Eclipse UI/org/eclipse/ui/internal/util/Util.java 16 Nov 2006 18:45:07 -0000 >@@ -750,4 +750,41 @@ > > return splitStr; > } >+ >+ /** >+ * Foundation replacement for String.replaceAll(*). >+ * >+ * @param src the starting string. >+ * @param find the string to find. >+ * @param replacement the string to replace. >+ * @return The new string. >+ * @since 3.3 >+ */ >+ public static String replaceAll(String src, String find, String replacement) { >+ final int len = src.length(); >+ final int findLen = find.length(); >+ >+ int idx = src.indexOf(find); >+ if (idx < 0) { >+ return src; >+ } >+ >+ StringBuffer buf = new StringBuffer(); >+ int beginIndex = 0; >+ while (idx != -1 && idx < len) { >+ buf.append(src.substring(beginIndex, idx)); >+ buf.append(replacement); >+ >+ beginIndex = idx + findLen; >+ if (beginIndex < len) { >+ idx = src.indexOf(find, beginIndex); >+ } else { >+ idx = -1; >+ } >+ } >+ if (beginIndex<len) { >+ buf.append(src.substring(beginIndex, (idx==-1?len:idx))); >+ } >+ return buf.toString(); >+ } > } >Index: Eclipse UI/org/eclipse/ui/internal/keys/KeysPreferencePage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/KeysPreferencePage.java,v >retrieving revision 1.15 >diff -u -r1.15 KeysPreferencePage.java >--- Eclipse UI/org/eclipse/ui/internal/keys/KeysPreferencePage.java 26 Oct 2006 16:57:58 -0000 1.15 >+++ Eclipse UI/org/eclipse/ui/internal/keys/KeysPreferencePage.java 16 Nov 2006 18:45:07 -0000 >@@ -1384,8 +1384,9 @@ > for (int i = 0; i < items.length; i++) { > final TableItem item = items[i]; > for (int j = 0; j < numColumns; j++) { >- fileWriter.write('"' + item.getText(j).replaceAll( >- "\"", "\"\"") + '"'); //$NON-NLS-1$//$NON-NLS-2$ >+ String buf = Util.replaceAll(item.getText(j), "\"", //$NON-NLS-1$ >+ "\"\""); //$NON-NLS-1$ >+ fileWriter.write("\"" + buf + "\""); //$NON-NLS-1$//$NON-NLS-2$ > if (j < numColumns - 1) { > fileWriter.write(','); > } >@@ -1407,7 +1408,7 @@ > }; > SafeRunner.run(runnable); > } >- >+ > /** > * Handles the selection event on the remove button. This removes all > * user-defined bindings matching the given key sequence, scheme and >#P org.eclipse.ui.tests >Index: Eclipse UI Tests/org/eclipse/ui/tests/keys/KeysTestSuite.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/KeysTestSuite.java,v >retrieving revision 1.20 >diff -u -r1.20 KeysTestSuite.java >--- Eclipse UI Tests/org/eclipse/ui/tests/keys/KeysTestSuite.java 6 May 2005 17:59:11 -0000 1.20 >+++ Eclipse UI Tests/org/eclipse/ui/tests/keys/KeysTestSuite.java 16 Nov 2006 18:45:09 -0000 >@@ -48,6 +48,7 @@ > addTest(new TestSuite(Bug43597Test.class)); > addTest(new TestSuite(Bug43610Test.class)); > addTest(new TestSuite(Bug43800Test.class)); >+ addTest(new TestSuite(KeysCsvTest.class)); > // TODO disabled since it refers to the Java builder and nature, > // which are not available in an RCP build > // addTest(new TestSuite(Bug44460Test.class)); >Index: Eclipse UI Tests/org/eclipse/ui/tests/keys/KeysCsvTest.java >=================================================================== >RCS file: Eclipse UI Tests/org/eclipse/ui/tests/keys/KeysCsvTest.java >diff -N Eclipse UI Tests/org/eclipse/ui/tests/keys/KeysCsvTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI Tests/org/eclipse/ui/tests/keys/KeysCsvTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.tests.keys; >+ >+import org.eclipse.ui.internal.util.Util; >+ >+import junit.framework.TestCase; >+ >+/** >+ * @since 3.3 >+ * >+ */ >+public class KeysCsvTest extends TestCase { >+ >+ public void testReplace() throws Exception { >+ final String src = "Test the \"replaceAll\""; >+ final String dest = "Test the \"\"replaceAll\"\""; >+ String val = Util.replaceAll(src, "\"", "\"\""); >+ assertEquals(dest, val); >+ } >+ >+ public void testReplaceFirst() throws Exception { >+ final String src = "\"Hello world!"; >+ final String dest = "\"\"Hello world!"; >+ String val = Util.replaceAll(src, "\"", "\"\""); >+ assertEquals(dest, val); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 164678
:
53950
| 54006