Author: dmaliarevich
Date: 2011-06-30 09:29:30 -0400 (Thu, 30 Jun 2011)
New Revision: 32499
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsUtils.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java
Log:
https://issues.jboss.org/browse/JBIDE-9276 , fixed.
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsUtils.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsUtils.java 2011-06-30
11:34:41 UTC (rev 32498)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsUtils.java 2011-06-30
13:29:30 UTC (rev 32499)
@@ -421,9 +421,9 @@
k++;
value = properties.getProperty(key);
if (value != null) {
- value = value.replaceAll("\t", "\\\\t") //$NON-NLS-1$
//$NON-NLS-2$
- .replaceAll("\r", "\\\\r") //$NON-NLS-1$ //$NON-NLS-2$
- .replaceAll("\n", "\\\\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ value = value.replaceAll("\t", "\\\\t"); //$NON-NLS-1$
//$NON-NLS-2$
+ value = value.replaceAll("\r", "\\\\r"); //$NON-NLS-1$
//$NON-NLS-2$
+ value = value.replaceAll("\n", "\\\\n"); //$NON-NLS-1$
//$NON-NLS-2$
}
tableItem.setText(new String[] {key, value});
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java 2011-06-30
11:34:41 UTC (rev 32498)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java 2011-06-30
13:29:30 UTC (rev 32499)
@@ -148,7 +148,6 @@
propsValue = new Text(propsStringGroup, SWT.BORDER);
propsValue.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1));
propsValue.setText(Constants.EMPTY);
- propsValue.setEditable(false);
/*
* Create New File Checkbox
@@ -253,7 +252,19 @@
* @return a pair <code>key=value</code>
*/
public String getKeyValuePair() {
- return propsKey.getText() + Constants.EQUAL + propsValue.getText();
+ /*
+ * While initializing 'propsValue' field \t\r\n were replaced by \\\\t, etc.
+ * Now we should return escaped characters, and during saving tha properties
+ * they will treated as escape symbols as well.
+ * Otherwise \\\\t string will be put into the properties file.
+ */
+ String value = propsValue.getText();
+ if (value != null) {
+ value = value.replaceAll("\\\\t", "\t"); //$NON-NLS-1$
//$NON-NLS-2$
+ value = value.replaceAll("\\\\r", "\r"); //$NON-NLS-1$
//$NON-NLS-2$
+ value = value.replaceAll("\\\\n", "\n"); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+ return propsKey.getText() + Constants.EQUAL + EncodedProperties.saveConvert(value,
true);
}
/**
@@ -391,8 +402,17 @@
* Key should be generated first.
*/
propsKey.setText(ExternalizeStringsUtils.generatePropertyKey(text));
- propsValue.setText(EncodedProperties.saveConvert(text, true));
/*
+ * Replaced escaped symbols by strings.
+ */
+ String value = text;
+ if (value != null) {
+ value = value.replaceAll("\t", "\\\\t"); //$NON-NLS-1$
//$NON-NLS-2$
+ value = value.replaceAll("\r", "\\\\r"); //$NON-NLS-1$
//$NON-NLS-2$
+ value = value.replaceAll("\n", "\\\\n"); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+ propsValue.setText(value);
+ /*
* Initialize bundle messages field
*/
if (bm == null) {