use of net.heartsome.cat.common.innertag.TagStyle in project translationstudio8 by heartsome.
the class TagDisplayConverter method canonicalToDisplayValue.
/**
* (non-Javadoc)
* @see net.sourceforge.nattable.data.convert.DefaultDisplayConverter#canonicalToDisplayValue(java.lang.Object)
*/
public Object canonicalToDisplayValue(Object xmlValue) {
if (xmlValue == null || xmlValue.toString().length() == 0) {
return "";
}
String originalValue = xmlValue.toString();
TagStyle tagStyle = xliffEditor.getTagStyleManager().getTagStyle();
// if (TagStyle.FULL.equals(tagStyle)) {
// return originalValue;
// } else {
StringBuffer displayValue = new StringBuffer(originalValue);
int columnIndex = table.getColumnIndexByPosition(currentCell.getColumnPosition());
if (xliffEditor.isHorizontalLayout()) {
if (columnIndex == xliffEditor.getSrcColumnIndex()) {
// 设置内部标记索引及样式
InnerTagUtil.parseXmlToDisplayValue(displayValue, tagStyle);
} else if (columnIndex == xliffEditor.getTgtColumnIndex()) {
int rowIndex = currentCell.getLayer().getRowIndexByPosition(currentCell.getRowPosition());
int srcColumnPosition = LayerUtil.getColumnPositionByIndex(table, xliffEditor.getSrcColumnIndex());
if (srcColumnPosition != -1) {
// 得到Source列的位置
DataLayer dataLayer = LayerUtil.getLayer(table, DataLayer.class);
String srcOriginalValue = dataLayer.getDataValueByPosition(srcColumnPosition, rowIndex).toString();
InnerTagUtil.parseXmlToDisplayValueFromSource(srcOriginalValue, displayValue, tagStyle);
} else {
// 设置内部标记索引及样式
InnerTagUtil.parseXmlToDisplayValue(displayValue, tagStyle);
}
// 恢复初始值
currentCell = null;
} else {
// do nothing
}
} else {
int rowIndex = currentCell.getLayer().getRowIndexByPosition(currentCell.getRowPosition());
if (columnIndex == xliffEditor.getSrcColumnIndex() && rowIndex % 2 == 0) {
//源语言
// 设置内部标记索引及样式
InnerTagUtil.parseXmlToDisplayValue(displayValue, tagStyle);
} else if (columnIndex == xliffEditor.getTgtColumnIndex()) {
//目标语言
int srcColumnPosition = LayerUtil.getColumnPositionByIndex(table, xliffEditor.getSrcColumnIndex());
if (srcColumnPosition != -1) {
// 得到Source列的位置
// DataLayer dataLayer = LayerUtil.getLayer(table, DataLayer.class);
String srcOriginalValue = table.getDataValueByPosition(srcColumnPosition, rowIndex - 1).toString();
InnerTagUtil.parseXmlToDisplayValueFromSource(srcOriginalValue, displayValue, tagStyle);
} else {
// 设置内部标记索引及样式
InnerTagUtil.parseXmlToDisplayValue(displayValue, tagStyle);
}
// 恢复初始值
currentCell = null;
} else {
// do nothing
}
}
return InnerTagUtil.resolveTag(displayValue.toString());
// }
}