Home » Eclipse Projects » Eclipse Platform » How to select editor based on content instead of file extension
How to select editor based on content instead of file extension [message #305902] |
Sun, 16 July 2006 05:40  |
Eclipse User |
|
|
|
Originally posted by: lmmw66-remove-this.telenet.be
Hi All,
I've written a plug-in that has a multi-page editor that handles special c
source files. The first line in those source files indicate whether my editor
can handle them. If my editor can not handle them I would like the
framework to open the cdt editor.
I associated my editor to the .c and .h extension; the problem is that
the eclipse framework now sends all .c and .h files to my editor, also
those that I can not handle. Is there a possibility to let the eclipse
framework decide on what editor to instantiate based on the content of the
file instead of its file extension?
Thanks,
ludwig
|
|
| |
Re: How to select editor based on content instead of file extension [message #306000 is a reply to message #305938] |
Mon, 17 July 2006 16:31   |
Eclipse User |
|
|
|
Originally posted by: lmmw66-remove-this.telenet.be
Thanks for the info Tom. However for some reason I can't get it working ;-(
My describer class never gets called by the framework.
This is the relevant part of my plugin.xml
<extension
point="org.eclipse.ui.editors">
<editor
class="org.eclipse.odt.ui.editors.OOCEditor"
default="false"
extensions="ooc,xml,c,h"
icon="icons/files/ooc_file.gif"
id="org.eclipse.odt.editors.OOCEditor"
name="OOC Editor">
<contentTypeBinding contentTypeId="ooc-source"/>
</editor>
</extension>
<extension
point="org.eclipse.core.runtime.contentTypes">
<content-type
base-type="org.eclipse.core.runtime.text"
file-extensions="c,h,ooc,xml"
id="ooc-source"
name="ooc-source"
priority="normal">
<describer class="org.eclipse.odt.ui.editors.OOCDescriber"/>
</content-type>
</extension>
When I open any .c,.h file, my OOCEditor is created. The OOCDescriber
class is never called. Any idea?
Thanks a lot,
ludwig
On Mon, 17 Jul 2006 11:02:27 +0200, Tom Eicher wrote:
> Ludwig,
>
> you can contribute to the org.eclipse.core.runtime.contentTypes
> extension point. You would probably declare your own special-c-file
> content type as subtype of C files, and contribute a describer that
> recognizes your special c-files.
>
> -tom
>
> Ludwig Weynants wrote:
>> I've written a plug-in that has a multi-page editor that handles special c
>> source files. The first line in those source files indicate whether my editor
>> can handle them. If my editor can not handle them I would like the
>> framework to open the cdt editor.
>>
>> I associated my editor to the .c and .h extension; the problem is that
>> the eclipse framework now sends all .c and .h files to my editor, also
>> those that I can not handle. Is there a possibility to let the eclipse
>> framework decide on what editor to instantiate based on the content of the
>> file instead of its file extension?
>>
>> Thanks,
>> ludwig
>>
|
|
|
Re: How to select editor based on content instead of file extension [message #306012 is a reply to message #306000] |
Tue, 18 July 2006 02:59   |
Eclipse User |
|
|
|
Ludwig Weynants wrote:
>Thanks for the info Tom. However for some reason I can't get it working ;-(
>My describer class never gets called by the framework.
>This is the relevant part of my plugin.xml
>
> <extension
> point="org.eclipse.ui.editors">
> <editor
> class="org.eclipse.odt.ui.editors.OOCEditor"
> default="false"
> extensions="ooc,xml,c,h"
> icon="icons/files/ooc_file.gif"
> id="org.eclipse.odt.editors.OOCEditor"
> name="OOC Editor">
> <contentTypeBinding contentTypeId="ooc-source"/>
> </editor>
> </extension>
> <extension
> point="org.eclipse.core.runtime.contentTypes">
> <content-type
> base-type="org.eclipse.core.runtime.text"
> file-extensions="c,h,ooc,xml"
> id="ooc-source"
> name="ooc-source"
> priority="normal">
> <describer class="org.eclipse.odt.ui.editors.OOCDescriber"/>
> </content-type>
> </extension>
>
>When I open any .c,.h file, my OOCEditor is created. The OOCDescriber
>class is never called. Any idea?
>
>
Start your target using -clean and if this doesn't help check the .log
for problems. Next, try with priority="high". In addition you might want
to use the existing BinarySignatureDescriber instead of witting a new
one. Take a look at the JDT Core plugin.xml how this can be done.
Dani
>Thanks a lot,
>ludwig
>
>On Mon, 17 Jul 2006 11:02:27 +0200, Tom Eicher wrote:
>
>
>>Ludwig,
>>
>>you can contribute to the org.eclipse.core.runtime.contentTypes
>>extension point. You would probably declare your own special-c-file
>>content type as subtype of C files, and contribute a describer that
>>recognizes your special c-files.
>>
>>-tom
>>
>>Ludwig Weynants wrote:
>>
>>
>>>I've written a plug-in that has a multi-page editor that handles special c
>>>source files. The first line in those source files indicate whether my editor
>>>can handle them. If my editor can not handle them I would like the
>>>framework to open the cdt editor.
>>>
>>>I associated my editor to the .c and .h extension; the problem is that
>>>the eclipse framework now sends all .c and .h files to my editor, also
>>>those that I can not handle. Is there a possibility to let the eclipse
>>>framework decide on what editor to instantiate based on the content of the
>>>file instead of its file extension?
>>>
>>>Thanks,
>>>ludwig
>>>
>>>
>>>
>
>
>
|
|
|
Re: How to select editor based on content instead of file extension [message #306034 is a reply to message #306012] |
Tue, 18 July 2006 14:49  |
Eclipse User |
|
|
|
Originally posted by: lmmw66-remove-this.telenet.be
On Tue, 18 Jul 2006 08:59:34 +0200, Daniel Megert wrote:
> Ludwig Weynants wrote:
>
>>Thanks for the info Tom. However for some reason I can't get it working ;-(
>>My describer class never gets called by the framework.
>>This is the relevant part of my plugin.xml
>>
>> <extension
>> point="org.eclipse.ui.editors">
>> <editor
>> class="org.eclipse.odt.ui.editors.OOCEditor"
>> default="false"
>> extensions="ooc,xml,c,h"
>> icon="icons/files/ooc_file.gif"
>> id="org.eclipse.odt.editors.OOCEditor"
>> name="OOC Editor">
>> <contentTypeBinding contentTypeId="ooc-source"/>
>> </editor>
>> </extension>
>> <extension
>> point="org.eclipse.core.runtime.contentTypes">
>> <content-type
>> base-type="org.eclipse.core.runtime.text"
>> file-extensions="c,h,ooc,xml"
>> id="ooc-source"
>> name="ooc-source"
>> priority="normal">
>> <describer class="org.eclipse.odt.ui.editors.OOCDescriber"/>
>> </content-type>
>> </extension>
>>
>>When I open any .c,.h file, my OOCEditor is created. The OOCDescriber
>>class is never called. Any idea?
>>
>>
> Start your target using -clean and if this doesn't help check the .log
> for problems. Next, try with priority="high". In addition you might want
> to use the existing BinarySignatureDescriber instead of witting a new
> one. Take a look at the JDT Core plugin.xml how this can be done.
>
> Dani
>
>>Thanks a lot,
>>ludwig
>>
>>On Mon, 17 Jul 2006 11:02:27 +0200, Tom Eicher wrote:
>>
>>
>>>Ludwig,
>>>
>>>you can contribute to the org.eclipse.core.runtime.contentTypes
>>>extension point. You would probably declare your own special-c-file
>>>content type as subtype of C files, and contribute a describer that
>>>recognizes your special c-files.
>>>
>>>-tom
>>>
>>>Ludwig Weynants wrote:
>>>
>>>
>>>>I've written a plug-in that has a multi-page editor that handles special c
>>>>source files. The first line in those source files indicate whether my editor
>>>>can handle them. If my editor can not handle them I would like the
>>>>framework to open the cdt editor.
>>>>
>>>>I associated my editor to the .c and .h extension; the problem is that
>>>>the eclipse framework now sends all .c and .h files to my editor, also
>>>>those that I can not handle. Is there a possibility to let the eclipse
>>>>framework decide on what editor to instantiate based on the content of the
>>>>file instead of its file extension?
>>>>
>>>>Thanks,
>>>>ludwig
>>>>
>>>>
>>>>
>>
>>
>>
The -clean option does the trick! Thanks a lot! Help was highly
appreciated.
ludwig
|
|
|
Goto Forum:
Current Time: Fri Jul 18 22:08:24 EDT 2025
Powered by FUDForum. Page generated in 0.05364 seconds
|