コード例 #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
  private void updateUI(boolean incomplete) {
    if (trace) GitTraceLocation.getTrace().traceEntry(GitTraceLocation.HISTORYVIEW.getLocation());
    try {
      if (!incomplete && loadedCommits.size() == lastUpdateCnt) return;

      final SWTCommit[] asArray = new SWTCommit[loadedCommits.size()];
      loadedCommits.toArray(asArray);
      page.showCommitList(this, loadedCommits, asArray, commitToShow, incomplete, highlightFlag);
      commitToShow = null;
      lastUpdateCnt = loadedCommits.size();
    } finally {
      if (trace) GitTraceLocation.getTrace().traceExit(GitTraceLocation.HISTORYVIEW.getLocation());
    }
  }
コード例 #3
0
 public void setActiveEditor(ITextEditor editor) {
   if (GitTraceLocation.QUICKDIFF.isActive())
     GitTraceLocation.getTrace()
         .traceEntry(GitTraceLocation.QUICKDIFF.getLocation(), editor.getTitle());
   IEditorInput editorInput = editor.getEditorInput();
   resource = ResourceUtil.getResource(editorInput);
 }
コード例 #4
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();
 }
コード例 #5
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;
  }
コード例 #6
0
  public IDocument getReference(IProgressMonitor monitor) throws CoreException {
    if (GitTraceLocation.QUICKDIFF.isActive())
      GitTraceLocation.getTrace()
          .trace(
              GitTraceLocation.QUICKDIFF.getLocation(),
              "(GitQuickDiffProvider) file: " + resource); // $NON-NLS-1$
    if (resource == null) return null;

    // Document must only be created once
    if (document == null) document = createDocument(resource);
    return document;
  }
コード例 #7
0
 public void dispose() {
   if (GitTraceLocation.QUICKDIFF.isActive())
     GitTraceLocation.getTrace().traceEntry(GitTraceLocation.QUICKDIFF.getLocation());
   if (document != null) document.dispose();
 }
コード例 #8
0
 /** Create the GitQuickDiffProvider instance */
 public GitQuickDiffProvider() {
   if (GitTraceLocation.QUICKDIFF.isActive())
     GitTraceLocation.getTrace().traceEntry(GitTraceLocation.QUICKDIFF.getLocation());
 }
コード例 #9
0
  @Override
  protected IStatus run(final IProgressMonitor monitor) {
    IStatus status = Status.OK_STATUS;
    int maxCommits =
        Activator.getDefault().getPreferenceStore().getInt(UIPreferences.HISTORY_MAX_NUM_COMMITS);
    boolean incomplete = false;
    try {
      if (trace) GitTraceLocation.getTrace().traceEntry(GitTraceLocation.HISTORYVIEW.getLocation());
      try {
        for (; ; ) {
          int oldsz = loadedCommits.size();
          if (trace)
            GitTraceLocation.getTrace()
                .trace(
                    GitTraceLocation.HISTORYVIEW.getLocation(),
                    "Filling commit list"); //$NON-NLS-1$
          // ensure that filling (here) and reading (CommitGraphTable)
          // the commit list is thread safe
          synchronized (loadedCommits) {
            if (commitToLoad != null) {
              loadedCommits.fillTo(commitToLoad, maxCommits);
              commitToShow = commitToLoad;
              commitToLoad = null;
            } else loadedCommits.fillTo(oldsz + BATCH_SIZE - 1);
          }
          if (monitor.isCanceled()) return Status.CANCEL_STATUS;
          final boolean loadIncrementally =
              !Activator.getDefault()
                  .getPreferenceStore()
                  .getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_FINDTOOLBAR);
          if (loadedCommits.size() > itemToLoad + (BATCH_SIZE / 2) + 1 && loadIncrementally) break;
          if (maxCommits > 0 && loadedCommits.size() > maxCommits) incomplete = true;
          if (incomplete || oldsz == loadedCommits.size()) break;

          if (loadedCommits.size() != 1)
            monitor.setTaskName(
                MessageFormat.format(
                    UIText.GenerateHistoryJob_taskFoundMultipleCommits,
                    Integer.valueOf(loadedCommits.size())));
          else monitor.setTaskName(UIText.GenerateHistoryJob_taskFoundSingleCommit);
        }
      } catch (IOException e) {
        status =
            new Status(
                IStatus.ERROR,
                Activator.getPluginId(),
                UIText.GenerateHistoryJob_errorComputingHistory,
                e);
      }
      if (trace)
        GitTraceLocation.getTrace()
            .trace(
                GitTraceLocation.HISTORYVIEW.getLocation(),
                "Loaded " + loadedCommits.size() + " commits"); // $NON-NLS-1$ //$NON-NLS-2$
      updateUI(incomplete);
    } finally {
      monitor.done();
      if (trace) GitTraceLocation.getTrace().traceExit(GitTraceLocation.HISTORYVIEW.getLocation());
    }
    return status;
  }
コード例 #10
0
ファイル: Activator.java プロジェクト: jlulwd/egit
 @Override
 public void optionsChanged(DebugOptions options) {
   // initialize the trace stuff
   debugOptions = options;
   GitTraceLocation.initializeFromOptions(options, isDebugging());
 }