It's all about the answers!

Ask a question

How to set mvsCodePage property by default for certain text files?

Roan Dawkins (122) | asked Jan 30 '14, 3:36 p.m.
edited Jan 31 '14, 3:02 p.m.
I'm trying to find a way to set the mvsCodePage property to a default value for certain text files.

I've defined the following in a plugin:
   <extension point="org.eclipse.core.contenttype.contentTypes">
      <content-type base-type="org.eclipse.core.runtime.text" file-extensions="type1,type2" id="" name="MyContent" priority="high" default-charset="UTF-8">
        <property name="mvsCodePage" value="IBM-1047"/>

Whenever you create a new file of the form *.type1 and *.type2 it gets assigned to MyContent. As such the file will have a default charset of UTF-8. I also want the file to have a default value for mvsCodePage but this setting doesn't seem to be taking.

So how do I set the mvsCodePage property on new files by default?

Looks like IFileItem inherits a method, setUserProperty that can be invoked. So if there's an extension point that will allow my code to get notified when a new file is added under source control, preferably after the content type is set, I could potentially retrieve the properties from the content type. Assuming I use some kind of convention like "jazz.user.propertyName=propertyValue" I could strip off the jazz.user and set propertyName=propertyValue on the IFileItem.

So is there such an extension point? It's hard to find doc on the client API.

One answer

permanent link
Pascal Fantoni (2111) | answered Feb 06 '14, 5:04 a.m.
Hi Roan,

The mvsCodePage is a user property and there is no extension point for it that would allow you to set this property automatically.
But perhaps you can write some kind of script which for example runs Command Line Interface (see the property set command).

Roan Dawkins commented Feb 06 '14, 10:00 a.m.

I can set the property manually via the eclipse client so setting the property is not the issue; I want it to get set by default for new files of a certain type. I was wondering more so if there is an extension point that I could extend that would allow my plugin to get notified when a new jazz file is created, preferably after the content type is set. Upon notification, I can set the user property.

Your answer

Register or to post your answer.