use of net.heartsome.cat.ts.core.file.ProjectConfiger in project translationstudio8 by heartsome.
the class NewProjectWizard method initProjectConfig.
/**
* 构建项目配置信息
* @param project
* ;
* @throws CoreException
*/
private void initProjectConfig(final IProject project, IProgressMonitor monitor) {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
final IProgressMonitor sMonitor = monitor;
sMonitor.beginTask(Messages.getString("wizard.NewProjectWizard.task2"), 3);
sMonitor.worked(1);
Display.getDefault().asyncExec(new Runnable() {
public void run() {
ProjectInfoBean bean = new ProjectInfoBean();
bean.setProjectName(project.getName());
bean.setMapField(firstPage.getFieldMap());
bean.setMapAttr(firstPage.getAttributeMap());
bean.setSourceLang(secondPage.getSrcLanguage());
bean.setTargetLang(secondPage.getTargetlanguage());
for (AbstractNewProjectWizardPage extensionPage : extensionPages) {
if (extensionPage.getPageType().equals("TM")) {
bean.setTmDb(extensionPage.getSelectedDatabase());
} else if (extensionPage.getPageType().equals("TB")) {
bean.setTbDb(extensionPage.getSelectedDatabase());
}
}
sMonitor.worked(1);
ProjectConfiger projCfg = ProjectConfigerFactory.getProjectConfiger(project);
sMonitor.worked(1);
projCfg.updateProjectConfig(bean);
// 记住当前语言信息
IPreferenceStore ps = Activator.getDefault().getPreferenceStore();
ps.setValue(IPreferenceConstants.NEW_PROJECT_SRC_LANG, bean.getSourceLang().getCode());
List<Language> targetLangList = bean.getTargetLang();
StringBuffer bf = new StringBuffer();
for (Language lang : targetLangList) {
bf.append(lang.getCode());
bf.append(",");
}
ps.setValue(IPreferenceConstants.NEW_PROJECT_TGT_LANG, bf.substring(0, bf.lastIndexOf(",")));
if (sMonitor.isCanceled()) {
try {
project.delete(true, sMonitor);
} catch (CoreException e) {
logger.error("", e);
}
throw new OperationCanceledException();
}
}
});
sMonitor.done();
}
Aggregations