Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Maetzel2004-03-15 10:17:36 +0000
committerKai Maetzel2004-03-15 10:17:36 +0000
commit182411a5226f9d22adbfd567cbff352ea1acd9aa (patch)
tree87b134c1d13520e669a0a4cc378132b19e198285 /org.eclipse.ui.editors
parent9e96e117b0d2741d947731e933a3e5afaa5b8951 (diff)
downloadeclipse.platform.text-182411a5226f9d22adbfd567cbff352ea1acd9aa.tar.gz
eclipse.platform.text-182411a5226f9d22adbfd567cbff352ea1acd9aa.tar.xz
eclipse.platform.text-182411a5226f9d22adbfd567cbff352ea1acd9aa.zip
#54058
Diffstat (limited to 'org.eclipse.ui.editors')
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java31
1 files changed, 25 insertions, 6 deletions
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java
index ffbea9281..2baa9d1c2 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java
@@ -757,7 +757,7 @@ public class FileDocumentProvider extends StorageDocumentProvider {
// --------------- Encoding support ---------------
/**
- * Returns the persited encoding for the given element.
+ * Returns the persisted encoding for the given element.
*
* @param element the element for which to get the persisted encoding
* @since 2.1
@@ -766,12 +766,31 @@ public class FileDocumentProvider extends StorageDocumentProvider {
if (element instanceof IFileEditorInput) {
IFileEditorInput editorInput= (IFileEditorInput)element;
IFile file= editorInput.getFile();
- if (file != null)
+ if (file != null) {
+ String encoding= null;
try {
- return file.getPersistentProperty(ENCODING_KEY);
- } catch (CoreException ex) {
- return null;
+ encoding= file.getPersistentProperty(ENCODING_KEY);
+ } catch (CoreException x) {
+ // we ignore exceptions here because we support the ENCODING_KEY property only for compatibility reasons
+ }
+ if (encoding != null) {
+ // if we found an old encoding property, we try to migrate it to the new core.resources encoding support
+ try {
+ file.setCharset(encoding);
+ // if successful delete old property
+ file.setPersistentProperty(ENCODING_KEY, null);
+ } catch (CoreException ex) {
+ handleCoreException(ex, TextEditorMessages.getString("FileDocumentProvider.getPersistedEncoding")); //$NON-NLS-1$
+ }
+ } else {
+ try {
+ encoding= file.getCharset();
+ } catch (CoreException e) {
+ encoding= null;
+ }
}
+ return encoding;
+ }
}
return null;
}
@@ -788,7 +807,7 @@ public class FileDocumentProvider extends StorageDocumentProvider {
IFileEditorInput editorInput= (IFileEditorInput)element;
IFile file= editorInput.getFile();
if (file != null)
- file.setPersistentProperty(ENCODING_KEY, encoding);
+ file.setCharset(encoding);
}
}

Back to the top