Java Code Examples for org.eclipse.core.runtime.IProgressMonitor#setCanceled()
The following examples show how to use
org.eclipse.core.runtime.IProgressMonitor#setCanceled() .
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: 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 2
Source File: AbstractDocXmlPersist.java From depan with Apache License 2.0 | 6 votes |
/** * Cancels the {@code monitor} if there is an exception, * but reports no worked steps on the supplied {@code monitor}. */ public void saveDocument( IFile file, T docInfo, IProgressMonitor monitor) { URI location = file.getLocationURI(); try { this.save(location, docInfo); file.refreshLocal(IResource.DEPTH_ZERO, monitor); } catch (Exception err) { if (null != monitor) { monitor.setCanceled(true); } String msg = buildSaveErrorMsg(location); logException(msg, err); } }
Example 3
Source File: BirtFacetUtil25.java From birt with Eclipse Public License 1.0 | 5 votes |
public void configureFilter(Map map, IProject project, SimpleImportOverwriteQuery query, IProgressMonitor monitor) { WebApp webApp = getWebApp(map, project, monitor); if (webApp == null) return; // handle filter settings Iterator it = map.keySet().iterator(); while (it.hasNext()) { String name = DataUtil.getString(it.next(), false); FilterBean bean = (FilterBean) map.get(name); if (bean == null) continue; // if contained this filter Object obj = getFilterByName(webApp, name); if (obj != null) { String ret = query.queryOverwrite("Filter '" + name + "'"); //$NON-NLS-1$ //$NON-NLS-2$ // check overwrite query result if (IOverwriteQuery.NO.equalsIgnoreCase(ret)) { continue; } if (IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) { monitor.setCanceled(true); return; } // remove old item webApp.getFilters().remove(obj); } String className = bean.getClassName(); String description = bean.getDescription(); // create filter object Filter filter = WebFactory.eINSTANCE.createFilter(); filter.setFilterName(name); filter.setFilterClass(className); Description descriptionObj = JavaeeFactory.eINSTANCE .createDescription(); descriptionObj.setValue(description); webApp.getFilters().add(filter); } }
Example 4
Source File: TmfTraceUtilsSearchingTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Test with a progress monitor that cancels the job. */ @Test public void testPreviousMatchingEventCancelled() { ITmfTrace trace = fTrace; assertNotNull(trace); Predicate<@NonNull ITmfEvent> predicate = event -> event.getName().equals("sched_switch"); IProgressMonitor monitor = new NullProgressMonitor(); monitor.setCanceled(true); ITmfEvent actualEvent = TmfTraceUtils.getPreviousEventMatching(trace, START_RANK, predicate, monitor); /* No event should be returend */ assertNull(actualEvent); }
Example 5
Source File: BirtFacetUtil25.java From birt with Eclipse Public License 1.0 | 4 votes |
public void configureFilterMapping(Map map, IProject project, SimpleImportOverwriteQuery query, IProgressMonitor monitor) { WebApp webApp = getWebApp(map, project, monitor); if (webApp == null) return; // handle filter-mapping settings Iterator it = map.keySet().iterator(); while (it.hasNext()) { String key = DataUtil.getString(it.next(), false); FilterMappingBean bean = (FilterMappingBean) map.get(key); if (bean == null) continue; // if contained this filter-mapping Object obj = getFilterMappingByKey(webApp.getFilterMappings(), key); if (obj != null) { String ret = query .queryOverwrite("Filter-mapping '" + key + "'"); //$NON-NLS-1$ //$NON-NLS-2$ // check overwrite query result if (IOverwriteQuery.NO.equalsIgnoreCase(ret)) { continue; } if (IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) { monitor.setCanceled(true); return; } // remove old item webApp.getFilterMappings().remove(obj); } // filter name String name = bean.getName(); // create FilterMapping object FilterMapping mapping = WebFactory.eINSTANCE.createFilterMapping(); // get filter by name Filter filter = (Filter) getFilterByName(webApp, name); if (filter != null) { mapping.setFilterName(filter.getFilterName()); if (bean.getUri() != null) { UrlPatternType urlPattern = JavaeeFactory.eINSTANCE .createUrlPatternType(); urlPattern.setValue(bean.getUri()); mapping.getUrlPatterns().add(urlPattern); } mapping.getServletNames().add(bean.getServletName()); // get Servlet object Servlet servlet = findServletByName(webApp, bean .getServletName()); // mapping.setServlet(servlet); if (servlet != null || bean.getUri() != null) webApp.getFilterMappings().add(mapping); } } }
Example 6
Source File: CrossflowDiagramEditor.java From scava with Eclipse Public License 2.0 | 4 votes |
/** * @generated */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell(); IEditorInput input = getEditorInput(); SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } dialog.create(); IDocumentProvider provider = getDocumentProvider(); if (provider == null) { // editor has been programmatically closed while the dialog was open return; } if (provider.isDeleted(input) && original != null) { String message = NLS.bind(Messages.CrossflowDiagramEditor_SavingDeletedFile, original.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IPath filePath = dialog.getResult(); if (filePath == null) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IFile file = workspaceRoot.getFile(filePath); final IEditorInput newInput = new FileEditorInput(file); // Check if the editor is already open IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy(); IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for (int i = 0; i < editorRefs.length; i++) { if (matchingStrategy.matches(editorRefs[i], newInput)) { MessageDialog.openWarning(shell, Messages.CrossflowDiagramEditor_SaveAsErrorTitle, Messages.CrossflowDiagramEditor_SaveAsErrorMessage); return; } } boolean success = false; try { provider.aboutToChange(newInput); getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); success = true; } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { ErrorDialog.openError(shell, Messages.CrossflowDiagramEditor_SaveErrorTitle, Messages.CrossflowDiagramEditor_SaveErrorMessage, x.getStatus()); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }
Example 7
Source File: BirtFacetUtil25.java From birt with Eclipse Public License 1.0 | 4 votes |
public void configureContextParam(Map map, IProject project, SimpleImportOverwriteQuery query, IProgressMonitor monitor) { WebApp webApp = getWebApp(map, project, monitor); if (webApp == null) return; Iterator it = map.keySet().iterator(); while (it.hasNext()) { String name = DataUtil.getString(it.next(), false); ContextParamBean bean = (ContextParamBean) map.get(name); if (bean == null) continue; // if contained this param List list = webApp.getContextParams(); int index = getContextParamIndexByName(list, name); if (index >= 0) { String ret = query .queryOverwrite("Context-param '" + name + "'"); //$NON-NLS-1$ //$NON-NLS-2$ // check overwrite query result if (IOverwriteQuery.NO.equalsIgnoreCase(ret)) { continue; } if (IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) { monitor.setCanceled(true); return; } // remove old item list.remove(index); } String value = bean.getValue(); String description = bean.getDescription(); ParamValue param = JavaeeFactory.eINSTANCE.createParamValue(); param.setParamName(name); param.setParamValue(value); if (description != null) { Description descriptionObj = JavaeeFactory.eINSTANCE .createDescription(); descriptionObj.setValue(description); param.getDescriptions().add(descriptionObj); } // add into list webApp.getContextParams().add(param); } }
Example 8
Source File: BirtFacetUtil.java From birt with Eclipse Public License 1.0 | 4 votes |
public void configureFilter( Map map, IProject project, SimpleImportOverwriteQuery query, IProgressMonitor monitor ) { WebApp webApp = getWebApp( map, project, monitor ); if ( webApp == null ) return; // handle filter settings Iterator it = map.keySet( ).iterator( ); while ( it.hasNext( ) ) { String name = DataUtil.getString( it.next( ), false ); FilterBean bean = (FilterBean) map.get( name ); if ( bean == null ) continue; // if contained this filter Object obj = webApp.getFilterNamed( name ); if ( obj != null ) { String ret = query.queryOverwrite( "Filter '" + name + "'" ); //$NON-NLS-1$ //$NON-NLS-2$ // check overwrite query result if ( IOverwriteQuery.NO.equalsIgnoreCase( ret ) ) { continue; } if ( IOverwriteQuery.CANCEL.equalsIgnoreCase( ret ) ) { monitor.setCanceled( true ); return; } // remove old item webApp.getFilters( ).remove( obj ); } String className = bean.getClassName( ); String description = bean.getDescription( ); // create filter object Filter filter = WebapplicationFactory.eINSTANCE.createFilter( ); filter.setName( name ); filter.setFilterClassName( className ); filter.setDescription( description ); webApp.getFilters( ).add( filter ); } }
Example 9
Source File: WebArtifactUtil.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Configure the servlet settings * * @param map * @param project * @param query * @param monitor * @throws CoreException */ public static void configureServlet( Map map, IProject project, IOverwriteQuery query, IProgressMonitor monitor ) throws CoreException { // cancel progress if ( monitor.isCanceled( ) ) return; if ( map == null || project == null ) { return; } // create WebArtifact WebArtifactEdit webEdit = WebArtifactEdit .getWebArtifactEditForWrite( project ); if ( webEdit == null ) return; try { WebApp webapp = (WebApp) webEdit.getDeploymentDescriptorRoot( ); // handle servlet settings Iterator it = map.keySet( ).iterator( ); while ( it.hasNext( ) ) { String name = DataUtil.getString( it.next( ), false ); ServletBean bean = (ServletBean) map.get( name ); if ( bean == null ) continue; // if contained this servlet Object obj = getServletByName( webapp.getServlets( ), name ); if ( obj != null ) { String ret = query .queryOverwrite( "Servlet '" + name + "'" ); //$NON-NLS-1$ //$NON-NLS-2$ // check overwrite query result if ( IOverwriteQuery.NO.equalsIgnoreCase( ret ) ) { continue; } if ( IOverwriteQuery.CANCEL.equalsIgnoreCase( ret ) ) { monitor.setCanceled( true ); return; } // remove old item webapp.getServlets( ).remove( obj ); } String className = bean.getClassName( ); String description = bean.getDescription( ); // create Servlet Type object ServletType servletType = WebapplicationFactory.eINSTANCE .createServletType( ); servletType.setClassName( className ); // create Servlet object Servlet servlet = WebapplicationFactory.eINSTANCE .createServlet( ); servlet.setServletName( name ); if ( description != null ) servlet.setDescription( description ); servlet.setWebType( servletType ); servlet.setWebApp( webapp ); } webEdit.saveIfNecessary( monitor ); } finally { webEdit.dispose( ); } }
Example 10
Source File: TmxConvert2FileDialog.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * (non-Javadoc) * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor) */ @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { TmxConvert2FileBean counverBean = getCounverBean(); int fileCount = counverBean.tmxFilePath.size(); AbstractTmx2File tmx2FileConverter = ConverterFactory.getTmx2FileConverter(counverBean.targetFileType); monitor.beginTask(Messages.getString("dialog.TmxConvert2FileDialog.convert.task.msg1"), fileCount * 100 + 10); String tmxPath = null; File targetFile = null; String currentConvertFileName = ""; try { final String exitsFileName = checkTargetFileExits(counverBean); if (!exitsFileName.isEmpty()) { final boolean isConfirm[] = new boolean[1]; isConfirm[0] = true; Display.getDefault().syncExec(new Runnable() { @Override public void run() { isConfirm[0] = OpenMessageUtils.openConfirmMessage(MessageFormat.format( Messages.getString("dialog.TmxConvert2FileDialog.overwriteFile"), exitsFileName)); } }); if (!isConfirm[0]) { monitor.setCanceled(true); return; } } monitor.worked(10); for (int i = 0; i < fileCount; i++) { tmxPath = counverBean.tmxFilePath.get(i); final File f = new File(tmxPath); currentConvertFileName = f.getName(); if (!f.exists() || !f.canRead()) { throw new Exception(MessageFormat.format( Messages.getString("dialog.TmxConvert2FileDialog.sourceFileNotexist"), f.getName())); } monitor.setTaskName(MessageFormat.format( Messages.getString("dialog.TmxConvert2FileDialog.convert.task.msg2"), tmxPath)); targetFile = getTargetFile(tmxPath, counverBean, i); if (null == targetFile) {// 取消覆盖目标文件 continue; } if (!targetFile.exists() || !targetFile.canWrite()) { throw new Exception( MessageFormat.format(Messages.getString("dialog.TmxConvert2FileDialog.targetFileNotexist"), targetFile.getName())); } if (monitor.isCanceled()) { return; } else { // TODO: 处理HSTM转换包含单元属性的情况 if (counverBean.targetFileType == ConverterFactory.FILE_TYPE_HSTM) { tmxPath = getHstmConvertPath(tmxPath); } SubProgressMonitor subFileJob = new SubProgressMonitor(monitor, 100); tmx2FileConverter.doCovnerter(tmxPath, targetFile, subFileJob); } monitor.worked(1); } } catch (Exception e) { if (null != targetFile) { targetFile.delete(); } LOGGER.error("", e); throw new InterruptedException(MessageFormat.format( Messages.getString("dialog.TmxConvert2FileDialog.convert.task.error"), currentConvertFileName, e.getMessage())); } finally { monitor.done(); } }
Example 11
Source File: BirtFacetUtil25.java From birt with Eclipse Public License 1.0 | 4 votes |
public void configureServletMapping(Map map, IProject project, SimpleImportOverwriteQuery query, IProgressMonitor monitor) { WebApp webApp = getWebApp(map, project, monitor); if (webApp == null) return; Iterator it = map.keySet().iterator(); while (it.hasNext()) { String uri = DataUtil.getString(it.next(), false); ServletMappingBean bean = (ServletMappingBean) map.get(uri); if (bean == null) continue; // if contained this servlet-mapping Object obj = getServletMappingByUri(webApp.getServletMappings(), uri); if (obj != null) { String ret = query .queryOverwrite("Servlet-mapping '" + uri + "'"); //$NON-NLS-1$ //$NON-NLS-2$ // check overwrite query result if (IOverwriteQuery.NO.equalsIgnoreCase(ret)) { continue; } if (IOverwriteQuery.CANCEL.equalsIgnoreCase(ret)) { monitor.setCanceled(true); return; } // remove old item webApp.getServletMappings().remove(obj); } // servlet name String name = bean.getName(); // create ServletMapping object ServletMapping mapping = WebFactory.eINSTANCE .createServletMapping(); // get servlet by name Servlet servlet = findServletByName(webApp, name); if (servlet != null) { mapping.setServletName(servlet.getServletName()); UrlPatternType urlPattern = JavaeeFactory.eINSTANCE .createUrlPatternType(); urlPattern.setValue(uri); mapping.getUrlPatterns().add(urlPattern); webApp.getServletMappings().add(mapping); // mapping.setUrlPattern(uri); // mapping.setWebApp( webapp ); } } }
Example 12
Source File: EclipseRemoteProgressIndicatorImpl.java From saros with GNU General Public License v2.0 | 4 votes |
private void mainloop(final IProgressMonitor monitor) { int worked = 0; boolean firstTime = true; update: while (true) { final ProgressActivity activity; try { if (monitor.isCanceled()) break update; // poll so this monitor can be closed locally activity = activities.poll(1000, TimeUnit.MILLISECONDS); if (activity == null) continue update; } catch (InterruptedException e) { return; } final String taskName = activity.getTaskName(); int newWorked; if (log.isTraceEnabled()) log.trace("executing progress activity: " + activity); switch (activity.getAction()) { case BEGINTASK: monitor.beginTask(taskName, activity.getWorkTotal()); continue update; case SETTASKNAME: monitor.setTaskName(taskName); continue update; case SUBTASK: if (taskName != null) monitor.subTask(taskName); newWorked = activity.getWorkCurrent(); if (newWorked > worked) { monitor.worked(newWorked - worked); worked = newWorked; } continue update; case UPDATE: if (firstTime) { monitor.beginTask(taskName, activity.getWorkTotal()); firstTime = false; } else { if (taskName != null) monitor.subTask(taskName); newWorked = activity.getWorkCurrent(); if (newWorked > worked) { monitor.worked(newWorked - worked); worked = newWorked; } } continue update; case DONE: monitor.done(); break update; case CANCEL: log.debug("progress was canceled by remote user"); monitor.setCanceled(true); break update; } } }
Example 13
Source File: ProcessDiagramEditor.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
/** * @generated */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell(); IEditorInput input = getEditorInput(); SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } dialog.create(); IDocumentProvider provider = getDocumentProvider(); if (provider == null) { // editor has been programmatically closed while the dialog was open return; } if (provider.isDeleted(input) && original != null) { String message = NLS.bind(Messages.ProcessDiagramEditor_SavingDeletedFile, original.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IPath filePath = dialog.getResult(); if (filePath == null) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IFile file = workspaceRoot.getFile(filePath); final IEditorInput newInput = new FileEditorInput(file); // Check if the editor is already open IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy(); IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for (int i = 0; i < editorRefs.length; i++) { if (matchingStrategy.matches(editorRefs[i], newInput)) { MessageDialog.openWarning(shell, Messages.ProcessDiagramEditor_SaveAsErrorTitle, Messages.ProcessDiagramEditor_SaveAsErrorMessage); return; } } boolean success = false; try { provider.aboutToChange(newInput); getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); success = true; } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { ErrorDialog.openError(shell, Messages.ProcessDiagramEditor_SaveErrorTitle, Messages.ProcessDiagramEditor_SaveErrorMessage, x.getStatus()); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }
Example 14
Source File: BirtFacetUtil.java From birt with Eclipse Public License 1.0 | 4 votes |
public void configureServlet( Map map, IProject project, SimpleImportOverwriteQuery query, IProgressMonitor monitor ) { WebApp webApp = getWebApp( map, project, monitor ); if ( webApp == null ) return; // handle servlet settings Iterator it = map.keySet( ).iterator( ); while ( it.hasNext( ) ) { String name = DataUtil.getString( it.next( ), false ); ServletBean bean = (ServletBean) map.get( name ); if ( bean == null ) continue; // if contained this servlet Object obj = webApp.getServletNamed( name ); if ( obj != null ) { String ret = query.queryOverwrite( "Servlet '" + name + "'" ); //$NON-NLS-1$ //$NON-NLS-2$ // check overwrite query result if ( IOverwriteQuery.NO.equalsIgnoreCase( ret ) ) { continue; } if ( IOverwriteQuery.CANCEL.equalsIgnoreCase( ret ) ) { monitor.setCanceled( true ); return; } // remove old item webApp.getServlets( ).remove( obj ); } String className = bean.getClassName( ); String description = bean.getDescription( ); // create Servlet Type object ServletType servletType = WebapplicationFactory.eINSTANCE .createServletType( ); servletType.setClassName( className ); // create Servlet object Servlet servlet = WebapplicationFactory.eINSTANCE.createServlet( ); servlet.setServletName( name ); if ( description != null ) servlet.setDescription( description ); servlet.setWebType( servletType ); servlet.setWebApp( webApp ); } }
Example 15
Source File: FoldingRangeHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
private void computeFoldingRanges(List<FoldingRange> foldingRanges, ITypeRoot unit, IProgressMonitor monitor) { try { ISourceRange range = unit.getSourceRange(); if (!SourceRange.isAvailable(range)) { return; } String contents = unit.getSource(); if (StringUtils.isBlank(contents)) { return; } final int shift = range.getOffset(); IScanner scanner = getScanner(); scanner.setSource(contents.toCharArray()); scanner.resetTo(shift, shift + range.getLength()); int start = shift; int token = 0; Stack<Integer> regionStarts = new Stack<>(); while (token != ITerminalSymbols.TokenNameEOF) { start = scanner.getCurrentTokenStartPosition(); switch (token) { case ITerminalSymbols.TokenNameCOMMENT_JAVADOC: case ITerminalSymbols.TokenNameCOMMENT_BLOCK: int end = scanner.getCurrentTokenEndPosition(); FoldingRange commentFoldingRange = new FoldingRange(scanner.getLineNumber(start) - 1, scanner.getLineNumber(end) - 1); commentFoldingRange.setKind(FoldingRangeKind.Comment); foldingRanges.add(commentFoldingRange); break; case ITerminalSymbols.TokenNameCOMMENT_LINE: String currentSource = String.valueOf(scanner.getCurrentTokenSource()); if (REGION_START_PATTERN.matcher(currentSource).lookingAt()) { regionStarts.push(start); } else if (REGION_END_PATTERN.matcher(currentSource).lookingAt()) { if (regionStarts.size() > 0) { FoldingRange regionFolding = new FoldingRange(scanner.getLineNumber(regionStarts.pop()) - 1, scanner.getLineNumber(start) - 1); regionFolding.setKind(FoldingRangeKind.Region); foldingRanges.add(regionFolding); } } break; default: break; } token = getNextToken(scanner); } computeTypeRootRanges(foldingRanges, unit, scanner); } catch (CoreException e) { JavaLanguageServerPlugin.logException("Problem with folding range for " + unit.getPath().toPortableString(), e); monitor.setCanceled(true); } }
Example 16
Source File: ProgressReporterManager.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
@Override public void setCanceled(boolean cancelled) { for (IProgressMonitor monitor : monitors) { monitor.setCanceled(cancelled); } }
Example 17
Source File: CompletionHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
private CompletionList computeContentAssist(ICompilationUnit unit, int line, int column, IProgressMonitor monitor) throws JavaModelException { CompletionResponses.clear(); if (unit == null) { return null; } List<CompletionItem> proposals = new ArrayList<>(); final int offset = JsonRpcHelpers.toOffset(unit.getBuffer(), line, column); CompletionProposalRequestor collector = new CompletionProposalRequestor(unit, offset, manager); // Allow completions for unresolved types - since 3.3 collector.setAllowsRequiredProposals(CompletionProposal.FIELD_REF, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.FIELD_REF, CompletionProposal.TYPE_IMPORT, true); collector.setAllowsRequiredProposals(CompletionProposal.FIELD_REF, CompletionProposal.FIELD_IMPORT, true); collector.setAllowsRequiredProposals(CompletionProposal.METHOD_REF, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.METHOD_REF, CompletionProposal.TYPE_IMPORT, true); collector.setAllowsRequiredProposals(CompletionProposal.METHOD_REF, CompletionProposal.METHOD_IMPORT, true); collector.setAllowsRequiredProposals(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, CompletionProposal.TYPE_REF, true); collector.setAllowsRequiredProposals(CompletionProposal.TYPE_REF, CompletionProposal.TYPE_REF, true); collector.setFavoriteReferences(getFavoriteStaticMembers()); if (offset >-1 && !monitor.isCanceled()) { IBuffer buffer = unit.getBuffer(); if (buffer != null && buffer.getLength() >= offset) { IProgressMonitor subMonitor = new ProgressMonitorWrapper(monitor) { private long timeLimit; private final long TIMEOUT = Long.getLong("completion.timeout", 5000); @Override public void beginTask(String name, int totalWork) { timeLimit = System.currentTimeMillis() + TIMEOUT; } @Override public boolean isCanceled() { return super.isCanceled() || timeLimit <= System.currentTimeMillis(); } }; try { if (isIndexEngineEnabled()) { unit.codeComplete(offset, collector, subMonitor); } else { ModelBasedCompletionEngine.codeComplete(unit, offset, collector, DefaultWorkingCopyOwner.PRIMARY, subMonitor); } proposals.addAll(collector.getCompletionItems()); if (isSnippetStringSupported() && !UNSUPPORTED_RESOURCES.contains(unit.getResource().getName())) { proposals.addAll(SnippetCompletionProposal.getSnippets(unit, collector.getContext(), subMonitor)); } proposals.addAll(new JavadocCompletionProposal().getProposals(unit, offset, collector, subMonitor)); } catch (OperationCanceledException e) { monitor.setCanceled(true); } } } proposals.sort(PROPOSAL_COMPARATOR); CompletionList list = new CompletionList(proposals); list.setIsIncomplete(!collector.isComplete()); return list; }
Example 18
Source File: ProgressUtils.java From TranskribusCore with GNU General Public License v3.0 | 4 votes |
public static void setCanceled(IProgressMonitor monitor, boolean value) { if (monitor != null) monitor.setCanceled(value); }
Example 19
Source File: BirtFacetUtil.java From birt with Eclipse Public License 1.0 | 4 votes |
public void configureTaglib( Map map, IProject project, SimpleImportOverwriteQuery query, IProgressMonitor monitor ) { WebApp webApp = getWebApp( map, project, monitor ); if ( webApp == null ) return; // handle taglib settings Iterator it = map.keySet( ).iterator( ); while ( it.hasNext( ) ) { String uri = DataUtil.getString( it.next( ), false ); TagLibBean bean = (TagLibBean) map.get( uri ); if ( bean == null ) continue; // if contained this taglib Object obj = getTagLibByUri( webApp, uri ); if ( obj != null ) { String ret = query.queryOverwrite( "Taglib '" + uri + "'" ); //$NON-NLS-1$ //$NON-NLS-2$ // check overwrite query result if ( IOverwriteQuery.NO.equalsIgnoreCase( ret ) ) { continue; } if ( IOverwriteQuery.CANCEL.equalsIgnoreCase( ret ) ) { monitor.setCanceled( true ); return; } // remove old item if ( obj instanceof TagLibRefType && webApp.getJspConfig( ) != null ) { webApp.getJspConfig( ).getTagLibs( ).remove( obj ); } else { webApp.getTagLibs( ).remove( obj ); } } String location = bean.getLocation( ); if ( webApp.getVersionID( ) == 23 ) { // create TaglibRef object for servlet 2.3 TagLibRef taglib = WebapplicationFactory.eINSTANCE .createTagLibRef( ); taglib.setTaglibURI( uri ); taglib.setTaglibLocation( location ); webApp.getTagLibs( ).add( taglib ); } else { // for servlet 2.4 JSPConfig jspConfig = JspFactory.eINSTANCE.createJSPConfig( ); TagLibRefType ref = JspFactory.eINSTANCE.createTagLibRefType( ); ref.setTaglibURI( uri ); ref.setTaglibLocation( location ); jspConfig.getTagLibs( ).add( ref ); webApp.setJspConfig( jspConfig ); } } }
Example 20
Source File: LocalAppEngineServerLaunchConfigurationDelegate.java From google-cloud-eclipse with Apache License 2.0 | 4 votes |
@Override public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException { SubMonitor progress = SubMonitor.convert(monitor, 50); if (!super.finalLaunchCheck(configuration, mode, progress.newChild(10))) { return false; } IStatus status = validateCloudSdk(progress.newChild(20)); if (!status.isOK()) { // Throwing a CoreException will result in the ILaunch hanging around in // an invalid state StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.LOG); return false; } // If we're auto-publishing before launch, check if there may be stale // resources not yet published. See // https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/1832 if (ServerCore.isAutoPublishing() && ResourcesPlugin.getWorkspace().isAutoBuilding()) { // Must wait for any current autobuild to complete so resource changes are triggered // and WTP will kick off ResourceChangeJobs. Note that there may be builds // pending that are unrelated to our resource changes, so simply checking // <code>JobManager.find(FAMILY_AUTO_BUILD).length > 0</code> produces too many // false positives. try { Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, progress.newChild(20)); } catch (InterruptedException ex) { /* ignore */ } IServer server = ServerUtil.getServer(configuration); if (server.shouldPublish() || hasPendingChangesToPublish()) { IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(promptStatus); if (prompter != null) { Object continueLaunch = prompter .handleStatus(StaleResourcesStatusHandler.CONTINUE_LAUNCH_REQUEST, configuration); if (!(Boolean) continueLaunch) { // cancel the launch so Server.StartJob won't raise an error dialog, since the // server won't have been started monitor.setCanceled(true); return false; } } } } return true; }