|
|
Re: Problem with IDE.openEditor(URI): cannot open external file in UTF8 [message #330966 is a reply to message #330950] |
Tue, 19 August 2008 18:27 |
Sergey Bushkov Messages: 29 Registered: July 2009 |
Junior Member |
|
|
Thanks for ideas, Daniel!
The second workaround does not work for me because the snippet editor
does not return adapter for IEncodingSupport (at least, in eclpse 3.3).
The first workaround.. well, I could not find which property should be
changed. But - instead - I found the better solution for my problem:
<extension point="org.eclipse.core.runtime.contentTypes">
<content-type
id = "xyz.my.id"
name = "xyz"
file-extensions="xyz"
default-charset="UTF-8"
...
/>
</extension>
This works fine for me, since I want to open files with specific
extension. So, you helped me actually :)
/Sergey
Daniel Megert wrote:
> Sergey Bushkov wrote:
>
>> Good day,
>>
>> I need to open an external file in editor. The following code works in
>> eclipse 3.3 for files in default system encoding:
>>
>> IEditorPart part = IDE.openEditor(page, file.toURI(),
>> "org.eclipse.jdt.debug.ui.SnippetEditor", true);
>>
>> I can't find any API to open that file in non-system encoding, e.g.
>> UTF-8.
>>
>> It's possible to change the default workbench encoding on the
>> workbench properties page; after that, the editor opens UTF-8 files
>> correctly. However, I don't want to change the entire workspace
>> settings - user preferences should be respected.
>>
>> Is there any workaround?
>
> You could set the preference (use putValue to prevent firing of property
> change events), open the editor and set it back. Another thing you could
> try is to open it with the wrong encoding and then set yours:
> IEncodingSupport encodingSupport=
> (IEncodingSupport)part.getAdapter(IEncodingSupport.class);
> encodingSupport.setEncoding(String);
>
> Dani
>
>>
>> Thanks
>> /Sergey
|
|
|
Powered by
FUDForum. Page generated in 0.02242 seconds