«« Unrecognized XSLTC extension Redirect:write My Experience Moving RCP Apps from 3.0 to 3.1 »»
blog header image
Content Type Support Saves Me Time

Eclipse 3.1's new support for content types is already helping me out.

Durham has a lot of Ant build files, many of which don't have the default Ant build file name build.xml. In the past I had to associate each of these different filenames with the Ant editor in preferences, which was tedious.


Eclipse 3.1 looks at the file's contents, sees that its an Ant XML build file and associates the file with the Ant editor right out of the box. This is especially helpful with XML files because there are so many different file types with the extension xml.

Fannnnntastic. It's little things like this that save me loads of time in the long run. That's exactly what using an IDE is all about.

Posted at July 10, 2005 at 10:50 AM EST
Last updated July 10, 2005 at 10:50 AM EST
Comments

Hmm, is that *really* what it's doing, cos my experience appears to be kinda the reverse.

Are you sure it hasnt just associated the Ant editor as the default editor for *all* .xml files? [Check Preferences -> General -> Editor -> File Associations].

I find that on a clean Eclipse 3.1 install, only build.xml files get opened in the Ant editor, all other .xml files use the basic text editor. It does, however, appear to remember if you've specifically used "Open With" to use the non-default editor.

The problem I'm having is that I've installed a plugin for editing xml files; it appears under the file associations (but isnt set as default). However, unless I specifically use "Open With", or set it as the default XML editor then it's not used. But if I select it as the default XML editor, then my Ant build files no longer open up in the Ant Editor (by default).

» Posted by: Eric at July 12, 2005 10:33 AM

Eric, there's a simple way to verify that the content type is being used. Copy one of your Ant build.xml files alongside the original (I used the name test.xml). Notice that it uses the Ant editor, just like build.xml.

Replace the entire contents of the copied file with a different tag, like <test/> save the file and then close the editor. Notice that the Ant editor icon is removed from the file in the Package Explorer. When you reopen the file it opens in a plain text editor.

» Posted by: Ryan at July 12, 2005 12:26 PM

Neat, so it does.

Its a shame then, that logic apparently gets skipped when I set the default editor for .xml files - what happens for me when I do this, is that build.xml files show with a different icon in the Package Explorer, and open in that editor, rather than the Ant editor.

And, once a default editor is set, I couldnt find a way to unset it - that is, return to the original behaviour - without a fresh install of Eclipse (and clean .metadata folder).

I guess, what I want to be able to do is use a different editor (ie not the plain text editor) for all non-Ant .xml files. I have it installed, and can force it via "Open With", but havent yet found a way to do this automagically, via File Associations.

» Posted by: Eric at July 12, 2005 01:45 PM
Google
 
Search scope: Web ryanlowe.ca