Java Code Examples for org.eclipse.core.runtime.jobs.Job#setPriority()
The following examples show how to use
org.eclipse.core.runtime.jobs.Job#setPriority() .
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: TerminateAllLaunchesAction.java From Pydev with Eclipse Public License 1.0 | 6 votes |
public static void terminateAllLaunches() { Job job = new Job("Terminate all Launches") { @Override protected IStatus run(IProgressMonitor monitor) { ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches(); for (ILaunch iLaunch : launches) { try { if (!iLaunch.isTerminated()) { iLaunch.terminate(); } } catch (Exception e) { Log.log(e); } } return Status.OK_STATUS; } }; job.setPriority(Job.INTERACTIVE); job.schedule(); }
Example 2
Source File: CodewindEclipseApplication.java From codewind-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public void buildComplete() { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name); if (project != null && project.isAccessible()) { Job job = new Job(NLS.bind(Messages.RefreshResourceJobLabel, project.getName())) { @Override protected IStatus run(IProgressMonitor monitor) { try { project.refreshLocal(IResource.DEPTH_INFINITE, monitor); return Status.OK_STATUS; } catch (Exception e) { Logger.logError("An error occurred while refreshing the resource: " + project.getLocation()); //$NON-NLS-1$ return new Status(IStatus.ERROR, CodewindCorePlugin.PLUGIN_ID, NLS.bind(Messages.RefreshResourceError, project.getLocation()), e); } } }; job.setPriority(Job.LONG); job.schedule(); } }
Example 3
Source File: AddSvnAndRefreshStartUp.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
@Override public void earlyStartup() { Job job = new WorkspaceJob("refresh svn view") { @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { monitor.beginTask("refresh", 4); initData(); monitor.worked(1); saveFeatureInfo(ip, userName, cookie); monitor.worked(1); addSvnToView(ip, userName, cookie); monitor.worked(1); monitor.done(); return Status.OK_STATUS; } }; job.setPriority(Job.SHORT); job.setSystem(true); job.schedule(200L); }
Example 4
Source File: LazyCommonViewerContentProvider.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
protected void asyncReload(){ Job job = Job.create(getJobName(), new ICoreRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException{ loadedElements = getElements(null); Display.getDefault().asyncExec(() -> { // virtual table ... AbstractTableViewer viewer = (AbstractTableViewer) commonViewer.getViewerWidget(); if (viewer != null && !viewer.getControl().isDisposed()) { viewer.setItemCount(loadedElements.length); } // trigger viewer refresh commonViewer.notify(Message.update); }); } }); job.setPriority(Job.SHORT); job.schedule(); }
Example 5
Source File: SCTPerspectiveManager.java From statecharts with Eclipse Public License 1.0 | 6 votes |
protected void schedulePerspectiveSwitchJob(final String perspectiveID) { Job switchJob = new UIJob(DebugUIPlugin.getStandardDisplay(), "Perspective Switch Job") { //$NON-NLS-1$ public IStatus runInUIThread(IProgressMonitor monitor) { IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow(); if (window != null && !(isCurrentPerspective(window, perspectiveID))) { switchToPerspective(window, perspectiveID); } // Force the debug view to open if (window != null) { try { window.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(SIMULATION_VIEW_ID); } catch (PartInitException e) { e.printStackTrace(); } } return Status.OK_STATUS; } }; switchJob.setSystem(true); switchJob.setPriority(Job.INTERACTIVE); switchJob.setRule(AsynchronousSchedulingRuleFactory.getDefault().newSerialPerObjectRule(this)); switchJob.schedule(); }
Example 6
Source File: AbstractTypeScriptConsole.java From typescript.java with MIT License | 5 votes |
@Override public void doAppendLine(final LineType lineType, final String line) { Job appendJob = new Job(TypeScriptUIMessages.TypeScriptConsoleJob_name) { @Override protected IStatus run(IProgressMonitor monitor) { intsalDoAppendLine(lineType, line); return Status.OK_STATUS; } }; appendJob.setPriority(Job.LONG); appendJob.schedule(); }
Example 7
Source File: EclipseRemoteProgressIndicatorImpl.java From saros with GNU General Public License v2.0 | 5 votes |
@Override public synchronized void start() { if (started) return; started = true; final Job job = new Job(CoreUtils.format(Messages.RemoteProgress_observing_progress_for, remoteUser)) { @Override protected IStatus run(IProgressMonitor monitor) { try { mainloop(monitor); return Status.OK_STATUS; } catch (Exception e) { log.error(e); return Status.CANCEL_STATUS; } finally { rpm.progressIndicatorStopped(EclipseRemoteProgressIndicatorImpl.this); } } }; job.setPriority(Job.SHORT); job.setUser(true); job.schedule(); running = true; }
Example 8
Source File: Activator.java From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 | 5 votes |
@Override public void earlyStartup() { plugin = this; preferencesPath = getStateLocation(); Job j = new StartupJob(); j.setPriority(Job.INTERACTIVE); j.schedule(); }
Example 9
Source File: ClearMarkersEditorAction.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
@Override public final void run(final IAction action) { if (currentEditor != null) { IFile file = ((FileEditorInput) (currentEditor.getEditorInput())).getFile(); Job job = new ClearMarkersJob(file, Arrays.asList(new WorkItem[] { new WorkItem(file) })); job.setUser(true); job.setPriority(Job.INTERACTIVE); IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) currentEditor.getEditorSite().getService( IWorkbenchSiteProgressService.class); service.schedule(job); } }
Example 10
Source File: SyntaxInitHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public void triggerInitialization(Collection<IPath> roots) { Job job = new WorkspaceJob("Initialize Workspace") { @Override public IStatus runInWorkspace(IProgressMonitor monitor) { long start = System.currentTimeMillis(); try { projectsManager.initializeProjects(roots, monitor); JavaLanguageServerPlugin.logInfo("Workspace initialized in " + (System.currentTimeMillis() - start) + "ms"); } catch (Exception e) { JavaLanguageServerPlugin.logException("Initialization failed ", e); } return Status.OK_STATUS; } /* (non-Javadoc) * @see org.eclipse.core.runtime.jobs.Job#belongsTo(java.lang.Object) */ @SuppressWarnings("unchecked") @Override public boolean belongsTo(Object family) { Collection<IPath> rootPathsSet = roots.stream().collect(Collectors.toSet()); boolean equalToRootPaths = false; if (family instanceof Collection<?>) { equalToRootPaths = rootPathsSet.equals(((Collection<IPath>) family).stream().collect(Collectors.toSet())); } return JAVA_LS_INITIALIZATION_JOBS.equals(family) || equalToRootPaths; } }; job.setPriority(Job.BUILD); job.setRule(ResourcesPlugin.getWorkspace().getRoot()); job.schedule(); }
Example 11
Source File: SVNTeamProviderType.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Create and schedule an auto-add job */ private static synchronized void createAutoAddJob(IProject project) { Job j = new AutoAddJob(project); j.setSystem(true); j.setPriority(Job.SHORT); j.setRule(ResourcesPlugin.getWorkspace().getRoot()); j.schedule(); }
Example 12
Source File: InitializeAfterLoadJob.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public IStatus runInUIThread(IProgressMonitor monitor) { Job job = new RealJob(JavaUIMessages.JavaPlugin_initializing_ui); job.setPriority(Job.SHORT); job.schedule(); return Status.OK_STATUS; }
Example 13
Source File: ClassFileEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected void installSemanticHighlighting() { super.installSemanticHighlighting(); Job job= new Job(JavaEditorMessages.OverrideIndicatorManager_intallJob) { /* * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) * @since 3.0 */ @Override protected IStatus run(IProgressMonitor monitor) { CompilationUnit ast= SharedASTProvider.getAST(getInputJavaElement(), SharedASTProvider.WAIT_YES, null); if (fOverrideIndicatorManager != null) fOverrideIndicatorManager.reconciled(ast, true, monitor); if (fSemanticManager != null) { SemanticHighlightingReconciler reconciler= fSemanticManager.getReconciler(); if (reconciler != null) reconciler.reconciled(ast, false, monitor); } if (isMarkingOccurrences()) installOccurrencesFinder(false); return Status.OK_STATUS; } }; job.setPriority(Job.DECORATE); job.setSystem(true); job.schedule(); }
Example 14
Source File: PyEditTitle.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Sadly, we have to restore all pydev editors that have a different icon to make it correct. * * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=308740 */ private void restoreAllPydevEditorsWithDifferentIcon() { if (!PyTitlePreferencesPage.useCustomInitIcon()) { return; } Job job = new Job("Invalidate images") { @Override protected IStatus run(IProgressMonitor monitor) { try { while (PydevPlugin.isAlive() && !doRestoreAllPydevEditorsWithDifferentIcons()) { //stop trying if the plugin is stopped synchronized (this) { try { Thread.sleep(200); } catch (InterruptedException e) { //ignore. } } } ; } finally { jobPool.removeJob(this); } return Status.OK_STATUS; } }; job.setPriority(Job.SHORT); jobPool.addJob(job); }
Example 15
Source File: PyEditNotifier.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Helper function to run the notifications of the editor in a job. * * @param runnable the runnable to be run. */ private void runIt(final INotifierRunnable runnable) { Job job = new Job("PyEditNotifier") { @Override protected IStatus run(IProgressMonitor monitor) { runnable.run(monitor); return Status.OK_STATUS; } }; job.setPriority(Job.SHORT); job.setSystem(true); job.schedule(); }
Example 16
Source File: CollaborationUtils.java From saros with GNU General Public License v2.0 | 5 votes |
/** * Starts a new session and shares the given projects with given contacts.<br> * Does nothing if a {@link ISarosSession session} is already running. * * @param projects the projects share * @param contacts the contacts to share the projects with * @nonBlocking */ public static void startSession(final Set<IProject> projects, final List<JID> contacts) { Job sessionStartupJob = new Job("Session Startup") { @Override protected IStatus run(IProgressMonitor monitor) { monitor.beginTask("Starting session...", IProgressMonitor.UNKNOWN); try { refreshProjects(projects, null); sessionManager.startSession(convert(projects)); Set<JID> participantsToAdd = new HashSet<JID>(contacts); ISarosSession session = sessionManager.getSession(); if (session == null) return Status.CANCEL_STATUS; sessionManager.invite(participantsToAdd, getSessionDescription(session)); } catch (Exception e) { log.error("could not start a Saros session", e); return new Status(IStatus.ERROR, Saros.PLUGIN_ID, e.getMessage(), e); } return Status.OK_STATUS; } }; sessionStartupJob.setPriority(Job.SHORT); sessionStartupJob.setUser(true); sessionStartupJob.schedule(); }
Example 17
Source File: DefaultAnalyticsEventHandler.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
public void sendEvent(final AnalyticsEvent event) { Job job = new Job("Sending Analytics Ping ...") //$NON-NLS-1$ { @Override protected IStatus run(IProgressMonitor monitor) { IAnalyticsUserManager userManager = AnalyticsEvent.getUserManager(); if (userManager == null) { // send as anonymous user if (!isValidResponse(responseCode = sendPing(event, null))) { // log the event to the database AnalyticsLogger.getInstance().logEvent(event); } return Status.OK_STATUS; } IAnalyticsUser user = userManager.getUser(); // Only send ping if user is logged in. Otherwise, we log it to the database if (user == null || !user.isOnline() || !isValidResponse(responseCode = sendPing(event, user))) { // log the event to the database AnalyticsLogger.getInstance().logEvent(event); } else { // Send out all previous events from the db synchronized (lock) { List<AnalyticsEvent> events = AnalyticsLogger.getInstance().getEvents(); // Sort the events. We want all project.create events to be first, and all project.delete events // to be last Collections.sort(events, new AnalyticsEventComparator()); for (AnalyticsEvent aEvent : events) { if (!isValidResponse(responseCode = sendPing(aEvent, user))) { return Status.OK_STATUS; } // Remove the event after it has been sent AnalyticsLogger.getInstance().clearEvent(aEvent); } } } return Status.OK_STATUS; } }; job.setSystem(true); job.setPriority(Job.BUILD); job.schedule(); // Make this a blocking job for unit tests if (EclipseUtil.isTesting()) { try { job.join(); } catch (InterruptedException e) { } } }
Example 18
Source File: AdditionalProjectInterpreterInfo.java From Pydev with Eclipse Public License 1.0 | 4 votes |
/** * @param project the project we want to get info on * @return the additional info for a given project (gotten from the cache with its name) * @throws MisconfigurationException */ public static AbstractAdditionalDependencyInfo getAdditionalInfoForProject(final IPythonNature nature) throws MisconfigurationException { if (nature == null) { return null; } IProject project = nature.getProject(); if (project == null) { return null; } String name = FileUtilsFileBuffer.getValidProjectName(project); synchronized (additionalNatureInfoLock) { AbstractAdditionalDependencyInfo info = additionalNatureInfo.get(name); if (info == null) { info = new AdditionalProjectInterpreterInfo(project); additionalNatureInfo.put(name, info); if (!info.load()) { recreateAllInfo(nature, new NullProgressMonitor()); } else { final AbstractAdditionalDependencyInfo temp = info; temp.setWaitForIntegrityCheck(true); //Ok, after it's loaded the first time, check the index integrity! Job j = new Job("Check index integrity for: " + project.getName()) { @Override protected IStatus run(IProgressMonitor monitor) { try (GlobalFeedbackReporter r = GlobalFeedback.start("Check index integrity...")) { new InterpreterInfoBuilder().syncInfoToPythonPath(monitor, nature); } catch (Exception e) { Log.log(e); } finally { temp.setWaitForIntegrityCheck(false); } return Status.OK_STATUS; } }; j.setPriority(Job.INTERACTIVE); j.setSystem(true); j.schedule(); } } return info; } }
Example 19
Source File: ToggleBreakpointAdapter.java From typescript.java with MIT License | 4 votes |
void toggleLineBreakpoint(final IWorkbenchPart part, final ITextSelection selection, final int linenumber) { Job job = new Job("Toggle Line Breakpoints") { protected IStatus run(IProgressMonitor monitor) { try { ITextEditor editor = getTextEditor(part); if(editor != null && part instanceof IEditorPart) { IResource resource = getResource((IEditorPart)part); if(resource == null) { resource = getResource((IEditorPart)part); reportToStatusLine(part, "Failed to create Javascript line breakpoint - the resource could no be computed"); return Status.CANCEL_STATUS; } IBreakpoint bp = lineBreakpointExists(resource, linenumber); if(bp != null) { DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(bp, true); return Status.OK_STATUS; } IDocumentProvider documentProvider = editor.getDocumentProvider(); IDocument document = documentProvider.getDocument(editor.getEditorInput()); int charstart = -1, charend = -1; try { IRegion line = document.getLineInformation(linenumber - 1); charstart = line.getOffset(); charend = charstart + line.getLength(); } catch (BadLocationException ble) {} HashMap<String, String> attributes = new HashMap<String, String>(); attributes.put(IJavaScriptBreakpoint.TYPE_NAME, null); attributes.put(IJavaScriptBreakpoint.SCRIPT_PATH, resource.getFullPath().makeAbsolute().toString()); attributes.put(IJavaScriptBreakpoint.ELEMENT_HANDLE, null); JavaScriptDebugModel.createLineBreakpoint(resource, linenumber, charstart, charend, attributes, true); return Status.OK_STATUS; } reportToStatusLine(part, "Failed to create Javascript line breakpoint"); return Status.CANCEL_STATUS; } catch(CoreException ce) { return ce.getStatus(); } } }; job.setPriority(Job.INTERACTIVE); job.setSystem(true); job.schedule(); }
Example 20
Source File: AnalysisKickOff.java From CogniCrypt with Eclipse Public License 2.0 | 4 votes |
/** * This method executes the actual analysis. */ public void run() { if (this.curProj == null) return; final Job analysis = new Job(Constants.ANALYSIS_LABEL) { @SuppressWarnings("deprecation") @Override protected IStatus run(final IProgressMonitor monitor) { int curSeed = 0; final SootThread sootThread = new SootThread(AnalysisKickOff.this.curProj, AnalysisKickOff.resultsReporter, depOnly); final MonitorReporter monitorThread = new MonitorReporter(AnalysisKickOff.resultsReporter, sootThread); monitorThread.start(); sootThread.start(); AnalysisKickOff.resultsReporter.setCgGenComplete(false); SubMonitor subMonitor = SubMonitor.convert(monitor, 100); SubMonitor cgGen = subMonitor.newChild(50); while (sootThread.isAlive()) { try { Thread.sleep(1); } catch (final InterruptedException e) {} if (!monitorThread.isCgGen()) { cgGen.setWorkRemaining(1000).split(1); cgGen.setTaskName("Constructing call Graphs..."); } else { if (monitorThread.getProcessedSeeds() - curSeed != 0) { curSeed = monitorThread.getProcessedSeeds(); subMonitor.split(monitorThread.getWorkUnitsCompleted() / 2); subMonitor.setTaskName("Completed " + monitorThread.getProcessedSeeds() + " of " + monitorThread.getTotalSeeds() + " seeds."); } } if (monitor.isCanceled()) { sootThread.stop(); Activator.getDefault().logInfo("Static analysis job cancelled for " + curProj.getElementName() + "."); return Status.CANCEL_STATUS; } } monitor.done(); AnalysisKickOff.resultsReporter.setPercentCompleted(0); AnalysisKickOff.resultsReporter.setProcessedSeeds(0); AnalysisKickOff.resultsReporter.setTotalSeeds(0); AnalysisKickOff.resultsReporter.setWorkUnitsCompleted(0); AnalysisKickOff.resultsReporter.setWork(0); if (sootThread.isSucc()) { Activator.getDefault().logInfo("Static analysis job successfully terminated for " + curProj.getElementName() + "."); return Status.OK_STATUS; } else { Activator.getDefault().logInfo("Static analysis failed for " + curProj.getElementName() + "."); return Status.CANCEL_STATUS; } } @Override protected void canceling() { cancel(); } }; analysis.setPriority(Job.LONG); analysis.schedule(); }