Convert Line Delimiter Programmatically [message #550562] |
Fri, 30 July 2010 15:40  |
Eclipse User |
|
|
|
Hello,
I would like to know if there is any way i can change a file's line delimiter programmatically. Something like calling the "Convert Line Delimiter To" from my code (giving an IFile or an IPath).
(changing the line delimiter in the preferences is not an option as it is not applied to already existing files.)
Thank you,
Miguel
|
|
|
|
|
|
Re: Convert Line Delimiter Programmatically [message #551121 is a reply to message #551061] |
Thu, 05 August 2010 06:29  |
Eclipse User |
|
|
|
Dani Megert wrote:
>> Thanks Dani, but what i need is a way to call the "File > Convert Line
>> Delimiters To" action from my code.
>>
>> I've been trying something like this:
>>
>> public static void convertLineDelimiters(IFile file) {
>> IPath[] paths = new IPath[] { file.getFullPath() };
>>
>> ITextFileBufferManager buffManager =
>> FileBuffers.getTextFileBufferManager();
>>
>> TextFileBufferOperation convertOperation =
>> new ConvertLineDelimitersOperation("\n");
>>
>> FileBufferOperationRunner runner = new
>> FileBufferOperationRunner(buffManager, null);
>>
>> runner.execute(paths, convertOperation, new NullProgressMonitor());
>> }
>>
>> But i'm having problems using objects from the package:
>> "org.eclipse.core.filebuffers.manipulation", any reason why?
>Maybe you didn't add it to the 'Require-Bundle' section in your manifest?
I'd completely forgotten about that. It's working.
Thank you so much,
Miguel Mateus
>
>Dani
>>
>> Thanks.
|
|
|
Powered by
FUDForum. Page generated in 0.06885 seconds