Java Code Examples for org.eclipse.core.runtime.SubProgressMonitor#beginTask()
The following examples show how to use
org.eclipse.core.runtime.SubProgressMonitor#beginTask() .
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: EclipseGitProgressTransformer.java From orion.server with Eclipse Public License 1.0 | 6 votes |
@Override public void beginTask(final String name, final int total) { endTask(); msg = name; lastWorked = 0; totalWork = total; task = new SubProgressMonitor(root, 1000); if (totalWork == UNKNOWN) task.beginTask(EMPTY_STRING, IProgressMonitor.UNKNOWN); else task.beginTask(EMPTY_STRING, totalWork); task.subTask(msg); if (job != null) { job.setTaskTotal(total); job.setTaskMessage(msg); } }
Example 2
Source File: InferTypeArgumentsConstraintsSolver.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void chooseTypes(ConstraintVariable2[] allConstraintVariables, SubProgressMonitor pm) { pm.beginTask("", allConstraintVariables.length); //$NON-NLS-1$ for (int i= 0; i < allConstraintVariables.length; i++) { ConstraintVariable2 cv= allConstraintVariables[i]; TypeEquivalenceSet set= cv.getTypeEquivalenceSet(); if (set == null) continue; //TODO: should not happen iff all unused constraint variables got pruned //TODO: should calculate only once per EquivalenceRepresentative; can throw away estimate TypeSet afterwards TType type= chooseSingleType((TypeSet) cv.getTypeEstimate()); //TODO: is null for Universe TypeSet setChosenType(cv, type); if (cv instanceof CollectionElementVariable2) { CollectionElementVariable2 elementCv= (CollectionElementVariable2) cv; fUpdate.addDeclaration(elementCv); } pm.worked(1); if (pm.isCanceled()) throw new OperationCanceledException(); } pm.done(); }
Example 3
Source File: CleanUpRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private Change[] cleanUpProject(IJavaProject project, CleanUpTarget[] targets, ICleanUp[] cleanUps, IProgressMonitor monitor) throws CoreException { CleanUpFixpointIterator iter= new CleanUpFixpointIterator(targets, cleanUps); SubProgressMonitor subMonitor= new SubProgressMonitor(monitor, 2 * targets.length * cleanUps.length); subMonitor.beginTask("", targets.length); //$NON-NLS-1$ subMonitor.subTask(Messages.format(FixMessages.CleanUpRefactoring_Parser_Startup_message, BasicElementLabels.getResourceName(project.getProject()))); try { while (iter.hasNext()) { iter.next(subMonitor); } return iter.getResult(); } finally { iter.dispose(); subMonitor.done(); } }
Example 4
Source File: Implementors.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Finds IMethod instances on the specified IType instances with identical signatures * as the specified IMethod parameter. * * @param method The method to find "equals" of. * @param types The types in which the search is performed. * * @return An array of methods which match the method parameter. */ private IJavaElement[] findMethods(IMethod method, IType[] types, IProgressMonitor progressMonitor) { Collection<IMethod> foundMethods = new ArrayList<IMethod>(); SubProgressMonitor subProgressMonitor = new SubProgressMonitor(progressMonitor, 10, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL); subProgressMonitor.beginTask("", types.length); //$NON-NLS-1$ try { for (int i = 0; i < types.length; i++) { IType type = types[i]; IMethod[] methods = type.findMethods(method); if (methods != null) { for (int j = 0; j < methods.length; j++) { foundMethods.add(methods[j]); } } subProgressMonitor.worked(1); } } finally { subProgressMonitor.done(); } return foundMethods.toArray(new IJavaElement[foundMethods.size()]); }
Example 5
Source File: DatabaseDataAccess.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * (non-Javadoc) * @see net.heartsome.cat.te.core.tmxdata.AbstractTmxDataAccess#batchAddTmxNote(org.eclipse.core.runtime.IProgressMonitor, * java.lang.String, java.lang.String) */ @Override public void batchAddTmxNote(IProgressMonitor monitor, String content, String filter) { monitor.beginTask("", 100); SubProgressMonitor filterJob = new SubProgressMonitor(monitor, 30); filterJob.beginTask("", 100); List<Integer> ids = new ArrayList<Integer>(); try { if (TeCoreConstant.FILTERID_allSeg.equals(filter)) {// 应用到整个数据库 ids = container.getDbOp().getAfterFilterTuPk(null, null, null); } else {// 应用到当前过滤结果 for (String str : super.tuIdentifiers) { ids.add(Integer.parseInt(str)); } } filterJob.done(); SubProgressMonitor addJob = new SubProgressMonitor(monitor, 70); facade.beginTransaction(); if (facade.batchAddTuNotes(content, ids, addJob)) { facade.commit(); } addJob.done(); } catch (SQLException e) { try { facade.rollback(); } catch (SQLException e1) { LOGGER.error("", e1); } LOGGER.error("", e); } finally { monitor.done(); } }
Example 6
Source File: DatabaseDataAccess.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * (non-Javadoc) * @see net.heartsome.cat.te.core.tmxdata.AbstractTmxDataAccess#batchAddTmxProp(org.eclipse.core.runtime.IProgressMonitor, * java.lang.String, java.lang.String, java.lang.String) */ @Override public void batchAddTmxProp(IProgressMonitor monitor, String type, String content, String filter) { monitor.beginTask("", 100); SubProgressMonitor filterJob = new SubProgressMonitor(monitor, 30); filterJob.beginTask("", 100); List<Integer> ids = new ArrayList<Integer>(); try { if (TeCoreConstant.FILTERID_allSeg.equals(filter)) {// 应用到整个数据库 ids = container.getDbOp().getAfterFilterTuPk(null, null, null); } else {// 应用到当前过滤结果 for (String str : super.tuIdentifiers) { ids.add(Integer.parseInt(str)); } } filterJob.done(); SubProgressMonitor addJob = new SubProgressMonitor(monitor, 70); facade.beginTransaction(); if (facade.batchAddTuProps(type, content, ids, addJob)) { facade.commit(); } addJob.done(); } catch (SQLException e) { try { facade.rollback(); } catch (SQLException e1) { LOGGER.error("", e1); } LOGGER.error("", e); } finally { monitor.done(); } }
Example 7
Source File: CleanUpRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private RefactoringStatus checkPostConditions(SubProgressMonitor monitor) throws CoreException { RefactoringStatus result= new RefactoringStatus(); ICleanUp[] cleanUps= getCleanUps(); monitor.beginTask("", cleanUps.length); //$NON-NLS-1$ monitor.subTask(FixMessages.CleanUpRefactoring_checkingPostConditions_message); try { for (int j= 0; j < cleanUps.length; j++) { result.merge(cleanUps[j].checkPostConditions(new SubProgressMonitor(monitor, 1))); } } finally { monitor.done(); } return result; }
Example 8
Source File: RenameAnalyzeUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
static ICompilationUnit[] createNewWorkingCopies(ICompilationUnit[] compilationUnitsToModify, TextChangeManager manager, WorkingCopyOwner owner, SubProgressMonitor pm) throws CoreException { pm.beginTask("", compilationUnitsToModify.length); //$NON-NLS-1$ ICompilationUnit[] newWorkingCopies= new ICompilationUnit[compilationUnitsToModify.length]; for (int i= 0; i < compilationUnitsToModify.length; i++) { ICompilationUnit cu= compilationUnitsToModify[i]; newWorkingCopies[i]= createNewWorkingCopy(cu, manager, owner, new SubProgressMonitor(pm, 1)); } pm.done(); return newWorkingCopies; }
Example 9
Source File: InferTypeArgumentsConstraintsSolver.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void runSolver(SubProgressMonitor pm) { pm.beginTask("", fWorkList.size() * 3); //$NON-NLS-1$ while (! fWorkList.isEmpty()) { // Get a variable whose type estimate has changed ConstraintVariable2 cv= fWorkList.removeFirst(); List<ITypeConstraint2> usedIn= fTCModel.getUsedIn(cv); processConstraints(usedIn); pm.worked(1); if (pm.isCanceled()) throw new OperationCanceledException(); } pm.done(); }
Example 10
Source File: RenameAnalyzeUtil.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
static ICompilationUnit[] createNewWorkingCopies(ICompilationUnit[] compilationUnitsToModify, TextChangeManager manager, WorkingCopyOwner owner, SubProgressMonitor pm) throws CoreException { pm.beginTask("", compilationUnitsToModify.length); //$NON-NLS-1$ ICompilationUnit[] newWorkingCopies= new ICompilationUnit[compilationUnitsToModify.length]; for (int i= 0; i < compilationUnitsToModify.length; i++) { ICompilationUnit cu= compilationUnitsToModify[i]; newWorkingCopies[i]= createNewWorkingCopy(cu, manager, owner, new SubProgressMonitor(pm, 1)); } pm.done(); return newWorkingCopies; }
Example 11
Source File: BinaryRefactoringHistoryWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Creates the necessary source code for the refactoring. * * @param monitor * the progress monitor to use * @return * the resulting status */ private RefactoringStatus createNecessarySourceCode(final IProgressMonitor monitor) { final RefactoringStatus status= new RefactoringStatus(); try { monitor.beginTask(JarImportMessages.JarImportWizard_prepare_import, 240); final IPackageFragmentRoot root= getPackageFragmentRoot(); if (root != null && fSourceFolder != null && fJavaProject != null) { try { final SubProgressMonitor subMonitor= new SubProgressMonitor(monitor, 40, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL); final IJavaElement[] elements= root.getChildren(); final List<IPackageFragment> list= new ArrayList<IPackageFragment>(elements.length); try { subMonitor.beginTask(JarImportMessages.JarImportWizard_prepare_import, elements.length); for (int index= 0; index < elements.length; index++) { final IJavaElement element= elements[index]; if (!fProcessedFragments.contains(element) && !element.getElementName().equals(META_INF_FRAGMENT)) list.add((IPackageFragment) element); subMonitor.worked(1); } } finally { subMonitor.done(); } if (!list.isEmpty()) { fProcessedFragments.addAll(list); final URI uri= fSourceFolder.getRawLocationURI(); if (uri != null) { final IPackageFragmentRoot sourceFolder= fJavaProject.getPackageFragmentRoot(fSourceFolder); IWorkspaceRunnable runnable= null; if (canUseSourceAttachment()) { runnable= new SourceCreationOperation(uri, list) { private IPackageFragment fFragment= null; @Override protected final void createCompilationUnit(final IFileStore store, final String name, final String content, final IProgressMonitor pm) throws CoreException { fFragment.createCompilationUnit(name, content, true, pm); } @Override protected final void createPackageFragment(final IFileStore store, final String name, final IProgressMonitor pm) throws CoreException { fFragment= sourceFolder.createPackageFragment(name, true, pm); } }; } else { runnable= new StubCreationOperation(uri, list, true) { private IPackageFragment fFragment= null; @Override protected final void createCompilationUnit(final IFileStore store, final String name, final String content, final IProgressMonitor pm) throws CoreException { fFragment.createCompilationUnit(name, content, true, pm); } @Override protected final void createPackageFragment(final IFileStore store, final String name, final IProgressMonitor pm) throws CoreException { fFragment= sourceFolder.createPackageFragment(name, true, pm); } }; } try { runnable.run(new SubProgressMonitor(monitor, 150, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)); } finally { fSourceFolder.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 50, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)); } } } } catch (CoreException exception) { status.addFatalError(exception.getLocalizedMessage()); } } } finally { monitor.done(); } return status; }
Example 12
Source File: EquinoxApplicationProcessor.java From neoscada with Eclipse Public License 1.0 | 4 votes |
@Override public void processLocal ( final IFolder output, final IProgressMonitor parentMonitor ) throws Exception { final IProgressMonitor monitor = new SubProgressMonitor ( parentMonitor, 13 ); // create context final OscarContext ctx = createContext (); // generate common content new SecurityProcessor ( this.app, ctx ).process ( new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1 new JdbcUserServiceModuleProcessor ( this.app, ctx ).process ( new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1 new EventStoragePostgresModuleProcessor ( this.app, ctx ).process ( new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1 new EventStorageJdbcModuleProcessor ( this.app, ctx ).process ( new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1 new EventInjectorJdbcProcessor ( this.app, ctx ).process ( new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1 new EventInjectorPostgresProcessor ( this.app, ctx ).process ( new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1 new ConnectionProcessor ( this.app, ctx ).process (); new ExporterProcessor ( this.app, ctx ).process (); // generate based on processors final Collection<OscarProcessor> processors = createProcessors (); monitor.worked ( 1 ); // COUNT:1 { final SubProgressMonitor subMonitor = new SubProgressMonitor ( monitor, 1 ); // COUNT:1 subMonitor.beginTask ( "Process application modules", processors.size () ); for ( final OscarProcessor processor : processors ) { processor.process ( ctx, this.app, subMonitor ); subMonitor.worked ( 1 ); } subMonitor.done (); } // generate custom content processForContext ( ctx, output, monitor ); // write out oscar context final OscarWriter writer = new OscarWriter ( ctx.getData (), ctx.getIgnoreFields () ); monitor.worked ( 1 ); // COUNT:1 final IFile file = output.getFile ( "configuration.oscar" ); //$NON-NLS-1$ try ( FileOutputStream fos = new FileOutputStream ( file.getRawLocation ().toOSString () ) ) { writer.write ( fos ); } monitor.worked ( 1 ); // COUNT:1 final IFile jsonFile = output.getFile ( "data.json" ); //$NON-NLS-1$ try ( final FileOutputStream fos = new FileOutputStream ( jsonFile.getRawLocation ().toOSString () ) ) { OscarWriter.writeData ( ctx.getData (), fos ); } monitor.worked ( 1 ); // COUNT:1 // write out profile new P2ProfileProcessor ( this.app ).process ( output.getLocation ().toFile (), monitor ); monitor.worked ( 1 ); // COUNT:1 // refresh output.refreshLocal ( IResource.DEPTH_INFINITE, monitor ); monitor.done (); }
Example 13
Source File: LockRepeatedSegmentHandler.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * 专门处理以 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 14
Source File: LockRepeatedSegmentHandler.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
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 15
Source File: ExtractClassRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private RefactoringStatus updateReferences(IType type, ParameterObjectFactory pof, IProgressMonitor pm) throws CoreException { RefactoringStatus status= new RefactoringStatus(); pm.beginTask(RefactoringCoreMessages.ExtractClassRefactoring_progress_updating_references, 100); try { pm.worked(10); if (pm.isCanceled()) throw new OperationCanceledException(); List<IField> validIFields= new ArrayList<IField>(); for (Iterator<FieldInfo> iterator= fVariables.values().iterator(); iterator.hasNext();) { FieldInfo info= iterator.next(); if (isCreateField(info)) validIFields.add(info.ifield); } if (validIFields.size() == 0) { status.addWarning(RefactoringCoreMessages.ExtractClassRefactoring_warning_no_fields_moved, JavaStatusContext.create(type)); return status; } SearchPattern pattern= RefactoringSearchEngine.createOrPattern(validIFields.toArray(new IField[validIFields.size()]), IJavaSearchConstants.ALL_OCCURRENCES); SearchResultGroup[] results= RefactoringSearchEngine.search(pattern, RefactoringScopeFactory.create(type), pm, status); SubProgressMonitor spm= new SubProgressMonitor(pm, 90); spm.beginTask(RefactoringCoreMessages.ExtractClassRefactoring_progress_updating_references, results.length * 10); try { for (int i= 0; i < results.length; i++) { SearchResultGroup group= results[i]; ICompilationUnit unit= group.getCompilationUnit(); CompilationUnitRewrite cuRewrite; if (unit.equals(fBaseCURewrite.getCu())) cuRewrite= fBaseCURewrite; else cuRewrite= new CompilationUnitRewrite(unit); spm.worked(1); status.merge(replaceReferences(pof, group, cuRewrite)); if (cuRewrite != fBaseCURewrite) //Change for fBaseCURewrite will be generated later fChangeManager.manage(unit, cuRewrite.createChange(true, new SubProgressMonitor(spm, 9))); if (spm.isCanceled()) throw new OperationCanceledException(); } } finally { spm.done(); } } finally { pm.done(); } return status; }
Example 16
Source File: LockRepeatedSegmentHandler.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * 专门处理以 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 17
Source File: LockRepeatedSegmentHandler.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
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; }