Search in sources :

Example 1 with TransProgressFAResult

use of net.heartsome.cat.ts.ui.qa.model.TransProgressFAResult in project translationstudio8 by heartsome.

the class TranslationProgressFA method paraSetInputData.

public void paraSetInputData(IContainer curContainer, StringBuffer paraFAdata, int paddLeft) {
    paddLeft += 10;
    // 先判断该容器中是否有直接子文件为本次分析文件
    if (hasFAIFiles(curContainer)) {
        // 每个文件的具体数据
        for (int fIndex = 0; fIndex < model.getAnalysisIFileList().size(); fIndex++) {
            IFile curIFile = model.getAnalysisIFileList().get(fIndex);
            if (curIFile.getParent().equals(curContainer)) {
                TransProgressFAResult faResult = transProgFAResultMap.get(curIFile.getLocation().toOSString());
                paraFAdata.append("\t\t<tr id='" + curContainer.getFullPath().toOSString() + "' name='paras' " + "onmouseover= \"this.bgColor= '#F1F1FC'\" onmouseout= \"this.bgColor='#FFFFFF'\" bgcolor='#FFFFFF'>\n");
                paraFAdata.append("\t\t\t<td class='fileTd' style='padding-left: " + paddLeft + "'>" + curIFile.getName() + // 文件名
                "</td>\n");
                paraFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getNotTransPara() + // 未翻译文本段数
                "</td>\n");
                paraFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getNotTransParasRatio() + // 未翻译文本段比例
                "</td>\n");
                paraFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getTranslatedPara() + // 已翻译文本段数
                "</td>\n");
                paraFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getTransParasRatio() + // 已翻译文本段比例
                "</td>\n");
                paraFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getLockedPara() + // 锁定文本段
                "</td>\n");
                paraFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getTotalParas() + // 总段数
                "</td>\n");
                paraFAdata.append("\t\t</tr>\n");
            }
        }
    }
    // 遍历所有含有分析文件的容器,找出当前容器的子容器,
    for (int index = 0; index < allFolderList.size(); index++) {
        IContainer childContainer = allFolderList.get(index);
        if (childContainer.getParent().equals(curContainer)) {
            TransProgressFAResult faResult = transProgFAResultMap.get(childContainer.getLocation().toOSString());
            String folderId = childContainer.getFullPath().toOSString();
            paraFAdata.append("<tr id='" + curContainer.getFullPath().toOSString() + "' name='paras' " + "onmouseover= \"this.bgColor= '#F1F1FC'\" onmouseout= \"this.bgColor='#FFFFFF'\" bgcolor='#FFFFFF'>\n" + "<td class='folderTd' >\n" + "<a href='javascript:void(0)' id='" + folderId + "' name='paras' class='link' style='padding-left: " + paddLeft + "'" + "title='" + Messages.getString("qa.all.fa.clickToShrink") + "' onclick='clickFolder(id, name)'>" + "<span id='" + folderId + "_span'>-</span> " + childContainer.getName() + "</a></td>\n" + "<td class='folderTd' align='right'>" + faResult.getNotTransPara() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getNotTransParasRatio() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getTranslatedPara() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getTransParasRatio() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getLockedPara() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getTotalParas() + "</td>\n" + "</tr>\n");
            paraSetInputData(childContainer, paraFAdata, paddLeft);
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) TransProgressFAResult(net.heartsome.cat.ts.ui.qa.model.TransProgressFAResult) IContainer(org.eclipse.core.resources.IContainer)

Example 2 with TransProgressFAResult

use of net.heartsome.cat.ts.ui.qa.model.TransProgressFAResult in project translationstudio8 by heartsome.

the class TranslationProgressFA method wordsSetInputData.

/**
	 * 向字数分析的字数展示模块填充数据
	 * @param curContainer
	 * @param wordsFAdata
	 */
public void wordsSetInputData(IContainer curContainer, StringBuffer wordsFAdata, int paddLeft) {
    paddLeft += 10;
    // 先判断该容器中是否有直接子文件为本次分析文件
    if (hasFAIFiles(curContainer)) {
        // 每个文件的具体数据
        for (int fIndex = 0; fIndex < model.getAnalysisIFileList().size(); fIndex++) {
            IFile curIFile = model.getAnalysisIFileList().get(fIndex);
            if (curIFile.getParent().equals(curContainer)) {
                TransProgressFAResult faResult = transProgFAResultMap.get(curIFile.getLocation().toOSString());
                wordsFAdata.append("\t\t<tr id='" + curContainer.getFullPath().toOSString() + "' name='words' " + "onmouseover= \"this.bgColor= '#F1F1FC'\" onmouseout= \"this.bgColor='#FFFFFF'\" bgcolor='#FFFFFF'>\n");
                wordsFAdata.append("\t\t\t<td class='fileTd' style='padding-left: " + paddLeft + "'>" + curIFile.getName() + // 文件名
                "</td>\n");
                wordsFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getNotTransWords() + // 未翻译字数
                "</td>\n");
                wordsFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getNotTransWordsRatio() + // 未翻译字数比例
                "</td>\n");
                wordsFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getTranslatedWords() + // 已翻译字数
                "</td>\n");
                wordsFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getTransWordsRatio() + // 已翻译字数比例
                "</td>\n");
                wordsFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getLockedWords() + // 锁定字数
                "</td>\n");
                wordsFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getTotalWords() + // 总字数
                "</td>\n");
                wordsFAdata.append("\t\t</tr>\n");
            }
        }
    }
    // 遍历所有含有分析文件的容器,找出当前容器的子容器,
    for (int index = 0; index < allFolderList.size(); index++) {
        IContainer childContainer = allFolderList.get(index);
        if (childContainer.getParent().equals(curContainer)) {
            TransProgressFAResult faResult = transProgFAResultMap.get(childContainer.getLocation().toOSString());
            String folderId = childContainer.getFullPath().toOSString();
            wordsFAdata.append("<tr id='" + curContainer.getFullPath().toOSString() + "' name='words' " + "onmouseover= \"this.bgColor= '#F1F1FC'\" onmouseout= \"this.bgColor='#FFFFFF'\" bgcolor='#FFFFFF'>\n" + "<td class='folderTd' ><a href='javascript:void(0)' id='" + folderId + "' name='words' class='link' style='padding-left: " + paddLeft + "'" + "title='" + Messages.getString("qa.all.fa.clickToShrink") + "' onclick='clickFolder(id, name)'>" + "<span id='" + folderId + "_span'>-</span> " + childContainer.getName() + "</a></td>\n" + "<td class='folderTd' align='right'>" + faResult.getNotTransWords() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getNotTransWordsRatio() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getTranslatedWords() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getTransWordsRatio() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getLockedWords() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getTotalWords() + "</td>\n" + "</tr>\n");
            wordsSetInputData(childContainer, wordsFAdata, paddLeft);
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) TransProgressFAResult(net.heartsome.cat.ts.ui.qa.model.TransProgressFAResult) IContainer(org.eclipse.core.resources.IContainer)

Example 3 with TransProgressFAResult

use of net.heartsome.cat.ts.ui.qa.model.TransProgressFAResult in project translationstudio8 by heartsome.

the class TranslationProgressFA method createFAResultHtml.

public String createFAResultHtml() {
    allFolderList = new LinkedList<IContainer>();
    Date createDate = new Date();
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String createTime = formatter.format(createDate);
    formatter = new SimpleDateFormat("yyyyMMdd-HHmmss");
    String htmlNameTime = formatter.format(createDate);
    IProject curProject = model.getAnalysisIFileList().get(0).getProject();
    String htmlName = "TRLog" + htmlNameTime + ".html";
    String htmlPath = curProject.getLocation().append("Intermediate").append("Report").append(htmlName).toOSString();
    File htmlFile = new File(htmlPath);
    if (!htmlFile.getParentFile().exists()) {
        htmlFile.getParentFile().mkdirs();
    }
    FileOutputStream output;
    try {
        output = new FileOutputStream(htmlPath);
        output.write(QAConstant.FA_HtmlDoctype.getBytes("UTF-8"));
        output.write("<html>\n".getBytes("UTF-8"));
        String headerNode = QAConstant.FA_htmlHeader;
        headerNode = headerNode.replace("###Title###", Messages.getString("qa.fileAnalysis.TranslationProgressFA.name1"));
        output.write(headerNode.getBytes("UTF-8"));
        output.write("\t<body>\n".getBytes("UTF-8"));
        output.write(("<p class=\"title\">" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.TransProgresFA") + "</p>").getBytes("UTF-8"));
        // ----------------<<<<<<start-- 下面是相关信息提示部份---------------------
        output.write("\t<div>\n".getBytes("UTF-8"));
        output.write("\t\t<table class=\"infoTableStyle\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n".getBytes("UTF-8"));
        // 分析文件总数
        String title = Messages.getString("qa.fa.info.fileSum");
        String content = "" + model.getSubFileNum();
        String infoStr = QAConstant.FA_Report_Info.replace("###Title###", title).replace("###Content###", content);
        output.write(infoStr.getBytes("UTF-8"));
        // 分析失败文件
        title = Messages.getString("qa.fa.info.errorFiles");
        StringBuffer errorFileSB = new StringBuffer();
        errorFileSB.append("\t\t\t<div style=\"margin-bottom: 2px;\">");
        errorFileSB.append(model.getErrorIFileList().size());
        errorFileSB.append("</div>");
        for (IFile iFile : model.getErrorIFileList()) {
            errorFileSB.append("\t\t\t<div style=\"margin-bottom: 2px;\">");
            errorFileSB.append(iFile.getFullPath().toOSString());
            errorFileSB.append("</div>");
        }
        infoStr = QAConstant.FA_Report_Info.replace("###Title###", title).replace("###Content###", errorFileSB.toString());
        output.write(infoStr.getBytes("UTF-8"));
        // 报告生成时间
        title = Messages.getString("qa.fa.info.createTime");
        infoStr = QAConstant.FA_Report_Info.replace("###Title###", title).replace("###Content###", createTime);
        output.write(infoStr.getBytes("UTF-8"));
        output.write("</table></div><br>\n".getBytes("UTF-8"));
        // ---------------->>>>>>end-- 报表信息提示部分结束---------------------
        // --------------字数---------------------
        output.write(("\t\t<div class=\"legendStyle\"><b>" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.words") + "</b></div>").getBytes("UTF-8"));
        StringBuffer wordsFAdata = new StringBuffer();
        getAllFolder(curProject, allFolderList);
        setDataToFolder(curProject);
        // 创建一个表
        wordsFAdata.append("\t<table class='tableStyle' cellpadding='0' cellspacing='1'> \n");
        // 表头
        wordsFAdata.append("\t\t<tr>\n");
        wordsFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='22%'>" + Messages.getString("qa.all.fa.fileName") + "</td>\n");
        wordsFAdata.append("\t\t\t<td class='headerTd' colSpan='2' width='26%'>" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.nonTrans") + "</td>\n");
        wordsFAdata.append("\t\t\t<td class='headerTd' colSpan='2' width='26%'>" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.translated") + "</td>\n");
        wordsFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='13%'>" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.lockedWords") + "</td>\n");
        wordsFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='13%'>" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.wordsSum") + "</td>\n");
        wordsFAdata.append("\t\t</tr>\n");
        wordsFAdata.append("\t\t<tr>\n");
        wordsFAdata.append("\t\t\t<td class='headerTd' width='13%'>" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.transWords") + "</td>\n");
        wordsFAdata.append("\t\t\t<td class='headerTd' width='13%'>" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.transWordsProp") + "</td>\n");
        wordsFAdata.append("\t\t\t<td class='headerTd' width='13%'>" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.transWords") + "</td>\n");
        wordsFAdata.append("\t\t\t<td class='headerTd' width='13%'>" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.transWordsProp") + "</td>\n");
        wordsFAdata.append("\t\t</tr>\n");
        // 首先写下项目
        TransProgressFAResult proFaResult = transProgFAResultMap.get(curProject.getLocation().toOSString());
        int paddLeft = 6;
        String folderId = curProject.getFullPath().toOSString();
        wordsFAdata.append("<tr onmouseover= \"this.bgColor= '#F1F1FC'\" onmouseout= \"this.bgColor='#FFFFFF'\" bgcolor='#FFFFFF'>\n" + "<td class='folderTd' style='padding-left: 6'>\n" + "<a href='javascript:void(0)' id='" + folderId + "' name='words' class='link' title='" + Messages.getString("qa.all.fa.clickToShrink") + "' " + " onclick='clickFolder(id, name)' ><span id='" + folderId + "_span'>-</span> " + curProject.getName() + "</a></td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getNotTransWords() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getNotTransWordsRatio() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getTranslatedWords() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getTransWordsRatio() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getLockedWords() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getTotalWords() + "</td>\n" + "</tr>");
        wordsSetInputData(curProject, wordsFAdata, paddLeft);
        wordsFAdata.append("\t</table>\n");
        output.write(wordsFAdata.toString().getBytes("UTF-8"));
        output.write("<br/>\n".getBytes("UTF-8"));
        // --------------文本段---------------------
        output.write(("\t\t<div class=\"legendStyle\"><b>" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.paragraph") + "</b></div>").getBytes("UTF-8"));
        StringBuffer paraFAdata = new StringBuffer();
        // 创建一个表
        paraFAdata.append("\t<table class='tableStyle' cellpadding='0' cellspacing='1'> \n");
        // 表头
        paraFAdata.append("\t\t<tr>\n");
        paraFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='22%'>" + Messages.getString("qa.all.fa.fileName") + "</td>\n");
        paraFAdata.append("\t\t\t<td class='headerTd' colSpan='2' width='26%'>" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.nonTrans") + "</td>\n");
        paraFAdata.append("\t\t\t<td class='headerTd' colSpan='2' width='26%'>" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.translated") + "</td>\n");
        paraFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='13%'>" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.lockedParasNum") + "</td>\n");
        paraFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='13%'>" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.parasSum") + "</td>\n");
        paraFAdata.append("\t\t</tr>\n");
        paraFAdata.append("\t\t<tr>\n");
        paraFAdata.append("\t\t\t<td class='headerTd' width='13%'>" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.transParasNum") + "</td>\n");
        paraFAdata.append("\t\t\t<td class='headerTd' width='13%'>" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.transWordsProp") + "</td>\n");
        paraFAdata.append("\t\t\t<td class='headerTd' width='13%'>" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.transParasNum") + "</td>\n");
        paraFAdata.append("\t\t\t<td class='headerTd' width='13%'>" + Messages.getString("qa.fileAnalysis.TranslationProgressFA.transWordsProp") + "</td>\n");
        paraFAdata.append("\t\t</tr>\n");
        // 首先写下项目
        paddLeft = 6;
        paraFAdata.append("<tr onmouseover= \"this.bgColor= '#F1F1FC'\" onmouseout= \"this.bgColor='#FFFFFF'\" bgcolor='#FFFFFF'>\n" + "<td class='folderTd' style='padding-left: 6'>\n" + "<a href='javascript:void(0)' id='" + folderId + "' name='paras' class='link' title='" + Messages.getString("qa.all.fa.clickToShrink") + "' " + " onclick='clickFolder(id, name)' ><span id='" + folderId + "_span'>-</span> " + curProject.getName() + "</a></td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getNotTransPara() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getNotTransParasRatio() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getTranslatedPara() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getTransParasRatio() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getLockedPara() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getTotalParas() + "</td>\n" + "</tr>");
        paraSetInputData(curProject, paraFAdata, paddLeft);
        paraFAdata.append("\t</table>\n");
        output.write(paraFAdata.toString().getBytes("UTF-8"));
        //			output.write("\t\t</fieldset><br/>\n".getBytes("UTF-8"));
        // -----------文本段结束--------------
        /*			String htmlPathDiv = "<div style='width:100%;font-size:14;color:blue;'>" + Messages.getString("qa.all.fa.fileLocation")
					+ curProject.getFullPath().append("Report").append(htmlName).toOSString() + "</div>";
			output.write(htmlPathDiv.getBytes("UTF-8"));*/
        output.write("\t</body>\n".getBytes("UTF-8"));
        output.write("</html>".getBytes("UTF-8"));
        output.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        logger.error(Messages.getString("qa.fileAnalysis.TranslationProgressFA.log3"), e);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        logger.error(Messages.getString("qa.fileAnalysis.TranslationProgressFA.log4"), e);
    } catch (IOException e) {
        e.printStackTrace();
        logger.error(Messages.getString("qa.fileAnalysis.TranslationProgressFA.log5"), e);
    }
    return htmlPath;
}
Also used : IFile(org.eclipse.core.resources.IFile) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) TransProgressFAResult(net.heartsome.cat.ts.ui.qa.model.TransProgressFAResult) IOException(java.io.IOException) Date(java.util.Date) IProject(org.eclipse.core.resources.IProject) FileOutputStream(java.io.FileOutputStream) IContainer(org.eclipse.core.resources.IContainer) SimpleDateFormat(java.text.SimpleDateFormat) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 4 with TransProgressFAResult

use of net.heartsome.cat.ts.ui.qa.model.TransProgressFAResult in project translationstudio8 by heartsome.

the class TranslationProgressFA method setDataToFolder.

/**
	 * 将文件下所有的子文件(直接或间接子文件)的值加到文件夹中
	 */
public void setDataToFolder(IProject curProject) {
    // 先存放项目相关的信息,所有的文件都存放在该项目中的,因此直接遍历所有的文件
    TransProgressFAResult proFaResult = new TransProgressFAResult();
    for (int i = 0; i < model.getAnalysisIFileList().size(); i++) {
        IFile ifile = model.getAnalysisIFileList().get(i);
        TransProgressFAResult faResult = transProgFAResultMap.get(ifile.getLocation().toOSString());
        proFaResult.setNotTransPara(faResult.getNotTransPara());
        proFaResult.setTranslatedPara(faResult.getTranslatedPara());
        proFaResult.setLockedPara(faResult.getLockedPara());
        proFaResult.setNotTransWords(faResult.getNotTransWords());
        proFaResult.setTranslatedWords(faResult.getTranslatedWords());
        proFaResult.setLockedWords(faResult.getLockedWords());
    }
    transProgFAResultMap.put(curProject.getLocation().toOSString(), proFaResult);
    // 先遍历所有的文件夹
    for (int index = 0; index < allFolderList.size(); index++) {
        IContainer container = allFolderList.get(index);
        TransProgressFAResult folderFaResult = new TransProgressFAResult();
        // 循环所有的已经分析完的文件
        for (int i = 0; i < model.getAnalysisIFileList().size(); i++) {
            IFile ifile = model.getAnalysisIFileList().get(i);
            IContainer iFileParent = ifile.getParent();
            while (iFileParent != null) {
                if (iFileParent.equals(container)) {
                    TransProgressFAResult faResult = transProgFAResultMap.get(ifile.getLocation().toOSString());
                    folderFaResult.setNotTransPara(faResult.getNotTransPara());
                    folderFaResult.setTranslatedPara(faResult.getTranslatedPara());
                    folderFaResult.setLockedPara(faResult.getLockedPara());
                    folderFaResult.setNotTransWords(faResult.getNotTransWords());
                    folderFaResult.setTranslatedWords(faResult.getTranslatedWords());
                    folderFaResult.setLockedWords(faResult.getLockedWords());
                    break;
                } else {
                    iFileParent = iFileParent.getParent();
                }
            }
        }
        transProgFAResultMap.put(container.getLocation().toOSString(), folderFaResult);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) TransProgressFAResult(net.heartsome.cat.ts.ui.qa.model.TransProgressFAResult) IContainer(org.eclipse.core.resources.IContainer)

Example 5 with TransProgressFAResult

use of net.heartsome.cat.ts.ui.qa.model.TransProgressFAResult in project translationstudio8 by heartsome.

the class TranslationProgressFA method beginAnalysis.

@Override
public int beginAnalysis(FAModel model, IProgressMonitor monitor, QAXmlHandler handler) {
    this.model = model;
    super.setModel(model);
    transProgFAResultMap = new HashMap<String, TransProgressFAResult>();
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    // 要分析的文件的所有
    int allTUSize = model.getAllTuSize();
    int traversalTuIndex = 0;
    int totalWork = allTUSize % workInterval == 0 ? (allTUSize / workInterval) : (allTUSize / workInterval) + 1;
    monitor.beginTask("", totalWork);
    for (int index = 0; index < model.getAnalysisIFileList().size(); index++) {
        IFile iFile = model.getAnalysisIFileList().get(index);
        monitor.setTaskName(MessageFormat.format(Messages.getString("qa.fileAnalysis.TranslationProgressFA.tip1"), iFile.getFullPath().toOSString()));
        String iFilePath = iFile.getLocation().toOSString();
        // 获取单个文件的翻译进度的数据
        Map<String, Integer> transProgMap = handler.getTransProgressData(iFilePath, monitor, workInterval, traversalTuIndex);
        // 如果获取的结果为null,则表示用户退出程序
        if (transProgMap == null) {
            return QAConstant.QA_ZERO;
        }
        traversalTuIndex += handler.getTuSizeMap().get(iFilePath);
        int notTransPara = transProgMap.get("notTransPara");
        int translatedPara = transProgMap.get("translatedPara");
        int notTransWords = transProgMap.get("notTransWords");
        int translatedWords = transProgMap.get("translatedWords");
        int lockedWords = transProgMap.get("lockedWords");
        int lockedPara = transProgMap.get("lockedPara");
        TransProgressFAResult transResult = new TransProgressFAResult(notTransPara, translatedPara, lockedPara, notTransWords, translatedWords, lockedWords);
        transProgFAResultMap.put(iFilePath, transResult);
    }
    if (!handler.monitorWork(monitor, traversalTuIndex, workInterval, true)) {
        return QAConstant.QA_ZERO;
    }
    // 开始填充数据
    printTransProgFAReslut();
    return QAConstant.QA_FIRST;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) TransProgressFAResult(net.heartsome.cat.ts.ui.qa.model.TransProgressFAResult)

Aggregations

TransProgressFAResult (net.heartsome.cat.ts.ui.qa.model.TransProgressFAResult)5 IFile (org.eclipse.core.resources.IFile)5 IContainer (org.eclipse.core.resources.IContainer)4 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 IProject (org.eclipse.core.resources.IProject)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1