use of net.heartsome.cat.tmx.converter.bean.File2TmxConvertBean in project translationstudio8 by heartsome.
the class ConverterUtil method convert2Tmx.
public static File convert2Tmx(String fileName, IProgressMonitor monitor) throws ImportException {
File file = new File(fileName);
if (!file.exists()) {
throw new ImportException(fileName + Messages.getString("converter.ConverterUtil.msg"));
}
if (fileName.toLowerCase().endsWith(".tmx")) {
return null;
}
AbstractFile2Tmx file2TmxConverter = ConverterFactory.getFile2TmxConverter(fileName);
if (null == file2TmxConverter) {
return null;
}
File createTempFile = null;
boolean hasError = true;
try {
createTempFile = File.createTempFile("Tmx_", "" + System.currentTimeMillis() + ".tmx");
SubProgressMonitor spm = new SubProgressMonitor(monitor, 30);
File2TmxConvertBean bean = new File2TmxConvertBean();
bean.sourceFilePath = fileName;
bean.newTmxFilePath = createTempFile.getAbsolutePath();
file2TmxConverter.doCovnerter(bean, spm);
hasError = false;
} catch (IOException e) {
LOGGER.error("", e);
throw new ImportException(e.getMessage().replace("\n", " "));
} catch (Exception e) {
LOGGER.error("", e);
throw new ImportException(e.getMessage().replace("\n", " "));
} finally {
if (hasError && null != createTempFile) {
createTempFile.delete();
}
}
return createTempFile;
}
Aggregations