org.eclipse.ui.progress.IWorkbenchSiteProgressService Java Examples

The following examples show how to use org.eclipse.ui.progress.IWorkbenchSiteProgressService. 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: AbstractStatsView.java    From eclipse-cs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Causes the view to re-sync its contents with the workspace. Note that changes will be scheduled
 * in a background job, and may not take effect immediately.
 */
protected final void refresh() {

  @SuppressWarnings("cast")
  final IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) getSite()
          .getAdapter(IWorkbenchSiteProgressService.class);

  // rebuild statistics data
  CreateStatsJob job = new CreateStatsJob(getFilter(), getViewId());
  job.setPriority(Job.DECORATE);
  job.setRule(ResourcesPlugin.getWorkspace().getRoot());
  job.addJobChangeListener(new JobChangeAdapter() {
    @Override
    public void done(IJobChangeEvent event) {
      mStats = ((CreateStatsJob) event.getJob()).getStats();
      Job uiJob = new WorkbenchJob(Messages.AbstractStatsView_msgRefreshStats) {

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          handleStatsRebuilt();
          return Status.OK_STATUS;
        }
      };
      uiJob.setPriority(Job.DECORATE);
      uiJob.setSystem(true);
      uiJob.schedule();
    }
  });
  service.schedule(job, 0, true);
}
 
Example #2
Source File: ClearMarkersEditorAction.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@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 #3
Source File: WebAppLaunchViewActivator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
  IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
  if (window != null) {
    IWorkbenchPage page = window.getActivePage();
    if (page != null) {
      IViewPart webAppView = page.findView(WebAppLaunchView.ID);
      if (webAppView == null) {
        try {
          webAppView = page.showView(WebAppLaunchView.ID);
        } catch (PartInitException e) {
          return StatusUtilities.newErrorStatus(e, Activator.PLUGIN_ID);
        }
      }

      if (webAppView != null) {
        synchronized(boldingLock) {
          if (bolding) {
            if (webAppView.getSite() != null) {
              IWorkbenchSiteProgressService service = 
                (IWorkbenchSiteProgressService) webAppView.getSite().getAdapter(
                  IWorkbenchSiteProgressService.class);
              if (service != null) {
                service.warnOfContentChange();
              }
            }
          } else {
            page.bringToTop(webAppView);
          }
        }
      }
    }
  }
  return Status.OK_STATUS;
}
 
Example #4
Source File: Utils.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public static void schedule(Job job, IWorkbenchSite site) {
	if (site != null) {
		IWorkbenchSiteProgressService siteProgress = (IWorkbenchSiteProgressService) site.getAdapter(IWorkbenchSiteProgressService.class);
		if (siteProgress != null) {
			siteProgress.schedule(job, 0, true /* use half-busy cursor */);
			return;
		}
	}
	job.schedule();
}
 
Example #5
Source File: ClipboardOperationAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private IProgressService getProgressService() {
	IEditorPart editor= getTextEditor();
	if (editor != null) {
		IWorkbenchPartSite site= editor.getSite();
		if (site != null)
			return (IWorkbenchSiteProgressService) editor.getSite().getAdapter(IWorkbenchSiteProgressService.class);
	}
	return PlatformUI.getWorkbench().getProgressService();
}
 
Example #6
Source File: AbstractFindbugsView.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Get the IWorkbenchSiteProgressService for the receiver.
 *
 * @return IWorkbenchSiteProgressService or <code>null</code>.
 */
protected IWorkbenchSiteProgressService getProgressService() {
    IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) getSite().getAdapter(
            IWorkbenchSiteProgressService.class);
    return service;
}
 
Example #7
Source File: AbstractTimeGraphView.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Forces a rebuild of the entries list, even if entries already exist for this
 * trace
 */
protected void rebuild() {
    try (FlowScopeLog parentLogger = new FlowScopeLogBuilder(LOGGER, Level.FINE, "TimeGraphView:Rebuilding").setCategory(getViewId()).build()) { //$NON-NLS-1$
        setTimeBoundsAndRefresh();
        ITmfTrace viewTrace = fTrace;
        if (viewTrace == null) {
            return;
        }
        resetView(viewTrace);

        List<IMarkerEventSource> markerEventSources = new ArrayList<>();
        synchronized (fBuildJobMap) {
            // Run the build jobs through the site progress service if available
            IWorkbenchSiteProgressService service = null;
            IWorkbenchPartSite site = getSite();
            if (site != null) {
                service = site.getService(IWorkbenchSiteProgressService.class);
            }
            for (ITmfTrace trace : getTracesToBuild(viewTrace)) {
                if (trace == null) {
                    break;
                }
                List<@NonNull IMarkerEventSource> adapters = TmfTraceAdapterManager.getAdapters(trace, IMarkerEventSource.class);
                markerEventSources.addAll(adapters);

                Job buildJob = new Job(getTitle() + Messages.AbstractTimeGraphView_BuildJob) {
                    @Override
                    protected IStatus run(IProgressMonitor monitor) {
                        new BuildRunnable(trace, viewTrace, parentLogger).run(monitor);
                        monitor.done();
                        return Status.OK_STATUS;
                    }
                };
                fBuildJobMap.put(trace, buildJob);
                if (service != null) {
                    service.schedule(buildJob);
                } else {
                    buildJob.schedule();
                }
            }
        }
        fMarkerEventSourcesMap.put(viewTrace, markerEventSources);
    }
}
 
Example #8
Source File: PatListeContentProvider.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Object[] getElements(Object inputElement){
	if (bValid || bUpdating) {
		return pats;
	}
	if (pfilter != null) {
		pats = new String[] {
			Messages.PatListeContentProvider_LoadingData
		};
		((TableViewer) commonViewer.getViewerWidget()).setItemCount(1);
	}
	
	if (!CoreHub.acl.request(AccessControlDefaults.PATIENT_DISPLAY)) {
		return new Object[0];
	}
	
	Job job = new Job(Messages.PatListeContentProvider_LoadingPatients) {
		@Override
		protected IStatus run(IProgressMonitor monitor){
			monitor.beginTask(Messages.PatListeContentProvider_LoadPatients,
				IProgressMonitor.UNKNOWN);
			if (pfilter != null) {
				if (pfilter.aboutToStart() == false) {
					return Status.CANCEL_STATUS;
				}
			}
			// perform actual loading
			syncRefresh();
			monitor.done();
			return Status.OK_STATUS;
		}
	};
	job.setPriority(Job.SHORT);
	job.setUser(false);
	bUpdating = true;
	IWorkbenchSiteProgressService siteService =
		(IWorkbenchSiteProgressService) site.getSite().getAdapter(
			IWorkbenchSiteProgressService.class);
	siteService.schedule(job, 0, true);
	
	job.setProperty(IProgressConstants.ICON_PROPERTY, Images.IMG_AUSRUFEZ_ROT.getImage());
	
	return pats;
}