use of net.heartsome.cat.ts.core.bean.PropGroupBean in project translationstudio8 by heartsome.
the class XLFHandler method getPrpoGroups.
// 获取当前节点下的属性组集合。
private Vector<PropGroupBean> getPrpoGroups(VTDUtils vu) throws XPathParseException, XPathEvalException, NavException {
VTDNav vn = vu.getVTDNav();
Vector<PropGroupBean> pgs = new Vector<PropGroupBean>();
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath("./prop-group");
while (ap.evalXPath() != -1) {
vn.push();
Vector<PropBean> props = getProps(vu);
vn.pop();
PropGroupBean pg = new PropGroupBean(props);
// 获取属性组名称。
pg.setName(vu.getCurrentElementAttribut("name", null));
pgs.add(pg);
}
ap.resetXPath();
ap.declareXPathNameSpace("xml", VTDUtils.XML_NAMESPACE_URL);
ap.declareXPathNameSpace(hsNSPrefix, hsR7NSUrl);
ap.selectXPath("./hs:prop-group");
while (ap.evalXPath() != -1) {
vn.push();
Vector<PropBean> props = getProps(vu);
vn.pop();
PropGroupBean pg = new PropGroupBean(props);
// 获取属性组名称。
pg.setName(vu.getCurrentElementAttribut("name", null));
pgs.add(pg);
}
if (pgs.isEmpty()) {
pgs = null;
}
return pgs;
}
use of net.heartsome.cat.ts.core.bean.PropGroupBean in project translationstudio8 by heartsome.
the class MatchViewPart method loadData.
private synchronized void loadData(List<AltTransBean> matches) {
if (matches == null) {
return;
}
IEditorReference[] editorReferences = getSite().getPage().getEditorReferences();
if (editorReferences.length == 0) {
return;
}
for (AltTransBean altTransBean : matches) {
String type = altTransBean.getMatchProps().get("hs:matchType");
if (type == null || type.equals("")) {
type = "others";
}
String orgin = altTransBean.getMatchOrigin();
if (orgin == null) {
// Fixed bug 2258 by Jason 翻译匹配面板不支持非 HS 工具匹配信息的显示
orgin = "";
}
String srcContent = altTransBean.getSrcContent();
if (srcContent == null || srcContent.equals("")) {
continue;
}
String tgtContent = altTransBean.getTgtContent();
if (tgtContent == null || tgtContent.equals("")) {
continue;
}
String quality = altTransBean.getMatchProps().get("match-quality").trim();
if (quality == null) {
quality = "";
} else {
if (!quality.endsWith("%")) {
quality += "%";
}
}
String changeDate = null;
String changeid = null;
String creationDate = null;
String creationid = null;
Vector<PropGroupBean> propGroups = altTransBean.getPropGroups();
StringBuffer toolTipBfTemp = new StringBuffer();
if (propGroups != null) {
for (PropGroupBean propGroupBean : propGroups) {
List<PropBean> propBeans = propGroupBean.getProps();
for (PropBean bean : propBeans) {
String ptype = bean.getProptype();
String pVal = bean.getValue();
if (ptype.equals("changeDate")) {
if (pVal != null && !pVal.equals("")) {
changeDate = DateUtils.formatDateFromUTC(pVal);
}
} else if (ptype.equals("changeId")) {
changeid = pVal;
} else if (ptype.equals("creationId")) {
creationid = pVal;
} else if (ptype.equals("creationDate")) {
if (pVal != null && !pVal.equals("")) {
creationDate = DateUtils.formatDateFromUTC(pVal);
}
} else {
toolTipBfTemp.append(ptype).append(" : ").append(pVal).append("\n");
}
}
}
}
StringBuffer toolTipBf = new StringBuffer();
if (creationid != null && !creationid.equals("")) {
toolTipBf.append(Messages.getString("view.MatchViewPart.info.tooltip.creationId")).append(creationid).append("\n");
}
if (creationDate != null && !creationDate.equals("")) {
toolTipBf.append(Messages.getString("view.MatchViewPart.info.tooltip.creationDate")).append(creationDate).append("\n");
}
toolTipBf.append(toolTipBfTemp);
StringBuffer msgBf = new StringBuffer();
if (changeDate != null && !changeDate.equals("")) {
msgBf.append(changeDate);
}
if (changeid != null && !changeid.equals("")) {
if (msgBf.length() != 0) {
msgBf.append(" | ");
}
msgBf.append(changeid);
}
if (orgin != null && !orgin.equals("")) {
if (msgBf.length() != 0) {
msgBf.append(" | ");
}
msgBf.append(orgin);
}
if (gridTable.isDisposed()) {
return;
}
String toolId = altTransBean.getMatchProps().get("tool-id");
GridItem gridItem = new GridItem(gridTable, SWT.NONE);
gridItem.setText(0, srcContent);
gridItem.setText(1, quality);
gridItem.setText(2, tgtContent);
gridItem.setToolTipText(0, toolId);
gridItem.setToolTipText(1, toolId);
gridItem.setToolTipText(2, toolId);
// 保存信息
gridItem.setData("info", resetSpecialString(msgBf.toString()));
gridItem.setData("infoTooltip", resetSpecialString(toolTipBf.toString()));
// 保存目标纯文本
gridItem.setData("tgtText", altTransBean.getTgtText());
// 保存目标纯文本
gridItem.setData("tgtContent", tgtContent);
gridItem.setData("matchType", type);
gridItem.setData("quality", quality.substring(0, quality.lastIndexOf('%')));
gridItem.setData("typeImage", getImageByType(type));
gridItem.setData("tmFuzzyInfo", altTransBean.getFuzzyResult());
}
}
use of net.heartsome.cat.ts.core.bean.PropGroupBean in project translationstudio8 by heartsome.
the class TmUtils method fuzzyResult2Alttransbean.
public static Vector<AltTransBean> fuzzyResult2Alttransbean(List<FuzzySearchResult> fuzzyResults) {
Vector<AltTransBean> altTrans = new Vector<AltTransBean>();
for (FuzzySearchResult result : fuzzyResults) {
AltTransBean atb = new AltTransBean();
// Map<String, String> match = tu.getTuInfo();
TmxTU tu = result.getTu();
// 获取源节点内容、属性及纯文本
atb.setSrcText(tu.getSource().getPureText());
atb.setTgtText(tu.getTarget().getPureText());
Hashtable<String, String> matchProps = new Hashtable<String, String>();
matchProps.put("match-quality", result.getSimilarity() + "");
matchProps.put("origin", result.getDbName());
matchProps.put("tool-id", "Translation Memory");
matchProps.put("hs:matchType", "TM");
matchProps.put("xml:space", "default");
atb.setMatchProps(matchProps);
Hashtable<String, String> srcProps = new Hashtable<String, String>();
srcProps.put("xml:lang", tu.getSource().getLangCode());
atb.setSrcProps(srcProps);
atb.setSrcContent(tu.getSource().getFullText());
Hashtable<String, String> tgtProps = new Hashtable<String, String>();
tgtProps.put("xml:lang", tu.getTarget().getLangCode());
atb.setTgtProps(tgtProps);
atb.setTgtContent(tu.getTarget().getFullText());
Vector<PropGroupBean> pgs = new Vector<PropGroupBean>();
Vector<PropBean> props = new Vector<PropBean>();
PropBean pb = new PropBean("creationId", tu.getCreationUser());
props.add(pb);
pb = new PropBean("creationDate", tu.getCreationDate());
props.add(pb);
pb = new PropBean("changeId", tu.getChangeUser());
props.add(pb);
pb = new PropBean("changeDate", tu.getChangeDate());
props.add(pb);
List<TmxProp> attrValList = tu.getProps();
for (TmxProp attr : attrValList) {
String name = attr.getName();
if (name == null || name.equals("")) {
continue;
}
String value = attr.getValue();
if (value == null || value.equals("")) {
continue;
}
PropBean prop = new PropBean(name, value);
props.add(prop);
}
PropGroupBean pg = new PropGroupBean(props);
// 获取属性组名称。
pg.setName("hs:prop-group");
pgs.add(pg);
atb.setPropGroups(pgs);
atb.setFuzzyResult(result);
altTrans.add(atb);
}
return altTrans;
}
use of net.heartsome.cat.ts.core.bean.PropGroupBean in project translationstudio8 by heartsome.
the class TSFileHandler method getPrpoGroups.
// 获取当前节点下的属性组集合。
private Vector<PropGroupBean> getPrpoGroups(VTDUtils vu) throws XPathParseException, XPathEvalException, NavException {
VTDNav vn = vu.getVTDNav();
Vector<PropGroupBean> pgs = new Vector<PropGroupBean>();
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath("./prop-group");
while (ap.evalXPath() != -1) {
vn.push();
Vector<PropBean> props = getProps(vu);
vn.pop();
PropGroupBean pg = new PropGroupBean(props);
// 获取属性组名称。
int nameInx = vn.getAttrVal("name");
if (nameInx != -1) {
pg.setName(vn.toString(nameInx));
}
pgs.add(pg);
}
ap.resetXPath();
ap.declareXPathNameSpace(hsNSPrefix, hsR7NSUrl);
ap.selectXPath("./hs:prop-group");
while (ap.evalXPath() != -1) {
vn.push();
Vector<PropBean> props = getProps(vu);
vn.pop();
PropGroupBean pg = new PropGroupBean(props);
// 获取属性组名称。
int nameInx = vn.getAttrVal("name");
if (nameInx != -1) {
pg.setName(vn.toString(nameInx));
}
pgs.add(pg);
}
if (pgs.isEmpty()) {
pgs = null;
}
return pgs;
}
use of net.heartsome.cat.ts.core.bean.PropGroupBean in project translationstudio8 by heartsome.
the class TmUtils method altTransInfoConverter.
/**
* 将从库中获取的匹配转成以 AltTransBean 封装的匹配数据,在转换的过程与当前 AltTrans重复的记录将被忽略
* @param dbMatches
* 从数据库中获取的匹配
* @param currentAltTrans
* 当前已经存原altTrans
* @return 和当前匹配不重复的AltTrans集;
*/
public static Vector<AltTransBean> altTransInfoConverter(List<FuzzySearchResult> dbMatches, Vector<AltTransBean> currentAltTrans) {
Vector<AltTransBean> altTrans = new Vector<AltTransBean>();
Vector<AltTransBean> existAltTrans = new Vector<AltTransBean>();
for (FuzzySearchResult result : dbMatches) {
AltTransBean atb = new AltTransBean();
// Map<String, String> match = tu.getTuInfo();
TmxTU tu = result.getTu();
// 获取源节点内容、属性及纯文本
atb.setSrcText(tu.getSource().getPureText());
atb.setTgtText(tu.getTarget().getPureText());
if (isMatchExist(currentAltTrans, atb, result.getDbName(), existAltTrans)) {
continue;
}
Hashtable<String, String> matchProps = new Hashtable<String, String>();
matchProps.put("match-quality", result.getSimilarity() + "");
matchProps.put("origin", result.getDbName());
matchProps.put("tool-id", "Translation Memory");
matchProps.put("hs:matchType", "TM");
matchProps.put("xml:space", "default");
atb.setMatchProps(matchProps);
Hashtable<String, String> srcProps = new Hashtable<String, String>();
srcProps.put("xml:lang", tu.getSource().getLangCode());
atb.setSrcProps(srcProps);
atb.setSrcContent(tu.getSource().getFullText());
Hashtable<String, String> tgtProps = new Hashtable<String, String>();
tgtProps.put("xml:lang", tu.getTarget().getLangCode());
atb.setTgtProps(tgtProps);
atb.setTgtContent(tu.getTarget().getFullText());
Vector<PropGroupBean> pgs = new Vector<PropGroupBean>();
Vector<PropBean> props = new Vector<PropBean>();
PropBean pb = new PropBean("creationId", tu.getCreationUser());
props.add(pb);
pb = new PropBean("creationDate", tu.getCreationDate());
props.add(pb);
pb = new PropBean("changeId", tu.getChangeUser());
props.add(pb);
pb = new PropBean("changeDate", tu.getChangeDate());
props.add(pb);
List<TmxProp> attrValList = tu.getProps();
for (TmxProp attr : attrValList) {
String name = attr.getName();
if (name == null || name.equals("")) {
continue;
}
String value = attr.getValue();
if (value == null || value.equals("")) {
continue;
}
PropBean prop = new PropBean(name, value);
props.add(prop);
}
PropGroupBean pg = new PropGroupBean(props);
// 获取属性组名称。
pg.setName("hs:prop-group");
pgs.add(pg);
atb.setPropGroups(pgs);
altTrans.add(atb);
}
if (altTrans.size() > 0) {
altTrans.addAll(existAltTrans);
} else {
currentAltTrans.addAll(existAltTrans);
}
return altTrans;
}
Aggregations