summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikaël Barbero2013-05-13 11:17:06 (EDT)
committer Mikaël Barbero2013-05-13 11:17:06 (EDT)
commitb7121adc92f30982a447d78c090600aaf0f4fb40 (patch)
tree62d96142da0eea1c770765bb1b1eb4bc1a749579
parent79cb2b3291b1e9e2c784ab707444aae90e663539 (diff)
downloadorg.eclipse.emf.compare-b7121adc92f30982a447d78c090600aaf0f4fb40.zip
org.eclipse.emf.compare-b7121adc92f30982a447d78c090600aaf0f4fb40.tar.gz
org.eclipse.emf.compare-b7121adc92f30982a447d78c090600aaf0f4fb40.tar.bz2
fix choco commit
String(byte[], Charset) is JDK6 only
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/text/EMFCompareTextMergeViewer.java19
1 files changed, 15 insertions, 4 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/text/EMFCompareTextMergeViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/text/EMFCompareTextMergeViewer.java
index 06d8829..eaac7bb 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/text/EMFCompareTextMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/text/EMFCompareTextMergeViewer.java
@@ -21,6 +21,7 @@ import com.google.common.io.Closeables;
import java.io.IOException;
import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
import java.util.Collections;
import java.util.EventObject;
import java.util.List;
@@ -193,8 +194,8 @@ public class EMFCompareTextMergeViewer extends TextMergeViewer implements IPrope
SWTUtil.safeAsyncExec(new Runnable() {
public void run() {
- String leftValueFromWidget = new String(getContents(true), Charsets.UTF_8);
- String rightValueFromWidget = new String(getContents(false), Charsets.UTF_8);
+ String leftValueFromWidget = getContents(true, Charsets.UTF_8.name());
+ String rightValueFromWidget = getContents(false, Charsets.UTF_8.name());
IEqualityHelper equalityHelper = getComparison().getEqualityHelper();
if (!equalityHelper.matchingAttributeValues(leftValueFromModel, leftValueFromWidget)
|| !equalityHelper.matchingAttributeValues(rightValueFromModel, rightValueFromWidget)) {
@@ -212,7 +213,7 @@ public class EMFCompareTextMergeViewer extends TextMergeViewer implements IPrope
InputStream content = null;
try {
content = contentAccessor.getContents();
- ret = new String(ByteStreams.toByteArray(content), Charsets.UTF_8);
+ ret = new String(ByteStreams.toByteArray(content), Charsets.UTF_8.name());
} catch (CoreException e) {
} catch (IOException e) {
} finally {
@@ -297,10 +298,20 @@ public class EMFCompareTextMergeViewer extends TextMergeViewer implements IPrope
return false;
}
+ protected String getContents(boolean isLeft, String charsetName) {
+ try {
+ return new String(getContents(isLeft), Charsets.UTF_8.name());
+ } catch (UnsupportedEncodingException e) {
+ // UTF_8 is a standard charset guaranteed to be supported by all Java platform
+ // implementations
+ }
+ return null; // can not happen.
+ }
+
private void updateModel(final AttributeChange diff, final EAttribute eAttribute,
final IEqualityHelper equalityHelper, final EObject eObject, boolean isLeft) {
final String oldValue = getStringValue(eObject, eAttribute);
- final String newValue = new String(getContents(isLeft));
+ String newValue = getContents(isLeft, Charsets.UTF_8.name());
final boolean oldAndNewEquals = equalityHelper.matchingAttributeValues(newValue, oldValue);
if (eObject != null && !oldAndNewEquals && getCompareConfiguration().isLeftEditable()) {