use of net.heartsome.cat.convert.ui.action.ConversionCompleteAction in project translationstudio8 by heartsome.
the class ConverterViewModel method convert.
/**
* 根据用户的选择和配置信息,执行文件的转换功能
* @return ;
*/
public Map<String, String> convert() {
// System.out.print(getConfigBean().toString());
// 以用户最后在配置对话框所选择的源文件为准
JobRunnable runnalbe = new JobRunnable() {
private Map<String, String> conversionResult;
public IStatus run(IProgressMonitor monitor) {
IStatus result = Status.OK_STATUS;
try {
conversionResult = convertWithoutJob(monitor);
} catch (OperationCanceledException e) {
LOGGER.info(Messages.getString("model.ConverterViewModel.logger2"), e);
result = Status.CANCEL_STATUS;
} catch (ConverterException e) {
String msg = Messages.getString("model.ConverterViewModel.logger3");
Object[] args = { getConfigBean().getSource() };
LOGGER.error(new MessageFormat(msg).format(args), e);
result = e.getStatus();
} finally {
ConverterViewModel.this.close();
}
return result;
}
public void showResults(IStatus status) {
IAction action = getRunnableCompletedAction(status);
if (action != null) {
action.run();
}
}
public IAction getRunnableCompletedAction(IStatus status) {
return new ConversionCompleteAction(Messages.getString("model.ConverterViewModel.msg1"), status, conversionResult);
}
};
Job conversionJob = JobFactoryFacade.createJob(Display.getDefault(), "conversion job", runnalbe);
conversionJob.setUser(true);
conversionJob.setRule(conversionItem.getProject());
conversionJob.schedule();
return null;
}
Aggregations