Search in sources :

Example 1 with HsMultiCellEditor

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;
}
Also used : XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) HsMultiCellEditor(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.HsMultiCellEditor) ArrayList(java.util.ArrayList) IEditorPart(org.eclipse.ui.IEditorPart) StyledTextCellEditor(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.StyledTextCellEditor)

Aggregations

ArrayList (java.util.ArrayList)1 HsMultiCellEditor (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.HsMultiCellEditor)1 StyledTextCellEditor (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.StyledTextCellEditor)1 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)1 IEditorPart (org.eclipse.ui.IEditorPart)1