use of net.heartsome.cat.common.locale.Language in project translationstudio8 by heartsome.
the class ProjectSettingTMPage method checkDbHashMatch.
/**
* 需要调用Database模块 检查当前项目在库中是否有语言对的匹配
* @param dbModel
* 数据库信息;
*/
public void checkDbHashMatch(DatabaseModelBean dbModel) {
Language srcLang = super.projectInfoBean.getSourceLang();
DBOperator dbOp = DatabaseService.getDBOperator(dbModel.toDbMetaData());
if (null == dbOp) {
return;
}
try {
if (dbOp != null) {
dbOp.start();
dbModel.setHasMatch(dbOp.checkHasMatchs(srcLang.getCode(), "M"));
}
} catch (Exception e) {
LOGGER.error("", e);
dbModel.setHasMatch(false);
} finally {
if (dbOp != null) {
try {
if (dbOp != null) {
dbOp.end();
}
} catch (SQLException e) {
LOGGER.error("", e);
}
}
}
}
use of net.heartsome.cat.common.locale.Language in project translationstudio8 by heartsome.
the class MatchViewPart method getTuInfoBean.
private TransUnitInfo2TranslationBean getTuInfoBean(TransUnitBean transUnit, XLFHandler handler, String rowId) {
String srcFullText = transUnit.getSrcContent();
String srcPureText = transUnit.getSrcText();
if ("".equals(srcFullText.trim()) || "".equals(srcPureText.trim())) {
return null;
}
sourceColunmCellRenderer.setTuSrcText(srcFullText);
String srcLanguage = transUnit.getSrcLang();
String tgtLanguage = transUnit.getTgtLang();
tgtLanguage = handler.getNatTableColumnName().get("target");
Language srcLang = LocaleService.getLanguageConfiger().getLanguageByCode(srcLanguage);
Language tgtLang = LocaleService.getLanguageConfiger().getLanguageByCode(tgtLanguage);
if (srcLang.isBidi() || tgtLang.isBidi()) {
gridTable.setOrientation(SWT.RIGHT_TO_LEFT);
} else {
gridTable.setOrientation(SWT.LEFT_TO_RIGHT);
}
TransUnitInfo2TranslationBean tuInfoBean = new TransUnitInfo2TranslationBean();
tuInfoBean.setSrcFullText(srcFullText);
tuInfoBean.setSrcPureText(srcPureText);
tuInfoBean.setSrcLanguage(srcLanguage);
tuInfoBean.setTgtLangugage(tgtLanguage);
int contextSize = tmMatcher.getContextSize();
if (contextSize != 0) {
Map<String, String> context = handler.getTransUnitContext(rowId, contextSize);
tuInfoBean.setPreContext(context.get("x-preContext"));
tuInfoBean.setNextContext(context.get("x-nextContext"));
} else {
tuInfoBean.setPreContext("");
tuInfoBean.setNextContext("");
}
return tuInfoBean;
}
use of net.heartsome.cat.common.locale.Language in project translationstudio8 by heartsome.
the class ProjectConfiger method getSourceLanguage.
/**
* 获取项目源语言
* @return 返加null或Language,如果是null表示没有获取到项目的源语言;
* @throws XPathParseException
* @throws NavException
* @throws XPathEvalException
*/
public Language getSourceLanguage() throws XPathParseException, XPathEvalException, NavException {
AutoPilot ap = new AutoPilot(vu.getVTDNav());
ap.selectXPath("/projectDescription/hs/language/source");
if (ap.evalXPath() != -1) {
String code = vu.getCurrentElementAttribut("code", "");
String name = vu.getElementContent();
String image = vu.getCurrentElementAttribut("image", "");
String isBidi = vu.getCurrentElementAttribut("isbidi", "No");
return new Language(code, name, image, isBidi.equals("NO") ? false : true);
}
return null;
}
use of net.heartsome.cat.common.locale.Language in project translationstudio8 by heartsome.
the class LanguageLabelProvider method getImage.
public Image getImage(Object element) {
if (element instanceof Language) {
Language lang = (Language) element;
String code = lang.getCode();
String imagePath = lang.getImagePath();
if (imagePath != null && !imagePath.equals("")) {
ImageDescriptor imageDesc = Activator.getImageDescriptor(imagePath);
if (imageDesc != null) {
ImageData data = imageDesc.getImageData().scaledTo(16, 12);
Image image = new Image(Display.getDefault(), data);
// 销毁原来的图片
Image im = imageCache.put(code, image);
if (im != null && !im.isDisposed()) {
im.dispose();
}
return image;
}
}
}
return null;
}
use of net.heartsome.cat.common.locale.Language 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