Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » When do I need an org.eclipse.core.filebuffers.documentSetup extension?
When do I need an org.eclipse.core.filebuffers.documentSetup extension? [message #292583] Fri, 07 October 2005 15:20 Go to next message
Eclipse UserFriend
Originally posted by: mark_melvin.amis.com

I just found out that my editor is broken if I try to add a *new* file
extension using Window > Preferences > General > Editors > File
Associations. In particular, the outline and content assist work fine
but there is no syntax highlighting.

I have since discovered that it is because I not only have defined an
org.eclipse.ui.editors extension, but I have also defined an
org.eclipse.core.filebuffers.documentSetup on the known set of default
file extensions. As it turns out this is what hooks up my partitioner,
and why my syntax highlighting doesn't work for *other* extensions. My
question is: "Why did I do this?" ;o) I mean, if I recal l, I was using
the Ant stuff as a reference way back when. I did this when I was
developing pre-3.0, and for the life of me I can't figure out why it
would be required. It is obviously wrong, because it doesn;t work.

So, in the 3.1 era:

1) What is org.eclipse.core.filebuffers.documentSetup for?
2) Where *should* I put the code that hooks up my partitioning. For
example:

/*
* @see
org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup (org.eclipse.jface.text.IDocument)
*/
public void setup(IDocument document) {
if (document instanceof IDocumentExtension3) {
IDocumentExtension3 extension3= (IDocumentExtension3) document;
IDocumentPartitioner partitioner = createDocumentPartitioner();
extension3.setDocumentPartitioner(MY_PARTITIONING, partitioner);
partitioner.connect(document);
}
}

Thanks,
Mark.
Re: When do I need an org.eclipse.core.filebuffers.documentSetup extension? [message #292585 is a reply to message #292583] Fri, 07 October 2005 16:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mark_melvin.amis.com

OK, I just found this bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=72598 that is essentially
the same problem I am having, and I have grokked the AntUI source to see
how this has been worked around. Unfortunately my model is so
completely different from Ant's now (I don't have content types, or even
a document model) I can't see how to work this in. And quite frankly I
am so freaking confused with editors, document providers, partitioners,
file buffers, etc. my head is ready to explode. This stuff has changed
so much from pre-3.0 that most of the code I see is a huge confusing
mess of concepts. Every book I have (even books supposedly updated to
3.0) talks about deprecated or stale concepts and I am constantly
fighting an uphill battle on this stuff. I went to a presentation on
filebuffers at EclipseCON last year (present by Kai-Uwe Matzel) and was
conpletely confused again. It seemed like there were 10 more new
concepts not mentioned in any books or articles here.

So, is there a PROPER example/book/article of how to implement a simple
syntax-highlighting editor using updated, 3.1 concepts somewhere? All
the source I can find seems to contain a very confusing mix of the *old*
way and some of the *new* way of doing things. There are partitioners,
source viewer configurations, storage document providers, text file
document providers, forwarding document providers, document setup
participants....exactly how many layers do I need to make an editor here
that will work properly with the File Associations and Content Types
preferences??

Any pointers would be greatly appreciated.

Thanks,
Mark.

Mark Melvin wrote:
> I just found out that my editor is broken if I try to add a *new* file
> extension using Window > Preferences > General > Editors > File
> Associations. In particular, the outline and content assist work fine
> but there is no syntax highlighting.
>
> I have since discovered that it is because I not only have defined an
> org.eclipse.ui.editors extension, but I have also defined an
> org.eclipse.core.filebuffers.documentSetup on the known set of default
> file extensions. As it turns out this is what hooks up my partitioner,
> and why my syntax highlighting doesn't work for *other* extensions. My
> question is: "Why did I do this?" ;o) I mean, if I recal l, I was using
> the Ant stuff as a reference way back when. I did this when I was
> developing pre-3.0, and for the life of me I can't figure out why it
> would be required. It is obviously wrong, because it doesn;t work.
>
> So, in the 3.1 era:
>
> 1) What is org.eclipse.core.filebuffers.documentSetup for?
> 2) Where *should* I put the code that hooks up my partitioning. For
> example:
>
> /*
> * @see
> org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup (org.eclipse.jface.text.IDocument)
>
> */
> public void setup(IDocument document) {
> if (document instanceof IDocumentExtension3) {
> IDocumentExtension3 extension3= (IDocumentExtension3) document;
> IDocumentPartitioner partitioner = createDocumentPartitioner();
> extension3.setDocumentPartitioner(MY_PARTITIONING,
> partitioner);
> partitioner.connect(document);
> }
> }
>
> Thanks,
> Mark.
Re: When do I need an org.eclipse.core.filebuffers.documentSetup extension? [message #292628 is a reply to message #292583] Sun, 09 October 2005 09:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex.vandenabeele.telenet.be

Hi,

I recently coped with the same problems you're having and managed to get
a working syntax highlighting editor, so:

Mark Melvin schreef:
> I just found out that my editor is broken if I try to add a *new* file
> extension using Window > Preferences > General > Editors > File
> Associations. In particular, the outline and content assist work fine
> but there is no syntax highlighting.
>
> I have since discovered that it is because I not only have defined an
> org.eclipse.ui.editors extension, but I have also defined an
> org.eclipse.core.filebuffers.documentSetup on the known set of default
> file extensions. As it turns out this is what hooks up my partitioner,
> and why my syntax highlighting doesn't work for *other* extensions. My
> question is: "Why did I do this?" ;o) I mean, if I recal l, I was using
> the Ant stuff as a reference way back when. I did this when I was
> developing pre-3.0, and for the life of me I can't figure out why it
> would be required. It is obviously wrong, because it doesn;t work.
>
> So, in the 3.1 era:
>
> 1) What is org.eclipse.core.filebuffers.documentSetup for?

Like you say, it hooks your doument partitioner and in the plugin.xml
file you need to indicate for which ectensions it is needed. You can
specify multiple extensions there.


> 2) Where *should* I put the code that hooks up my partitioning. For
> example:
>
> /*
> * @see
> org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup (org.eclipse.jface.text.IDocument)
>
> */
> public void setup(IDocument document) {
> if (document instanceof IDocumentExtension3) {
> IDocumentExtension3 extension3= (IDocumentExtension3) document;
> IDocumentPartitioner partitioner = createDocumentPartitioner();
> extension3.setDocumentPartitioner(MY_PARTITIONING,
> partitioner);
> partitioner.connect(document);
> }
> }

This code seems the same as mine, thus this should work.

Alex
Re: When do I need an org.eclipse.core.filebuffers.documentSetup extension? [message #292706 is a reply to message #292628] Tue, 11 October 2005 14:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mark_melvin.amis.com

Hey Alex,

Thanks for the reply - however the problem I have is when I add a "new"
extension using Window > Preferences > General > Editors > File >
Associations. If I do this, and add a brand new file extension
associated with my editor, syntax highlighting doesn't work.

Does this work for you?

Mark.

Alex Vanden Abeele wrote:
> Hi,
>
> I recently coped with the same problems you're having and managed to get
> a working syntax highlighting editor, so:
>
> Mark Melvin schreef:
>
>> I just found out that my editor is broken if I try to add a *new* file
>> extension using Window > Preferences > General > Editors > File
>> Associations. In particular, the outline and content assist work fine
>> but there is no syntax highlighting.
>>
>> I have since discovered that it is because I not only have defined an
>> org.eclipse.ui.editors extension, but I have also defined an
>> org.eclipse.core.filebuffers.documentSetup on the known set of default
>> file extensions. As it turns out this is what hooks up my
>> partitioner, and why my syntax highlighting doesn't work for *other*
>> extensions. My question is: "Why did I do this?" ;o) I mean, if I
>> recal l, I was using the Ant stuff as a reference way back when. I
>> did this when I was developing pre-3.0, and for the life of me I can't
>> figure out why it would be required. It is obviously wrong, because
>> it doesn;t work.
>>
>> So, in the 3.1 era:
>>
>> 1) What is org.eclipse.core.filebuffers.documentSetup for?
>
>
> Like you say, it hooks your doument partitioner and in the plugin.xml
> file you need to indicate for which ectensions it is needed. You can
> specify multiple extensions there.
>
>
>> 2) Where *should* I put the code that hooks up my partitioning. For
>> example:
>>
>> /*
>> * @see
>> org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup (org.eclipse.jface.text.IDocument)
>>
>> */
>> public void setup(IDocument document) {
>> if (document instanceof IDocumentExtension3) {
>> IDocumentExtension3 extension3= (IDocumentExtension3)
>> document;
>> IDocumentPartitioner partitioner =
>> createDocumentPartitioner();
>> extension3.setDocumentPartitioner(MY_PARTITIONING,
>> partitioner);
>> partitioner.connect(document);
>> }
>> }
>
>
> This code seems the same as mine, thus this should work.
>
> Alex
Re: When do I need an org.eclipse.core.filebuffers.documentSetup extension? [message #292839 is a reply to message #292583] Thu, 13 October 2005 09:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: daniel.megert.eclipse.org

Mark Melvin wrote:

> I just found out that my editor is broken if I try to add a *new* file
> extension using Window > Preferences > General > Editors > File
> Associations. In particular, the outline and content assist work fine
> but there is no syntax highlighting.
>
> I have since discovered that it is because I not only have defined an
> org.eclipse.ui.editors extension, but I have also defined an
> org.eclipse.core.filebuffers.documentSetup on the known set of default
> file extensions. As it turns out this is what hooks up my
> partitioner, and why my syntax highlighting doesn't work for *other*
> extensions. My question is: "Why did I do this?" ;o) I mean, if I
> recal l, I was using the Ant stuff as a reference way back when. I
> did this when I was developing pre-3.0, and for the life of me I can't
> figure out why it would be required. It is obviously wrong, because
> it doesn;t work.
>
> So, in the 3.1 era:
>
> 1) What is org.eclipse.core.filebuffers.documentSetup for?

The intent is that a new document can be setup with various things like
partitioning. This setup should be of general interest e.g. install a
Java partitioning for a Java document and care must be taken not
conflict with other setup participants. If you just write an editor you
probably don't need to provide this extension point but rather have your
own document provider (most likely extending TextFileDocumentProvider)
which does the document setup in its constructor.

> 2) Where *should* I put the code that hooks up my partitioning. For
> example:

Do it in the constructur of your own document provider (see also above).

Dani

>
> /*
> * @see
> org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup (org.eclipse.jface.text.IDocument)
>
> */
> public void setup(IDocument document) {
> if (document instanceof IDocumentExtension3) {
> IDocumentExtension3 extension3= (IDocumentExtension3)
> document;
> IDocumentPartitioner partitioner =
> createDocumentPartitioner();
> extension3.setDocumentPartitioner(MY_PARTITIONING,
> partitioner);
> partitioner.connect(document);
> }
> }
>
> Thanks,
> Mark.
Re: When do I need an org.eclipse.core.filebuffers.documentSetup extension? [message #293010 is a reply to message #292839] Fri, 14 October 2005 19:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mark_melvin.amis.com

Daniel Megert wrote:
> Mark Melvin wrote:
>> So, in the 3.1 era:
>>
>> 1) What is org.eclipse.core.filebuffers.documentSetup for?
>
>
> The intent is that a new document can be setup with various things like
> partitioning. This setup should be of general interest e.g. install a
> Java partitioning for a Java document and care must be taken not
> conflict with other setup participants. If you just write an editor you
> probably don't need to provide this extension point but rather have your
> own document provider (most likely extending TextFileDocumentProvider)
> which does the document setup in its constructor.
>
>> 2) Where *should* I put the code that hooks up my partitioning. For
>> example:
>
>
> Do it in the constructur of your own document provider (see also above).
>

Thanks for the reply...but this is the frustrating part. All of the
editors in the platform itself (Ant, Java) use a
documentSetupParticipant. So, if I am not supposed to use one for a
simple editor, I have no real good reference (source code-wise) to look
at. You mention I should just use a document provider. OK. Well, the
JDT doesn't seem to declare one, and neither does the Ant editor, so
right away I am in the dark about how they fit into the whole scheme of
things.
And what about compare/merge viewers? I used to see syntax highlighting
when comparing two files but that doesn't work anymore either. I don't
get a chance to set the document provider for a merge viewer, so what
should I do in this case? Is this where the filebuffers.* extension
points come into play, and is this why the Ant and JDT plugins do not
use a simple document provider?
My problem is there are really no good step-by-step examples for any of
this stuff. There is either a really simple one with a simple document
provider, but these seem fall apart when you start wanting to add more
complex things to your editor; or, at the other end of the spectrum is a
super-convoluted editor like the Java or Ant editors (no offense
intended) which are just very complicated bits of code, and it takes a
loooong time to figure out what the heck is going on - especially if you
are not familiar with the internals of Eclipse.

<sigh>

I am trying not to sound too frustrated here, but I have been pulling my
hair out just trying to get my syntax highlighting back in the compare
viewer for a couple days now and I am no further along than I was
before. I also intend to do fancier stuff in my editor in the future
and don't want to "dumb it down" now, only to find out I have to redo it
all later to support some feature.

SO

The way I see it is - the "new" way of doing things seems to be to use
content types and the org.eclipse.core.filebuffers.document* extension
points. So, that is what I would rather do. However, there are no
examples in any books I have and the code in the platform is just more
confusing than it has to be. Are there any good (meaning simple)
examples, or any documents out there that explain the new paradigm of
content types, and documentSetupParticipants, and how to use them?

Thanks,
Mark.
Re: When do I need an org.eclipse.core.filebuffers.documentSetup extension? [message #293012 is a reply to message #293010] Fri, 14 October 2005 21:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mark_melvin.amis.com

> And what about compare/merge viewers? I used to see syntax highlighting
> when comparing two files but that doesn't work anymore either. I don't
> get a chance to set the document provider for a merge viewer, so what
> should I do in this case? Is this where the filebuffers.* extension
> points come into play, and is this why the Ant and JDT plugins do not
> use a simple document provider?

Well, as it turns out, a content merge viewer will only partition the
content and display syntax highlighting if the
SourceViewerConfiguration#getConfiguredDocumentPartitioning returns
IDocumentExtension3.DEFAULT_PARTITIONING. I don't know why, but this is
the only way I could get it to work (forget about the fact that I want
to partition it using *my* partitioning), and this is also what the JDT
appears to do as well. Is there a reason for this?

Mark.
Re: When do I need an org.eclipse.core.filebuffers.documentSetup extension? [message #293047 is a reply to message #293010] Mon, 17 October 2005 09:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: daniel.megert.eclipse.org

Mark Melvin wrote:

> Daniel Megert wrote:
>
>> Mark Melvin wrote:
>>
>>> So, in the 3.1 era:
>>>
>>> 1) What is org.eclipse.core.filebuffers.documentSetup for?
>>
>>
>>
>> The intent is that a new document can be setup with various things
>> like partitioning. This setup should be of general interest e.g.
>> install a Java partitioning for a Java document and care must be
>> taken not conflict with other setup participants. If you just write
>> an editor you probably don't need to provide this extension point but
>> rather have your own document provider (most likely extending
>> TextFileDocumentProvider) which does the document setup in its
>> constructor.
>>
> >> 2) Where *should* I put the code that hooks up my partitioning. For
> >> example:
> >
> >
> > Do it in the constructur of your own document provider (see also
> above).
> >
>
> Thanks for the reply...but this is the frustrating part. All of the
> editors in the platform itself (Ant, Java) use a documentSetupParticipant.

Yes, because they provide a default partitioning for Java and Ant files.
However, e.g. the CompilationUnitDocumentProvider ensures that the
partitioning which is needed by the Java editor is in-place (e.g. if
opening a non-java file).

> So, if I am not supposed to use one for a simple editor, I have no
> real good reference (source code-wise) to look at. You mention I
> should just use a document provider. OK. Well, the JDT doesn't seem
> to declare one, and neither does the Ant editor, so right away

Not true, see CompilationUnitDocumentProvider and AntEditorDocumentProvider.

> I am in the dark about how they fit into the whole scheme of things.
> And what about compare/merge viewers?

The merger source viewers follow a different scheme since they are
embedded inside a compare editor/viewer. They are not affected by file
buffers.

> I used to see syntax highlighting when comparing two files but that
> doesn't work anymore either. I don't get a chance to set the document
> provider for a merge viewer, so what should I do in this case? Is
> this where the filebuffers.* extension points come into play, and is
> this why the Ant and JDT plugins do not use a simple document provider?
> My problem is there are really no good step-by-step examples for any
> of this stuff. There is either a really simple one with a simple
> document provider, but these seem fall apart when you start wanting to
> add more complex things to your editor; or, at the other end of the
> spectrum is a super-convoluted editor like the Java or Ant editors (no
> offense intended) which are just very complicated bits of code, and it
> takes a loooong time to figure out what the heck is going on -
> especially if you are not familiar with the internals of Eclipse.
>
> <sigh>
>
> I am trying not to sound too frustrated here, but I have been pulling
> my hair out just trying to get my syntax highlighting back in the
> compare viewer for a couple days now and I am no further along than I
> was before. I also intend to do fancier stuff in my editor in the
> future and don't want to "dumb it down" now, only to find out I have
> to redo it all later to support some feature.
>
> SO
>
> The way I see it is - the "new" way of doing things seems to be to use
> content types and the org.eclipse.core.filebuffers.document* extension
> points. So, that is what I would rather do. However, there are no
> examples in any books I have and the code in the platform is just more
> confusing than it has to be. Are there any good (meaning simple)
> examples, or any documents out there that explain the new paradigm of
> content types, and documentSetupParticipants, and how to use them?
>
> Thanks,
> Mark.
Re: When do I need an org.eclipse.core.filebuffers.documentSetup extension? [message #293048 is a reply to message #293012] Mon, 17 October 2005 09:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: daniel.megert.eclipse.org

Mark Melvin wrote:

>> And what about compare/merge viewers? I used to see syntax
>> highlighting when comparing two files but that doesn't work anymore
>> either. I don't get a chance to set the document provider for a
>> merge viewer, so what should I do in this case? Is this where the
>> filebuffers.* extension points come into play, and is this why the
>> Ant and JDT plugins do not use a simple document provider?
>
>
> Well, as it turns out, a content merge viewer will only partition the
> content and display syntax highlighting if the
> SourceViewerConfiguration#getConfiguredDocumentPartitioning returns
> IDocumentExtension3.DEFAULT_PARTITIONING.

This is true for e.g. the (internal) JavaMergeViewer but another merge
viewer might decide to define and use its own partitioning.

> I don't know why, but this is the only way I could get it to work
> (forget about the fact that I want to partition it using *my*
> partitioning), and this is also what the JDT appears to do as well.
> Is there a reason for this?

The reason is to allow to partition a document in different ways at the
same time. IIf the configured partitioning is changed to something other
than IDocumentExtension3.DEFAULT_PARTITIONING then features like syntax
coloring have to be setup/hooked to that partitioning.

Dani

>
> Mark.
Re: When do I need an org.eclipse.core.filebuffers.documentSetup extension? [message #293058 is a reply to message #293047] Mon, 17 October 2005 13:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mark_melvin.amis.com

Daniel Megert wrote:
> Mark Melvin wrote:
>> So, if I am not supposed to use one for a simple editor, I have no
>> real good reference (source code-wise) to look at. You mention I
>> should just use a document provider. OK. Well, the JDT doesn't seem
>> to declare one, and neither does the Ant editor, so right away
>
>
> Not true, see CompilationUnitDocumentProvider and
> AntEditorDocumentProvider.
>

Thanks for the reponses on this. I'm trying to follow...

OK, I agree there are these document providers present, but what I meant
was they don't seem to declare them using the
org.eclipse.ui.editors.documentProviders extension point. They just
manually hook them up at runtime with setDocumentProvider(). What's the
difference?


>> I am in the dark about how they fit into the whole scheme of things.
>> And what about compare/merge viewers?
>
>
> The merger source viewers follow a different scheme since they are
> embedded inside a compare editor/viewer. They are not affected by file
> buffers.
>

OK.
Re: When do I need an org.eclipse.core.filebuffers.documentSetup extension? [message #293059 is a reply to message #293048] Mon, 17 October 2005 13:51 Go to previous message
Eclipse UserFriend
Originally posted by: mark_melvin.amis.com

Daniel Megert wrote:
> Mark Melvin wrote:
>
>>> And what about compare/merge viewers? I used to see syntax
>>> highlighting when comparing two files but that doesn't work anymore
>>> either. I don't get a chance to set the document provider for a
>>> merge viewer, so what should I do in this case? Is this where the
>>> filebuffers.* extension points come into play, and is this why the
>>> Ant and JDT plugins do not use a simple document provider?
>>
>>
>>
>> Well, as it turns out, a content merge viewer will only partition the
>> content and display syntax highlighting if the
>> SourceViewerConfiguration#getConfiguredDocumentPartitioning returns
>> IDocumentExtension3.DEFAULT_PARTITIONING.
>
>
> This is true for e.g. the (internal) JavaMergeViewer but another merge
> viewer might decide to define and use its own partitioning.
>
>> I don't know why, but this is the only way I could get it to work
>> (forget about the fact that I want to partition it using *my*
>> partitioning), and this is also what the JDT appears to do as well.
>> Is there a reason for this?
>
>
> The reason is to allow to partition a document in different ways at the
> same time. IIf the configured partitioning is changed to something other
> than IDocumentExtension3.DEFAULT_PARTITIONING then features like syntax
> coloring have to be setup/hooked to that partitioning.

Well, that's what I am doing as far as I can tell, but I cannot get
syntax highlighting to work at all no matter what I do unless I change
my partitioning to IDocumentExtension3.DEFAULT_PARTITIONING. I've tried
hooking up my own partitioning manually, etc. but it just doesn't seem
to work. I must be doing something wrong. Do you have an example of a
different merge viewer that uses a different kind of partitioning, and
still shows syntax highlighting?

Thanks,
Mark.
Previous Topic:how can i implement accessible plugins?
Next Topic:Problem with exporting plugin in Eclipse 3.1
Goto Forum:
  


Current Time: Sat Oct 19 22:40:06 GMT 2024

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

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

Back to the top