Search in sources :

Example 61 with XLFHandler

use of net.heartsome.cat.ts.core.file.XLFHandler 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 62 with XLFHandler

use of net.heartsome.cat.ts.core.file.XLFHandler 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)

Example 63 with XLFHandler

use of net.heartsome.cat.ts.core.file.XLFHandler in project translationstudio8 by heartsome.

the class ReverseConversionWizardPage method getTgtEncoding.

/**
	 * 取得目标文件的编码
	 * @param xliffPath
	 * @return ;
	 */
private String getTgtEncoding(String xliffPath) {
    XLFHandler handler = new XLFHandler();
    Map<String, Object> resultMap = handler.openFile(xliffPath);
    if (resultMap == null || Constant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) resultMap.get(Constant.RETURNVALUE_RESULT)) {
        //$NON-NLS-1$
        return "";
    }
    List<HashMap<String, String>> documentInfo = handler.getDocumentInfo(xliffPath);
    if (documentInfo.size() > 0) {
        return documentInfo.get(0).get(DocumentPropertiesKeys.ENCODING);
    }
    return "";
}
Also used : HashMap(java.util.HashMap) XLFHandler(net.heartsome.cat.ts.core.file.XLFHandler)

Aggregations

XLFHandler (net.heartsome.cat.ts.core.file.XLFHandler)63 IEditorPart (org.eclipse.ui.IEditorPart)45 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)36 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)24 ArrayList (java.util.ArrayList)21 IFile (org.eclipse.core.resources.IFile)16 FileEditorInput (org.eclipse.ui.part.FileEditorInput)16 List (java.util.List)14 IProject (org.eclipse.core.resources.IProject)13 ExecutionException (org.eclipse.core.commands.ExecutionException)11 InvocationTargetException (java.lang.reflect.InvocationTargetException)10 CoreException (org.eclipse.core.runtime.CoreException)9 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 Shell (org.eclipse.swt.widgets.Shell)8 IViewPart (org.eclipse.ui.IViewPart)8 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)8 IXliffEditor (net.heartsome.cat.ts.ui.editors.IXliffEditor)7 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)6 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)6