[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform] How to associate custom editor with particular files?

I have written an editor that I want to be associated with any Java files with names of the format *DAO.java. (A slightly more sophisticated version would look for classes that extend a particular base class, rather than go purely off the filename, but I'd be happy with either for now).

In the definition of my editor contribution, I specify an extension of java, and a filename of *DAO.java. It appears that the filename is completely ignored, because if I set default=true for this editor, then it opens for all .java files; and if I set default=false, then it doesn't open for any file.

So I thought the next step would be to define a contentType. I definted a contentType with extensions=java, and filename=*DAO.java. (I used a base type of org.eclipse.core.runtime.text, but I'd prefer to use the base type that represents Java source files, if someone can tell me what that is). I added a contentTypeBinding to my editor. If I leave the extension and filename settings on the editor, then the behavior is unchanged (i.e., depends entirely on whether default is true). If I remove those settings (attempting to force it to rely only on the contentTypeBinding), then the editor is never opened.

What's the proper procedure here? I shouldn't have to write a Describer class, since the files for which my editor should be invoked can be completely identified via the filename pattern, but it seems like the filename pattern is ignored on both the Editor contribution and on the ContentType contribution.

Mike