コード例 #1
0
ファイル: Activator.java プロジェクト: jlulwd/egit
    @Override
    protected IStatus run(IProgressMonitor monitor) {
      // The core plugin might have been stopped before we could cancel
      // this job.
      RepositoryCache repositoryCache =
          org.eclipse.egit.core.Activator.getDefault().getRepositoryCache();
      if (repositoryCache == null) return Status.OK_STATUS;

      Repository[] repos = repositoryCache.getAllRepositories();
      if (repos.length == 0) return Status.OK_STATUS;

      // When people use Git from the command line a lot of changes
      // may happen. Don't scan when inactive depending on the user's
      // choice.

      if (Activator.getDefault()
          .getPreferenceStore()
          .getBoolean(UIPreferences.REFESH_ONLY_WHEN_ACTIVE)) {
        if (!isActive()) {
          monitor.done();
          if (doReschedule) schedule(REPO_SCAN_INTERVAL);
          return Status.OK_STATUS;
        }
      }

      monitor.beginTask(UIText.Activator_scanningRepositories, repos.length);
      try {
        for (Repository repo : repos) {
          if (monitor.isCanceled()) break;
          if (GitTraceLocation.REPOSITORYCHANGESCANNER.isActive())
            GitTraceLocation.getTrace()
                .trace(
                    GitTraceLocation.REPOSITORYCHANGESCANNER.getLocation(),
                    "Scanning " + repo + " for changes"); // $NON-NLS-1$ //$NON-NLS-2$

          repo.scanForRepoChanges();
          monitor.worked(1);
        }
      } catch (IOException e) {
        if (GitTraceLocation.REPOSITORYCHANGESCANNER.isActive())
          GitTraceLocation.getTrace()
              .trace(
                  GitTraceLocation.REPOSITORYCHANGESCANNER.getLocation(),
                  "Stopped rescheduling " + getName() + "job"); // $NON-NLS-1$ //$NON-NLS-2$
        return createErrorStatus(UIText.Activator_scanError, e);
      } finally {
        monitor.done();
      }
      if (GitTraceLocation.REPOSITORYCHANGESCANNER.isActive())
        GitTraceLocation.getTrace()
            .trace(
                GitTraceLocation.REPOSITORYCHANGESCANNER.getLocation(),
                "Rescheduling " + getName() + " job"); // $NON-NLS-1$ //$NON-NLS-2$
      if (doReschedule) schedule(REPO_SCAN_INTERVAL);
      return Status.OK_STATUS;
    }
コード例 #2
0
ファイル: Activator.java プロジェクト: jlulwd/egit
 /**
  * Figure which projects belong to a repository, add them to a set of project to refresh and
  * schedule the refresh as a job.
  */
 void triggerRefresh() {
   if (GitTraceLocation.REPOSITORYCHANGESCANNER.isActive()) {
     GitTraceLocation.getTrace()
         .trace(
             GitTraceLocation.REPOSITORYCHANGESCANNER.getLocation(),
             "Triggered refresh"); //$NON-NLS-1$
   }
   schedule();
 }
コード例 #3
0
ファイル: Activator.java プロジェクト: jlulwd/egit
  @Override
  public void stop(final BundleContext context) throws Exception {
    if (refreshHandle != null) {
      refreshHandle.remove();
      refreshHandle = null;
    }

    if (focusListener != null) {
      if (PlatformUI.isWorkbenchRunning())
        PlatformUI.getWorkbench().removeWindowListener(focusListener);
      focusListener = null;
    }

    if (GitTraceLocation.REPOSITORYCHANGESCANNER.isActive())
      GitTraceLocation.getTrace()
          .trace(
              GitTraceLocation.REPOSITORYCHANGESCANNER.getLocation(),
              "Trying to cancel " + rcs.getName() + " job"); // $NON-NLS-1$ //$NON-NLS-2$

    rcs.setReschedule(false);

    rcs.cancel();
    if (GitTraceLocation.REPOSITORYCHANGESCANNER.isActive())
      GitTraceLocation.getTrace()
          .trace(
              GitTraceLocation.REPOSITORYCHANGESCANNER.getLocation(),
              "Trying to cancel " + refreshJob.getName() + " job"); // $NON-NLS-1$ //$NON-NLS-2$
    refreshJob.cancel();

    rcs.join();
    refreshJob.join();

    if (GitTraceLocation.REPOSITORYCHANGESCANNER.isActive())
      GitTraceLocation.getTrace()
          .trace(
              GitTraceLocation.REPOSITORYCHANGESCANNER.getLocation(),
              "Jobs terminated"); //$NON-NLS-1$

    super.stop(context);
    plugin = null;
  }