/** * Print a debug message to the console. * Prepend the message with the current date, the name of the current thread and the current job if present. */ public static void debug(String message) { StringBuilder output = new StringBuilder(); Job currentJob = Job.getJobManager().currentJob(); if (currentJob != null) { output.append(currentJob.getClass().getName()); output.append("("); //$NON-NLS-1$ output.append(currentJob.getName()); output.append("): "); //$NON-NLS-1$ } output.append(message); DEBUG_TRACE.trace(null, output.toString()); }
/** * Print a debug message to the console. * Prepend the message with the current date, the name of the current thread and the current job if present. */ public static void debug(String message) { StringBuilder output = new StringBuilder(); output.append(new Date(System.currentTimeMillis())); output.append(" - ["); //$NON-NLS-1$ output.append(Thread.currentThread().getName()); output.append("] "); //$NON-NLS-1$ Job currentJob = Job.getJobManager().currentJob(); if (currentJob != null) { output.append(currentJob.getClass().getName()); output.append("("); //$NON-NLS-1$ output.append(currentJob.getName()); output.append("): "); //$NON-NLS-1$ } output.append(message); System.out.println(output.toString()); }
/** * Print a debug message to the console. * Prepend the message with the current date, the name of the current thread and the current job if present. */ public static void debug(String message) { StringBuilder output = new StringBuilder(); output.append(new Date(System.currentTimeMillis())); output.append(" - ["); //$NON-NLS-1$ output.append(Thread.currentThread().getName()); output.append("] "); //$NON-NLS-1$ Job currentJob = Job.getJobManager().currentJob(); if (currentJob != null) { output.append(currentJob.getClass().getName()); output.append("("); //$NON-NLS-1$ output.append(currentJob.getName()); output.append("): "); //$NON-NLS-1$ } output.append(message); System.out.println(output.toString()); }
/** * Workaround a deficiency of ISourceLookupParticipant API, which does not provide access to a progress monitor. * * <p> * This method can be called in three different cases: * <ol> * <li>from UI thread, in which case {@code null} is return. this tells the caller to only perform fast operations (i.e. cache lookups) on this * thread and submit any long-running operations as background jobs * <li>from background job with existing IProgressMonitor, in which case the monitor is returned * <li>from background job without IProgressMonitor, in which case {@link NullProgressMonitor} is returned. * </ol> */ public static IProgressMonitor getContextMonitor(IProgressMonitor monitor) { if (monitor == null) { Job job = Job.getJobManager().currentJob(); if (job != null) { // current implementation can perform workspace project cache initialization on system job without any user feedback // although eclipse ui remains responsive, source lookup will appear to do nothing until initialization is complete // a fix requires changes to ISourceLookupParticipant#findSourceElements API to accept user-visible progress monitor monitor = new NullProgressMonitor(); } } return monitor; }
private boolean suppressAuthentication() { Job job = Job.getJobManager().currentJob(); if (job != null) { return job.getProperty(LoadMetadataRepositoryJob.SUPPRESS_AUTHENTICATION_JOB_MARKER) != null; } return false; }
/** Waits for all the jobs to finish. */ public static void waitForJobsToFinish() { EclipseMisc.withService(IJobManager.class, jobManager -> { Job job; while ((job = jobManager.currentJob()) != null) { System.out.print(" waiting for " + job.getName() + " to finish... "); job.join(); System.out.println("complete."); } }); } }
@Override public void threadChange(Thread thread) { //we must make sure we aren't transferring control away from a thread that //already owns a scheduling rule because this is deadlock prone (bug 105491) if (rule == null) { return; } Job currentJob = Job.getJobManager().currentJob(); if (currentJob == null) { return; } ISchedulingRule currentRule = currentJob.getRule(); if (currentRule == null) { return; } throw new IllegalStateException("Cannot fork a thread from a thread owning a rule"); //$NON-NLS-1$ }
public void threadChange(Thread thread) { // we must make sure we aren't transferring control away from a thread that // already owns a scheduling rule because this is deadlock prone (bug 105491) if (rule == null) { return; } Job currentJob = Job.getJobManager().currentJob(); if (currentJob == null) { return; } ISchedulingRule currentRule = currentJob.getRule(); if (currentRule == null) { return; } throw new IllegalStateException( "Cannot fork a thread from a thread owning a rule"); // $NON-NLS-1$ }
try { ISchedulingRule rule= null; Job job= Job.getJobManager().currentJob(); if (job != null) rule= job.getRule();
try { ISchedulingRule rule= null; Job job= Job.getJobManager().currentJob(); if (job != null) rule= job.getRule();
try { ISchedulingRule rule= null; Job job= Job.getJobManager().currentJob(); if (job != null) rule= job.getRule();
/** * Another thread is attempting to modify the workspace. Flag the auto-build * as interrupted so that it will cancel and reschedule itself */ synchronized void interrupt() { //if already interrupted, do nothing if (interrupted) return; switch (getState()) { case NONE : return; case WAITING : //put the job to sleep if it is waiting to run setInterrupted(!sleep()); break; case RUNNING : //make sure autobuild doesn't interrupt itself if (Job.getJobManager().currentJob() == this) return; setInterrupted(true); break; } //clear the autobuild avoidance flag if we were interrupted if (interrupted) avoidBuild = false; }
/** * Another thread is attempting to modify the workspace. Flag the auto-build * as interrupted so that it will cancel and reschedule itself */ synchronized void interrupt() { //if already interrupted, do nothing if (interrupted) return; switch (getState()) { case NONE : return; case WAITING : //put the job to sleep if it is waiting to run setInterrupted(!sleep()); break; case RUNNING : //make sure autobuild doesn't interrupt itself if (Job.getJobManager().currentJob() == this) return; setInterrupted(true); break; } //clear the autobuild avoidance flag if we were interrupted if (interrupted) avoidBuild = false; }
/** * Another thread is attempting to modify the workspace. Flag the auto-build * as interrupted so that it will cancel and reschedule itself */ synchronized void interrupt() { //if already interrupted, do nothing if (interrupted) return; switch (getState()) { case NONE : return; case WAITING : //put the job to sleep if it is waiting to run setInterrupted(!sleep()); break; case RUNNING : //make sure autobuild doesn't interrupt itself if (Job.getJobManager().currentJob() == this) return; setInterrupted(true); break; } //clear the autobuild avoidance flag if we were interrupted if (interrupted) avoidBuild = false; }
public IStatus validateInJob(final IValidationContext helper, final IReporter reporter) throws ValidationException { Job currentJob = Platform.getJobManager().currentJob(); ISchedulingRule rule = null; if (currentJob != null) { rule = currentJob.getRule(); } IWorkspaceRunnable validationRunnable = new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { try { doValidate(helper, reporter); } catch (ValidationException e) { throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID_JSP_CORE, 0, PLUGIN_ID_JSP_CORE, e)); } } }; try { JavaCore.run(validationRunnable, rule, new NullProgressMonitor()); } catch (CoreException e) { if (e.getCause() instanceof ValidationException) { throw (ValidationException) e.getCause(); } throw new ValidationException(new LocalizedMessage(IMessage.ERROR_AND_WARNING, e.getMessage()), e); } return Status.OK_STATUS; } }
if (pathPrefixHistory == null) { Job job = Job.getJobManager().currentJob(); if (job instanceof RefreshJob) {
public static synchronized void executeAsync(final long startDelay, final boolean showToUser) { Job currentJob = Job.getJobManager().currentJob(); if (currentJob instanceof ResourceBlockingOperationJob) {
public boolean performFinish() { IWorkspaceRunnable op= new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException { try { finishPage(monitor); } catch (InterruptedException e) { throw new OperationCanceledException(e.getMessage()); } } }; try { ISchedulingRule rule= null; Job job= Job.getJobManager().currentJob(); if (job != null) rule= job.getRule(); IRunnableWithProgress runnable= null; if (rule != null) runnable= new WorkbenchRunnableAdapter(op, rule, true); else runnable= new WorkbenchRunnableAdapter(op, getSchedulingRule()); getContainer().run(canRunForked(), true, runnable); } catch (InvocationTargetException e) { handleFinishException(getShell(), e); return false; } catch (InterruptedException e) { return false; } return true; }
try { ISchedulingRule rule= null; Job job= Job.getJobManager().currentJob(); if (job != null) rule= job.getRule();
try { ISchedulingRule rule= null; Job job= Job.getJobManager().currentJob(); if (job != null) rule= job.getRule();