Search code examples
eclipserunnablejobs

Disabling busy cursor for eclipse Job


This code does what I need, with the exception that there is a quick switch between the normal cursor, and the busy cursor happening extremely fast.

    /* this code is run inside the createPartControl(Composite parent) method of a ViewPart */
    Job job = new Job("refreshing")
    {
        @Override
        protected IStatus run(IProgressMonitor monitor)
        {

            while (data.isReading())
            {
                Display.getDefault().syncExec(new Runnable()
                {

                    @Override
                    public void run()
                    {

                        treeViewer.setInput(DataView.this.dataModel.getArray());

                    }

                });
            }

            return Status.OK_STATUS;
        }
    };
    job.schedule();

So is there a way of disabling the busy cursor of a Job in eclipse? Also, could this happen because the Job is called in a GUI class?


Solution

  • Call

    job.setSystem(true);
    

    before you schedule the job. From the JavaDoc:

    Sets whether or not this job is a system job. System jobs are typically not revealed to users in any UI presentation of jobs. Other than their UI presentation, system jobs act exactly like other jobs. If this value is not explicitly set, jobs are treated as non-system jobs. This method must be called before the job is scheduled.

    However I think the busy cursor is coming from the BusyIndicator.showWhile call in AbstractTreeViewer.createChildren which the tree setInput will call. I don't think you can do anything about.