org.eclipse.core.runtime.OperationCanceledException Java Examples
The following examples show how to use
org.eclipse.core.runtime.OperationCanceledException.
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: RenamedElementTracker.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public Map<URI, URI> renameAndTrack(Iterable<URI> renamedElementURIs, String newName, ResourceSet resourceSet, IRenameStrategy renameStrategy, IProgressMonitor monitor) { Map<EObject, URI> renamedElement2oldURI = resolveRenamedElements(renamedElementURIs, resourceSet); if (monitor.isCanceled()) { throw new OperationCanceledException(); } renameStrategy.applyDeclarationChange(newName, resourceSet); if (monitor.isCanceled()) { throw new OperationCanceledException(); } Map<URI, URI> old2newURI = relocateRenamedElements(renamedElement2oldURI); if (monitor.isCanceled()) { throw new OperationCanceledException(); } renameStrategy.revertDeclarationChange(resourceSet); return old2newURI; }
Example #2
Source File: ResourceUIValidatorExtension.java From n4js with Eclipse Public License 1.0 | 6 votes |
private void addMarkers(IFile file, Resource resource, CheckMode mode, IProgressMonitor monitor) throws OperationCanceledException { try { List<Issue> list = getValidator(resource).validate(resource, mode, getCancelIndicator(monitor)); if (monitor.isCanceled()) { throw new OperationCanceledException(); } deleteMarkers(file, mode, monitor); if (monitor.isCanceled()) { throw new OperationCanceledException(); } createMarkers(file, resource, list); } catch (OperationCanceledError error) { throw error.getWrapped(); } catch (CoreException e) { LOGGER.error(e.getMessage(), e); } }
Example #3
Source File: Html2Xliff.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * Process list. * @throws ParserConfigurationException * * @throws SAXException the SAX exception * @throws IOException * Signals that an I/O exception has occurred. * @throws SAXException * the SAX exception */ private void processList(IProgressMonitor monitor) throws IOException, SAXException { monitor.beginTask(Messages.getString("html.Html2Xliff.task2"), segments.size()); monitor.subTask(""); for (int i = 0; i < segments.size(); i++) { if (monitor.isCanceled()) { throw new OperationCanceledException(Messages.getString("html.cancel")); } monitor.worked(1); String text = segments.get(i); if (isTranslateable(text)) { extractSegment(text); } else { // send directly to skeleton writeSkeleton(text); } } monitor.done(); }
Example #4
Source File: SplitTmx.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 是否覆盖 * @param fileLC * @return ; */ private void checkRepeate(final String fileLC, final IProgressMonitor monitor) { if (new File(fileLC).exists()) { if (!always) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { FileCoverMsgDialog dialog = new FileCoverMsgDialog(Display.getDefault().getActiveShell(), fileLC); retunCode = dialog.open(); always = dialog.isAlways(); } }); } }else { retunCode = FileCoverMsgDialog.OVER; } if (retunCode == FileCoverMsgDialog.CANCEL) { monitor.setCanceled(true); throw new OperationCanceledException(); } }
Example #5
Source File: WarPublisher.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
public static IStatus[] publishExploded(IProject project, IPath destination, IPath safeWorkDirectory, IProgressMonitor monitor) throws CoreException { Preconditions.checkNotNull(project, "project is null"); //$NON-NLS-1$ Preconditions.checkNotNull(destination, "destination is null"); //$NON-NLS-1$ Preconditions.checkArgument(!destination.isEmpty(), "destination is empty path"); //$NON-NLS-1$ Preconditions.checkNotNull(safeWorkDirectory, "safeWorkDirectory is null"); //$NON-NLS-1$ if (monitor.isCanceled()) { throw new OperationCanceledException(); } SubMonitor subMonitor = SubMonitor.convert(monitor, 100); subMonitor.setTaskName(Messages.getString("task.name.publish.war")); //$NON-NLS-1$ IModuleResource[] resources = flattenResources(project, safeWorkDirectory, subMonitor.newChild(10)); if (resources.length == 0) { IStatus error = StatusUtil.error(WarPublisher.class, project.getName() + " has no resources to publish"); //$NON-NLS-1$ return new IStatus[] {error}; } return PublishUtil.publishFull(resources, destination, subMonitor.newChild(90)); }
Example #6
Source File: BuildPathsBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static void addJavaNature(IProject project, IProgressMonitor monitor) throws CoreException { if (monitor != null && monitor.isCanceled()) { throw new OperationCanceledException(); } if (!project.hasNature(JavaCore.NATURE_ID)) { IProjectDescription description = project.getDescription(); String[] prevNatures= description.getNatureIds(); String[] newNatures= new String[prevNatures.length + 1]; System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); newNatures[prevNatures.length]= JavaCore.NATURE_ID; description.setNatureIds(newNatures); project.setDescription(description, monitor); } else { if (monitor != null) { monitor.worked(1); } } }
Example #7
Source File: ReorgQueries.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private boolean getResult(int[] result) throws OperationCanceledException { switch(result[0]){ case IDialogConstants.YES_TO_ALL_ID: fYesToAll= true; return true; case IDialogConstants.YES_ID: return true; case IDialogConstants.CANCEL_ID: throw new OperationCanceledException(); case IDialogConstants.NO_ID: return false; case IDialogConstants.NO_TO_ALL_ID: fNoToAll= true; return false; default: Assert.isTrue(false); return false; } }
Example #8
Source File: Html2Xliff.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * Process list. * @throws ParserConfigurationException * * @throws SAXException the SAX exception * @throws IOException * Signals that an I/O exception has occurred. * @throws SAXException * the SAX exception */ private void processList(IProgressMonitor monitor) throws IOException, SAXException { monitor.beginTask(Messages.getString("html.Html2Xliff.task2"), segments.size()); monitor.subTask(""); for (int i = 0; i < segments.size(); i++) { if (monitor.isCanceled()) { throw new OperationCanceledException(Messages.getString("html.cancel")); } monitor.worked(1); String text = segments.get(i); if (isTranslateable(text)) { extractSegment(text); } else { // send directly to skeleton writeSkeleton(text); } } monitor.done(); }
Example #9
Source File: ExternalizeStringsAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private List<NonNLSElement> analyze(IPackageFragment pack, IProgressMonitor pm) throws CoreException { try{ if (pack == null) return new ArrayList<NonNLSElement>(0); ICompilationUnit[] cus= pack.getCompilationUnits(); pm.beginTask("", cus.length); //$NON-NLS-1$ pm.setTaskName(pack.getElementName()); List<NonNLSElement> l= new ArrayList<NonNLSElement>(cus.length); for (int i= 0; i < cus.length; i++){ pm.subTask(BasicElementLabels.getFileName(cus[i])); NonNLSElement element= analyze(cus[i]); if (element != null) l.add(element); pm.worked(1); if (pm.isCanceled()) throw new OperationCanceledException(); } return l; } finally { pm.done(); } }
Example #10
Source File: ResourceRelocationProcessor.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected void executeParticipants(ResourceRelocationContext context, SubMonitor monitor) { List<? extends IResourceRelocationStrategy> strategies = strategyRegistry.getStrategies(); if (context.getChangeType() == ResourceRelocationContext.ChangeType.COPY) { context.getChangeSerializer().setUpdateRelatedFiles(false); } monitor.setWorkRemaining(strategies.size()); for (IResourceRelocationStrategy strategy : strategies) { try { monitor.split(1); strategy.applyChange(context); } catch (OperationCanceledException t) { issues.add(ERROR, "Operation was cancelled while applying resource changes", t); LOG.error(t.getMessage(), t); break; } } }
Example #11
Source File: CreateCopyOfCompilationUnitChange.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Override protected IFile getOldFile(IProgressMonitor monitor) throws OperationCanceledException { try { monitor.beginTask("", 12); //$NON-NLS-1$ String oldSource= super.getSource(); IPath oldPath= super.getPath(); String newTypeName= fNameQuery.getNewName(); try { String newSource= getCopiedFileSource(new SubProgressMonitor(monitor, 9), fOldCu, newTypeName); setSource(newSource); setPath(fOldCu.getResource().getParent().getFullPath().append(JavaModelUtil.getRenamedCUName(fOldCu, newTypeName))); return super.getOldFile(new SubProgressMonitor(monitor, 1)); } catch (CoreException e) { setSource(oldSource); setPath(oldPath); return super.getOldFile(new SubProgressMonitor(monitor, 2)); } } finally { monitor.done(); } }
Example #12
Source File: TypeScriptRenameProcessor.java From typescript.java with MIT License | 6 votes |
@Override public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException { RefactoringStatus status = new RefactoringStatus(); // Consume "rename" tsserver command. try { rename = tsFile.rename(offset, isFindInComments(), isFindInStrings()).get(1000, TimeUnit.MILLISECONDS); RenameInfo info = rename.getInfo(); if (!info.isCanRename()) { // Refactoring cannot be done. status.addError(info.getLocalizedErrorMessage()); } } catch (Exception e) { status.addError(e.getMessage()); } return status; }
Example #13
Source File: DerivedResourceCleanerJob.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected IStatus cleanUpDerivedResources(IProgressMonitor monitor, IProject project) throws CoreException, OperationCanceledException { if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } if (shouldBeProcessed(project)) { IContainer container = project; if (folderNameToClean != null) container = container.getFolder(new Path(folderNameToClean)); for (IFile derivedFile : derivedResourceMarkers.findDerivedResources(container, null)) { derivedFile.delete(true, monitor); if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } } } return Status.OK_STATUS; }
Example #14
Source File: AbstractBuilderState.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public synchronized ImmutableList<IResourceDescription.Delta> update(BuildData buildData, IProgressMonitor monitor) { ensureLoaded(); final SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.AbstractBuilderState_0, 1); subMonitor.subTask(Messages.AbstractBuilderState_0); if (buildData.isEmpty()) return ImmutableList.of(); if (monitor.isCanceled()) throw new OperationCanceledException(); final ResourceDescriptionsData newData = getCopiedResourceDescriptionsData(); final Collection<IResourceDescription.Delta> result = doUpdate(buildData, newData, subMonitor.split(1)); if (monitor.isCanceled()) throw new OperationCanceledException(); final ResourceDescriptionChangeEvent event = new ResourceDescriptionChangeEvent(result); // update the reference setResourceDescriptionsData(newData); notifyListeners(event); return event.getDeltas(); }
Example #15
Source File: ReferenceFinder.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override public void findReferences( TargetURIs targetURIs, Set<URI> candidates, IResourceAccess resourceAccess, IResourceDescriptions descriptions, Acceptor acceptor, IProgressMonitor monitor) { if (!targetURIs.isEmpty() && !candidates.isEmpty()) { SubMonitor subMonitor = SubMonitor.convert(monitor, targetURIs.size() / MONITOR_CHUNK_SIZE + 1); IProgressMonitor useMe = subMonitor.newChild(1); int i = 0; for (URI candidate : candidates) { if (subMonitor.isCanceled()) throw new OperationCanceledException(); IReferenceFinder languageSpecific = getLanguageSpecificReferenceFinder(candidate); doFindReferencesWith(languageSpecific, targetURIs, candidate, resourceAccess, descriptions, acceptor, useMe); i++; if (i % MONITOR_CHUNK_SIZE == 0) { useMe = subMonitor.newChild(1); } } } }
Example #16
Source File: DefaultFoldingRegionProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void computeObjectFolding(XtextResource xtextResource, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor) { IParseResult parseResult = xtextResource.getParseResult(); if(parseResult != null){ EObject rootASTElement = parseResult.getRootASTElement(); if(rootASTElement != null){ if (cancelIndicator.isCanceled()) throw new OperationCanceledException(); if (isHandled(rootASTElement)) { computeObjectFolding(rootASTElement, foldingRegionAcceptor); } if (shouldProcessContent(rootASTElement)) { TreeIterator<EObject> allContents = rootASTElement.eAllContents(); while (allContents.hasNext()) { if (cancelIndicator.isCanceled()) throw new OperationCanceledException(); EObject eObject = allContents.next(); if (isHandled(eObject)) { computeObjectFolding(eObject, foldingRegionAcceptor); } if (!shouldProcessContent(eObject)) { allContents.prune(); } } } } } }
Example #17
Source File: EmfResourceReferenceUpdater.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected void createReferenceUpdates(ElementRenameArguments elementRenameArguments, Multimap<URI, IReferenceDescription> resource2references, ResourceSet resourceSet, IRefactoringUpdateAcceptor updateAcceptor, IProgressMonitor monitor) { for (URI referringResourceURI : resource2references.keySet()) { try { if (monitor.isCanceled()) throw new OperationCanceledException(); Resource referringResource = resourceSet.getResource(referringResourceURI, false); EObject refactoredElement = resourceSet.getEObject(elementRenameArguments.getNewElementURI(elementRenameArguments.getTargetElementURI()), true); if (referringResource != refactoredElement.eResource()) { if (refactoredElement instanceof EClassifier) { for (IReferenceDescription reference : resource2references.get(referringResourceURI)) { EObject source = referringResource.getEObject(reference.getSourceEObjectUri().fragment()); if (source == null) { LOG.error("Couldn't find source element "+ reference.getSourceEObjectUri() + " in " + referringResource.getURI()); } else { EObject referringEReference = source.eContainer(); if (referringEReference != null && referringEReference instanceof EReference) ((EReference) referringEReference).setEType((EClassifier) refactoredElement); } } } changeUtil.addSaveAsUpdate(referringResource, updateAcceptor); } } catch (OperationCanceledException e) { throw e; } catch (Exception exc) { throw new WrappedException(exc); } } }
Example #18
Source File: CompilationUnitReorgChange.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public final Change perform(IProgressMonitor pm) throws CoreException, OperationCanceledException { pm.beginTask(getName(), 1); try { ICompilationUnit unit= getCu(); ResourceMapping mapping= JavaElementResourceMapping.create(unit); Change result= doPerformReorg(new SubProgressMonitor(pm, 1)); markAsExecuted(unit, mapping); return result; } finally { pm.done(); } }
Example #19
Source File: CheckUpdateHandler.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
@Override protected void doPostLoadBackgroundWork(IProgressMonitor monitor) throws OperationCanceledException { operation = getProvisioningUI().getUpdateOperation(null, null); // check for updates IStatus resolveStatus = operation.resolveModal(monitor); if (resolveStatus.getSeverity() == IStatus.CANCEL) throw new OperationCanceledException(); }
Example #20
Source File: CompilationDirector.java From textuml with Eclipse Public License 1.0 | 5 votes |
private void clean(IFileStore root, boolean deleteIfEmpty, IProgressMonitor monitor) throws CoreException { if (monitor.isCanceled()) throw new OperationCanceledException(); if (isUMLFile(root) && MDDUtil.isGenerated(root.toURI())) { safeDelete(root); return; } IFileStore[] children = root.childStores(EFS.NONE, null); for (int i = 0; i < children.length; i++) clean(children[i], false, monitor); if (deleteIfEmpty && root.childStores(EFS.NONE, null).length == 0) root.delete(EFS.NONE, null); }
Example #21
Source File: ReplaceConditionalWithPolymorphism.java From JDeodorant with MIT License | 5 votes |
@Override public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { RefactoringStatus status= new RefactoringStatus(); try { pm.beginTask("Checking preconditions...", 1); } finally { pm.done(); } return status; }
Example #22
Source File: OutlineRefreshJob.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.7 */ protected void restoreChildrenSelectionAndExpansion(IOutlineNode parent, Resource resource, OutlineTreeState formerState, OutlineTreeState newState, CancelIndicator cancelIndicator) { List<IOutlineNode> children = parent.getChildren(); for(IOutlineNode child: children) { if(cancelIndicator.isCanceled()) throw new OperationCanceledException(); if(containsUsingComparer(formerState.getExpandedNodes(), child)) { restoreChildrenSelectionAndExpansion(child, resource, formerState, newState, cancelIndicator); newState.addExpandedNode(child); } if(containsUsingComparer(formerState.getSelectedNodes(), child)) { newState.addSelectedNode(child); } } }
Example #23
Source File: Auditor.java From eclipse-cs with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void fileStarted(AuditEvent event) { if (mMonitor.isCanceled()) { throw new OperationCanceledException(); } // get the current IFile reference mResource = getFile(event.getFileName()); mMarkerCount = 0; if (mResource != null) { // begin subtask if (mMonitorCounter == 0) { mMonitor.subTask(NLS.bind(Messages.Auditor_msgCheckingFile, mResource.getName())); } // increment monitor-counter this.mMonitorCounter++; } else { IPath filePath = new Path(event.getFileName()); IPath dirPath = filePath.removeFileExtension().removeLastSegments(1); IPath projectPath = mProject.getLocation(); if (projectPath.isPrefixOf(dirPath)) { // find the resource with a project relative path mResource = mProject.findMember(dirPath.removeFirstSegments(projectPath.segmentCount())); } else { // if the resource is not inside the project, take project // as resource - this should not happen mResource = mProject; } } }
Example #24
Source File: SubclipseSubscriberChangeSetManager.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
protected boolean doDispatchEvents(IProgressMonitor monitor) throws TeamException { if (dispatchEvents.isEmpty()) { return false; } if (isShutdown()) throw new OperationCanceledException(); ResourceDiffTree[] locked = null; try { locked = beginDispath(); for (Iterator iter = dispatchEvents.iterator(); iter.hasNext();) { Event event = (Event) iter.next(); switch (event.getType()) { case RESOURCE_REMOVAL: handleRemove(event.getResource()); break; case RESOURCE_CHANGE: handleChange(event.getResource(), ((ResourceEvent)event).getDepth()); break; default: break; } if (isShutdown()) throw new OperationCanceledException(); } } catch (CoreException e) { throw TeamException.asTeamException(e); } finally { try { endDispatch(locked, monitor); } finally { dispatchEvents.clear(); } } return true; }
Example #25
Source File: SyncUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public void waitForBuild(IProgressMonitor monitor) { try { workspace.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); } catch (CoreException e) { throw new OperationCanceledException(e.getMessage()); } }
Example #26
Source File: ExtractMethodRefactoring.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { StatusWrapper status = statusProvider.get(); try { status.merge(validateMethodName(methodName)); status.merge(validateParameters()); ITextRegion expressionsRegion = getExpressionsRegion(); ITextRegion predecessorRegion = locationInFileProvider.getFullTextRegion(originalMethod); if (pm.isCanceled()) { throw new OperationCanceledException(); } Section expressionSection = rewriter.newSection(expressionsRegion.getOffset(), expressionsRegion.getLength()); Section declarationSection = rewriter.newSection(predecessorRegion.getOffset() + predecessorRegion.getLength(), 0); createMethodCallEdit(expressionSection, expressionsRegion); if (pm.isCanceled()) { throw new OperationCanceledException(); } createMethodDeclarationEdit(declarationSection, expressionSection.getBaseIndentLevel(), expressionsRegion); if (pm.isCanceled()) { throw new OperationCanceledException(); } textEdit = replaceConverter.convertToTextEdit(rewriter.getChanges()); } catch (OperationCanceledException e) { throw e; } catch (Exception exc) { handleException(exc, status); } return status.getRefactoringStatus(); }
Example #27
Source File: ExtractMethodRefactoring.java From JDeodorant with MIT License | 5 votes |
@Override public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { RefactoringStatus status= new RefactoringStatus(); try { pm.beginTask("Checking preconditions...", 1); } finally { pm.done(); } return status; }
Example #28
Source File: CheckUpdateHandler.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
@Override protected void doPostLoadBackgroundWork(IProgressMonitor monitor) throws OperationCanceledException { operation = getProvisioningUI().getUpdateOperation(null, null); // check for updates IStatus resolveStatus = operation.resolveModal(monitor); if (resolveStatus.getSeverity() == IStatus.CANCEL) throw new OperationCanceledException(); }
Example #29
Source File: JavaReconcilingStrategy.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Performs the reconcile and returns the AST if it was computed. * * @param unit the compilation unit * @param initialReconcile <code>true</code> if this is the initial reconcile * @return the AST or <code>null</code> if none * @throws JavaModelException if the original Java element does not exist * @since 3.4 */ private CompilationUnit reconcile(ICompilationUnit unit, boolean initialReconcile) throws JavaModelException { /* fix for missing cancel flag communication */ IProblemRequestorExtension extension= getProblemRequestorExtension(); if (extension != null) { extension.setProgressMonitor(fProgressMonitor); extension.setIsActive(true); } try { boolean isASTNeeded= initialReconcile || JavaPlugin.getDefault().getASTProvider().isActive(unit); // reconcile if (fIsJavaReconcilingListener && isASTNeeded) { int reconcileFlags= ICompilationUnit.FORCE_PROBLEM_DETECTION; if (ASTProvider.SHARED_AST_STATEMENT_RECOVERY) reconcileFlags|= ICompilationUnit.ENABLE_STATEMENTS_RECOVERY; if (ASTProvider.SHARED_BINDING_RECOVERY) reconcileFlags|= ICompilationUnit.ENABLE_BINDINGS_RECOVERY; CompilationUnit ast= unit.reconcile(ASTProvider.SHARED_AST_LEVEL, reconcileFlags, null, fProgressMonitor); if (ast != null) { // mark as unmodifiable ASTNodes.setFlagsToAST(ast, ASTNode.PROTECT); return ast; } } else unit.reconcile(ICompilationUnit.NO_AST, true, null, fProgressMonitor); } catch (OperationCanceledException ex) { Assert.isTrue(fProgressMonitor == null || fProgressMonitor.isCanceled()); } finally { /* fix for missing cancel flag communication */ if (extension != null) { extension.setProgressMonitor(null); extension.setIsActive(false); } } return null; }
Example #30
Source File: EclipseFileImpl.java From saros with GNU General Public License v2.0 | 5 votes |
@Override public void create(InputStream input) throws IOException { try { getDelegate().create(input, false, null); } catch (CoreException | OperationCanceledException e) { throw new IOException(e); } }