use of net.heartsome.cat.ts.core.bean.NoteBean in project translationstudio8 by heartsome.
the class TSFileHandler method getNotes.
// 获取当前节点的所有批注。
private Vector<NoteBean> getNotes(VTDUtils vu) throws XPathEvalException, NavException, XPathParseException {
Vector<NoteBean> notes = new Vector<NoteBean>();
VTDNav vn = vu.getVTDNav();
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath("./note");
while (ap.evalXPath() != -1) {
NoteBean note = new NoteBean(vu.getElementContent());
int attInx = vn.getAttrVal("xml:lang");
if (attInx != -1) {
note.setLang(vn.toString(attInx));
}
attInx = vn.getAttrVal("from");
if (attInx != -1) {
note.setFrom(vn.toString(attInx));
}
attInx = vn.getAttrVal("priority");
if (attInx != -1) {
note.setPriority(vn.toString(attInx));
}
attInx = vn.getAttrVal("annotates");
if (attInx != -1) {
note.setAnnotates(vn.toString(attInx));
}
notes.add(note);
}
if (notes.isEmpty()) {
notes = null;
}
return notes;
}
use of net.heartsome.cat.ts.core.bean.NoteBean in project translationstudio8 by heartsome.
the class XLFHandler method getNotes.
// 获取当前节点的所有批注。
private Vector<NoteBean> getNotes(VTDUtils vu) throws XPathEvalException, NavException, XPathParseException {
Vector<NoteBean> notes = new Vector<NoteBean>();
VTDNav vn = vu.getVTDNav();
AutoPilot ap = new AutoPilot(vn);
ap.declareXPathNameSpace("xml", VTDUtils.XML_NAMESPACE_URL);
ap.declareXPathNameSpace(hsNSPrefix, hsR7NSUrl);
ap.selectXPath("./note");
while (ap.evalXPath() != -1) {
NoteBean note = new NoteBean(vu.getElementContent());
note.setLang(vu.getCurrentElementAttribut("xml:lang", null));
note.setFrom(vu.getCurrentElementAttribut("from", null));
note.setPriority(vu.getCurrentElementAttribut("priority", null));
note.setAnnotates(vu.getCurrentElementAttribut("annotates", null));
note.setApplyCurrent(vu.getCurrentElementAttribut("hs:apply-current", "Yes"));
notes.add(0, note);
}
if (notes.isEmpty()) {
notes = null;
}
return notes;
}
use of net.heartsome.cat.ts.core.bean.NoteBean in project translationstudio8 by heartsome.
the class XLFHandler method getNotes.
public Vector<NoteBean> getNotes(String rowId) throws NavException, XPathParseException, XPathEvalException {
Vector<NoteBean> notes = new Vector<NoteBean>();
VTDNav vn = getVTDNavByRowId(rowId);
VTDUtils vu = new VTDUtils(vn);
AutoPilot ap = new AutoPilot(vn);
ap.declareXPathNameSpace("xml", VTDUtils.XML_NAMESPACE_URL);
ap.declareXPathNameSpace(hsNSPrefix, hsR7NSUrl);
String tuXPath = RowIdUtil.parseRowIdToXPath(rowId);
ap.selectXPath(tuXPath + "/note");
while (ap.evalXPath() != -1) {
NoteBean note = new NoteBean(vu.getElementContent());
note.setLang(vu.getCurrentElementAttribut("xml:lang", null));
note.setFrom(vu.getCurrentElementAttribut("from", null));
note.setPriority(vu.getCurrentElementAttribut("priority", null));
note.setAnnotates(vu.getCurrentElementAttribut("annotates", null));
note.setApplyCurrent(vu.getCurrentElementAttribut("hs:apply-current", "Yes"));
notes.add(0, note);
}
if (notes.isEmpty()) {
notes = null;
}
return notes;
}
use of net.heartsome.cat.ts.core.bean.NoteBean in project translationstudio8 by heartsome.
the class UpdateNoteDialog method initTable.
private void initTable() {
Vector<NoteBean> noteBeans = xliffEditor.getRowTransUnitBean(rowIndex).getNotes();
if (noteBeans != null && noteBeans.size() > 0) {
String[][] arrTableItem = new String[noteBeans.size()][];
for (int i = 0; i < noteBeans.size(); i++) {
NoteBean bean = noteBeans.get(i);
String strNote = bean.getNoteText();
String date = "";
String strText = "";
if (strNote != null) {
// Bug #2334:添加批注包含特殊字符保存失败
strNote = TextUtil.resetSpecialString(strNote);
if (strNote.indexOf(":") != -1) {
date = strNote.substring(0, strNote.indexOf(":"));
if (validData(date)) {
strText = strNote.substring(strNote.indexOf(":") + 1);
} else {
date = "";
strText = strNote;
}
} else {
strText = strNote;
}
}
String strCurrent = bean.getApplyCurrent();
if (strCurrent == null || strCurrent.equals("Yes")) {
strCurrent = NatTableConstant.CURRENT_TEXT;
} else {
strCurrent = NatTableConstant.ALL_TEXT;
}
arrTableItem[i] = new String[] { String.valueOf(i + 1), bean.getFrom(), date, strText, strCurrent };
}
tableViewer.setInput(arrTableItem);
} else {
tableViewer.setInput(null);
}
}
use of net.heartsome.cat.ts.core.bean.NoteBean in project translationstudio8 by heartsome.
the class DeleteSelectionSegmentNotesHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
return null;
}
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
boolean res = MessageDialog.openConfirm(window.getShell(), Messages.getString("handler.DeleteSelectionSegmentNotesHandler.msgTitle1"), Messages.getString("handler.DeleteSelectionSegmentNotesHandler.msg1"));
if (res) {
XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
XLFHandler handler = xliffEditor.getXLFHandler();
List<String> lstRowId = xliffEditor.getSelectedRowIds();
// 先将应用范围为当前文本段的批注删除
handler.deleteEditableSegmentNote(lstRowId);
try {
HashMap<String, Vector<NoteBean>> mapNote = new HashMap<String, Vector<NoteBean>>();
for (String rowId : lstRowId) {
// 删除应用范围为所有文本段的批注
Vector<NoteBean> noteBeans = xliffEditor.getXLFHandler().getNotes(rowId);
if (noteBeans != null && noteBeans.size() > 0) {
mapNote.put(rowId, noteBeans);
}
}
xliffEditor.getXLFHandler().deleteNote(mapNote);
} catch (NavException e) {
LOGGER.error("", e);
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), Messages.getString("handler.DeleteSelectionSegmentNotesHandler.msgTitle2"), Messages.getString("handler.DeleteSelectionSegmentNotesHandler.msg2"));
} catch (XPathParseException e) {
LOGGER.error("", e);
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), Messages.getString("handler.DeleteSelectionSegmentNotesHandler.msgTitle2"), Messages.getString("handler.DeleteSelectionSegmentNotesHandler.msg2"));
} catch (XPathEvalException e) {
LOGGER.error("", e);
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), Messages.getString("handler.DeleteSelectionSegmentNotesHandler.msgTitle2"), Messages.getString("handler.DeleteSelectionSegmentNotesHandler.msg2"));
} finally {
xliffEditor.refresh();
}
}
return null;
}
Aggregations