Search in sources :

Example 1 with QuickTranslationImpl

use of net.heartsome.cat.ts.quicktranslation.QuickTranslationImpl 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)

Aggregations

QuickTranslationImpl (net.heartsome.cat.ts.quicktranslation.QuickTranslationImpl)1 IComplexMatch (net.heartsome.cat.ts.tm.complexMatch.IComplexMatch)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