thanks for your answer. This is working now:
public class MyDslFileSystemAccess extends EclipseResourceFileSystemAccess2 {
private static final Logger LOGGER = LoggerFactory.getLogger( MyDslFileSystemAccess.class );
@Override
protected IFile getFile( String fileName, String outputName ) {
IFile file = super.getFile( fileName, outputName );
if (fileName != null && fileName.endsWith( "properties" ) && !file.exists()) {
try {
file.create(getInputStream("", file.getCharset(true)), true, getMonitor());
} catch (CoreException e) {
LOGGER.error( "failed to create file {} : {}", fileName, e.getMessage() );
}
}
return file;
}
}
I tried first to set the charset for file, but I got an exception when I called the generator the first time and the properties file did not exist yet. The exception complained that the resource did not exist. When I called the generator the second time everything was working and the charset could be set - but this was working anyway. My problem was the first call of the code generator.
So I created the file before setting the charset and now it was working. Then I tried if it was necessary to set the charset and found out that it was not. Creating the file was enough.
Thanks for your help - it pointed me to the right direction.]]>