use of net.heartsome.cat.common.innertag.factory.XliffInnerTagFactory in project translationstudio8 by heartsome.
the class SegmentViewer method setText.
/**
* @see net.heartsome.cat.ts.ui.innertag.ISegmentViewer#setText(java.lang.String)
*/
public void setText(String text) {
// 重置缓存的标记。
reset();
if (isSource()) {
// 当前是源文本
IInnerTagFactory innerTagFactory = new XliffInnerTagFactory(text, placeHolderBuilder);
List<InnerTagBean> innerTagBeans = innerTagFactory.getInnerTagBeans();
for (InnerTagBean innerTagBean : innerTagBeans) {
InnerTag innerTag = InnerTagUtil.createInnerTagControl(getTextWidget(), innerTagBean, tagStyle);
innerTag.setVisible(false);
innerTagCacheList.add(innerTag);
sourceMaxTagIndex = Math.max(sourceMaxTagIndex, innerTagBean.getIndex());
}
// 记录错误标记的起始,source 中所有标记都不是错误标记。
errorTagStart = innerTagCacheList.size();
text = innerTagFactory.getText();
} else {
// 当前是目标文本
XliffInnerTagFactory innerTagFactory = new XliffInnerTagFactory(source, placeHolderBuilder);
// source 中包含的内部标记。
List<InnerTagBean> sourceInnerTagBeans = innerTagFactory.getInnerTagBeans();
// 记录错误标记的起始,source 中所有标记都不是错误标记。
errorTagStart = sourceInnerTagBeans.size();
// 如果当前是 Target,就先记录 Source 中的最大索引。
for (InnerTagBean innerTagBean : sourceInnerTagBeans) {
// 记录source中内部标记的最大标记索引。
sourceMaxTagIndex = Math.max(sourceMaxTagIndex, innerTagBean.getIndex());
}
text = innerTagFactory.parseInnerTag(text, true);
List<InnerTagBean> innerTagBeans = innerTagFactory.getInnerTagBeans();
for (InnerTagBean innerTagBean : innerTagBeans) {
InnerTag innerTag = InnerTagUtil.createInnerTagControl(getTextWidget(), innerTagBean, tagStyle);
innerTag.setVisible(false);
innerTagCacheList.add(innerTag);
}
}
getTextWidget().setText(resetRegularString(text));
}
Aggregations