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 182449 Details for
Bug 328524
[nls tooling] Properties File editor could escape \ on paste
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
fix + tests
afterrevert-escapeslash1.txt (text/plain), 28.28 KB, created by
Deepak Azad
on 2010-11-05 02:16:34 EDT
(
hide
)
Description:
fix + tests
Filename:
MIME Type:
Creator:
Deepak Azad
Created:
2010-11-05 02:16:34 EDT
Size:
28.28 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui >Index: ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java,v >retrieving revision 1.137 >diff -u -r1.137 PreferencesMessages.java >--- ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java 5 Nov 2010 05:49:58 -0000 1.137 >+++ ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java 5 Nov 2010 06:08:01 -0000 >@@ -692,6 +692,7 @@ > public static String PropertiesFileEditorPreferencePage_underline; > public static String PropertiesFileEditorPreferencePage_preview; > public static String PropertiesFileEditorPreferencePage_link; >+ public static String PropertiesFileEditorPreferencePage_when_pasting_escape_backslash_if_required; > public static String SmartTypingConfigurationBlock_autoclose_title; > public static String SmartTypingConfigurationBlock_automove_title; > public static String SmartTypingConfigurationBlock_tabs_message_tab_text; >Index: ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties,v >retrieving revision 1.521 >diff -u -r1.521 PreferencesMessages.properties >--- ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties 5 Nov 2010 05:49:58 -0000 1.521 >+++ ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties 5 Nov 2010 06:08:01 -0000 >@@ -805,6 +805,7 @@ > > # DO NOT TRANSLATE "org.eclipse.ui.preferencePages.GeneralTextEditor" and "org.eclipse.ui.preferencePages.ColorsAndFonts" > PropertiesFileEditorPreferencePage_link= Properties file editor preferences. See <a href=\"org.eclipse.ui.preferencePages.GeneralTextEditor\">'Text Editors'</a> for general text editor preferences and <a href=\"org.eclipse.ui.preferencePages.ColorsAndFonts\">'Colors and Fonts'</a> to configure the font. >+PropertiesFileEditorPreferencePage_when_pasting_escape_backslash_if_required=When pasting, escape backslash if required > > # smart typing block > SmartTypingConfigurationBlock_autoclose_title=Automatically close >Index: ui/org/eclipse/jdt/internal/ui/preferences/PropertiesFileEditorPreferencePage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PropertiesFileEditorPreferencePage.java,v >retrieving revision 1.29 >diff -u -r1.29 PropertiesFileEditorPreferencePage.java >--- ui/org/eclipse/jdt/internal/ui/preferences/PropertiesFileEditorPreferencePage.java 5 Nov 2010 05:49:58 -0000 1.29 >+++ ui/org/eclipse/jdt/internal/ui/preferences/PropertiesFileEditorPreferencePage.java 5 Nov 2010 06:08:01 -0000 >@@ -358,6 +358,13 @@ > */ > private IColorManager fColorManager; > >+ /** >+ * Check box for preference that controls whether backslashes are escaped if required, when >+ * pasting in a properties file. >+ * >+ * @since 3.7 >+ */ >+ private Button fCheckboxEscapeBackslash; > > /** > * Creates a new preference page. >@@ -382,6 +389,8 @@ > overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, colorKey + UNDERLINE)); > } > >+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.PROPERTIES_FILE_WHEN_PASTING_ESCAPE_BACKSLASH_IF_REQUIRED)); >+ > OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; > overlayKeys.toArray(keys); > return keys; >@@ -586,6 +595,8 @@ > > createSyntaxPage(contents); > >+ createTypingPreferences(contents); >+ > initialize(); > > Dialog.applyDialogFont(contents); >@@ -622,9 +633,27 @@ > filler.setLayoutData(gd); > } > >+ private void createTypingPreferences(Composite contents) { >+ fCheckboxEscapeBackslash= new Button(contents, SWT.CHECK); >+ fCheckboxEscapeBackslash.setText(PreferencesMessages.PropertiesFileEditorPreferencePage_when_pasting_escape_backslash_if_required); >+ GridData gd= new GridData(SWT.BEGINNING, SWT.CENTER, false, false); >+ gd.verticalIndent= 10; >+ fCheckboxEscapeBackslash.setLayoutData(gd); >+ fCheckboxEscapeBackslash.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ fOverlayStore.setValue(PreferenceConstants.PROPERTIES_FILE_WHEN_PASTING_ESCAPE_BACKSLASH_IF_REQUIRED, fCheckboxEscapeBackslash.getSelection()); >+ } >+ }); >+ } >+ >+ private void resetTypingPreferences() { >+ fCheckboxEscapeBackslash.setSelection(fOverlayStore.getBoolean(PreferenceConstants.PROPERTIES_FILE_WHEN_PASTING_ESCAPE_BACKSLASH_IF_REQUIRED)); >+ } >+ > private void initialize() { > > initializeFields(); >+ resetTypingPreferences(); > > for (int i= 0, n= fSyntaxColorListModel.length; i < n; i++) > fHighlightingColorList.add(new HighlightingColorListItem (fSyntaxColorListModel[i][0], fSyntaxColorListModel[i][1], fSyntaxColorListModel[i][1] + BOLD, fSyntaxColorListModel[i][1] + ITALIC, fSyntaxColorListModel[i][1] + STRIKETHROUGH, fSyntaxColorListModel[i][1] + UNDERLINE, null)); >@@ -665,6 +694,8 @@ > > handleSyntaxColorListSelection(); > >+ resetTypingPreferences(); >+ > super.performDefaults(); > > fPreviewViewer.invalidateTextPresentation(); >Index: ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileAutoEditStrategy.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileAutoEditStrategy.java,v >retrieving revision 1.3 >diff -u -r1.3 PropertiesFileAutoEditStrategy.java >--- ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileAutoEditStrategy.java 5 Nov 2010 05:49:58 -0000 1.3 >+++ ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileAutoEditStrategy.java 5 Nov 2010 06:08:01 -0000 >@@ -17,23 +17,40 @@ > > import org.eclipse.core.resources.IFile; > >+import org.eclipse.jface.preference.IPreferenceStore; >+ > import org.eclipse.jface.text.DocumentCommand; > import org.eclipse.jface.text.IAutoEditStrategy; > import org.eclipse.jface.text.IDocument; > >+import org.eclipse.jdt.ui.PreferenceConstants; >+ > /** > * Auto edit strategy that escapes a character if it cannot be encoded in the .properties file's > * encoding. > * >+ * <p> >+ * Backslashes are escaped only when the pasted text is not perfectly correct for the .properties >+ * file, i.e. if the text contains >+ * <ul> >+ * <li>a single backslash that is not followed by <code>t,n,f,r,u,\</code></li> >+ * <li>a character which requires Unicode escapes</li> >+ * </ul> >+ * Escaping of backslash is controlled by the preference >+ * {@link PreferenceConstants#PROPERTIES_FILE_WHEN_PASTING_ESCAPE_BACKSLASH_IF_REQUIRED} >+ * </p> >+ * > * @since 3.7 > */ > public class PropertiesFileAutoEditStrategy implements IAutoEditStrategy { > >+ private final IPreferenceStore fPreferenceStore; > private final IFile fFile; > private String fCharsetName; > private CharsetEncoder fCharsetEncoder; > >- public PropertiesFileAutoEditStrategy(IFile file) { >+ public PropertiesFileAutoEditStrategy(IPreferenceStore preferenceStore, IFile file) { >+ fPreferenceStore= preferenceStore; > fFile= file; > } > >@@ -52,23 +69,62 @@ > return; > } > >- if (fCharsetEncoder.canEncode(command.text)) >+ String text= command.text; >+ boolean escapeUnicodeChars= !fCharsetEncoder.canEncode(text); >+ boolean escapeSlash= (text.length() > 1) >+ && fPreferenceStore.getBoolean(PreferenceConstants.PROPERTIES_FILE_WHEN_PASTING_ESCAPE_BACKSLASH_IF_REQUIRED) && (escapeUnicodeChars || shouldEscapeSlashes(text)); >+ >+ if (!escapeUnicodeChars && !escapeSlash) > return; > >- command.text= escape(command.text); >+ command.text= escape(text, escapeUnicodeChars, escapeSlash); > } > >- private static String escape(String s) { >+ /** >+ * Tests if the backslashes should be escaped in the given text. >+ * >+ * @param text the text >+ * @return <code>true</code> if backslashes need to be escaped, <code>false</code> otherwise >+ */ >+ private boolean shouldEscapeSlashes(String text) { >+ int length= text.length(); >+ for (int i= 0; i < length; i++) { >+ char c= text.charAt(i); >+ if (c == '\\') { >+ if (i < length - 1) { >+ char nextC= text.charAt(i + 1); >+ switch (nextC) { >+ case 't': >+ case 'n': >+ case 'f': >+ case 'r': >+ case 'u': >+ break; >+ case '\\': >+ i++; >+ break; >+ default: >+ return true; >+ } >+ }else { >+ return true; >+ } >+ } >+ } >+ return false; >+ } >+ >+ private static String escape(String s, boolean escapeUnicodeChars, boolean escapeSlash) { > StringBuffer sb= new StringBuffer(s.length()); > int length= s.length(); > for (int i= 0; i < length; i++) { > char c= s.charAt(i); >- sb.append(escape(c)); >+ sb.append(escape(c, escapeUnicodeChars, escapeSlash)); > } > return sb.toString(); > } > >- private static String escape(char c) { >+ private static String escape(char c, boolean escapeUnicodeChars, boolean escapeSlash) { > switch (c) { > case '\t': > return "\t";//$NON-NLS-1$ >@@ -79,10 +135,9 @@ > case '\r': > return "\r";//$NON-NLS-1$ > case '\\': >- return "\\";//$NON-NLS-1$ >- >+ return escapeSlash ? "\\\\" : "\\"; //$NON-NLS-1$ //$NON-NLS-2$ > default: >- return PropertiesFileEscapes.escape(c); >+ return escapeUnicodeChars ? PropertiesFileEscapes.escape(c) : String.valueOf(c); > } > } > } >Index: ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileSourceViewerConfiguration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileSourceViewerConfiguration.java,v >retrieving revision 1.39 >diff -u -r1.39 PropertiesFileSourceViewerConfiguration.java >--- ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileSourceViewerConfiguration.java 5 Nov 2010 05:49:58 -0000 1.39 >+++ ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileSourceViewerConfiguration.java 5 Nov 2010 06:08:01 -0000 >@@ -348,7 +348,7 @@ > for (int i= 0; i < autoEditStrategies.length; i++) { > stratergies.add(autoEditStrategies[i]); > } >- stratergies.add(new PropertiesFileAutoEditStrategy(((IFileEditorInput)fTextEditor.getEditorInput()).getFile())); >+ stratergies.add(new PropertiesFileAutoEditStrategy(fPreferenceStore, ((IFileEditorInput)fTextEditor.getEditorInput()).getFile())); > return (IAutoEditStrategy[])stratergies.toArray(new IAutoEditStrategy[stratergies.size()]); > } catch (CoreException e) { > JavaPlugin.log(e); >Index: ui/org/eclipse/jdt/ui/PreferenceConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/PreferenceConstants.java,v >retrieving revision 1.257 >diff -u -r1.257 PreferenceConstants.java >--- ui/org/eclipse/jdt/ui/PreferenceConstants.java 5 Nov 2010 05:49:58 -0000 1.257 >+++ ui/org/eclipse/jdt/ui/PreferenceConstants.java 5 Nov 2010 06:08:01 -0000 >@@ -3569,6 +3569,17 @@ > public static final String PROPERTIES_FILE_COLORING_ARGUMENT_UNDERLINE= PROPERTIES_FILE_COLORING_ARGUMENT + EDITOR_UNDERLINE_SUFFIX; > > /** >+ * A named preference that controls whether backslashes are escaped if required, when pasting in >+ * a properties file. >+ * <p> >+ * Value is of type <code>Boolean</code>. >+ * </p> >+ * >+ * @since 3.7 >+ */ >+ public static final String PROPERTIES_FILE_WHEN_PASTING_ESCAPE_BACKSLASH_IF_REQUIRED= "pf_when_pasting_escape_backslash_if_required"; //$NON-NLS-1$ >+ >+ /** > * A named preference that stores the content assist LRU history > * <p> > * Value is an XML encoded version of the history. >@@ -3890,6 +3901,8 @@ > store.setDefault(PreferenceConstants.PROPERTIES_FILE_COLORING_COMMENT_BOLD, false); > store.setDefault(PreferenceConstants.PROPERTIES_FILE_COLORING_COMMENT_ITALIC, false); > >+ store.setDefault(PreferenceConstants.PROPERTIES_FILE_WHEN_PASTING_ESCAPE_BACKSLASH_IF_REQUIRED, true); >+ > // semantic highlighting > SemanticHighlightings.initDefaults(store); > >#P org.eclipse.jdt.ui.tests >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui.tests/META-INF/MANIFEST.MF,v >retrieving revision 1.17 >diff -u -r1.17 MANIFEST.MF >--- META-INF/MANIFEST.MF 5 Nov 2010 05:34:10 -0000 1.17 >+++ META-INF/MANIFEST.MF 5 Nov 2010 06:08:04 -0000 >@@ -33,6 +33,7 @@ > org.eclipse.jdt.ui.tests.performance;x-internal:=true, > org.eclipse.jdt.ui.tests.performance.views;x-internal:=true, > org.eclipse.jdt.ui.tests.preferences;x-internal:=true, >+ org.eclipse.jdt.ui.tests.propertiesfileeditor;x-internal:=true, > org.eclipse.jdt.ui.tests.quickfix;x-internal:=true, > org.eclipse.jdt.ui.tests.search;x-internal:=true, > org.eclipse.jdt.ui.tests.ui.internal.compatibility;x-internal:=true, >Index: ui/org/eclipse/jdt/ui/tests/AutomatedSuite.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/AutomatedSuite.java,v >retrieving revision 1.55 >diff -u -r1.55 AutomatedSuite.java >--- ui/org/eclipse/jdt/ui/tests/AutomatedSuite.java 25 Nov 2008 11:01:46 -0000 1.55 >+++ ui/org/eclipse/jdt/ui/tests/AutomatedSuite.java 5 Nov 2010 06:08:04 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 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 >@@ -26,6 +26,7 @@ > import org.eclipse.jdt.ui.tests.jarexport.JarExportTests; > import org.eclipse.jdt.ui.tests.model.ContentProviderTests; > import org.eclipse.jdt.ui.tests.packageview.PackageExplorerTests; >+import org.eclipse.jdt.ui.tests.propertiesfileeditor.PropertiesFileEditorTests; > import org.eclipse.jdt.ui.tests.quickfix.QuickFixTest; > import org.eclipse.jdt.ui.tests.search.SearchTest; > import org.eclipse.jdt.ui.tests.wizardapi.NewJavaProjectWizardTest; >@@ -73,6 +74,7 @@ > addTest(BuildpathModifierActionTest.suite()); > > addTest(JarExportTests.suite()); >+ addTest(PropertiesFileEditorTests.suite()); > } > } > >Index: ui/org/eclipse/jdt/ui/tests/propertiesfileeditor/PropertiesFileAutoEditStrategyTest.java >=================================================================== >RCS file: ui/org/eclipse/jdt/ui/tests/propertiesfileeditor/PropertiesFileAutoEditStrategyTest.java >diff -N ui/org/eclipse/jdt/ui/tests/propertiesfileeditor/PropertiesFileAutoEditStrategyTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/ui/tests/propertiesfileeditor/PropertiesFileAutoEditStrategyTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,334 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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.jdt.ui.tests.propertiesfileeditor; >+ >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.Reader; >+import java.io.StringReader; >+ >+import junit.framework.Test; >+import junit.framework.TestCase; >+import junit.framework.TestSuite; >+ >+import org.eclipse.jdt.testplugin.JavaProjectHelper; >+ >+import org.eclipse.core.runtime.CoreException; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IFolder; >+ >+import org.eclipse.jface.preference.IPreferenceStore; >+ >+import org.eclipse.jface.text.DocumentCommand; >+ >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.IPackageFragment; >+import org.eclipse.jdt.core.IPackageFragmentRoot; >+ >+import org.eclipse.jdt.ui.PreferenceConstants; >+import org.eclipse.jdt.ui.tests.core.ProjectTestSetup; >+ >+import org.eclipse.jdt.internal.ui.JavaPlugin; >+import org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertiesFileAutoEditStrategy; >+ >+/** >+ * PropertiesFileAutoEditStratergyTest >+ * >+ * @since 3.7 >+ */ >+public class PropertiesFileAutoEditStrategyTest extends TestCase { >+ >+ private static final String UTF_8= "UTF-8"; >+ private static final String ISO_8859_1= "ISO-8859-1"; >+ >+ private DocumentCommand fDocumentCommand; >+ >+ private IPreferenceStore fPreferenceStore; >+ >+ private PropertiesFileAutoEditStrategy fPropertiesFileAutoEditStrategyISO_8859_1; >+ private PropertiesFileAutoEditStrategy fPropertiesFileAutoEditStrategyUTF8; >+ >+ private IJavaProject fJProject1; >+ private IPackageFragmentRoot fSourceFolder; >+ private IFile fPropertiesFileISO_8859_1; >+ private IFile fPropertiesFileUTF8; >+ >+ public PropertiesFileAutoEditStrategyTest(String name) { >+ super(name); >+ fPreferenceStore= JavaPlugin.getDefault().getPreferenceStore(); >+ fDocumentCommand= new DocumentCommand() { >+ }; >+ } >+ >+ public static Test suite() { >+ return new ProjectTestSetup(new TestSuite(PropertiesFileAutoEditStrategyTest.class)); >+ } >+ >+ protected void setUp() throws Exception { >+ super.setUp(); >+ setEscapeBackslashIfRequired(true); // make sure that the preference is set to true >+ try { >+ fJProject1= ProjectTestSetup.getProject(); >+ fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src"); >+ IPackageFragment pack= fSourceFolder.createPackageFragment("test", false, null); >+ fPropertiesFileISO_8859_1= write((IFolder)pack.getCorrespondingResource(), "", "Messages_ISO_8859_1.properties"); >+ fPropertiesFileISO_8859_1.setCharset(ISO_8859_1, null); >+ fPropertiesFileUTF8= write((IFolder)pack.getCorrespondingResource(), "", "Messages_UTF8.properties"); >+ fPropertiesFileUTF8.setCharset(UTF_8, null); >+ fPropertiesFileAutoEditStrategyISO_8859_1= new PropertiesFileAutoEditStrategy(fPreferenceStore, fPropertiesFileISO_8859_1); >+ fPropertiesFileAutoEditStrategyUTF8= new PropertiesFileAutoEditStrategy(fPreferenceStore, fPropertiesFileUTF8); >+ } catch (CoreException e) { >+ e.printStackTrace(); >+ } >+ } >+ >+ protected void tearDown() throws Exception { >+ JavaProjectHelper.clear(fJProject1, ProjectTestSetup.getDefaultClasspath()); >+ super.tearDown(); >+ } >+ >+ //utility methods >+ private void performTestISO_8859_1() { >+ fPropertiesFileAutoEditStrategyISO_8859_1.customizeDocumentCommand(null, fDocumentCommand); >+ } >+ >+ private void performTestAutoEscapeSlashDisabledISO_8859_1() { >+ setEscapeBackslashIfRequired(false); >+ fPropertiesFileAutoEditStrategyISO_8859_1.customizeDocumentCommand(null, fDocumentCommand); >+ setEscapeBackslashIfRequired(true); >+ } >+ >+ private void performTestUTF8() { >+ fPropertiesFileAutoEditStrategyUTF8.customizeDocumentCommand(null, fDocumentCommand); >+ } >+ >+ private void performTestAutoEscapeSlashDisabledUTF8() { >+ setEscapeBackslashIfRequired(false); >+ fPropertiesFileAutoEditStrategyUTF8.customizeDocumentCommand(null, fDocumentCommand); >+ setEscapeBackslashIfRequired(true); >+ } >+ >+ private void setEscapeBackslashIfRequired(boolean value) { >+ fPreferenceStore.setValue(PreferenceConstants.PROPERTIES_FILE_WHEN_PASTING_ESCAPE_BACKSLASH_IF_REQUIRED, value); >+ } >+ >+ private IFile write(IFolder folder, final String content, final String fileName) throws CoreException { >+ InputStream stream= new InputStream() { >+ private final Reader fReader= new StringReader(content); >+ >+ public int read() throws IOException { >+ return fReader.read(); >+ } >+ }; >+ IFile file= fJProject1.getProject().getFile(folder.getProjectRelativePath().append(fileName)); >+ file.create(stream, true, null); >+ return file; >+ } >+ >+ //typing ISO-8859-1 >+ public void testTypeISO_8859_1_01() throws Exception { >+ fDocumentCommand.text= "\\"; >+ performTestISO_8859_1(); >+ assertEquals("\\", fDocumentCommand.text); >+ } >+ >+ public void testTypeISO_8859_1_02() throws Exception { >+ fDocumentCommand.text= "\t"; >+ performTestISO_8859_1(); >+ assertEquals("\t", fDocumentCommand.text); >+ } >+ >+ public void testTypeISO_8859_1_03() throws Exception { >+ fDocumentCommand.text= "\f"; >+ performTestISO_8859_1(); >+ assertEquals("\f", fDocumentCommand.text); >+ } >+ >+ public void testTypeISO_8859_1_04() throws Exception { >+ fDocumentCommand.text= "\r"; >+ performTestISO_8859_1(); >+ assertEquals("\r", fDocumentCommand.text); >+ } >+ >+ public void testTypeISO_8859_1_05() throws Exception { >+ fDocumentCommand.text= "\n"; >+ performTestISO_8859_1(); >+ assertEquals("\n", fDocumentCommand.text); >+ } >+ >+ public void testTypeISO_8859_1_06() throws Exception { >+ fDocumentCommand.text= "\u2603"; >+ performTestISO_8859_1(); >+ assertEquals("\\u2603", fDocumentCommand.text); >+ } >+ >+ //typing UTF-8 >+ public void testTypeUTF8_01() throws Exception { >+ fDocumentCommand.text= "\u2603"; >+ performTestUTF8(); >+ assertEquals("\u2603", fDocumentCommand.text); >+ } >+ >+ //paste ISO-8859-1 >+ public void testPasteISO_8859_1_01() throws Exception { >+ fDocumentCommand.text= "C:\\Program Files\\Java"; >+ performTestISO_8859_1(); >+ assertEquals("C:\\\\Program Files\\\\Java", fDocumentCommand.text); >+ } >+ >+ public void testPasteISO_8859_1_02() throws Exception { >+ fDocumentCommand.text= "C:\\new folder\\A.java"; >+ performTestISO_8859_1(); >+ assertEquals("C:\\\\new folder\\\\A.java", fDocumentCommand.text); >+ } >+ >+ public void testPasteISO_8859_1_03() throws Exception { >+ fDocumentCommand.text= "\u0926 \u0905"; >+ performTestISO_8859_1(); >+ assertEquals("\\u0926 \\u0905", fDocumentCommand.text); >+ } >+ >+ public void testPasteISO_8859_1_04() throws Exception { >+ fDocumentCommand.text= "\u0926 \\u0905"; >+ performTestISO_8859_1(); >+ assertEquals("\\u0926 \\\\u0905", fDocumentCommand.text); >+ } >+ >+ public void testPasteISO_8859_1_05() throws Exception { >+ fDocumentCommand.text= "ä \u0926"; >+ performTestISO_8859_1(); >+ assertEquals("ä \\u0926", fDocumentCommand.text); >+ } >+ >+ public void testPasteISO_8859_1_06() throws Exception { >+ fDocumentCommand.text= "some text\\"; >+ performTestISO_8859_1(); >+ assertEquals("some text\\\\", fDocumentCommand.text); >+ } >+ >+ //paste UTF-8 >+ public void testPasteUTF8_01() throws Exception { >+ fDocumentCommand.text= "C:\\Program Files\\Java"; >+ performTestUTF8(); >+ assertEquals("C:\\\\Program Files\\\\Java", fDocumentCommand.text); >+ } >+ >+ public void testPasteUTF8_02() throws Exception { >+ fDocumentCommand.text= "C:\\new folder\\A.java"; >+ performTestUTF8(); >+ assertEquals("C:\\\\new folder\\\\A.java", fDocumentCommand.text); >+ } >+ >+ public void testPasteUTF8_03() throws Exception { >+ fDocumentCommand.text= "\u0926 \u0905"; >+ performTestUTF8(); >+ assertEquals("\u0926 \u0905", fDocumentCommand.text); >+ } >+ >+ public void testPasteUTF8_04() throws Exception { >+ fDocumentCommand.text= "\u0926 \\u0905"; >+ performTestUTF8(); >+ assertEquals("\u0926 \\u0905", fDocumentCommand.text); >+ } >+ >+ public void testPasteUTF8_05() throws Exception { >+ fDocumentCommand.text= "\u0926 \\some text"; >+ performTestUTF8(); >+ assertEquals("\u0926 \\\\some text", fDocumentCommand.text); >+ } >+ >+ //paste from properties file ISO-8859-1 >+ public void testPasteFromPropertiesFileISO_8859_1_01() throws Exception { >+ fDocumentCommand.text= "\t \n \f \r"; >+ performTestISO_8859_1(); >+ assertEquals("\t \n \f \r", fDocumentCommand.text); >+ } >+ >+ public void testPasteFromPropertiesFileISO_8859_1_02() throws Exception { >+ fDocumentCommand.text= "\\u00e4 \\t \\u0926 \\n"; >+ performTestISO_8859_1(); >+ assertEquals("\\u00e4 \\t \\u0926 \\n", fDocumentCommand.text); >+ } >+ >+ public void testPasteFromPropertiesFileISO_8859_1_03() throws Exception { >+ fDocumentCommand.text= "C:\\\\Program Files\\\\Java"; >+ performTestISO_8859_1(); >+ assertEquals("C:\\\\Program Files\\\\Java", fDocumentCommand.text); >+ } >+ >+ public void testPasteFromPropertiesFileISO_8859_1_04() throws Exception { >+ fDocumentCommand.text= "C:\\\\new folder\\\\A.java"; >+ performTestISO_8859_1(); >+ assertEquals("C:\\\\new folder\\\\A.java", fDocumentCommand.text); >+ } >+ >+ public void testPasteFromPropertiesFileISO_8859_1_05() throws Exception { >+ fDocumentCommand.text= "\\u2603 \\\\u2603"; >+ performTestISO_8859_1(); >+ assertEquals("\\u2603 \\\\u2603", fDocumentCommand.text); >+ } >+ >+ // paste ISO-8859-1 and PreferenceConstants.PROPERTIES_FILE_ESCAPE_BACKSLASH_ON_PASTE_IF_REQUIRED disabled >+ public void testAutoEscapeSlashDisabledISO_8859_1_01() throws Exception { >+ fDocumentCommand.text= "C:\\Program Files\\Java"; >+ performTestAutoEscapeSlashDisabledISO_8859_1(); >+ assertEquals("C:\\Program Files\\Java", fDocumentCommand.text); >+ } >+ >+ public void testAutoEscapeSlashDisabledISO_8859_1_02() throws Exception { >+ fDocumentCommand.text= "C:\\new folder\\A.java"; >+ performTestAutoEscapeSlashDisabledISO_8859_1(); >+ assertEquals("C:\\new folder\\A.java", fDocumentCommand.text); >+ } >+ >+ public void testAutoEscapeSlashDisabledISO_8859_1_03() throws Exception { >+ fDocumentCommand.text= "\u0926 \\u0905"; >+ performTestAutoEscapeSlashDisabledISO_8859_1(); >+ assertEquals("\\u0926 \\u0905", fDocumentCommand.text); >+ } >+ >+ //paste UTF-8 and PreferenceConstants.PROPERTIES_FILE_ESCAPE_BACKSLASH_ON_PASTE_IF_REQUIRED disabled >+ public void testAutoEscapeSlashDisabledUTF8_01() throws Exception { >+ fDocumentCommand.text= "\u0926 \\some text"; >+ performTestAutoEscapeSlashDisabledUTF8(); >+ assertEquals("\u0926 \\some text", fDocumentCommand.text); >+ } >+ >+ //change encoding of file >+ public void testChangeEncodingOfFile_01() throws Exception { >+ fDocumentCommand.text= "\u2603"; >+ performTestUTF8(); >+ assertEquals("\u2603", fDocumentCommand.text); >+ >+ fPropertiesFileUTF8.setCharset(ISO_8859_1, null); >+ >+ fDocumentCommand.text= "\u2603"; >+ performTestUTF8(); >+ assertEquals("\\u2603", fDocumentCommand.text); >+ >+ fPropertiesFileUTF8.setCharset(UTF_8, null); >+ } >+ >+ public void testChangeEncodingOfFile_02() throws Exception { >+ fDocumentCommand.text= "\u2603"; >+ performTestISO_8859_1(); >+ assertEquals("\\u2603", fDocumentCommand.text); >+ >+ fPropertiesFileISO_8859_1.setCharset(UTF_8, null); >+ >+ fDocumentCommand.text= "\u2603"; >+ performTestISO_8859_1(); >+ assertEquals("\u2603", fDocumentCommand.text); >+ >+ fPropertiesFileISO_8859_1.setCharset(ISO_8859_1, null); >+ } >+} >Index: ui/org/eclipse/jdt/ui/tests/propertiesfileeditor/PropertiesFileEditorTests.java >=================================================================== >RCS file: ui/org/eclipse/jdt/ui/tests/propertiesfileeditor/PropertiesFileEditorTests.java >diff -N ui/org/eclipse/jdt/ui/tests/propertiesfileeditor/PropertiesFileEditorTests.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/ui/tests/propertiesfileeditor/PropertiesFileEditorTests.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,25 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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.jdt.ui.tests.propertiesfileeditor; >+ >+import junit.framework.Test; >+import junit.framework.TestSuite; >+ >+public class PropertiesFileEditorTests { >+ >+ public static Test suite() { >+ TestSuite suite= new TestSuite("Test for org.eclipse.jdt.ui.tests.propertiesfileeditor"); >+ //$JUnit-BEGIN$ >+ suite.addTest(PropertiesFileAutoEditStrategyTest.suite()); >+ //$JUnit-END$ >+ return suite; >+ } >+}
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 328524
:
181574
|
181613
|
182449
|
182556
|
183841
|
184015
|
184025
|
184574
|
184585
|
184598
|
184619