Java Code Examples for org.eclipse.core.runtime.SubProgressMonitor#setTaskName()

The following examples show how to use org.eclipse.core.runtime.SubProgressMonitor#setTaskName() . 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: TmxLargeFileDataAccess.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 删除重复文本段 删除重复的TU,原文和译文相同。删除时如果TU中只有2个TUV,则直接删除TU;如果TU中有超过2个TUV则只删除当前TUV 保留最新的TUV
 * @return ;
 */
public boolean deleteDupaicate(IProgressMonitor monitor, boolean ignoreTag, boolean ignoreCase) {
	monitor.beginTask("", 100);
	SubProgressMonitor subFilerJob = new SubProgressMonitor(monitor, 40);
	subFilerJob.setTaskName(Messages.getString("core.fileAccess.filterDupliacteSegment"));
	TmxFilterQueryUtil filterQuery = new TmxFilterQueryUtil(container, super.currSrcLang, super.currTgtLang);
	filterQuery.setIngoreTag(ignoreTag);
	filterQuery.setIgnoreCase(ignoreCase);
	List<String> filterResultList = filterQuery.getDuplicate4DeleteIds(subFilerJob);
	subFilerJob.done();
	if (filterResultList.size() == 0) {
		return false;
	}

	SubProgressMonitor subDeleteJob = new SubProgressMonitor(monitor, 60);
	subDeleteJob.setTaskName(Messages.getString("core.fileAccess.deleteDuplicateSegment"));
	deleteTus(filterResultList.toArray(new String[] {}), subDeleteJob);
	subDeleteJob.done();

	return true;
}
 
Example 2
Source File: TmxLargeFileDataAccess.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 删除相同原文不同译文的TU,删除时如果TU中只有2个TUV,则直接删除TU;如果TU中有超过2个TUV则只删除当前TUV
 * @param ignoreTag
 * @return ;
 */

public boolean deleteSameSrcDiffTgt(IProgressMonitor monitor, boolean ignoreTag, boolean ignoreCase) {
	monitor.beginTask("", 100);
	SubProgressMonitor subFilerJob = new SubProgressMonitor(monitor, 40);
	subFilerJob.setTaskName(Messages.getString("core.fileAccess.filterSameSrcDiffTgtSegment"));
	TmxFilterQueryUtil filterQuery = new TmxFilterQueryUtil(container, super.currSrcLang, super.currTgtLang);
	filterQuery.setIngoreTag(ignoreTag);
	filterQuery.setIgnoreCase(ignoreCase);
	List<String> filterResultList = filterQuery.getSrcSameButTgtDiff4DeleteIds(subFilerJob);
	subFilerJob.done();
	if (filterResultList.size() == 0) {
		return false;
	}

	SubProgressMonitor subDeleteJob = new SubProgressMonitor(monitor, 60);
	subDeleteJob.setTaskName(Messages.getString("core.fileAccess.deleteSameSrcDiffTgtSegment"));
	deleteTus(filterResultList.toArray(new String[] {}), subDeleteJob);
	subDeleteJob.done();

	return true;

}
 
Example 3
Source File: DatabaseDataAccess.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * (non-Javadoc)
 * @see net.heartsome.cat.te.core.tmxdata.AbstractTmxDataAccess#deleteTgtEmpty(org.eclipse.core.runtime.IProgressMonitor)
 */
@Override
public boolean deleteTgtEmpty(IProgressMonitor monitor,boolean ignoreTag) {

	try {
		monitor.beginTask("", 100);
		monitor.setTaskName(Messages.getString("core.databaseAccess.filter.empty.taskname"));
		SubProgressMonitor subFilterTask = new SubProgressMonitor(monitor, 30);
		List<Integer> tgtEmptyTU = facade.getTgtEmptyTU(super.currTgtLang, subFilterTask, ignoreTag);
		SubProgressMonitor subDeleteTask = new SubProgressMonitor(monitor, 70);
		if (tgtEmptyTU.isEmpty()) {
			subDeleteTask.done();
			return false;
		}
		subDeleteTask.setTaskName(Messages.getString("core.databaseAccess.delete.empty.taskname"));
		facade.deleteTuByIds(tgtEmptyTU, currSrcLang, currTgtLang, null, subDeleteTask);
		monitor.done();
	} catch (SQLException e) {
		LOGGER.error("", e);

	} finally {
		monitor.done();
	}
	return false;
}
 
Example 4
Source File: DatabaseDataAccess.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * (non-Javadoc)
 * @see net.heartsome.cat.te.core.tmxdata.AbstractTmxDataAccess#deleteDupaicate(org.eclipse.core.runtime.IProgressMonitor,
 *      boolean)
 */
@Override
public boolean deleteDupaicate(IProgressMonitor monitor, boolean ignoreTag, boolean ignoreCase) {
	DatabaseAccessUtils deleteUtil = new DatabaseAccessUtils(facade, currSrcLang, currTgtLang, ignoreTag,
			ignoreCase);
	try {
		monitor.beginTask("", 100);
		SubProgressMonitor subFilerJob = new SubProgressMonitor(monitor, 40);
		subFilerJob.setTaskName(Messages.getString("core.fileAccess.filterDupliacteSegment"));
		List<Integer> tuids = deleteUtil.getId4DulicateDelete(subFilerJob);
		subFilerJob.done();
		SubProgressMonitor subdeleteJob = new SubProgressMonitor(monitor, 60);
		subdeleteJob.setTaskName(Messages.getString("core.fileAccess.deleteDuplicateSegment"));
		facade.deleteTuByIds(tuids, currSrcLang, currTgtLang, System.getProperty("user.name"), subdeleteJob);
		subdeleteJob.done();
	} catch (SQLException e) {
		LOGGER.error("", e);
	} finally {
		monitor.done();
	}
	return false;
}
 
Example 5
Source File: DatabaseDataAccess.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * (non-Javadoc)
 * @see net.heartsome.cat.te.core.tmxdata.AbstractTmxDataAccess#deleteSameSrcDiffTgt(org.eclipse.core.runtime.IProgressMonitor,
 *      boolean)
 */
@Override
public boolean deleteSameSrcDiffTgt(IProgressMonitor monitor, boolean ignoreTag, boolean ignoreCase) {
	DatabaseAccessUtils deleteUtil = new DatabaseAccessUtils(facade, currSrcLang, currTgtLang, ignoreTag,
			ignoreCase);
	try {
		SubProgressMonitor subFilerJob = new SubProgressMonitor(monitor, 40);
		subFilerJob.setTaskName(Messages.getString("core.fileAccess.filterSameSrcDiffTgtSegment"));
		List<Integer> tuids = deleteUtil.getId4SrcSameDiffTgtDelete(subFilerJob);
		SubProgressMonitor subdeleteJob = new SubProgressMonitor(monitor, 60);
		subdeleteJob.setTaskName(Messages.getString("core.fileAccess.deleteSameSrcDiffTgtSegment"));
		facade.deleteTuByIds(tuids, currSrcLang, currTgtLang, System.getProperty("user.name"), subdeleteJob);
	} catch (SQLException e) {
		LOGGER.error("", e);
	} finally {
		monitor.done();
	}
	return false;
}
 
Example 6
Source File: LockRepeatedSegmentHandler.java    From translationstudio8 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 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: 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 9
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;
}