Package org.eclipse.core.runtime.jobs

Examples of org.eclipse.core.runtime.jobs.Job


      };
    }

    /* Create a Normal Job */
    else {
      fJob = new Job("") { //$NON-NLS-1$
        @Override
        protected IStatus run(IProgressMonitor monitor) {
          try {
            if (!monitor.isCanceled() && fTask != null)
              return fTask.run(monitor);
View Full Code Here


   */
  public void finish() {

    /* Run Retention since settings changed */
    if (fSettingsChanged) {
      Job retentionJob = new Job("Performing clean-up...") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
          try {
            monitor.beginTask("Performing clean-up...", fEntities.size());

            for (IEntity entity : fEntities) {
              if (entity instanceof IBookMark)
                RetentionStrategy.process((IBookMark) entity);
              else if (entity instanceof IFolder)
                RetentionStrategy.process((IFolder) entity);

              monitor.worked(1);
            }
          } finally {
            monitor.done();
          }

          return Status.OK_STATUS;
        }
      };

      retentionJob.schedule();
    }
  }
View Full Code Here

    fBatchJob = createBatchJob();
    fIndexListener = registerListeners();
  }

  private Job createBatchJob() {
    Job job = new Job("Batch Job") {
      @Override
      protected IStatus run(IProgressMonitor monitor) {
        fBatchInProcess.set(false);
        fForceQuickUpdate.set(false);

        /* Update all saved searches */
        SafeRunner.run(new LoggingSafeRunnable() {
          public void run() throws Exception {
            updateSavedSearches(true);
          }
        });

        return Status.OK_STATUS;
      }
    };

    job.setSystem(true);
    job.setUser(false);

    return job;
  }
View Full Code Here

        fScheduledJobs.decrementAndGet();
        break;
      }

      /* Create the Job */
      Job job = createJob();

      /* Listen to Job's Lifecycle */
      job.addJobChangeListener(new JobChangeAdapter() {

        /* Update Fields when a Job is Done */
        @Override
        public void done(IJobChangeEvent event) {
          fDone.incrementAndGet();

          if (fDone.get() == fTotalWork.get())
            fDuration.set(System.currentTimeMillis() - start);

          /* Re-Schedule this Job if there is work left to do */
          if (!fOpenTasksQueue.isEmpty())
            event.getJob().schedule();
          else
            fScheduledJobs.decrementAndGet();
        }
      });

      /*
       * Workaround: Since we are using our own Job for displaying Progress, we
       * don't want these Jobs show up in the Progress View. There is currently
       * no bug-free solution of aggregating the Progress of N Jobs into a
       * single Monitor.
       */
      job.setSystem(true);

      /* Schedule it immediately */
      job.schedule();
    }
  }
View Full Code Here

    }
  }

  /* Create a Job for a Task to handle */
  private Job createJob() {
    Job job = new Job("") { //$NON-NLS-1$
      @Override
      protected IStatus run(final IProgressMonitor monitor) {

        /* Poll the next Task */
        final ITask task = fOpenTasksQueue.poll();
View Full Code Here

   * @param delay
   * @param runnable
   */
  public static void runInBackgroundThread(int delay, final Runnable runnable) {
    Assert.isNotNull(runnable);
    Job job = new Job("Job Runner") { //$NON-NLS-1$
      @Override
      public IStatus run(IProgressMonitor monitor) {
        runnable.run();
        return Status.OK_STATUS;
      }
    };

    job.setSystem(true);
    job.setUser(false);
    job.schedule(delay);
  }
View Full Code Here

    if (displayChange)
      EditorUtils.updateFilterAndGrouping();

    /* Peform clean-up on all BookMarks */
    if (runCleanup) {
      Job retentionJob = new Job("Performing clean-up...") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
          try {
            monitor.beginTask("Performing clean-up...", rootFolders.size());

            for (IFolder rootFolder : rootFolders) {
              RetentionStrategy.process(rootFolder);
              monitor.worked(1);
            }
          } finally {
            monitor.done();
          }

          return Status.OK_STATUS;
        }
      };

      retentionJob.schedule();
    }
  }
View Full Code Here

      };
    }

    /* Create a Normal Job */
    else {
      fJob = new Job("") { //$NON-NLS-1$
        @Override
        protected IStatus run(IProgressMonitor monitor) {
          try {
            if (!monitor.isCanceled() && fTask != null)
              return fTask.run(monitor);
View Full Code Here

    fBatchJob = createBatchJob();
    fIndexListener = registerListeners();
  }

  private Job createBatchJob() {
    Job job = new Job("") { //$NON-NLS-1$
      @Override
      protected IStatus run(IProgressMonitor monitor) {
        fBatchInProcess.set(false);
        fForceQuickUpdate.set(false);

        /* Update all saved searches */
        SafeRunner.run(new LoggingSafeRunnable() {
          public void run() throws Exception {
            if (!Controller.getDefault().isShuttingDown())
              updateSavedSearches(true);
          }
        });

        return Status.OK_STATUS;
      }
    };

    job.setSystem(true);
    job.setUser(false);

    return job;
  }
View Full Code Here

      });
    }
  }

  private void scheduleUpdate(final IBookMark bookMark, Long intervalInSeconds) {
    Job updateJob = new ReloadJob(bookMark, ""); //$NON-NLS-1$
    updateJob.setSystem(true);
    updateJob.schedule(intervalInSeconds * 1000);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.core.runtime.jobs.Job

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.