Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Convert Line Delimiter Programmatically
Convert Line Delimiter Programmatically [message #550562] Fri, 30 July 2010 15:40 Go to next message
Eclipse UserFriend
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 #550670 is a reply to message #550562] Wed, 04 August 2010 02:30 Go to previous messageGo to next message
Eclipse UserFriend
Miguel Mateus wrote:
> 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.)
File > Convert Line Delimiters To

Dani
>
> Thank you,
> Miguel
Re: Convert Line Delimiter Programmatically [message #550981 is a reply to message #550670] Wed, 04 August 2010 14:27 Go to previous messageGo to next message
Eclipse UserFriend
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?

Thanks.
Re: Convert Line Delimiter Programmatically [message #551061 is a reply to message #550981] Thu, 05 August 2010 01:52 Go to previous messageGo to next message
Eclipse UserFriend
Miguel Mateus 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?

Dani
>
> Thanks.
Re: Convert Line Delimiter Programmatically [message #551121 is a reply to message #551061] Thu, 05 August 2010 06:29 Go to previous message
Eclipse UserFriend
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.
Previous Topic:Unable to delete/move files after opening
Next Topic:Project set import (Error deleting resources) eclipse 3.4.2, 3.5.2 and 3.6
Goto Forum:
  


Current Time: Sat Jul 05 07:27:31 EDT 2025

Powered by FUDForum. Page generated in 0.06885 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top