use of org.eclipse.core.resources.IContainer in project translationstudio8 by heartsome.
the class EditProgressFA method setDataToFolder.
/**
* 将文件下所有的子文件(直接或间接子文件)的值加到文件夹中
*/
public void setDataToFolder(IProject curProject) {
// 先存放项目相关的信息,所有的文件都存放在该项目中的,因此直接遍历所有的文件
EditProgressFAResult proFaResult = new EditProgressFAResult();
for (int i = 0; i < model.getAnalysisIFileList().size(); i++) {
IFile ifile = model.getAnalysisIFileList().get(i);
EditProgressFAResult faResult = editProgFAResultMap.get(ifile.getLocation().toOSString());
proFaResult.setNotApprovedParas(faResult.getNotApprovedParas());
proFaResult.setApprovedParas(faResult.getApprovedParas());
proFaResult.setLockedParas(faResult.getLockedParas());
proFaResult.setNotApprovedWords(faResult.getNotApprovedWords());
proFaResult.setApprovedWords(faResult.getApprovedWords());
proFaResult.setLockedWords(faResult.getLockedWords());
}
editProgFAResultMap.put(curProject.getLocation().toOSString(), proFaResult);
// 先遍历所有的文件夹
for (int index = 0; index < allFolderList.size(); index++) {
IContainer container = allFolderList.get(index);
EditProgressFAResult folderFaResult = new EditProgressFAResult();
// 循环所有的已经分析完的文件
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)) {
EditProgressFAResult faResult = editProgFAResultMap.get(ifile.getLocation().toOSString());
folderFaResult.setNotApprovedParas(faResult.getNotApprovedParas());
folderFaResult.setApprovedParas(faResult.getApprovedParas());
folderFaResult.setLockedParas(faResult.getLockedParas());
folderFaResult.setNotApprovedWords(faResult.getNotApprovedWords());
folderFaResult.setApprovedWords(faResult.getApprovedWords());
folderFaResult.setLockedWords(faResult.getLockedWords());
break;
} else {
iFileParent = iFileParent.getParent();
}
}
}
editProgFAResultMap.put(container.getLocation().toOSString(), folderFaResult);
}
}
use of org.eclipse.core.resources.IContainer 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);
}
}
}
use of org.eclipse.core.resources.IContainer 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);
}
}
}
use of org.eclipse.core.resources.IContainer in project translationstudio8 by heartsome.
the class WordsFA method paraSetInputData.
/**
* 创建第二张表的数据,关于文本段的统计
* @param curContainer
* @param paraFAdata
* @param paddLeft ;
*/
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)) {
WordsFAResult faResult = WordsFAResultMap.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.getNewPara() + "</td>\n");
if (interMatch) {
// 内部匹配文本段
paraFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getInterMatchPara() + "</td>\n");
}
// 外部匹配文本段
paraFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getExterMatchPara() + "</td>\n");
if (interRepeat) {
// 内部重复文本段
paraFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getInterRepeatPara() + "</td>\n");
}
// 外部重复文本段
paraFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getExterRepeatPara() + "</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.getTotalPara() + "</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)) {
WordsFAResult faResult = WordsFAResultMap.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' ><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.getNewPara() + "</td>\n" + "<td class='folderTd' align='right'>" + (interMatch ? faResult.getInterMatchPara() + "</td>\n" + "<td class='folderTd' align='right'>" : "") + faResult.getExterMatchPara() + "</td>\n" + "<td class='folderTd' align='right'>" + (interRepeat ? faResult.getInterRepeatPara() + "</td>\n" + "<td class='folderTd' align='right'>" : "") + faResult.getExterRepeatPara() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getLockedPara() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getTotalPara() + "</td>\n" + "</tr>\n");
paraSetInputData(childContainer, paraFAdata, paddLeft);
}
}
}
use of org.eclipse.core.resources.IContainer in project translationstudio8 by heartsome.
the class BatchQAHandler method execute.
@SuppressWarnings("unchecked")
public Object execute(ExecutionEvent event) throws ExecutionException {
isMultiFile = false;
preferenceStore = Activator.getDefault().getPreferenceStore();
// UNDO 如果焦点在其他视图上时,获取的文件错误。
IFile multiTempIFile = null;
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
final Shell shell = window.getShell();
// ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
IViewPart viewPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("net.heartsome.cat.common.ui.navigator.view");
ArrayList<IFile> selectIFiles = new ArrayList<IFile>();
if (HandlerUtil.getActivePart(event) instanceof IViewPart) {
ISelection currentSelection = (StructuredSelection) viewPart.getSite().getSelectionProvider().getSelection();
if (currentSelection != null && !currentSelection.isEmpty() && currentSelection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) currentSelection;
Iterator<Object> selectIt = structuredSelection.iterator();
while (selectIt.hasNext()) {
Object object = selectIt.next();
if (object instanceof IFile) {
IFile selectFile = (IFile) object;
String fileExtension = selectFile.getFileExtension();
// 如果后缀名不是xlf,那么就进行提示
if (fileExtension == null || !CommonFunction.validXlfExtension(fileExtension)) {
boolean isSure = MessageDialog.openConfirm(shell, Messages.getString("qa.all.dialog.warning"), MessageFormat.format(Messages.getString("qa.all.tip.notXliff"), new Object[] { selectFile.getFullPath() }));
if (!isSure) {
return null;
}
continue;
}
selectIFiles.add(selectFile);
} else if (object instanceof IProject) {
IProject selectProject = (IProject) object;
try {
ResourceUtils.getXliffs(selectProject, selectIFiles);
} catch (Exception e) {
e.printStackTrace();
logger.error(Messages.getString("qa.handlers.BatchQAHandler.log1"), e);
}
} else if (object instanceof IContainer) {
IContainer selectContainer = (IContainer) object;
try {
ResourceUtils.getXliffs(selectContainer, selectIFiles);
} catch (Exception e) {
logger.error(Messages.getString("qa.handlers.BatchQAHandler.log1"), e);
e.printStackTrace();
}
}
}
}
} else {
//如果左边未选择品质检查的类型,那么,获取nattable中打开的文件
IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
String XLIFF_EDITOR_ID = "net.heartsome.cat.ts.ui.xliffeditor.nattable.editor";
if (activeEditor != null && !activeEditor.getSite().getId().equals(XLIFF_EDITOR_ID)) {
MessageDialog.openWarning(shell, Messages.getString("qa.all.dialog.warning"), Messages.getString("qa.handlers.BatchQAHandler.tip2"));
return null;
}
XLIFFEditorImplWithNatTable nattable = (XLIFFEditorImplWithNatTable) activeEditor;
isMultiFile = nattable.isMultiFile();
multiTempIFile = ((FileEditorInput) nattable.getEditorInput()).getFile();
if (isMultiFile) {
List<String> multiFilesList = new XLFHandler().getMultiFiles(multiTempIFile);
for (String multiFileStr : multiFilesList) {
selectIFiles.add(ResourceUtils.fileToIFile(multiFileStr));
}
} else {
selectIFiles.add(multiTempIFile);
}
}
CommonFunction.removeRepeateSelect(selectIFiles);
if (selectIFiles.size() == 0) {
MessageDialog.openWarning(shell, Messages.getString("qa.all.dialog.warning"), Messages.getString("qa.handlers.BatchQAHandler.tip1"));
return null;
}
List<IFile> lstFiles = new ArrayList<IFile>();
XLFValidator.resetFlag();
for (IFile iFile : selectIFiles) {
if (!XLFValidator.validateXliffFile(iFile)) {
lstFiles.add(iFile);
}
}
XLFValidator.resetFlag();
selectIFiles.removeAll(lstFiles);
if (selectIFiles.size() == 0) {
return null;
}
model = new QAModel();
model.setQaXlfList(selectIFiles);
quality = new QualityAssurance(model);
BatchQADialog dialog = new BatchQADialog(shell, model, isMultiFile);
int result = dialog.open();
if (result == IDialogConstants.OK_ID) {
// 先调用方法,查看品质检查结果视图是否处于显示状态,如果显示了的。删除数据
IWorkbenchPage workbenchPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart view = workbenchPage.findView(QAResultViewPart.ID);
if (view != null) {
// 运行时,将结果视图中列表的数据清除
((QAResultViewPart) view).clearTableData();
}
QAResult qaResult = new QAResult();
// 存储品质检查的检查项
model.setBatchQAItemIdList(getBatchQAItems());
// 存储品质检查的检查时不包括的文本段
model.setNotInclude(getNotIncludePara());
//给品质检查结果视图发出通告,本次检查对象为合并打开文件
// qaResult.firePropertyChange(isMultiFile, new MultiFilesOper(selectIFiles.get(0).getProject(), selectIFiles, multiTempIFile));
// 将当前所处理的文件传至 qaResult
List<String> fileList = new ArrayList<String>();
for (IFile iFIle : model.getQaXlfList()) {
fileList.add(iFIle.getLocation().toOSString());
}
qaResult.setFilePathList(fileList);
HsMultiActiveCellEditor.commit(true);
if (isMultiFile) {
model.setMuliFiles(true);
model.setMultiOper(new MultiFilesOper(selectIFiles.get(0).getProject(), selectIFiles, multiTempIFile));
qaResult.setMultiOper(model.getMultiOper());
quality.beginMultiFileQA(qaResult);
} else {
model.setMuliFiles(false);
qaResult.setMultiOper(model.getMultiOper());
quality.beginQA(qaResult);
}
}
return null;
}
Aggregations