use of net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.HsMultiCellEditor in project translationstudio8 by heartsome.
the class DeleteAllTagsHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (editor instanceof XLIFFEditorImplWithNatTable) {
XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
int[] rows = xliffEditor.getSelectedRows();
if (rows.length == 0) {
return null;
}
HsMultiCellEditor targetCellEditor = HsMultiActiveCellEditor.getTargetEditor();
StyledTextCellEditor cellEditor = targetCellEditor.getCellEditor();
if (cellEditor == null || cellEditor.isClosed()) {
return null;
}
if (rows.length == 1) {
// 清除内部标记
cellEditor.clearTags();
return null;
} else {
int activeEditRowIndex = targetCellEditor.getRowIndex();
// 清除内部标记
cellEditor.clearTags();
if (!xliffEditor.isHorizontalLayout()) {
activeEditRowIndex = activeEditRowIndex / 2;
}
// non active row
int[] nonActiveRows = new int[rows.length - 1];
int i = 0;
for (int row : rows) {
if (row == activeEditRowIndex) {
continue;
}
nonActiveRows[i++] = row;
}
List<String> rowIdList = new ArrayList<String>(xliffEditor.getXLFHandler().getRowIds(rows));
xliffEditor.getXLFHandler().removeAllTags(rowIdList);
xliffEditor.refresh();
}
}
return null;
}
Aggregations