Search in sources :

Example 6 with NattableUtil

use of net.heartsome.cat.ts.ui.xliffeditor.nattable.utils.NattableUtil in project translationstudio8 by heartsome.

the class NeedReviewSegmentHandler 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> selectedRowIds = xliffEditor.getSelectedRowIds();
        boolean isNeedReview = true;
        //先判断所有的选择文本段的是否锁定状态
        for (String rowId : selectedRowIds) {
            if (!handler.isNeedReview(rowId)) {
                isNeedReview = false;
                break;
            }
        }
        NattableUtil util = NattableUtil.getInstance(xliffEditor);
        util.changIsQuestionState(selectedRowIds, isNeedReview ? "no" : "yes");
    }
    return null;
}
Also used : XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) NattableUtil(net.heartsome.cat.ts.ui.xliffeditor.nattable.utils.NattableUtil) IEditorPart(org.eclipse.ui.IEditorPart) XLFHandler(net.heartsome.cat.ts.core.file.XLFHandler)

Example 7 with NattableUtil

use of net.heartsome.cat.ts.ui.xliffeditor.nattable.utils.NattableUtil in project translationstudio8 by heartsome.

the class MergeSegmentHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
        return null;
    }
    XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
    NattableUtil util = NattableUtil.getInstance(xliffEditor);
    util.mergeSegment();
    return null;
}
Also used : XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) NattableUtil(net.heartsome.cat.ts.ui.xliffeditor.nattable.utils.NattableUtil) IEditorPart(org.eclipse.ui.IEditorPart)

Example 8 with NattableUtil

use of net.heartsome.cat.ts.ui.xliffeditor.nattable.utils.NattableUtil in project translationstudio8 by heartsome.

the class ExecuteFuzzyTranslationHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    IEditorPart editor = window.getActivePage().getActiveEditor();
    if (!XLIFF_EDITOR_ID.equals(editor.getSite().getId())) {
        return null;
    }
    final XLIFFEditorImplWithNatTable nattable = (XLIFFEditorImplWithNatTable) editor;
    final NattableUtil util = NattableUtil.getInstance(nattable);
    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            //				monitor.beginTask(Messages.getString("translation.ExecuteFuzzyTranslationHandler.task1"), 8);
            // 首选获取有译文的trans-unit
            monitor.beginTask(Messages.getString("translation.ExecuteFuzzyTranslationHandler.task2"), 10);
            XLFHandler handler = nattable.getXLFHandler();
            Map<String, List<String>> rowIdMap = new HashMap<String, List<String>>();
            rowIdMap = RepeatRowSearcher.getRepeateRowsForFuzzy(handler);
            monitor.worked(1);
            util.propagateTranslations(rowIdMap, monitor);
            monitor.done();
        }
    };
    try {
        new ProgressMonitorDialog(nattable.getEditorSite().getShell()).run(true, true, runnable);
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    nattable.autoResize();
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) HashMap(java.util.HashMap) NattableUtil(net.heartsome.cat.ts.ui.xliffeditor.nattable.utils.NattableUtil) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IEditorPart(org.eclipse.ui.IEditorPart) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) List(java.util.List) XLFHandler(net.heartsome.cat.ts.core.file.XLFHandler)

Aggregations

XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)8 NattableUtil (net.heartsome.cat.ts.ui.xliffeditor.nattable.utils.NattableUtil)8 IEditorPart (org.eclipse.ui.IEditorPart)8 XLFHandler (net.heartsome.cat.ts.core.file.XLFHandler)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 IMatchViewPart (net.heartsome.cat.ts.ui.view.IMatchViewPart)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 IViewPart (org.eclipse.ui.IViewPart)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1