Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Weinand2003-11-18 18:00:27 -0500
committerAndre Weinand2003-11-18 18:00:27 -0500
commit83ec631e6a1bee33d8d6a17c94acb138604360bc (patch)
treee9a0a37fa314e46bba7670b995185ad969f70895
parent7e92c49b38c31bb127c787f78dc4fe49532e710a (diff)
downloadeclipse.platform.team-83ec631e6a1bee33d8d6a17c94acb138604360bc.tar.gz
eclipse.platform.team-83ec631e6a1bee33d8d6a17c94acb138604360bc.tar.xz
eclipse.platform.team-83ec631e6a1bee33d8d6a17c94acb138604360bc.zip
prepared for non-uniform encoding support
-rw-r--r--examples/org.eclipse.compare.examples/.project4
-rw-r--r--examples/org.eclipse.compare.examples/plugin.xml53
-rw-r--r--examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/KeyValuePairStructureCreator.java3
-rw-r--r--examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/Util.java17
4 files changed, 44 insertions, 33 deletions
diff --git a/examples/org.eclipse.compare.examples/.project b/examples/org.eclipse.compare.examples/.project
index 1fe5dffd9..ffb43f38f 100644
--- a/examples/org.eclipse.compare.examples/.project
+++ b/examples/org.eclipse.compare.examples/.project
@@ -4,13 +4,11 @@
<comment></comment>
<projects>
<project>org.eclipse.compare</project>
+ <project>org.eclipse.core.boot</project>
<project>org.eclipse.core.resources</project>
<project>org.eclipse.core.runtime</project>
- <project>org.eclipse.jface</project>
<project>org.eclipse.jface.text</project>
- <project>org.eclipse.swt</project>
<project>org.eclipse.ui</project>
- <project>org.eclipse.ui.workbench</project>
</projects>
<buildSpec>
<buildCommand>
diff --git a/examples/org.eclipse.compare.examples/plugin.xml b/examples/org.eclipse.compare.examples/plugin.xml
index 99cb21233..a920de7da 100644
--- a/examples/org.eclipse.compare.examples/plugin.xml
+++ b/examples/org.eclipse.compare.examples/plugin.xml
@@ -7,32 +7,33 @@
version="3.0.0"
provider-name="%providerName">
-<requires>
- <import plugin="org.eclipse.ui"/>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.compare"/>
-</requires>
+ <runtime>
+ <library name="compareexamples.jar">
+ <export name="*"/>
+ </library>
+ </runtime>
+
+ <requires>
+ <import plugin="org.eclipse.ui"/>
+ <import plugin="org.eclipse.core.resources"/>
+ <import plugin="org.eclipse.compare"/>
+ <import plugin="org.eclipse.jface.text"/>
+ </requires>
-<runtime>
- <library name="compareexamples.jar">
- <export name="*"/>
- </library>
-</runtime>
-
-<extension
- point="org.eclipse.compare.contentMergeViewers">
- <viewer
- extensions="kvtxt"
- class="org.eclipse.compare.examples.structurecreator.TextMergeViewerCreator">
- </viewer>
-</extension>
-
-<extension
- point="org.eclipse.compare.structureCreators">
- <structureCreator
- extensions="kv"
- class="org.eclipse.compare.examples.structurecreator.KeyValuePairStructureCreator">
- </structureCreator>
-</extension>
+ <extension
+ point="org.eclipse.compare.contentMergeViewers">
+ <viewer
+ extensions="kvtxt"
+ class="org.eclipse.compare.examples.structurecreator.TextMergeViewerCreator">
+ </viewer>
+ </extension>
+
+ <extension
+ point="org.eclipse.compare.structureCreators">
+ <structureCreator
+ extensions="kv"
+ class="org.eclipse.compare.examples.structurecreator.KeyValuePairStructureCreator">
+ </structureCreator>
+ </extension>
</plugin>
diff --git a/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/KeyValuePairStructureCreator.java b/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/KeyValuePairStructureCreator.java
index 04f3f880f..6155275b7 100644
--- a/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/KeyValuePairStructureCreator.java
+++ b/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/KeyValuePairStructureCreator.java
@@ -92,9 +92,8 @@ public class KeyValuePairStructureCreator implements IStructureCreator {
return null;
IStreamContentAccessor sca= (IStreamContentAccessor) input;
-
try {
- String contents= Util.readString(sca.getContents());
+ String contents= Util.readString(sca);
if (contents == null)
contents= ""; //$NON-NLS-1$
Document doc= new Document(contents);
diff --git a/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/Util.java b/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/Util.java
index 04ae99f8a..69e074221 100644
--- a/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/Util.java
+++ b/examples/org.eclipse.compare.examples/src/org/eclipse/compare/examples/structurecreator/Util.java
@@ -13,7 +13,10 @@ package org.eclipse.compare.examples.structurecreator;
import java.io.*;
import java.util.*;
+import org.eclipse.compare.IStreamContentAccessor;
+import org.eclipse.compare.IStreamContentAccessorExtension2;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
public class Util {
@@ -36,7 +39,7 @@ public class Util {
* (<code>ResourcesPlugin.getEncoding()</code>).
* Returns null if an error occurred.
*/
- static String readString(InputStream is) {
+ private static String readString(InputStream is, String encoding) {
if (is == null)
return null;
BufferedReader reader= null;
@@ -44,7 +47,7 @@ public class Util {
StringBuffer buffer= new StringBuffer();
char[] part= new char[2048];
int read= 0;
- reader= new BufferedReader(new InputStreamReader(is, ResourcesPlugin.getEncoding()));
+ reader= new BufferedReader(new InputStreamReader(is, encoding));
while ((read= reader.read(part)) != -1)
buffer.append(part, 0, read);
@@ -63,4 +66,14 @@ public class Util {
}
return null;
}
+
+ static String readString(IStreamContentAccessor sa) throws CoreException {
+ InputStream is= sa.getContents();
+ String encoding= null;
+ if (sa instanceof IStreamContentAccessorExtension2)
+ encoding= ((IStreamContentAccessorExtension2)sa).getCharset();
+ if (encoding == null)
+ encoding= ResourcesPlugin.getEncoding();
+ return readString(is, encoding);
+ }
}

Back to the top