Kris
Kris

Reputation: 3957

How to define a contentType of file association in Eclipse using a regular Expression

I am implementing an editor which specializes an existing Editor (The Java Properties file editor) in Eclipse.

My editor should be used instead of the 'general' editor only for certain files. The names of these files can be recognized as matching a pattern "application*.properties". For example

When the filename does not match the pattern then the regular properties file editor should be used.

I tried creating a new content-type and associate that with my editor. I can get this to work if I associate the content-type explicitly with exact file names... like this:

<extension
     point="org.eclipse.core.contenttype.contentTypes">
  <content-type
        ...
        file-names="application.properties,application-test.properties,application-prod.properties"
  </content-type>
</extension>

What I really wanted to is this, but it does not work:

<extension
     point="org.eclipse.core.contenttype.contentTypes">
  <content-type
        ...
        file-names="application*.properties"
  </content-type>
</extension>

Is there a way to define content types that match more generally to regular-expression or glob patterns rather than just recognizing them based on an exactly matching filename or extension?

Upvotes: 1

Views: 933

Answers (1)

nitind
nitind

Reputation: 20003

Nope. You can still add *.properties to your editor's declared list of file associations and choose to open it from a file's "Open With..." context menu.

Upvotes: 2

Related Questions