Search in sources :

Example 1 with IComplexMatch

use of net.heartsome.cat.ts.tm.complexMatch.IComplexMatch in project translationstudio8 by heartsome.

the class ExecuteQuickTranslation method execute.

/** (non-Javadoc)
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
	 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    if (TranslateParameter.getInstance().isAutoQuickTrans()) {
        return null;
    }
    final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    final IEditorPart editor = HandlerUtil.getActiveEditor(event);
    if (!(editor instanceof IXliffEditor)) {
        return null;
    }
    final IXliffEditor xliffEditor = (IXliffEditor) editor;
    final int[] selectedRowIndexs = xliffEditor.getSelectedRows();
    if (selectedRowIndexs.length == 0) {
        return null;
    }
    //		TransUnitBean transUnitBean = xliffEditor.getRowTransUnitBean(selectedRowIndexs[selectedRowIndexs.length - 1]);
    IComplexMatch matcher = new QuickTranslationImpl();
    //		FileEditorInput input = (FileEditorInput) editor.getEditorInput();
    //		IProject project = input.getFile().getProject();
    //		List<AltTransBean> newAltTrans = matcher.executeTranslation(transUnitBean, project);
    //		if(newAltTrans.size() == 0){
    //			return null;
    //		}
    IViewPart viewPart = window.getActivePage().findView(MatchViewPart.ID);
    if (viewPart != null && viewPart instanceof MatchViewPart) {
        MatchViewPart matchView = (MatchViewPart) viewPart;
        matchView.manualExecComplexTranslation(selectedRowIndexs[0], xliffEditor, matcher);
    //			matchView.replaceMatchs(newAltTrans);
    //			matchView.refreshView(xliffEditor, selectedRowIndexs[selectedRowIndexs.length - 1]);
    }
    //		}
    return null;
}
Also used : MatchViewPart(net.heartsome.cat.ts.ui.translation.view.MatchViewPart) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IComplexMatch(net.heartsome.cat.ts.tm.complexMatch.IComplexMatch) QuickTranslationImpl(net.heartsome.cat.ts.quicktranslation.QuickTranslationImpl) IViewPart(org.eclipse.ui.IViewPart) IEditorPart(org.eclipse.ui.IEditorPart) IXliffEditor(net.heartsome.cat.ts.ui.editors.IXliffEditor)

Example 2 with IComplexMatch

use of net.heartsome.cat.ts.tm.complexMatch.IComplexMatch in project translationstudio8 by heartsome.

the class TranslationTaskContainer method pushTranslationTask.

public synchronized void pushTranslationTask(TranslationTaskData data) {
    Object matcher = data.getMatcher();
    if (matcher instanceof ISimpleMatcher) {
        ISimpleMatcher _matcher = (ISimpleMatcher) matcher;
        for (TranslationTaskData d : dataList) {
            Object m = d.getMatcher();
            if (m instanceof ISimpleMatcher) {
                ISimpleMatcher _m = (ISimpleMatcher) m;
                if (_m.getMathcerToolId().equals(_matcher.getMathcerToolId())) {
                    return;
                }
            }
        }
    } else if (matcher instanceof IComplexMatch) {
        IComplexMatch _matcher = (IComplexMatch) matcher;
        for (TranslationTaskData d : dataList) {
            Object m = d.getMatcher();
            if (m instanceof IComplexMatch) {
                IComplexMatch _m = (IComplexMatch) m;
                if (_m.getToolId().equals(_matcher.getToolId())) {
                    return;
                }
            }
        }
    }
    dataList.add(0, data);
}
Also used : IComplexMatch(net.heartsome.cat.ts.tm.complexMatch.IComplexMatch) ISimpleMatcher(net.heartsome.cat.ts.tm.simpleMatch.ISimpleMatcher)

Aggregations

IComplexMatch (net.heartsome.cat.ts.tm.complexMatch.IComplexMatch)2 QuickTranslationImpl (net.heartsome.cat.ts.quicktranslation.QuickTranslationImpl)1 ISimpleMatcher (net.heartsome.cat.ts.tm.simpleMatch.ISimpleMatcher)1 IXliffEditor (net.heartsome.cat.ts.ui.editors.IXliffEditor)1 MatchViewPart (net.heartsome.cat.ts.ui.translation.view.MatchViewPart)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IViewPart (org.eclipse.ui.IViewPart)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1