use of net.heartsome.cat.ts.ui.util.MultiFilesOper in project translationstudio8 by heartsome.
the class AutomaticQA method setInitData.
public void setInitData(XLFHandler handler) {
this.handler = handler;
preferenceStore = Activator.getDefault().getPreferenceStore();
model = new QAModel();
window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
filterMap = getNotIncludePara();
root = ResourcesPlugin.getWorkspace().getRoot();
xmlHandler = new QAXmlHandler();
// 存储品质检查的检查项
model.setBatchQAItemIdList(getAutoQAItems());
// 存储品质检查的检查时不包括的文本段
model.setNotInclude(filterMap);
model.setShell(window.getShell());
XLIFFEditorImplWithNatTable nattable = XLIFFEditorImplWithNatTable.getCurrent();
boolean isMultiFile = nattable.isMultiFile();
if (isMultiFile) {
model.setMuliFiles(true);
IFile multiTempIFile = ((FileEditorInput) nattable.getEditorInput()).getFile();
ArrayList<IFile> selectIFiles = (ArrayList<IFile>) ResourceUtils.filesToIFiles(nattable.getMultiFileList());
model.setMultiOper(new MultiFilesOper(selectIFiles.get(0).getProject(), selectIFiles, multiTempIFile));
} else {
model.setMuliFiles(false);
}
}
use of net.heartsome.cat.ts.ui.util.MultiFilesOper 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;
}
use of net.heartsome.cat.ts.ui.util.MultiFilesOper in project translationstudio8 by heartsome.
the class OpenMultiXliffHandler method execute.
@SuppressWarnings("unchecked")
public Object execute(ExecutionEvent event) throws ExecutionException {
IViewPart viewPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("net.heartsome.cat.common.ui.navigator.view");
ISelection currentSelection = (StructuredSelection) viewPart.getSite().getSelectionProvider().getSelection();
if (currentSelection.isEmpty() || !(currentSelection instanceof IStructuredSelection)) {
return null;
}
IStructuredSelection structuredSelection = (IStructuredSelection) currentSelection;
Iterator<Object> selectIt = structuredSelection.iterator();
final ArrayList<IFile> selectIFiles = new ArrayList<IFile>();
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
shell = window.getShell();
// 先验证是否跨项目
IProject selectedProject = null;
while (selectIt.hasNext()) {
Object object = selectIt.next();
if (object instanceof IFile) {
IFile iFile = (IFile) object;
if (!CommonFunction.validXlfExtension(iFile.getFileExtension())) {
MessageDialog.openInformation(shell, Messages.getString("handlers.OpenMultiXliffHandler.msgTitle"), MessageFormat.format(Messages.getString("handlers.OpenMultiXliffHandler.msg1"), iFile.getFullPath().toOSString()));
continue;
}
selectIFiles.add(iFile);
if (selectedProject == null) {
selectedProject = iFile.getProject();
} else {
if (selectedProject != iFile.getProject()) {
MessageDialog.openInformation(shell, Messages.getString("handlers.OpenMultiXliffHandler.msgTitle"), Messages.getString("handlers.OpenMultiXliffHandler.msg2"));
return null;
}
}
} else if (object instanceof IContainer) {
IContainer selectContainer = (IContainer) object;
if (selectedProject == null) {
selectedProject = selectContainer.getProject();
}
// 判断当前文件夹是否处于 XLIFF 文件夹下
try {
ResourceUtils.getXliffs(selectContainer, selectIFiles);
} catch (CoreException e) {
logger.error(Messages.getString("handlers.OpenMultiXliffHandler.logger1"), selectContainer.getFullPath().toOSString(), e);
}
}
}
// 过滤重复选择文件
CommonFunction.removeRepeateSelect(selectIFiles);
if (selectIFiles.size() < 2) {
MessageDialog.openInformation(shell, Messages.getString("handlers.OpenMultiXliffHandler.msgTitle"), Messages.getString("handlers.OpenMultiXliffHandler.msg3"));
return null;
}
MultiFilesOper oper = new MultiFilesOper(selectedProject, selectIFiles);
// 先验证这些文件是否已经合并打开,如果是,则退出
if (oper.validExist()) {
return null;
}
// 判断是否有重复打开的文件,并删除缓存中要合并打开的文件。
if (oper.hasOpenedIFile()) {
if (oper.getSelectIFiles().size() <= 0) {
MessageDialog.openInformation(shell, Messages.getString("handlers.OpenMultiXliffHandler.msgTitle"), Messages.getString("handlers.OpenMultiXliffHandler.msg4"));
return null;
} else {
boolean isResponse = MessageDialog.openConfirm(shell, Messages.getString("handlers.OpenMultiXliffHandler.msgTitle2"), Messages.getString("handlers.OpenMultiXliffHandler.msg5"));
if (isResponse) {
if (oper.getSelectIFiles().size() < 2) {
MessageDialog.openInformation(shell, Messages.getString("handlers.OpenMultiXliffHandler.msgTitle"), Messages.getString("handlers.OpenMultiXliffHandler.msg6"));
return null;
}
} else {
return null;
}
}
}
final IFile multiIFile = oper.createMultiTempFile();
if (multiIFile != null && multiIFile.exists()) {
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(Messages.getString("handler.OpenMultiXliffHandler.tip1"), 10);
IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 7, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
// 进行判断所选择文件的语言对是否符合标准,先解析文件
final XLFHandler xlfHander = new XLFHandler();
final Map<String, Object> newResultMap = xlfHander.openFiles(ResourceUtils.iFilesToFiles(selectIFiles), subMonitor);
// 针对解析失败
if (newResultMap == null || QAConstant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) newResultMap.get(QAConstant.RETURNVALUE_RESULT)) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
MessageDialog.openInformation(shell, Messages.getString("handlers.OpenMultiXliffHandler.msgTitle"), (String) newResultMap.get(Constant.RETURNVALUE_MSG));
}
});
return;
}
// 验证是否有多个语言
boolean hasDiffrentLangPair = false;
Map<String, ArrayList<String>> langMap = xlfHander.getLanguages();
if (langMap.size() > 1) {
hasDiffrentLangPair = true;
} else {
for (Entry<String, ArrayList<String>> entry : langMap.entrySet()) {
if (entry.getValue().size() > 1) {
hasDiffrentLangPair = true;
}
}
}
if (monitor.isCanceled()) {
return;
}
monitor.worked(1);
if (hasDiffrentLangPair) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
MessageDialog.openInformation(shell, Messages.getString("handlers.OpenMultiXliffHandler.msgTitle"), Messages.getString("handlers.OpenMultiXliffHandler.msg7"));
}
});
// 先删除临时文件,再退出
try {
multiIFile.delete(true, monitor);
} catch (CoreException e) {
logger.error(Messages.getString("handlers.OpenMultiXliffHandler.logger2"), e);
}
return;
}
final boolean[] validateResult = new boolean[] { false };
Display.getDefault().syncExec(new Runnable() {
public void run() {
validateResult[0] = XLFValidator.validateXlifIFiles(selectIFiles);
}
});
if (!validateResult[0]) {
try {
multiIFile.delete(true, monitor);
} catch (CoreException e) {
logger.error(Messages.getString("handlers.OpenMultiXliffHandler.logger2"), e);
}
return;
}
final FileEditorInput input = new FileEditorInput(multiIFile);
if (monitor.isCanceled()) {
return;
}
monitor.worked(1);
Display.getDefault().syncExec(new Runnable() {
public void run() {
try {
// UNDO 这里合并打开时,要考虑传入参数xlfHandler,以防多次解析文件带来的消耗。
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, XLIFF_EDITOR_ID, true);
} catch (PartInitException e) {
e.printStackTrace();
}
}
});
if (monitor.isCanceled()) {
return;
}
monitor.worked(1);
monitor.done();
}
};
try {
new ProgressMonitorDialog(shell).run(true, true, runnable);
} catch (Exception e) {
logger.error(Messages.getString("handlers.OpenMultiXliffHandler.logger3"), e);
}
} else {
MessageDialog.openInformation(shell, Messages.getString("handlers.OpenMultiXliffHandler.msgTitle"), Messages.getString("handlers.OpenMultiXliffHandler.msg8"));
return null;
}
return null;
}
use of net.heartsome.cat.ts.ui.util.MultiFilesOper in project translationstudio8 by heartsome.
the class NumberOrTagConsisQAHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
boolean isMultiFile = false;
IFile multiTempIFile = null;
IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
// 改为布局
if (editorPart != null && editorPart instanceof XLIFFEditorImplWithNatTable) {
String qaItem = event.getParameter("qaItemId");
XLIFFEditorImplWithNatTable nattable = (XLIFFEditorImplWithNatTable) editorPart;
ArrayList<IFile> selectIFiles = new ArrayList<IFile>();
FileEditorInput input = (FileEditorInput) nattable.getEditorInput();
// 首先判断是否是合并打开的文件
if (nattable.isMultiFile()) {
isMultiFile = true;
}
if (isMultiFile) {
multiTempIFile = input.getFile();
List<String> multiFilesList = new XLFHandler().getMultiFiles(multiTempIFile);
for (String filePath : multiFilesList) {
selectIFiles.add(ResourceUtils.fileToIFile(filePath));
}
} else {
selectIFiles.add(input.getFile());
}
QAModel model = new QAModel();
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
shell = window.getShell();
// 先调用方法,查看品质检查结果视图是否处于显示状态,如果是显示的,就删除数据
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));
if (isMultiFile) {
model.setMuliFiles(true);
model.setMultiOper(new MultiFilesOper(selectIFiles.get(0).getProject(), selectIFiles, multiTempIFile));
} else {
model.setMuliFiles(false);
}
boolean isNumberQA = false;
if (QAConstant.QA_NUMBER.equals(qaItem)) {
isNumberQA = true;
} else if (QAConstant.QA_TAG.equals(qaItem)) {
isNumberQA = false;
}
List<String> fileList = new ArrayList<String>();
for (IFile iFIle : selectIFiles) {
fileList.add(iFIle.getLocation().toOSString());
}
qaResult.setFilePathList(fileList);
HsMultiActiveCellEditor.commit(true);
beginQA(selectIFiles, model, isNumberQA, qaResult);
}
return null;
}
use of net.heartsome.cat.ts.ui.util.MultiFilesOper in project translationstudio8 by heartsome.
the class LockRepeatedSegmentHandler method execute.
@Override
public Object execute(final ExecutionEvent event, final List<IFile> iFileList) {
list = iFileList;
tmMatcher = new TmMatcher();
isCancel = false;
continuee = true;
isLocked = false;
if (list == null || list.isEmpty()) {
if (list.size() == 0) {
MessageDialog.openInformation(shell, Messages.getString("translation.LockRepeatedSegmentHandler.msgTitle"), Messages.getString("translation.LockRepeatedSegmentHandler.msg1"));
return null;
}
return null;
}
try {
window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
} catch (ExecutionException e1) {
LOGGER.error("", e1);
e1.printStackTrace();
}
// 首先验证是否是合并打开的文件 --robert
if (isEditor) {
IEditorReference[] editorRefe = window.getActivePage().findEditors(new FileEditorInput(list.get(0)), XLIFF_EDITOR_ID, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID);
if (editorRefe.length <= 0) {
return null;
}
nattable = (XLIFFEditorImplWithNatTable) editorRefe[0].getEditor(true);
// 针对合并打开
if (nattable.isMultiFile()) {
list = ResourceUtils.filesToIFiles(nattable.getMultiFileList());
}
}
// 添加验证 peason
List<IFile> lstFiles = new ArrayList<IFile>();
XLFValidator.resetFlag();
for (IFile iFile : list) {
if (!XLFValidator.validateXliffFile(iFile)) {
lstFiles.add(iFile);
}
}
XLFValidator.resetFlag();
if (!(list instanceof ArrayList)) {
list = new ArrayList<IFile>(list);
}
list.removeAll(lstFiles);
if (list.size() == 0) {
return null;
}
CommonFunction.removeRepeateSelect(list);
final LockRepeatedSegmentDialog dialog = new LockRepeatedSegmentDialog(shell, list, Messages.getString("translation.LockRepeatedSegmentHandler.dialog"));
if (dialog.open() == LockRepeatedSegmentDialog.OK) {
isLockInnerRepeatedSegment = dialog.isLockInnerRepeatedSegment();
isLockTM100Segment = dialog.isLockTM100Segment();
isLockTM101Segment = dialog.isLockTM101Segment();
if (!dialog.isLockInnerRepeatedSegment() && !dialog.isLockTM100Segment() && !dialog.isLockTM101Segment()) {
// “锁定内部”、“锁定100%”、“锁定101%”都未选中。
return null;
}
if (!isEditor) {
// 如果针对单个文件, 先验证是否有合并打开的
MultiFilesOper oper = new MultiFilesOper(list.get(0).getProject(), (ArrayList<IFile>) list);
// 如果有合并打开的文件,那么将这种转换成针对编辑器的方式处理
if (oper.validExist()) {
final IFile multiTempIFile = oper.getMultiFilesTempIFile(true);
IEditorReference[] editorRefe = window.getActivePage().findEditors(new FileEditorInput(multiTempIFile), XLIFF_EDITOR_ID, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID);
// 如果这几个文件没有合并打开,
if (editorRefe.length > 0) {
nattable = (XLIFFEditorImplWithNatTable) editorRefe[0].getEditor(true);
continuee = false;
}
}
}
// 开始进行处理
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
int totalWork = dialog.isLockInnerRepeatedSegment() ? list.size() : 0;
totalWork = (dialog.isLockTM100Segment() || dialog.isLockTM101Segment()) ? totalWork * 2 : totalWork;
monitor.beginTask(Messages.getString("translation.LockRepeatedSegmentHandler.task1"), totalWork);
// 修改结果显示为是否成功
final LockRepeatedSegmentResultDialog lrsrd = new LockRepeatedSegmentResultDialog(shell, list);
// 是否进行外部匹配
boolean checkTM = false;
curProject = list.get(0).getProject();
// 锁定外部完全匹配与外部上下文匹配
if ((dialog.isLockTM100Segment() || dialog.isLockTM101Segment())) {
// 如果是针对编辑器,那么将里面的文件进行统一处理
if (isEditor) {
LockTMSegment lts = lockTMSegmentOFEditor(list, dialog.isLockTM100Segment(), dialog.isLockTM101Segment(), monitor);
// 用户指定退出操作
if (lts == null && isCancel) {
return;
}
lrsrd.setLockedFullMatchResult(lts.getLockedFullMatchResult());
lrsrd.setLockedContextResult(lts.getLockedContextResult());
lrsrd.setTuNumResult(lts.getTuNumResult());
checkTM = true;
} else {
if (continuee) {
Map<String, Integer> lockedFullMatchResultMap = new HashMap<String, Integer>();
Map<String, Integer> lockedContextMatchResultMap = new HashMap<String, Integer>();
Map<String, Integer> lockedTuNumResultMap = new HashMap<String, Integer>();
for (int i = 0; i < list.size(); i++) {
IFile iFile = list.get(i);
LockTMSegment lts = lockTMSegment(Arrays.asList(iFile), dialog.isLockTM100Segment(), dialog.isLockTM101Segment(), monitor);
if (lts == null && isCancel) {
return;
}
// 返回的为空,是解析异常的文件被删除了。
if (lts != null) {
lockedFullMatchResultMap.putAll(lts.getLockedFullMatchResult());
lockedContextMatchResultMap.putAll(lts.getLockedContextResult());
lockedTuNumResultMap.putAll(lts.getTuNumResult());
} else {
i--;
}
}
lrsrd.setLockedFullMatchResult(lockedFullMatchResultMap);
lrsrd.setLockedContextResult(lockedContextMatchResultMap);
lrsrd.setTuNumResult(lockedTuNumResultMap);
checkTM = true;
} else {
LockTMSegment lts = lockTMSegmentOFEditor(list, dialog.isLockTM100Segment(), dialog.isLockTM101Segment(), monitor);
if (lts == null && isCancel) {
return;
}
lrsrd.setLockedFullMatchResult(lts.getLockedFullMatchResult());
lrsrd.setLockedContextResult(lts.getLockedContextResult());
lrsrd.setTuNumResult(lts.getTuNumResult());
checkTM = true;
}
}
}
// 锁定内部重复
if (dialog.isLockInnerRepeatedSegment()) {
SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, list.size(), SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
HashMap<String, Integer> lockedInnerRepeatedResault = new HashMap<String, Integer>();
HashMap<String, Integer> tuNumResult = null;
if (!checkTM) {
tuNumResult = new HashMap<String, Integer>();
}
Map<String, int[]> resMap = lockInnerRepeatedSegment(list, subMonitor, checkTM);
for (IFile iFile : list) {
String filePath = ResourceUtils.iFileToOSPath(iFile);
int[] res = resMap.get(filePath);
if (!checkTM) {
int countTU = res[0];
tuNumResult.put(filePath, countTU);
}
int countLockedInnerRepeatedSegment = res[1];
lockedInnerRepeatedResault.put(filePath, countLockedInnerRepeatedSegment);
}
lrsrd.setLockedInnerRepeatedResault(lockedInnerRepeatedResault);
if (!checkTM) {
lrsrd.setTuNumResult(tuNumResult);
}
}
Display.getDefault().asyncExec(new Runnable() {
public void run() {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (editor != null && editor instanceof XLIFFEditorImplWithNatTable) {
XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
xliffEditor.reloadXliff();
}
// lrsrd.open();
if (hasWrongResults(list, lrsrd)) {
MessageDialog.openInformation(shell, Messages.getString("translation.LockRepeatedSegmentHandler.msgTitle"), Messages.getString("dialog.LockRepeatedSegmentResultDialog.locksuccesful"));
} else {
MessageDialog.openInformation(shell, Messages.getString("translation.LockRepeatedSegmentHandler.msgTitle"), Messages.getString("dialog.LockRepeatedSegmentResultDialog.locksuccesful"));
}
lrsrd.close();
HsMultiActiveCellEditor.refrushCellsEditAbility();
}
});
} finally {
monitor.done();
}
}
};
try {
new ProgressMonitorDialog(shell).run(true, true, runnable);
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
Aggregations