use of net.heartsome.cat.ts.core.file.XLFHandler in project translationstudio8 by heartsome.
the class AbstractExportHandler method getXlfBean.
private XliffBean getXlfBean(IFile file) {
XliffBean bean = null;
XLFHandler xlfHandler = new XLFHandler();
Map<String, Object> result = xlfHandler.openFile(file.getLocation().toOSString());
Object obj = result.get(Constant.RETURNVALUE_RESULT);
if (obj != null && (Integer) obj == Constant.RETURNVALUE_RESULT_SUCCESSFUL) {
bean = xlfHandler.getXliffInfo().get(file.getLocation().toOSString()).get(0);
}
return bean;
}
use of net.heartsome.cat.ts.core.file.XLFHandler in project translationstudio8 by heartsome.
the class ShowPreviousUnapprovedHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
return null;
}
XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
int[] selectedRows = xliffEditor.getSelectedRows();
if (selectedRows.length < 1) {
return null;
}
Arrays.sort(selectedRows);
int firstSelectedRow = selectedRows[0];
XLFHandler handler = xliffEditor.getXLFHandler();
int row = handler.getPreviousUnapprovedSegmentIndex(firstSelectedRow);
if (row != -1) {
xliffEditor.jumpToRow(row);
} else {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
MessageDialog.openWarning(window.getShell(), "", "不存在上一未批准文本段。");
}
return null;
}
use of net.heartsome.cat.ts.core.file.XLFHandler in project translationstudio8 by heartsome.
the class ShowPreviousUntranslatableHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
return null;
}
XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
int[] selectedRows = xliffEditor.getSelectedRows();
if (selectedRows.length < 1) {
return null;
}
Arrays.sort(selectedRows);
int firstSelectedRow = selectedRows[0];
XLFHandler handler = xliffEditor.getXLFHandler();
int row = handler.getPreviousUntranslatableSegmentIndex(firstSelectedRow);
if (row != -1) {
xliffEditor.jumpToRow(row);
} else {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
MessageDialog.openWarning(window.getShell(), "", "不存在上一不可翻译文本段。");
}
return null;
}
use of net.heartsome.cat.ts.core.file.XLFHandler in project translationstudio8 by heartsome.
the class LockSegmentHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
// 这是之前的实现方式,这是锁定文本段。锁定全部文本段,锁定可编辑文本段的共同 handler,--robert 2012-05-02
// String lockSegment = event.getParameter("lockSegment");
// if (lockSegment == null) {
// return null;
// }
// State state = event.getCommand().getState(RegistryToggleState.STATE_ID);
// boolean isSelect = (Boolean) (state.getValue());
// state.setValue(!isSelect);
// IEditorPart editor = HandlerUtil.getActiveEditor(event);
// if (editor instanceof XLIFFEditorImplWithNatTable) {
// XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
//
// // 批准可编辑文本段时要初始化 rowIds ,批准所有文本段则不需要
// if (lockSegment.equals("lockDuplicateSegment")) {
// // TODO 解决如何高效获取重复文本段后再做
//
// } else {
// ArrayList<String> rowIds = null;
// if (lockSegment.equals("lockEditableSegment")) {
// rowIds = xliffEditor.getXLFHandler().getRowIds();
// } else if (lockSegment.equals("lockAllSegment")) {
// rowIds = null;
// }
// NattableUtil util = new NattableUtil(xliffEditor);
// util.lockTransUnits(rowIds, !isSelect);
// // 改变单元格编辑器模式为“只读”
// util.changeCellEditorMode(rowIds, null);
// // TODO 入库
//
// }
//
// }
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (editor instanceof XLIFFEditorImplWithNatTable) {
XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
XLFHandler handler = xliffEditor.getXLFHandler();
ArrayList<String> rowIds = (ArrayList<String>) xliffEditor.getSelectedRowIds();
ArrayList<String> needLockRowIds = new ArrayList<String>();
// 先判断所有的选择文本段的是否锁定状态
for (String rowId : rowIds) {
if (!handler.isLocked(rowId)) {
needLockRowIds.add(rowId);
}
}
NattableUtil util = NattableUtil.getInstance(xliffEditor);
// 如果都是锁定状态的,那么把它们都变成未锁定
if (needLockRowIds.size() <= 0) {
util.lockTransUnits(rowIds, false);
} else {
util.lockTransUnits(needLockRowIds, true);
// 改变单元格编辑器模式为“只读”
// util.changeCellEditorMode(rowIds, null);
}
HsMultiActiveCellEditor.refrushCellsEditAbility();
}
return null;
}
use of net.heartsome.cat.ts.core.file.XLFHandler in project translationstudio8 by heartsome.
the class CopySourceHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (editor instanceof XLIFFEditorImplWithNatTable) {
XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
XLFHandler handler = xliffEditor.getXLFHandler();
List<String> rowIds = xliffEditor.getSelectedRowIds();
boolean locked = false;
Map<String, String> map = new HashMap<String, String>();
for (int i = 0; i < rowIds.size(); i++) {
String rowId = rowIds.get(i);
if (handler.isLocked(rowId)) {
// 已经批准或者已锁定,则不进行修改。
locked = true;
continue;
}
String srcContent = handler.getSrcContent(rowId);
String newValue = srcContent == null ? "" : srcContent;
map.put(rowId, newValue);
}
if (locked) {
if (!MessageDialog.openConfirm(xliffEditor.getSite().getShell(), Messages.getString("handler.CopySourceHandler.msgTitle"), Messages.getString("handler.CopySourceHandler.msg"))) {
return null;
}
}
StyledTextCellEditor cellEditor = HsMultiActiveCellEditor.getTargetStyledEditor();
if (cellEditor != null) {
HsMultiActiveCellEditor.setCellEditorForceFocus(cellEditor.getColumnPosition(), cellEditor.getRowPosition());
}
xliffEditor.updateSegments(map, xliffEditor.getTgtColumnIndex(), null, null);
}
return null;
}
Aggregations