Package org.eclipse.ui.progress

Examples of org.eclipse.ui.progress.WorkbenchJob


    });
  }

  /* Create the Job that refreshes the TreeViewer */
  private void createRefreshJob() {
    fRefreshJob = new WorkbenchJob("Refresh BookMarkSearchbar") {//$NON-NLS-1$
      @Override
      public IStatus runInUIThread(IProgressMonitor monitor) {

        /* Tree Disposed */
        if (fViewer.getControl().isDisposed())
View Full Code Here


    });
  }

  /* Create the Job that refreshes the TreeViewer */
  private void createRefreshJob() {
    fRefreshJob = new WorkbenchJob("") {//$NON-NLS-1$
      @Override
      public IStatus runInUIThread(IProgressMonitor monitor) {

        /* Tree Disposed */
        if (fViewer.getControl().isDisposed())
View Full Code Here

   * Get the update WorkbenchJob.
   *
   * @return WorkbenchJob
   */
  private WorkbenchJob getUpdateJob() {
    WorkbenchJob job = new WorkbenchJob(
        WorkbenchMessages.DecorationScheduler_UpdateJobName) {

      int currentIndex = NEEDS_INIT;

      LabelProviderChangedEvent labelProviderChangedEvent;

      ILabelProviderListener[] listeners;

      public IStatus runInUIThread(IProgressMonitor monitor) {

        synchronized (DecorationScheduler.this) {
          if (shutdown) {
            return Status.CANCEL_STATUS;
          }
        }

        // If this is the first one check again in case
        // someone has already cleared it out.
        if (currentIndex == NEEDS_INIT) {
          if (hasPendingUpdates()) {
            // If the removal came in while we were waiting clear it
            // anyways
            removedListeners.clear();
            return Status.OK_STATUS;
          }
          setUpUpdates();
        }

        if (listeners.length == 0) {
          return Status.OK_STATUS;
        }

        monitor.beginTask(
            WorkbenchMessages.DecorationScheduler_UpdatingTask,
            IProgressMonitor.UNKNOWN);

        long startTime = System.currentTimeMillis();
        while (currentIndex < listeners.length) {
          ILabelProviderListener listener = listeners[currentIndex];
          currentIndex++;

          // If it was removed in the meantime then skip it.
          if (!removedListeners.contains(listener)) {
            decoratorManager.fireListener(
                labelProviderChangedEvent, listener);
          }

          // If it is taking long enough for the user to notice then
          // cancel the
          // updates.
          if ((System.currentTimeMillis() - startTime) >= UPDATE_DELAY / 2) {
            break;
          }
        }

        monitor.done();

        if (currentIndex >= listeners.length) {
          // Other decoration requests may have occurred due to
          // updates or we may have timed out updating listeners.
          // Only clear the results if there are none pending.
          if (awaitingDecoration.isEmpty()) {
            resultCache.clear();
          }

          if (!hasPendingUpdates()) {
            decorated();
          }
          currentIndex = NEEDS_INIT;// Reset
          labelProviderChangedEvent = null;
          removedListeners.clear();
          listeners = EMPTY_LISTENER_LIST;
        } else {
          schedule(UPDATE_DELAY);// Reschedule if we are not done
        }
        return Status.OK_STATUS;
      }

      private void setUpUpdates() {
        // Get the elements awaiting update and then
        // clear the list
        removedListeners.clear();
        currentIndex = 0;
        synchronized (pendingKey) {
          Object[] elements = pendingUpdate
              .toArray(new Object[pendingUpdate.size()]);
          pendingUpdate.clear();
          labelProviderChangedEvent = new LabelProviderChangedEvent(
              decoratorManager, elements);
        }
        listeners = decoratorManager.getListeners();
      }

      /*
       * (non-Javadoc)
       *
       * @see org.eclipse.core.runtime.jobs.Job#belongsTo(java.lang.Object)
       */
      public boolean belongsTo(Object family) {
        return DecoratorManager.FAMILY_DECORATE == family;
      }

      /*
       * (non-Javadoc)
       *
       * @see org.eclipse.core.runtime.jobs.Job#shouldRun()
       */
      public boolean shouldRun() {
        return PlatformUI.isWorkbenchRunning();
      }
    };

    job.setSystem(true);
    return job;
  }
View Full Code Here

                .getThread()) {
            fireListeners(event);
            return;
        }

        WorkbenchJob updateJob = new WorkbenchJob(WorkbenchMessages.DecorationScheduler_UpdateJobName) {
            /*
             * (non-Javadoc)
             *
             * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
             */
            public IStatus runInUIThread(IProgressMonitor monitor) {
                fireListeners(event);
                return Status.OK_STATUS;
            }
           
            /* (non-Javadoc)
       * @see org.eclipse.core.runtime.jobs.Job#belongsTo(java.lang.Object)
       */
      public boolean belongsTo(Object family) {
        return FAMILY_DECORATE == family;
      }
        };
        updateJob.setSystem(true);
        updateJob.schedule();

    }
View Full Code Here

    /**
     * Create the refresh job for the receiver.
     *
     */
  private void createRefreshJob() {
    refreshJob = new WorkbenchJob("Refresh Filter"){//$NON-NLS-1$
      /* (non-Javadoc)
       * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
       */
      public IStatus runInUIThread(IProgressMonitor monitor) {
        if(treeViewer.getControl().isDisposed()) {
View Full Code Here

    /**
     * Create the refresh job for the receiver.
     *
     */
    private void createRefreshJob() {
        refreshJob = new WorkbenchJob("Refresh Filter"){//$NON-NLS-1$
            /* (non-Javadoc)
             * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
             */
            public IStatus runInUIThread(IProgressMonitor monitor) {
                if(treeViewer.getControl().isDisposed())
View Full Code Here

     * @return a workbench job that can be scheduled to refresh the tree
     * @since eclipse 3.4
     */
    @Override
    protected WorkbenchJob doCreateRefreshJob() {
      final WorkbenchJob superJob = super.doCreateRefreshJob();

      return new WorkbenchJob(superJob.getName()) {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          IStatus status = superJob.runInUIThread(monitor); // do
                                    // filtering

          if (status.isOK()) {
            // expand the tree if filter has been cleared
            String text = getFilterString();
View Full Code Here

        updateFor(event);
        if (event.getJob().isUser()) {
          boolean noDialog = shouldRunInBackground();
          if (!noDialog) {
            final IJobChangeEvent finalEvent = event;
            WorkbenchJob showJob = new WorkbenchJob(
                ProgressMessages.ProgressManager_showInDialogName) {
              /*
               * (non-Javadoc)
               *
               * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
               */
              public IStatus runInUIThread(
                  IProgressMonitor monitor) {
                showInDialog(null, finalEvent.getJob());
                return Status.OK_STATUS;
              }
            };
            showJob.setSystem(true);
            showJob.schedule();
            return;
          }
        }
      }

View Full Code Here

   *            the dialog to open
   */
  private void scheduleProgressMonitorJob(
      final ProgressMonitorJobsDialog dialog) {

    final WorkbenchJob updateJob = new WorkbenchJob(
        ProgressMessages.ProgressManager_openJobName) {
      /*
       * (non-Javadoc)
       *
       * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
       */
      public IStatus runInUIThread(IProgressMonitor monitor) {
        setUserInterfaceActive(true);
        if (ProgressManagerUtil.safeToOpen(dialog, null)) {
          dialog.open();
        }
        return Status.OK_STATUS;
      }
    };
    updateJob.setSystem(true);
    updateJob.schedule(getLongOperationTime());

  }
View Full Code Here

       * @see org.eclipse.ui.internal.progress.FinishedJobs.KeptJobsListener#finished(org.eclipse.ui.internal.progress.JobTreeElement)
       */
      public void finished(JobTreeElement jte) {
        keptJobs.add(jte);
        final JobTreeElement element = jte;
        Job updateJob = new WorkbenchJob("Refresh finished") {//$NON-NLS-1$
          /* (non-Javadoc)
           * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
           */
          public IStatus runInUIThread(IProgressMonitor monitor) {
            refresh(new Object[] { element });
            return Status.OK_STATUS;
          }
        };
        updateJob.setSystem(true);
        updateJob.schedule();

      }

      /*
       * (non-Javadoc)
       *
       * @see org.eclipse.ui.internal.progress.FinishedJobs.KeptJobsListener#removed(org.eclipse.ui.internal.progress.JobTreeElement)
       */
      public void removed(JobTreeElement jte) {
        //null indicates they are all removed
        if(jte == null) {
          keptJobs.clear();
        } else {
          keptJobs.remove(jte);
        }
        final JobTreeElement element = jte;
        Job updateJob = new WorkbenchJob("Remove finished") {//$NON-NLS-1$
          /* (non-Javadoc)
           * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
           */
          public IStatus runInUIThread(IProgressMonitor monitor) {
            if(element == null) {
              refresh();
            } else {
              ProgressViewerContentProvider.this.remove(new Object[] { element });
            }
            return Status.OK_STATUS;
          }
        };
        updateJob.setSystem(true);
        updateJob.schedule();

      }

    };
    return keptJobListener;
View Full Code Here

TOP

Related Classes of org.eclipse.ui.progress.WorkbenchJob

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.