Java Code Examples for org.eclipse.core.runtime.SubProgressMonitor#PREPEND_MAIN_LABEL_TO_SUBTASK

The following examples show how to use org.eclipse.core.runtime.SubProgressMonitor#PREPEND_MAIN_LABEL_TO_SUBTASK . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NumberOrTagConsisQAHandler.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 解析文件
 * @param selectIFiles
 */
private boolean openFile(ArrayList<IFile> selectIFiles, IProgressMonitor monitor) {
	for (final IFile iFile : selectIFiles) {
		IProgressMonitor openMonitor = new SubProgressMonitor(monitor, 1,
				SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
		Map<String, Object> newResultMap = xmlHandler.openFile(iFile.getLocation().toOSString(), openMonitor);
		// 针对退出解析
		if (newResultMap != null
				&& QAConstant.RETURNVALUE_RESULT_RETURN.equals(newResultMap.get(QAConstant.RETURNVALUE_RESULT))) {
			return false;
		}

		if (newResultMap == null
				|| QAConstant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) newResultMap
						.get(QAConstant.RETURNVALUE_RESULT)) {
			return false;
		}
	}
	return true;
}
 
Example 2
Source File: JarFileExportOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Exports the resources as specified by the JAR package.
 *
 * @param	progressMonitor	the progress monitor that displays the progress
 * @throws InvocationTargetException thrown when an ecxeption occurred
 * @throws InterruptedException thrown when cancelled
 * @see	#getStatus()
 */
@Override
protected void execute(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
	int count= fJarPackages.length;
	progressMonitor.beginTask("", count); //$NON-NLS-1$
	try {
		for (int i= 0; i < count; i++) {
			SubProgressMonitor subProgressMonitor= new SubProgressMonitor(progressMonitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
			fJarPackage= fJarPackages[i];
			if (fJarPackage != null)
				singleRun(subProgressMonitor);
		}
	} finally {
		progressMonitor.done();
	}
}
 
Example 3
Source File: CallerFinder.java    From lapse-plus with GNU General Public License v3.0 5 votes vote down vote up
public static Collection/*<MethodUnitPair>*/ findDeclarations(IProgressMonitor progressMonitor, String methodName, IJavaProject project, boolean isConstructor) {
    try {
        SearchRequestor searchRequestor = new MethodSearchRequestor.MethodDeclarationsSearchRequestor(); 
        SearchEngine searchEngine = new SearchEngine();

        IProgressMonitor monitor = new SubProgressMonitor(
                progressMonitor, 5, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
        monitor.beginTask("Searching for calls to " + 
                methodName + (project != null ? " in " + project.getProject().getName() : ""), 100);            
        IJavaSearchScope searchScope = getSearchScope(project);
        // This is kind of hacky: we need to make up a string name for the search to work right
        log("Looking for " + methodName);
        int matchType = !isConstructor ? IJavaSearchConstants.METHOD : IJavaSearchConstants.CONSTRUCTOR;
        SearchPattern pattern = SearchPattern.createPattern(
                methodName, 
                matchType,
                IJavaSearchConstants.DECLARATIONS,
                SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE );
        
        searchEngine.search(
                pattern, 
                new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() },
                searchScope, 
                searchRequestor, 
                monitor
                );

        if(searchRequestor instanceof MethodSearchRequestor.MethodDeclarationsSearchRequestor){                
            return ((MethodSearchRequestor.MethodDeclarationsSearchRequestor)searchRequestor).getMethodUnitPairs();
        }else{
            return ((MethodSearchRequestor.MethodReferencesSearchRequestor)searchRequestor).getMethodUnitPairs();
        }
    } catch (CoreException e) {
        JavaPlugin.log(e);

        return new LinkedList();
    }
}
 
Example 4
Source File: DocumentPart.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void reverseConvert() throws Exception {
	// 处理的单元为 w:p
	String xpath = "/w:document/w:body/descendant::w:p";
	
	int allPSum = getNodeCount(xpath);
	initWorkInterval(allPSum);
	
	IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 12, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
	subMonitor.beginTask("", 
			allPSum % workInterval == 0 ? (allPSum / workInterval) : (allPSum / workInterval) + 1);
	subMonitor.setTaskName(Messages.getString("xlf2Docx.task5"));
	
	ap.selectXPath(xpath);
	int traverPIdx = 0;
	while(ap.evalXPath() != -1){
		traverPIdx ++;
		analysisReversePnode();
		
		monitorWork(subMonitor, traverPIdx, false);
	}
	xm.output(partPath);
	monitorWork(subMonitor, traverPIdx, true);
	subMonitor.done();
	
	
	//再处理可翻译属性
	xpath = "/w:document/w:body/descendant::w:p/w:r/w:pict/v:shape/@alt";
	reverseTranslateAttributes(xpath);
	monitor.worked(1);
	if (monitor.isCanceled()) {
		throw new OperationCanceledException(Messages.getString("docxConvert.task3"));
	}
}
 
Example 5
Source File: DocumentPart.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void reverseConvert() throws Exception {
	// 处理的单元为 w:p
	String xpath = "/w:document/w:body/descendant::w:p";
	
	int allPSum = getNodeCount(xpath);
	initWorkInterval(allPSum);
	
	IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 12, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
	subMonitor.beginTask("", 
			allPSum % workInterval == 0 ? (allPSum / workInterval) : (allPSum / workInterval) + 1);
	subMonitor.setTaskName(Messages.getString("xlf2Docx.task5"));
	
	ap.selectXPath(xpath);
	int traverPIdx = 0;
	while(ap.evalXPath() != -1){
		traverPIdx ++;
		analysisReversePnode();
		
		monitorWork(subMonitor, traverPIdx, false);
	}
	xm.output(partPath);
	monitorWork(subMonitor, traverPIdx, true);
	subMonitor.done();
	
	
	//再处理可翻译属性
	xpath = "/w:document/w:body/descendant::w:p/w:r/w:pict/v:shape/@alt";
	reverseTranslateAttributes(xpath);
	monitor.worked(1);
	if (monitor.isCanceled()) {
		throw new OperationCanceledException(Messages.getString("docxConvert.task3"));
	}
}
 
Example 6
Source File: Policy.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
    * Return a submonitor for monitor 
 * @param monitor the parent progress monitor
 * @param ticks the number of work ticks allocated from the
 *    parent monitor
 * @return IProgressMonitor
    */
public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) {
	if (monitor == null)
		return new NullProgressMonitor();
	if (monitor instanceof NullProgressMonitor)
		return monitor;
	return new SubProgressMonitor(monitor, ticks, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
}
 
Example 7
Source File: LockRepeatedSegmentHandler.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
private LockTMSegment lockTMSegment(final List<IFile> iFileList, boolean isLockTM100Segment,
		boolean isLockTM101Segment, IProgressMonitor monitor) {
	SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, iFileList.size(),
			SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
	subMonitor.beginTask("", 10);
	subMonitor.setTaskName(Messages.getString("translation.LockRepeatedSegmentHandler.task2"));
	XLFHandler xlfHandler = null;
	singleNattable = null;
	Display.getDefault().syncExec(new Runnable() {
		public void run() {
			IEditorReference[] editorRefer = window.getActivePage().findEditors(
					new FileEditorInput(iFileList.get(0)), XLIFF_EDITOR_ID,
					IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID);
			if (editorRefer.length > 0) {
				singleNattable = ((XLIFFEditorImplWithNatTable) editorRefer[0].getEditor(true));
			}
		}
	});
	if (singleNattable != null) {
		xlfHandler = singleNattable.getXLFHandler();
	}

	if (xlfHandler == null) {
		xlfHandler = new XLFHandler();
		for (final IFile iFile : iFileList) {
			File file = iFile.getLocation().toFile();
			try {
				Map<String, Object> resultMap = xlfHandler.openFile(file);
				if (resultMap == null
						|| Constant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) resultMap
								.get(Constant.RETURNVALUE_RESULT)) {
					// 打开文件失败。
					Display.getDefault().syncExec(new Runnable() {
						public void run() {
							MessageDialog.openInformation(shell, Messages
									.getString("translation.LockRepeatedSegmentHandler.msgTitle"), MessageFormat
									.format(Messages.getString("translation.LockRepeatedSegmentHandler.msg2"),
											iFile.getLocation().toOSString()));
						}
					});
					list.remove(iFile);
					return null;
				}
			} catch (Exception e) {
				LOGGER.error("", e);
				e.printStackTrace();
			}
			if (!monitorWork(monitor, 1)) {
				return null;
			}
		}
	} else {
		subMonitor.worked(1);
	}

	List<String> filesPath = ResourceUtils.IFilesToOsPath(iFileList);
	LockTMSegment lts = new LockTMSegment(xlfHandler, tmMatcher, filesPath, curProject);
	lts.setLockedContextMatch(isLockTM101Segment);
	lts.setLockedFullMatch(isLockTM100Segment);
	// 查记忆库并锁定,占剩下的 9/10。
	SubProgressMonitor subSubMonitor = new SubProgressMonitor(subMonitor, 9,
			SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
	if (!lts.executeTranslation(subSubMonitor)) {
		isCancel = true;
		subSubMonitor.done();
		subMonitor.done();
		return null;
	}
	subSubMonitor.done();
	subMonitor.done();

	if (singleNattable != null) {
		Display.getDefault().syncExec(new Runnable() {
			public void run() {
				singleNattable.getTable().redraw();
			}
		});
	}
	Map<String, List<String>> needLockRowIdMap = lts.getNeedLockRowIdMap();
	if (needLockRowIdMap.size() > 0) {
		lockTU(xlfHandler, needLockRowIdMap);
	}
	return lts;
}
 
Example 8
Source File: QualityAssurance.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 解析该文件,若返回false,则标志退出程序的执行
 */
public boolean openFile(IProgressMonitor monitor) {
	
	for (int fileIndex = 0; fileIndex < model.getQaXlfList().size(); fileIndex++) {
		IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1,
				SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
		final IFile iFile = model.getQaXlfList().get(fileIndex);
		subMonitor.setTaskName(MessageFormat.format(Messages.getString("qa.QualityAssurance.tip5"), new Object[] {
				Messages.getString("qa.all.qa"), iFile.getFullPath().toString() }));
		continuResponse = QAConstant.QA_ZERO;
		
		try {
			Map<String, Object> newResultMap = handler.openFile(iFile.getLocation().toOSString(), subMonitor);
			// 针对退出解析
			if (newResultMap != null
					&& QAConstant.RETURNVALUE_RESULT_RETURN.equals(newResultMap.get(QAConstant.RETURNVALUE_RESULT))) {
				return false;
			}
			
			if (newResultMap == null
					|| QAConstant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) newResultMap
							.get(QAConstant.RETURNVALUE_RESULT)) {
				// 针对文件解析出错
				Display.getDefault().syncExec(new Runnable() {
					public void run() {
						boolean response = MessageDialog.openConfirm(shell, _ERROR, MessageFormat.format(
								Messages.getString("qa.QualityAssurance.tip6"), new Object[] { iFile.getFullPath().toOSString() }));
						if (response) {
							continuResponse = QAConstant.QA_FIRST;
						} else {
							continuResponse = QAConstant.QA_TWO;
						}
					}
				});
			}
			
			if (continuResponse == QAConstant.QA_FIRST) {
				model.getQaXlfList().remove(fileIndex);
				fileIndex--;
				continue;
			} else if (continuResponse == QAConstant.QA_TWO) {
				return false;
			}
			
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(Messages.getString("qa.all.log.openXmlError"), e);
		}
	}
	return true;
}
 
Example 9
Source File: FileAnalysisHandler.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 解析所有的xliff文件
 * @param handler
 * @param monitor
 * @return
 */
public boolean openXliff(QAXmlHandler handler, IProgressMonitor monitor) {
	for (int fileIndex = 0; fileIndex < model.getAnalysisIFileList().size(); fileIndex++) {
		IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1,
				SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);

		final IFile iFile = model.getAnalysisIFileList().get(fileIndex);
		subMonitor.setTaskName(MessageFormat.format(Messages.getString("qa.handlers.FileAnalysisHandler.tip5"),
				new Object[] { title, iFile.getFullPath().toString() }));

		continuResponse = QAConstant.QA_ZERO;
		try {
			Map<String, Object> newResultMap = handler.openFile(iFile.getLocation().toOSString(), subMonitor);
			// 针对退出解析
			if (newResultMap != null
					&& QAConstant.RETURNVALUE_RESULT_RETURN.equals(newResultMap.get(QAConstant.RETURNVALUE_RESULT))) {
				return false;
			}

			if (newResultMap == null
					|| QAConstant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) newResultMap
							.get(QAConstant.RETURNVALUE_RESULT)) {
				model.getErrorIFileList().add(iFile);
				// 针对文件解析出错
				Display.getDefault().syncExec(new Runnable() {
					public void run() {
						boolean response = MessageDialog.openConfirm(shell, Messages
								.getString("qa.all.dialog.error"), MessageFormat.format(Messages
								.getString("qa.all.tip.openXliffError"), new Object[] { iFile.getFullPath()
								.toOSString() }));
						if (response) {
							continuResponse = QAConstant.QA_FIRST;
						} else {
							continuResponse = QAConstant.QA_TWO;
						}
					}
				});
			}

			if (continuResponse == QAConstant.QA_FIRST) {
				model.getAnalysisIFileList().remove(fileIndex);
				fileIndex--;
				continue;
			} else if (continuResponse == QAConstant.QA_TWO) {
				return false;
			}

			allTUSize += handler.getTuSizeMap().get(iFile.getLocation().toOSString());
		} catch (Exception e) {
			MessageDialog.openError(shell, Messages.getString("qa.all.dialog.info"),
					Messages.getString("qa.all.log.openXmlError") + e);
			logger.error(Messages.getString("qa.all.log.openXmlError"), e);
			return false;
		}
	}
	return true;

}
 
Example 10
Source File: LockRepeatedSegmentHandler.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 专门处理以 nattble 形式打开的文件
 * @param iFileList
 * @param isLockTM100Segment
 * @param isLockTM101Segment
 * @param monitor
 * @return ;
 */
private LockTMSegment lockTMSegmentOFEditor(List<IFile> iFileList, boolean isLockTM100Segment,
		boolean isLockTM101Segment, IProgressMonitor monitor) {
	XLFHandler xlfHandler = nattable.getXLFHandler();
	SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, iFileList.size(),
			SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
	subMonitor.beginTask("", 10);
	subMonitor.setTaskName(Messages.getString("translation.LockRepeatedSegmentHandler.task2"));

	// 解析文件,占 1/10,这里是直接获取编辑器的XLFHandler,故不需解析
	if (!monitorWork(subMonitor, 1)) {
		return null;
	}

	List<String> filesPath = ResourceUtils.IFilesToOsPath(iFileList);
	LockTMSegment lts = new LockTMSegment(xlfHandler, tmMatcher, filesPath, curProject);
	lts.setLockedContextMatch(isLockTM101Segment);
	lts.setLockedFullMatch(isLockTM100Segment);
	// 查记忆库并锁定,占剩下的 9/10。
	IProgressMonitor subSubMonitor = new SubProgressMonitor(monitor, 9,
			SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
	if (!lts.executeTranslation(subSubMonitor)) {
		subSubMonitor.done();
		subMonitor.done();
		isCancel = true;
		return null;
	}
	subSubMonitor.done();
	subMonitor.done();

	if (nattable != null) {
		Display.getDefault().syncExec(new Runnable() {
			public void run() {
				nattable.getTable().redraw();
			}
		});
	}
	Map<String, List<String>> needLockRowIdMap = lts.getNeedLockRowIdMap();
	if (needLockRowIdMap.size() > 0) {
		lockTU(xlfHandler, needLockRowIdMap);
	}
	return lts;
}
 
Example 11
Source File: LockRepeatedSegmentHandler.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
private LockTMSegment lockTMSegment(final List<IFile> iFileList, boolean isLockTM100Segment,
		boolean isLockTM101Segment, IProgressMonitor monitor) {
	SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, iFileList.size(),
			SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
	subMonitor.beginTask("", 10);
	subMonitor.setTaskName(Messages.getString("translation.LockRepeatedSegmentHandler.task2"));
	XLFHandler xlfHandler = null;
	singleNattable = null;
	Display.getDefault().syncExec(new Runnable() {
		public void run() {
			IEditorReference[] editorRefer = window.getActivePage().findEditors(
					new FileEditorInput(iFileList.get(0)), XLIFF_EDITOR_ID,
					IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID);
			if (editorRefer.length > 0) {
				singleNattable = ((XLIFFEditorImplWithNatTable) editorRefer[0].getEditor(true));
			}
		}
	});
	if (singleNattable != null) {
		xlfHandler = singleNattable.getXLFHandler();
	}

	if (xlfHandler == null) {
		xlfHandler = new XLFHandler();
		for (final IFile iFile : iFileList) {
			File file = iFile.getLocation().toFile();
			try {
				Map<String, Object> resultMap = xlfHandler.openFile(file);
				if (resultMap == null
						|| Constant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) resultMap
								.get(Constant.RETURNVALUE_RESULT)) {
					// 打开文件失败。
					Display.getDefault().syncExec(new Runnable() {
						public void run() {
							MessageDialog.openInformation(shell, Messages
									.getString("translation.LockRepeatedSegmentHandler.msgTitle"), MessageFormat
									.format(Messages.getString("translation.LockRepeatedSegmentHandler.msg2"),
											iFile.getLocation().toOSString()));
						}
					});
					list.remove(iFile);
					return null;
				}
			} catch (Exception e) {
				LOGGER.error("", e);
				e.printStackTrace();
			}
			if (!monitorWork(monitor, 1)) {
				return null;
			}
		}
	} else {
		subMonitor.worked(1);
	}

	List<String> filesPath = ResourceUtils.IFilesToOsPath(iFileList);
	LockTMSegment lts = new LockTMSegment(xlfHandler, tmMatcher, filesPath, curProject);
	lts.setLockedContextMatch(isLockTM101Segment);
	lts.setLockedFullMatch(isLockTM100Segment);
	// 查记忆库并锁定,占剩下的 9/10。
	SubProgressMonitor subSubMonitor = new SubProgressMonitor(subMonitor, 9,
			SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
	if (!lts.executeTranslation(subSubMonitor)) {
		isCancel = true;
		subSubMonitor.done();
		subMonitor.done();
		return null;
	}
	subSubMonitor.done();
	subMonitor.done();

	if (singleNattable != null) {
		Display.getDefault().syncExec(new Runnable() {
			public void run() {
				singleNattable.getTable().redraw();
			}
		});
	}
	Map<String, List<String>> needLockRowIdMap = lts.getNeedLockRowIdMap();
	if (needLockRowIdMap.size() > 0) {
		lockTU(xlfHandler, needLockRowIdMap);
	}
	return lts;
}
 
Example 12
Source File: QualityAssurance.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 解析该文件,若返回false,则标志退出程序的执行
 */
public boolean openFile(IProgressMonitor monitor) {
	
	for (int fileIndex = 0; fileIndex < model.getQaXlfList().size(); fileIndex++) {
		IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1,
				SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
		final IFile iFile = model.getQaXlfList().get(fileIndex);
		subMonitor.setTaskName(MessageFormat.format(Messages.getString("qa.QualityAssurance.tip5"), new Object[] {
				Messages.getString("qa.all.qa"), iFile.getFullPath().toString() }));
		continuResponse = QAConstant.QA_ZERO;
		
		try {
			Map<String, Object> newResultMap = handler.openFile(iFile.getLocation().toOSString(), subMonitor);
			// 针对退出解析
			if (newResultMap != null
					&& QAConstant.RETURNVALUE_RESULT_RETURN.equals(newResultMap.get(QAConstant.RETURNVALUE_RESULT))) {
				return false;
			}
			
			if (newResultMap == null
					|| QAConstant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) newResultMap
							.get(QAConstant.RETURNVALUE_RESULT)) {
				// 针对文件解析出错
				Display.getDefault().syncExec(new Runnable() {
					public void run() {
						boolean response = MessageDialog.openConfirm(shell, _ERROR, MessageFormat.format(
								Messages.getString("qa.QualityAssurance.tip6"), new Object[] { iFile.getFullPath().toOSString() }));
						if (response) {
							continuResponse = QAConstant.QA_FIRST;
						} else {
							continuResponse = QAConstant.QA_TWO;
						}
					}
				});
			}
			
			if (continuResponse == QAConstant.QA_FIRST) {
				model.getQaXlfList().remove(fileIndex);
				fileIndex--;
				continue;
			} else if (continuResponse == QAConstant.QA_TWO) {
				return false;
			}
			
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(Messages.getString("qa.all.log.openXmlError"), e);
		}
	}
	return true;
}
 
Example 13
Source File: FileAnalysisHandler.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 解析所有的xliff文件
 * @param handler
 * @param monitor
 * @return
 */
public boolean openXliff(QAXmlHandler handler, IProgressMonitor monitor) {
	for (int fileIndex = 0; fileIndex < model.getAnalysisIFileList().size(); fileIndex++) {
		IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1,
				SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);

		final IFile iFile = model.getAnalysisIFileList().get(fileIndex);
		subMonitor.setTaskName(MessageFormat.format(Messages.getString("qa.handlers.FileAnalysisHandler.tip5"),
				new Object[] { title, iFile.getFullPath().toString() }));

		continuResponse = QAConstant.QA_ZERO;
		try {
			Map<String, Object> newResultMap = handler.openFile(iFile.getLocation().toOSString(), subMonitor);
			// 针对退出解析
			if (newResultMap != null
					&& QAConstant.RETURNVALUE_RESULT_RETURN.equals(newResultMap.get(QAConstant.RETURNVALUE_RESULT))) {
				return false;
			}

			if (newResultMap == null
					|| QAConstant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) newResultMap
							.get(QAConstant.RETURNVALUE_RESULT)) {
				model.getErrorIFileList().add(iFile);
				// 针对文件解析出错
				Display.getDefault().syncExec(new Runnable() {
					public void run() {
						boolean response = MessageDialog.openConfirm(shell, Messages
								.getString("qa.all.dialog.error"), MessageFormat.format(Messages
								.getString("qa.all.tip.openXliffError"), new Object[] { iFile.getFullPath()
								.toOSString() }));
						if (response) {
							continuResponse = QAConstant.QA_FIRST;
						} else {
							continuResponse = QAConstant.QA_TWO;
						}
					}
				});
			}

			if (continuResponse == QAConstant.QA_FIRST) {
				model.getAnalysisIFileList().remove(fileIndex);
				fileIndex--;
				continue;
			} else if (continuResponse == QAConstant.QA_TWO) {
				return false;
			}

			allTUSize += handler.getTuSizeMap().get(iFile.getLocation().toOSString());
		} catch (Exception e) {
			MessageDialog.openError(shell, Messages.getString("qa.all.dialog.info"),
					Messages.getString("qa.all.log.openXmlError") + e);
			logger.error(Messages.getString("qa.all.log.openXmlError"), e);
			return false;
		}
	}
	return true;

}
 
Example 14
Source File: CompilationUnitDocumentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Creates and returns a new sub-progress monitor for the
 * given parent monitor.
 *
 * @param monitor the parent progress monitor
 * @param ticks the number of work ticks allocated from the parent monitor
 * @return the new sub-progress monitor
 */
private IProgressMonitor getSubProgressMonitor(IProgressMonitor monitor, int ticks) {
	if (monitor != null)
		return new SubProgressMonitor(monitor, ticks, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);

	return new NullProgressMonitor();
}
 
Example 15
Source File: EditorUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Creates and returns a new sub-progress monitor for the
 * given parent monitor.
 *
 * @param monitor the parent progress monitor
 * @param ticks the number of work ticks allocated from the parent monitor
 * @return the new sub-progress monitor
 * @since 3.4
 */
private static IProgressMonitor getSubProgressMonitor(IProgressMonitor monitor, int ticks) {
	if (monitor != null)
		return new SubProgressMonitor(monitor, ticks, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);

	return new NullProgressMonitor();
}
 
Example 16
Source File: ChangedLinesComputer.java    From Pydev with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Creates and returns a new sub-progress monitor for the
 * given parent monitor.
 *
 * @param monitor the parent progress monitor
 * @param ticks the number of work ticks allocated from the parent monitor
 * @return the new sub-progress monitor
 * @since 3.4
 */
private static IProgressMonitor getSubProgressMonitor(IProgressMonitor monitor, int ticks) {
    if (monitor != null) {
        return new SubProgressMonitor(monitor, ticks, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
    }

    return new NullProgressMonitor();
}
 
Example 17
Source File: Policy.java    From APICloud-Studio with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Return a submonitor for cases when we do not know the number of ticks ...
 * The main task label will be prepended to the subtask label.
 * @param monitor the parent progress monitor
 * @param ticks the number of work ticks allocated from the
 *    parent monitor
 * @return IProgressMonitor
 */
public static IProgressMonitor infiniteSubMonitorFor(IProgressMonitor monitor, int ticks) {
	if (monitor == null)
		return new NullProgressMonitor();
	if (monitor instanceof NullProgressMonitor)
		return monitor;
	return new InfiniteSubProgressMonitor(monitor, ticks, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
}
 
Example 18
Source File: Progress.java    From translationstudio8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 返回<code>SubProgressMonitor</code>
 * @param parent
 * @param ticks
 * @return ;
 */
public static IProgressMonitor getSubMonitor(IProgressMonitor parent, int ticks) {
	return new SubProgressMonitor(getMonitor(parent), ticks, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
}
 
Example 19
Source File: Progress.java    From tmxeditor8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 返回<code>SubProgressMonitor</code>
 * @param parent
 * @param ticks
 * @return ;
 */
public static IProgressMonitor getSubMonitor(IProgressMonitor parent, int ticks) {
	return new SubProgressMonitor(getMonitor(parent), ticks, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
}
 
Example 20
Source File: Progress.java    From tmxeditor8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 返回<code>SubProgressMonitor</code>
 * @param parent
 * @param ticks
 * @return ;
 */
public static IProgressMonitor getSubMonitor(IProgressMonitor parent, int ticks) {
	return new SubProgressMonitor(getMonitor(parent), ticks, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
}