Search in sources :

Example 11 with TransUnitInfo2TranslationBean

use of net.heartsome.cat.ts.tm.bean.TransUnitInfo2TranslationBean in project translationstudio8 by heartsome.

the class MatchViewPart method manualExecSimpleTranslation.

public void manualExecSimpleTranslation(int rowIndex, IXliffEditor editor, ISimpleMatcher simpleMatcher) {
    if (rowIndex == -1) {
        return;
    }
    // handler.getTransUnit(rowId);
    TransUnitBean transUnit = editor.getRowTransUnitBean(rowIndex);
    if (transUnit == null) {
        return;
    }
    XLFHandler handler = editor.getXLFHandler();
    if (handler == null) {
        return;
    }
    IProject prj = null;
    if (editor instanceof IEditorPart) {
        IEditorPart p = (IEditorPart) editor;
        FileEditorInput input = (FileEditorInput) p.getEditorInput();
        prj = input.getFile().getProject();
    }
    if (prj == null) {
        return;
    }
    String rowId = handler.getRowId(rowIndex);
    TransUnitInfo2TranslationBean tuInfo = getTuInfoBean(transUnit, handler, rowId);
    TranslationTaskData data = new TranslationTaskData(simpleMatcher, transUnit, tuInfo, editor, rowIndex, prj);
    synchronized (manualTranslationTaskContainer) {
        manualTranslationTaskContainer.pushTranslationTask(data);
        manualTranslationTaskContainer.notify();
    }
}
Also used : TransUnitBean(net.heartsome.cat.ts.core.bean.TransUnitBean) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IEditorPart(org.eclipse.ui.IEditorPart) XLFHandler(net.heartsome.cat.ts.core.file.XLFHandler) IProject(org.eclipse.core.resources.IProject) TransUnitInfo2TranslationBean(net.heartsome.cat.ts.tm.bean.TransUnitInfo2TranslationBean)

Example 12 with TransUnitInfo2TranslationBean

use of net.heartsome.cat.ts.tm.bean.TransUnitInfo2TranslationBean in project translationstudio8 by heartsome.

the class MatchViewPart method getTuInfoBean.

private TransUnitInfo2TranslationBean getTuInfoBean(TransUnitBean transUnit, XLFHandler handler, String rowId) {
    String srcFullText = transUnit.getSrcContent();
    String srcPureText = transUnit.getSrcText();
    if ("".equals(srcFullText.trim()) || "".equals(srcPureText.trim())) {
        return null;
    }
    sourceColunmCellRenderer.setTuSrcText(srcFullText);
    String srcLanguage = transUnit.getSrcLang();
    String tgtLanguage = transUnit.getTgtLang();
    tgtLanguage = handler.getNatTableColumnName().get("target");
    Language srcLang = LocaleService.getLanguageConfiger().getLanguageByCode(srcLanguage);
    Language tgtLang = LocaleService.getLanguageConfiger().getLanguageByCode(tgtLanguage);
    if (srcLang.isBidi() || tgtLang.isBidi()) {
        gridTable.setOrientation(SWT.RIGHT_TO_LEFT);
    } else {
        gridTable.setOrientation(SWT.LEFT_TO_RIGHT);
    }
    TransUnitInfo2TranslationBean tuInfoBean = new TransUnitInfo2TranslationBean();
    tuInfoBean.setSrcFullText(srcFullText);
    tuInfoBean.setSrcPureText(srcPureText);
    tuInfoBean.setSrcLanguage(srcLanguage);
    tuInfoBean.setTgtLangugage(tgtLanguage);
    int contextSize = tmMatcher.getContextSize();
    if (contextSize != 0) {
        Map<String, String> context = handler.getTransUnitContext(rowId, contextSize);
        tuInfoBean.setPreContext(context.get("x-preContext"));
        tuInfoBean.setNextContext(context.get("x-nextContext"));
    } else {
        tuInfoBean.setPreContext("");
        tuInfoBean.setNextContext("");
    }
    return tuInfoBean;
}
Also used : Language(net.heartsome.cat.common.locale.Language) TransUnitInfo2TranslationBean(net.heartsome.cat.ts.tm.bean.TransUnitInfo2TranslationBean) Point(org.eclipse.swt.graphics.Point)

Example 13 with TransUnitInfo2TranslationBean

use of net.heartsome.cat.ts.tm.bean.TransUnitInfo2TranslationBean in project translationstudio8 by heartsome.

the class MatchViewPart method manualExecComplexTranslation.

public void manualExecComplexTranslation(int rowIndex, IXliffEditor editor, IComplexMatch complexMatcher) {
    if (rowIndex == -1) {
        return;
    }
    // handler.getTransUnit(rowId);
    TransUnitBean transUnit = editor.getRowTransUnitBean(rowIndex);
    if (transUnit == null) {
        return;
    }
    XLFHandler handler = editor.getXLFHandler();
    if (handler == null) {
        return;
    }
    IProject prj = null;
    if (editor instanceof IEditorPart) {
        IEditorPart p = (IEditorPart) editor;
        FileEditorInput input = (FileEditorInput) p.getEditorInput();
        prj = input.getFile().getProject();
    }
    if (prj == null) {
        return;
    }
    String rowId = handler.getRowId(rowIndex);
    TransUnitInfo2TranslationBean tuInfo = getTuInfoBean(transUnit, handler, rowId);
    TranslationTaskData data = new TranslationTaskData(complexMatcher, transUnit, tuInfo, editor, rowIndex, prj);
    synchronized (manualTranslationTaskContainer) {
        manualTranslationTaskContainer.pushTranslationTask(data);
        manualTranslationTaskContainer.notify();
    }
}
Also used : TransUnitBean(net.heartsome.cat.ts.core.bean.TransUnitBean) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IEditorPart(org.eclipse.ui.IEditorPart) XLFHandler(net.heartsome.cat.ts.core.file.XLFHandler) IProject(org.eclipse.core.resources.IProject) TransUnitInfo2TranslationBean(net.heartsome.cat.ts.tm.bean.TransUnitInfo2TranslationBean)

Aggregations

TransUnitInfo2TranslationBean (net.heartsome.cat.ts.tm.bean.TransUnitInfo2TranslationBean)13 AutoPilot (com.ximpleware.AutoPilot)6 TransUnitBean (net.heartsome.cat.ts.core.bean.TransUnitBean)4 XLFHandler (net.heartsome.cat.ts.core.file.XLFHandler)4 IProject (org.eclipse.core.resources.IProject)4 IEditorPart (org.eclipse.ui.IEditorPart)4 FileEditorInput (org.eclipse.ui.part.FileEditorInput)4 FuzzySearchResult (net.heartsome.cat.common.bean.FuzzySearchResult)3 TranslationUnitAnalysisResult (net.heartsome.cat.common.bean.TranslationUnitAnalysisResult)2 Point (org.eclipse.swt.graphics.Point)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Language (net.heartsome.cat.common.locale.Language)1 WordsFABean (net.heartsome.cat.ts.core.qa.WordsFABean)1 IXliffEditor (net.heartsome.cat.ts.ui.editors.IXliffEditor)1 WordsFAResult (net.heartsome.cat.ts.ui.qa.model.WordsFAResult)1 IFile (org.eclipse.core.resources.IFile)1