Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » No Syntax coloring when opening a file with custom editor
No Syntax coloring when opening a file with custom editor [message #333270] Tue, 02 December 2008 21:14 Go to next message
Mike Jackson is currently offline Mike JacksonFriend
Messages: 128
Registered: July 2009
Senior Member
I have been updating a custom editor (cmakeed.sourceforge.net) and all
is generally going well except I have a small stumbling block.

My editor opens files with a name of "CMakeLists.txt" and "*.cmake". I
have a few projects where I have template files with names like
CMakeLists.txt.in and Project.cmake.in.

I can right click on the file in the project explorer and select the
"Open With..." menu which brings up the list of available editors. I
select CMakeEd and an editor opens BUT I have no syntax coloring or any
other custom feature that I wrote. The issues seems to be when I hit
the "createEmptyDocument(IFile) method in the
ResourceTextFileBufferManager class.

The line:

final IDocumentSetupParticipant[] participants=
((ResourceExtensionRegistry)fRegistry).getDocumentSetupParti cipants(file);

will

return a zero length array. I am assuming because it looks at the
extension points for my custom reader (among others) and decides that
the file name does not match what is in my extension point and so
returns nothing.

So my question: How do other editors handle this? I know I have had
instances where I have opened a file like source.cpp.in as a C plus
plus file and gotten the correct coloring, highlighting and all that.

Thanks for any help
Mike Jackson
BlueQuartz Software
Re: No Syntax coloring when opening a file with custom editor [message #333283 is a reply to message #333270] Wed, 03 December 2008 12:08 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Mike Jackson wrote:
> I have been updating a custom editor (cmakeed.sourceforge.net) and all
> is generally going well except I have a small stumbling block.
>
> My editor opens files with a name of "CMakeLists.txt" and "*.cmake". I
> have a few projects where I have template files with names like
> CMakeLists.txt.in and Project.cmake.in.
>
> I can right click on the file in the project explorer and select the
> "Open With..." menu which brings up the list of available editors. I
> select CMakeEd and an editor opens BUT I have no syntax coloring or
> any other custom feature that I wrote. The issues seems to be when I
> hit the "createEmptyDocument(IFile) method in the
> ResourceTextFileBufferManager class.
>
> The line:
>
> final IDocumentSetupParticipant[] participants=
> ((ResourceExtensionRegistry)fRegistry).getDocumentSetupParti cipants(file);
>
>
> will
> return a zero length array. I am assuming because it looks at the
> extension points for my custom reader (among others) and decides that
> the file name does not match what is in my extension point and so
> returns nothing.
>
> So my question: How do other editors handle this? I know I have had
> instances where I have opened a file like source.cpp.in as a C plus
> plus file and gotten the correct coloring, highlighting and all that.
Do something like that:

IDocumentProvider provider= new TextFileDocumentProvider();
provider= new ForwardingDocumentProvider(yourPartitioning, new
YourDocumentSetupParticipant(), provider);
setParentDocumentProvider(provider);

Dani
>
> Thanks for any help
> Mike Jackson
> BlueQuartz Software
>
Re: No Syntax coloring when opening a file with custom editor [message #333293 is a reply to message #333283] Wed, 03 December 2008 14:50 Go to previous messageGo to next message
Mike Jackson is currently offline Mike JacksonFriend
Messages: 128
Registered: July 2009
Senior Member
On 2008-12-03 07:08:58 -0500, Daniel Megert <daniel_megert@ch.ibm.com> said:

> Mike Jackson wrote:
>> I have been updating a custom editor (cmakeed.sourceforge.net) and all
>> is generally going well except I have a small stumbling block.
>>
>> My editor opens files with a name of "CMakeLists.txt" and "*.cmake". I
>> have a few projects where I have template files with names like
>> CMakeLists.txt.in and Project.cmake.in.
>>
>> I can right click on the file in the project explorer and select the
>> "Open With..." menu which brings up the list of available editors. I
>> select CMakeEd and an editor opens BUT I have no syntax coloring or any
>> other custom feature that I wrote. The issues seems to be when I hit
>> the "createEmptyDocument(IFile) method in the
>> ResourceTextFileBufferManager class.
>>
>> The line:
>>
>> final IDocumentSetupParticipant[] participants=
>> ((ResourceExtensionRegistry)fRegistry).getDocumentSetupParti cipants(file);

will
return
>>
>> a zero length array. I am assuming because it looks at the extension
>> points for my custom reader (among others) and decides that the file
>> name does not match what is in my extension point and so returns
>> nothing.
>>
>> So my question: How do other editors handle this? I know I have had
>> instances where I have opened a file like source.cpp.in as a C plus
>> plus file and gotten the correct coloring, highlighting and all that.
> Do something like that:
>
> IDocumentProvider provider= new TextFileDocumentProvider();
> provider= new ForwardingDocumentProvider(yourPartitioning, new
> YourDocumentSetupParticipant(), provider);
> setParentDocumentProvider(provider);
>
> Dani
>>
>> Thanks for any help
>> Mike Jackson
>> BlueQuartz Software

Awesome.. Thanks.. But I am still a bit "wet behind the ears" with this
so just _where_ would I put this code?

Thanks
Mike Jackson
Re: No Syntax coloring when opening a file with custom editor [message #333302 is a reply to message #333293] Wed, 03 December 2008 17:26 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Mike Jackson wrote:
> On 2008-12-03 07:08:58 -0500, Daniel Megert <daniel_megert@ch.ibm.com>
> said:
>
>> Mike Jackson wrote:
>>> I have been updating a custom editor (cmakeed.sourceforge.net) and
>>> all is generally going well except I have a small stumbling block.
>>>
>>> My editor opens files with a name of "CMakeLists.txt" and "*.cmake".
>>> I have a few projects where I have template files with names like
>>> CMakeLists.txt.in and Project.cmake.in.
>>>
>>> I can right click on the file in the project explorer and select the
>>> "Open With..." menu which brings up the list of available editors. I
>>> select CMakeEd and an editor opens BUT I have no syntax coloring or
>>> any other custom feature that I wrote. The issues seems to be when I
>>> hit the "createEmptyDocument(IFile) method in the
>>> ResourceTextFileBufferManager class.
>>>
>>> The line:
>>>
>>> final IDocumentSetupParticipant[] participants=
>>> ((ResourceExtensionRegistry)fRegistry).getDocumentSetupParti cipants(file);
>>>
>
> will
> return
>>>
>>> a zero length array. I am assuming because it looks at the extension
>>> points for my custom reader (among others) and decides that the file
>>> name does not match what is in my extension point and so returns
>>> nothing.
>>>
>>> So my question: How do other editors handle this? I know I have had
>>> instances where I have opened a file like source.cpp.in as a C plus
>>> plus file and gotten the correct coloring, highlighting and all that.
>> Do something like that:
>>
>> IDocumentProvider provider= new TextFileDocumentProvider();
>> provider= new ForwardingDocumentProvider(yourPartitioning,
>> new YourDocumentSetupParticipant(), provider);
>> setParentDocumentProvider(provider);
>>
>> Dani
>>>
>>> Thanks for any help
>>> Mike Jackson
>>> BlueQuartz Software
>
> Awesome.. Thanks.. But I am still a bit "wet behind the ears" with
> this so just _where_ would I put this code?
This needs to be in the constructor of your own document provider.

Dani
>
> Thanks
> Mike Jackson
>
Re: No Syntax coloring when opening a file with custom editor [message #333305 is a reply to message #333302] Wed, 03 December 2008 19:27 Go to previous messageGo to next message
Mike Jackson is currently offline Mike JacksonFriend
Messages: 128
Registered: July 2009
Senior Member
On 2008-12-03 12:26:14 -0500, Daniel Megert <daniel_megert@ch.ibm.com> said:

> Mike Jackson wrote:
>> On 2008-12-03 07:08:58 -0500, Daniel Megert <daniel_megert@ch.ibm.com> said:
>>
>>> Mike Jackson wrote:
>>>> I have been updating a custom editor (cmakeed.sourceforge.net) and all
>>>> is generally going well except I have a small stumbling block.
>>>>
>>>> My editor opens files with a name of "CMakeLists.txt" and "*.cmake". I
>>>> have a few projects where I have template files with names like
>>>> CMakeLists.txt.in and Project.cmake.in.
>>>>
>>>> I can right click on the file in the project explorer and select the
>>>> "Open With..." menu which brings up the list of available editors. I
>>>> select CMakeEd and an editor opens BUT I have no syntax coloring or any
>>>> other custom feature that I wrote. The issues seems to be when I hit
>>>> the "createEmptyDocument(IFile) method in the
>>>> ResourceTextFileBufferManager class.
>>>>
>>>> The line:
>>>>
>>>> final IDocumentSetupParticipant[] participants=
>>>> ((ResourceExtensionRegistry)fRegistry).getDocumentSetupParti cipants(file);

will
return

a
>>>>
>>>> zero length array. I am assuming because it looks at the extension
>>>> points for my custom reader (among others) and decides that the file
>>>> name does not match what is in my extension point and so returns
>>>> nothing.
>>>>
>>>> So my question: How do other editors handle this? I know I have had
>>>> instances where I have opened a file like source.cpp.in as a C plus
>>>> plus file and gotten the correct coloring, highlighting and all that.
>>> Do something like that:
>>>
>>> IDocumentProvider provider= new TextFileDocumentProvider();
>>> provider= new ForwardingDocumentProvider(yourPartitioning, new
>>> YourDocumentSetupParticipant(), provider);
>>> setParentDocumentProvider(provider);
>>>
>>> Dani
>>>>
>>>> Thanks for any help
>>>> Mike Jackson
>>>> BlueQuartz Software
>>
>> Awesome.. Thanks.. But I am still a bit "wet behind the ears" with this
>> so just _where_ would I put this code?
> This needs to be in the constructor of your own document provider.
>
> Dani

Ok. I put that in the Constructor of my "CMakeDocumentProvider" class.
I also had to change the CMakeEditor class to extend from
AbstractDecoratedTextEditor. Things still seem to work with regard to
all the other behaviors. I still have the same problem at the same line
as my original posting.

final IDocumentSetupParticipant[] participants=
((ResourceExtensionRegistry)fRegistry).getDocumentSetupParti cipants(file);

will

return a zero length array so the participant.setup(document); line
will never get called.

I am sure I am just missing something hopefully obvious.

Thanks for the help
Mike Jackson
Re: No Syntax coloring when opening a file with custom editor [message #333306 is a reply to message #333302] Wed, 03 December 2008 19:49 Go to previous message
Mike Jackson is currently offline Mike JacksonFriend
Messages: 128
Registered: July 2009
Senior Member
On 2008-12-03 12:26:14 -0500, Daniel Megert <daniel_megert@ch.ibm.com> said:

> Mike Jackson wrote:
>> On 2008-12-03 07:08:58 -0500, Daniel Megert <daniel_megert@ch.ibm.com> said:
>>
>>> Mike Jackson wrote:
>>>> I have been updating a custom editor (cmakeed.sourceforge.net) and all
>>>> is generally going well except I have a small stumbling block.
>>>>
>>>> My editor opens files with a name of "CMakeLists.txt" and "*.cmake". I
>>>> have a few projects where I have template files with names like
>>>> CMakeLists.txt.in and Project.cmake.in.
>>>>
>>>> I can right click on the file in the project explorer and select the
>>>> "Open With..." menu which brings up the list of available editors. I
>>>> select CMakeEd and an editor opens BUT I have no syntax coloring or any
>>>> other custom feature that I wrote. The issues seems to be when I hit
>>>> the "createEmptyDocument(IFile) method in the
>>>> ResourceTextFileBufferManager class.
>>>>
>>>> The line:
>>>>
>>>> final IDocumentSetupParticipant[] participants=
>>>> ((ResourceExtensionRegistry)fRegistry).getDocumentSetupParti cipants(file);

will
return

a
>>>>
>>>> zero length array. I am assuming because it looks at the extension
>>>> points for my custom reader (among others) and decides that the file
>>>> name does not match what is in my extension point and so returns
>>>> nothing.
>>>>
>>>> So my question: How do other editors handle this? I know I have had
>>>> instances where I have opened a file like source.cpp.in as a C plus
>>>> plus file and gotten the correct coloring, highlighting and all that.
>>> Do something like that:
>>>
>>> IDocumentProvider provider= new TextFileDocumentProvider();
>>> provider= new ForwardingDocumentProvider(yourPartitioning, new
>>> YourDocumentSetupParticipant(), provider);
>>> setParentDocumentProvider(provider);
>>>
>>> Dani
>>>>
>>>> Thanks for any help
>>>> Mike Jackson
>>>> BlueQuartz Software
>>
>> Awesome.. Thanks.. But I am still a bit "wet behind the ears" with this
>> so just _where_ would I put this code?
> This needs to be in the constructor of your own document provider.
>
> Dani

Got it!!. In the constructor for CMakeEditor I put the following:

IDocumentProvider provider= new TextFileDocumentProvider();
provider= new
ForwardingDocumentProvider(UIPlugin.CMAKE_PARTITIONING, new
CMakeDocumentSetupParticipant(), provider);
setDocumentProvider(provider);

And now things work as hoped/expected. THANKS!!.

Mike
Previous Topic:Custom Editor Saving File causes cursor position to be reset
Next Topic:CNF
Goto Forum:
  


Current Time: Fri Apr 19 22:57:07 GMT 2024

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

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

Back to the top