use of net.heartsome.cat.ts.core.qa.FileAnalysis in project translationstudio8 by heartsome.
the class FileAnalysisHandler method analysisFile.
/**
* 准备分析文件
*/
public void analysisFile(String title) {
final QAXmlHandler handler = new QAXmlHandler();
Job job = new Job(title) {
@Override
protected IStatus run(IProgressMonitor monitor) {
// 要分析的文件的个数
int fileNum = model.getAnalysisIFileList().size();
model.setSubFileNum(fileNum);
// 定义的进度条总共四格,其中,解析文件一格,分析文件三格
monitor.beginTask("", fileNum * 4);
// 解析文件,如果解析不成功,退出程序, 解析要分析的文件,用掉fileNum*1个格子
if (!openXliff(handler, monitor)) {
monitor.done();
return Status.CANCEL_STATUS;
}
if (model.getAnalysisIFileList().size() == 0) {
MessageDialog.openInformation(shell, Messages.getString("qa.all.dialog.info"), Messages.getString("qa.handlers.FileAnalysisHandler.tip4"));
return Status.CANCEL_STATUS;
}
// 填充要分析文件的所有trans-unit节点个数的总和
model.setAllTuSize(allTUSize);
FileAnalysis fileAnalysis = getClassInstance(faItemId);
// 分析文件用去fileNum*3个格子
IProgressMonitor subMonitor = new SubProgressMonitor(monitor, fileNum * 3, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
int analysisResult = fileAnalysis.beginAnalysis(model, subMonitor, handler);
if (analysisResult == -1 || analysisResult == QAConstant.QA_ZERO) {
return Status.CANCEL_STATUS;
}
subMonitor.done();
monitor.done();
return Status.OK_STATUS;
}
};
// 当程序退出时,检测当前 job 是否正常关闭
CommonFunction.jobCantCancelTip(job);
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void running(IJobChangeEvent event) {
ProgressIndicatorManager.displayProgressIndicator();
super.running(event);
}
@Override
public void done(IJobChangeEvent event) {
ProgressIndicatorManager.hideProgressIndicator();
super.done(event);
}
});
job.setUser(true);
job.schedule();
}
Aggregations