com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings Java Examples

The following examples show how to use com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings. 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: AbstractVcsHelperImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
public static CommittedChangeList getRemoteList(@Nonnull AbstractVcs vcs,
                                                @Nonnull VcsRevisionNumber revision,
                                                @Nonnull VirtualFile nonLocal)
        throws VcsException {
  final CommittedChangesProvider provider = vcs.getCommittedChangesProvider();
  final RepositoryLocation local = provider.getForNonLocal(nonLocal);
  if (local != null) {
    final String number = revision.asString();
    final ChangeBrowserSettings settings = provider.createDefaultSettings();
    final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, local, provider.getUnlimitedCountValue());
    if (changes != null) {
      for (CommittedChangeList change : changes) {
        if (number.equals(String.valueOf(change.getNumber()))) {
          return change;
        }
      }
    }
  }
  return null;
}
 
Example #2
Source File: AbstractVcsHelperImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
@Nullable
public <T extends CommittedChangeList, U extends ChangeBrowserSettings> T chooseCommittedChangeList(@Nonnull CommittedChangesProvider<T, U> provider,
                                                                                                    RepositoryLocation location) {
  final List<T> changes;
  try {
    changes = provider.getCommittedChanges(provider.createDefaultSettings(), location, 0);
  }
  catch (VcsException e) {
    return null;
  }
  final ChangesBrowserDialog dlg = new ChangesBrowserDialog(myProject, new CommittedChangesTableModel((List<CommittedChangeList>)changes,
                                                                                                      provider.getColumns(), false),
                                                            ChangesBrowserDialog.Mode.Choose, null);
  if (dlg.showAndGet()) {
    return (T)dlg.getSelectedChangeList();
  }
  else {
    return null;
  }
}
 
Example #3
Source File: ShowAllAffectedGenericAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static CommittedChangeList getRemoteList(final AbstractVcs vcs, final VcsRevisionNumber revision, final VirtualFile nonLocal)
  throws VcsException {
  final CommittedChangesProvider provider = vcs.getCommittedChangesProvider();
  final RepositoryLocation local = provider.getForNonLocal(nonLocal);
  if (local != null) {
    final String number = revision.asString();
    final ChangeBrowserSettings settings = provider.createDefaultSettings();
    final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, local, provider.getUnlimitedCountValue());
    if (changes != null) {
      for (CommittedChangeList change : changes) {
        if (number.equals(String.valueOf(change.getNumber()))) {
          return change;
        }
      }
    }
  }
  return null;
}
 
Example #4
Source File: CompositeCommittedChangesProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void setSettings(CompositeChangeBrowserSettings settings) {
  mySettings = settings;
  boolean dateFilterInitialized = false;
  for(AbstractVcs vcs: myEditors.keySet()) {
    final ChangeBrowserSettings vcsSettings = mySettings.get(vcs);
    final ChangesBrowserSettingsEditor editor = myEditors.get(vcs);
    //noinspection unchecked
    editor.setSettings(vcsSettings);
    if (!dateFilterInitialized) {
      myDateFilter.initValues(vcsSettings);
      dateFilterInitialized = true;
    }
    final JCheckBox checkBox = myEnabledCheckboxes.get(vcs);
    checkBox.setSelected(settings.getEnabledVcss().contains(vcs));
    updateVcsEnabled(checkBox, editor);
  }
}
 
Example #5
Source File: CommittedChangesCache.java    From consulo with Apache License 2.0 6 votes vote down vote up
private boolean canGetFromCache(final AbstractVcs vcs, final ChangeBrowserSettings settings, final VirtualFile root, final RepositoryLocation location, final int maxCount) throws IOException {
  ChangesCacheFile cacheFile = myCachesHolder.getCacheFile(vcs, root, location);
  if (cacheFile.isEmpty()) {
    return true;   // we'll initialize the cache and check again after that
  }
  if (settings.USE_DATE_BEFORE_FILTER && !settings.USE_DATE_AFTER_FILTER) {
    return cacheFile.hasCompleteHistory();
  }
  if (settings.USE_CHANGE_BEFORE_FILTER && !settings.USE_CHANGE_AFTER_FILTER) {
    return cacheFile.hasCompleteHistory();
  }

  boolean hasDateFilter = settings.USE_DATE_AFTER_FILTER || settings.USE_DATE_BEFORE_FILTER || settings.USE_CHANGE_AFTER_FILTER || settings.USE_CHANGE_BEFORE_FILTER;
  boolean hasNonDateFilter = settings.isNonDateFilterSpecified();
  if (!hasDateFilter && hasNonDateFilter) {
    return cacheFile.hasCompleteHistory();
  }
  if (settings.USE_DATE_AFTER_FILTER && settings.getDateAfter().getTime() < cacheFile.getFirstCachedDate().getTime()) {
    return cacheFile.hasCompleteHistory();
  }
  if (settings.USE_CHANGE_AFTER_FILTER && settings.getChangeAfterFilter().longValue() < cacheFile.getFirstCachedChangelist()) {
    return cacheFile.hasCompleteHistory();
  }
  return true;
}
 
Example #6
Source File: CommittedChangesCache.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public List<CommittedChangeList> getChanges(ChangeBrowserSettings settings,
                                            final VirtualFile file,
                                            @Nonnull final AbstractVcs vcs,
                                            final int maxCount,
                                            final boolean cacheOnly,
                                            final CommittedChangesProvider provider,
                                            final RepositoryLocation location) throws VcsException {
  if (settings instanceof CompositeCommittedChangesProvider.CompositeChangeBrowserSettings) {
    settings = ((CompositeCommittedChangesProvider.CompositeChangeBrowserSettings)settings).get(vcs);
  }
  if (provider instanceof CachingCommittedChangesProvider) {
    try {
      if (cacheOnly) {
        ChangesCacheFile cacheFile = myCachesHolder.getCacheFile(vcs, file, location);
        if (!cacheFile.isEmpty()) {

          final RepositoryLocation fileLocation = cacheFile.getLocation();
          fileLocation.onBeforeBatch();
          final List<CommittedChangeList> committedChangeLists = cacheFile.readChanges(settings, maxCount);
          fileLocation.onAfterBatch();
          return committedChangeLists;
        }
        return null;
      }
      else {
        if (canGetFromCache(vcs, settings, file, location, maxCount)) {
          return getChangesWithCaching(vcs, settings, file, location, maxCount);
        }
      }
    }
    catch (IOException e) {
      LOG.info(e);
    }
  }
  //noinspection unchecked
  return provider.getCommittedChanges(settings, location, maxCount);
}
 
Example #7
Source File: AbstractVcsHelperImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void openCommittedChangesTab(final CommittedChangesProvider provider,
                                    final RepositoryLocation location,
                                    final ChangeBrowserSettings settings,
                                    final int maxCount,
                                    String title) {
  DefaultActionGroup extraActions = new DefaultActionGroup();
  CommittedChangesPanel panel = new CommittedChangesPanel(myProject, provider, settings, location, extraActions);
  panel.setMaxCount(maxCount);
  panel.refreshChanges(false);
  final ContentFactory factory = ContentFactory.getInstance();
  if (title == null && location != null) {
    title = VcsBundle.message("browse.changes.content.title", location.toPresentableString());
  }
  final Content content = factory.createContent(panel, title, false);
  final ChangesViewContentI contentManager = ChangesViewContentManager.getInstance(myProject);
  contentManager.addContent(content);
  contentManager.setSelectedContent(content);

  extraActions.add(new CloseTabToolbarAction() {
    @Override
    public void actionPerformed(final AnActionEvent e) {
      contentManager.removeContent(content);
    }
  });

  ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID);
  if (!window.isVisible()) {
    window.activate(null);
  }
}
 
Example #8
Source File: AbstractVcsHelperImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void openCommittedChangesTab(final AbstractVcs vcs,
                                    final VirtualFile root,
                                    final ChangeBrowserSettings settings,
                                    final int maxCount,
                                    String title) {
  RepositoryLocationCache cache = CommittedChangesCache.getInstance(myProject).getLocationCache();
  RepositoryLocation location = cache.getLocation(vcs, VcsUtil.getFilePath(root), false);
  openCommittedChangesTab(vcs.getCommittedChangesProvider(), location, settings, maxCount, title);
}
 
Example #9
Source File: CompositeCommittedChangesProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
public CompositeChangeBrowserSettings getSettings() {
  Set<AbstractVcs> enabledVcss = new HashSet<AbstractVcs>();
  for(AbstractVcs vcs: myEditors.keySet()) {
    ChangeBrowserSettings settings = myEditors.get(vcs).getSettings();
    myDateFilter.saveValues(settings);
    mySettings.put(vcs, settings);
    if (myEnabledCheckboxes.get(vcs).isSelected()) {
      enabledVcss.add(vcs);
    }
  }
  mySettings.setEnabledVcss(enabledVcss);
  return mySettings;
}
 
Example #10
Source File: CommittedChangesCache.java    From consulo with Apache License 2.0 5 votes vote down vote up
private MyProjectChangesLoader(ChangeBrowserSettings settings, int maxCount, boolean cacheOnly, Consumer<List<CommittedChangeList>> consumer, Consumer<List<VcsException>> errorConsumer) {
  mySettings = settings;
  myMaxCount = maxCount;
  myCacheOnly = cacheOnly;
  myConsumer = consumer;
  myErrorConsumer = errorConsumer;
}
 
Example #11
Source File: CommittedChangesCache.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void getProjectChangesAsync(final ChangeBrowserSettings settings,
                                   final int maxCount,
                                   final boolean cacheOnly,
                                   final Consumer<List<CommittedChangeList>> consumer,
                                   final Consumer<List<VcsException>> errorConsumer) {
  final MyProjectChangesLoader loader = new MyProjectChangesLoader(settings, maxCount, cacheOnly, consumer, errorConsumer);
  myTaskQueue.run(loader);
}
 
Example #12
Source File: MockVcsHelper.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void openCommittedChangesTab(CommittedChangesProvider provider,
                                    RepositoryLocation location,
                                    ChangeBrowserSettings settings,
                                    int maxCount,
                                    String title) {
  throw new UnsupportedOperationException();
}
 
Example #13
Source File: TFSCommittedChangesProvider.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
@Override
public List<TFSChangeList> getCommittedChanges(final ChangeBrowserSettings settings,
                                               final RepositoryLocation location,
                                               final int maxCount) throws VcsException {
    final List<TFSChangeList> result = new ArrayList<TFSChangeList>();
    loadCommittedChanges(settings, location, maxCount, new AsynchConsumer<CommittedChangeList>() {
        public void finished() {
        }

        public void consume(final CommittedChangeList committedChangeList) {
            result.add((TFSChangeList) committedChangeList);
        }
    });
    return result;
}
 
Example #14
Source File: CommittedChangesCache.java    From consulo with Apache License 2.0 5 votes vote down vote up
private List<CommittedChangeList> initCache(final ChangesCacheFile cacheFile) throws VcsException, IOException {
  debug("Initializing cache for " + cacheFile.getLocation());
  final CachingCommittedChangesProvider provider = cacheFile.getProvider();
  final RepositoryLocation location = cacheFile.getLocation();
  final ChangeBrowserSettings settings = provider.createDefaultSettings();
  int maxCount = 0;
  if (isMaxCountSupportedForProject()) {
    maxCount = myState.getInitialCount();
  }
  else {
    settings.USE_DATE_AFTER_FILTER = true;
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DAY_OF_YEAR, -myState.getInitialDays());
    settings.setDateAfter(calendar.getTime());
  }
  //noinspection unchecked
  final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, location, maxCount);
  // when initially initializing cache, assume all changelists are locally available
  writeChangesInReadAction(cacheFile, changes); // this sorts changes in chronological order
  if (maxCount > 0 && changes.size() < myState.getInitialCount()) {
    cacheFile.setHaveCompleteHistory(true);
  }
  if (changes.size() > 0) {
    fireChangesLoaded(location, changes);
  }
  return changes;
}
 
Example #15
Source File: TFSCommittedChangesProvider.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
@Override
public Pair<TFSChangeList, FilePath> getOneList(final VirtualFile file, final VcsRevisionNumber number) throws VcsException {
    final ChangeBrowserSettings settings = createDefaultSettings();
    settings.USE_CHANGE_AFTER_FILTER = true;
    settings.USE_CHANGE_BEFORE_FILTER = true;
    settings.CHANGE_BEFORE = settings.CHANGE_AFTER = String.valueOf(((TfsRevisionNumber) number).getValue());
    final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(file);
    final List<TFSChangeList> list = getCommittedChanges(settings, getLocationFor(filePath), 1);
    if (list.size() == 1) {
        return Pair.create(list.get(0), filePath);
    }
    return null;
}
 
Example #16
Source File: CommittedChangesCache.java    From consulo with Apache License 2.0 5 votes vote down vote up
private List<CommittedChangeList> refreshCache(final ChangesCacheFile cacheFile) throws VcsException, IOException {
  final List<CommittedChangeList> newLists = new ArrayList<CommittedChangeList>();

  final CachingCommittedChangesProvider provider = cacheFile.getProvider();
  final RepositoryLocation location = cacheFile.getLocation();

  final Pair<Long, List<CommittedChangeList>> externalLists = myExternallyLoadedChangeLists.get(location.getKey());
  final long latestChangeList = getLatestListForFile(cacheFile);
  if ((externalLists != null) && (latestChangeList == externalLists.first.longValue())) {
    newLists.addAll(appendLoadedChanges(cacheFile, location, externalLists.second));
    myExternallyLoadedChangeLists.clear();
  }

  final ChangeBrowserSettings defaultSettings = provider.createDefaultSettings();
  int maxCount = 0;
  if (provider.refreshCacheByNumber()) {
    final long number = cacheFile.getLastCachedChangelist();
    debug("Refreshing cache for " + location + " since #" + number);
    if (number >= 0) {
      defaultSettings.CHANGE_AFTER = Long.toString(number);
      defaultSettings.USE_CHANGE_AFTER_FILTER = true;
    }
    else {
      maxCount = myState.getInitialCount();
    }
  }
  else {
    final Date date = cacheFile.getLastCachedDate();
    debug("Refreshing cache for " + location + " since " + date);
    defaultSettings.setDateAfter(date);
    defaultSettings.USE_DATE_AFTER_FILTER = true;
  }
  final List<CommittedChangeList> newChanges = provider.getCommittedChanges(defaultSettings, location, maxCount);
  debug("Loaded " + newChanges.size() + " new changelists");
  newLists.addAll(appendLoadedChanges(cacheFile, location, newChanges));

  return newLists;
}
 
Example #17
Source File: AbstractVcsHelperImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private AsynchronousListsLoader(@Nullable Project project, final CommittedChangesProvider provider,
                                final RepositoryLocation location, final ChangeBrowserSettings settings, final ChangesBrowserDialog dlg) {
  super(project, VcsBundle.message("browse.changes.progress.title"), true);
  myProvider = provider;
  myLocation = location;
  mySettings = settings;
  myDlg = dlg;
  myExceptions = new LinkedList<>();
}
 
Example #18
Source File: TFSVcs.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
@NotNull
public CommittedChangesProvider<TFSChangeList, ChangeBrowserSettings> getCommittedChangesProvider() {
    if (committedChangesProvider == null) {
        committedChangesProvider = new TFSCommittedChangesProvider(myProject);
    }
    return committedChangesProvider;
}
 
Example #19
Source File: CommittedChangesFilterDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
public CommittedChangesFilterDialog(Project project, ChangesBrowserSettingsEditor panel, ChangeBrowserSettings settings) {
  super(project, false);
  myPanel = panel;
  //noinspection unchecked
  myPanel.setSettings(settings);
  setTitle(VcsBundle.message("browse.changes.filter.title"));
  init();
  myErrorLabel.setForeground(Color.red);
  validateInput();
  myValidateAlarm.addRequest(myValidateRunnable, 500, ModalityState.stateForComponent(myPanel.getComponent()));
}
 
Example #20
Source File: CompositeCommittedChangesProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void put(final AbstractVcs vcs, final ChangeBrowserSettings settings) {
  myMap.put(vcs, settings);
}
 
Example #21
Source File: CommittedChangesFilterDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ChangeBrowserSettings getSettings() {
  return mySettings;
}
 
Example #22
Source File: CompositeCommittedChangesProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ChangeBrowserSettings get(final AbstractVcs vcs) {
  return myMap.get(vcs);
}
 
Example #23
Source File: CommittedChangesPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
public CommittedChangesPanel(Project project, final CommittedChangesProvider provider, final ChangeBrowserSettings settings,
                             @Nullable final RepositoryLocation location, @javax.annotation.Nullable ActionGroup extraActions) {
  super(new BorderLayout());
  mySettings = settings;
  myProject = project;
  myProvider = provider;
  myLocation = location;
  myShouldBeCalledOnDispose = new ArrayList<Runnable>();
  myBrowser = new CommittedChangesTreeBrowser(project, new ArrayList<CommittedChangeList>());
  Disposer.register(this, myBrowser);
  add(myBrowser, BorderLayout.CENTER);

  final VcsCommittedViewAuxiliary auxiliary = provider.createActions(myBrowser, location);

  JPanel toolbarPanel = new JPanel();
  toolbarPanel.setLayout(new BoxLayout(toolbarPanel, BoxLayout.X_AXIS));

  ActionGroup group = (ActionGroup) ActionManager.getInstance().getAction("CommittedChangesToolbar");

  ActionToolbar toolBar = myBrowser.createGroupFilterToolbar(project, group, extraActions,
                                                             auxiliary != null ? auxiliary.getToolbarActions() : Collections.<AnAction>emptyList());
  toolbarPanel.add(toolBar.getComponent());
  toolbarPanel.add(Box.createHorizontalGlue());
  toolbarPanel.add(myFilterComponent);
  myFilterComponent.setMinimumSize(myFilterComponent.getPreferredSize());
  myFilterComponent.setMaximumSize(myFilterComponent.getPreferredSize());
  myBrowser.setToolBar(toolbarPanel);

  if (auxiliary != null) {
    myShouldBeCalledOnDispose.add(auxiliary.getCalledOnViewDispose());
    myBrowser.setTableContextMenu(group, (auxiliary.getPopupActions() == null) ? Collections.<AnAction>emptyList() : auxiliary.getPopupActions());
  } else {
    myBrowser.setTableContextMenu(group, Collections.<AnAction>emptyList());
  }
  
  final AnAction anAction = ActionManager.getInstance().getAction("CommittedChanges.Refresh");
  anAction.registerCustomShortcutSet(CommonShortcuts.getRerun(), this);
  myBrowser.addFilter(myFilterComponent);
  myIfNotCachedReloader = myLocation == null ? null : new Consumer<String>() {
    @Override
    public void consume(String s) {
      refreshChanges(false);
    }
  };
}
 
Example #24
Source File: TFSVersionFilterComponent.java    From azure-devops-intellij with MIT License 4 votes vote down vote up
public TFSVersionFilterComponent(final boolean showDateFilter) {
    super(showDateFilter);
    standardPanel.setLayout(new BorderLayout());
    standardPanel.add(getStandardPanel(), BorderLayout.CENTER);
    init(new ChangeBrowserSettings());
}
 
Example #25
Source File: CompositeCommittedChangesProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
public CompositeChangeBrowserSettings(final Map<AbstractVcs, ChangeBrowserSettings> map) {
  myMap = map;
  myEnabledVcs.addAll(map.keySet());
}
 
Example #26
Source File: AbstractVcsHelperImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void loadAndShowCommittedChangesDetails(@Nonnull final Project project,
                                               @Nonnull final VcsRevisionNumber revision,
                                               @Nonnull final VirtualFile virtualFile,
                                               @Nonnull VcsKey vcsKey,
                                               @Nullable final RepositoryLocation location,
                                               final boolean isNonLocal) {
  final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).findVcsByName(vcsKey.getName());
  if (vcs == null) return;
  final CommittedChangesProvider provider = vcs.getCommittedChangesProvider();
  if (provider == null) return;
  if (isNonLocal && provider.getForNonLocal(virtualFile) == null) return;

  final String title = VcsBundle.message("paths.affected.in.revision",
                                         revision instanceof ShortVcsRevisionNumber
                                         ? ((ShortVcsRevisionNumber)revision).toShortString()
                                         : revision.asString());
  final CommittedChangeList[] list = new CommittedChangeList[1];
  final FilePath[] targetPath = new FilePath[1];
  final VcsException[] exc = new VcsException[1];

  final BackgroundableActionLock lock = BackgroundableActionLock.getLock(project, VcsBackgroundableActions.COMMITTED_CHANGES_DETAILS,
                                                                         revision, virtualFile.getPath());
  if (lock.isLocked()) return;
  lock.lock();

  Task.Backgroundable task = new Task.Backgroundable(project, title, true) {
    @Override
    public void run(@Nonnull ProgressIndicator indicator) {
      try {
        if (!isNonLocal) {
          final Pair<CommittedChangeList, FilePath> pair = provider.getOneList(virtualFile, revision);
          if (pair != null) {
            list[0] = pair.getFirst();
            targetPath[0] = pair.getSecond();
          }
        }
        else {
          if (location != null) {
            final ChangeBrowserSettings settings = provider.createDefaultSettings();
            settings.USE_CHANGE_BEFORE_FILTER = true;
            settings.CHANGE_BEFORE = revision.asString();
            final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, location, 1);
            if (changes != null && changes.size() == 1) {
              list[0] = changes.get(0);
            }
          }
          else {
            list[0] = getRemoteList(vcs, revision, virtualFile);
          }
        }
      }
      catch (VcsException e) {
        exc[0] = e;
      }
    }

    @Override
    public void onCancel() {
      lock.unlock();
    }

    @Override
    public void onSuccess() {
      lock.unlock();
      if (exc[0] != null) {
        showError(exc[0], failedText(virtualFile, revision));
      }
      else if (list[0] == null) {
        Messages.showErrorDialog(project, failedText(virtualFile, revision), getTitle());
      }
      else {
        VirtualFile navigateToFile = targetPath[0] != null ?
                                     new VcsVirtualFile(targetPath[0].getPath(), null, VcsFileSystem.getInstance()) :
                                     virtualFile;
        showChangesListBrowser(list[0], navigateToFile, title);
      }
    }
  };

  // we can's use runProcessWithProgressAsynchronously(task) because then ModalityState.NON_MODAL would be used
  CoreProgressManager progressManager = (CoreProgressManager)ProgressManager.getInstance();
  progressManager.runProcessWithProgressAsynchronously(task, new BackgroundableProcessIndicator(task), null, ModalityState.current());
}
 
Example #27
Source File: ShowAllAffectedGenericAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static void showSubmittedFiles(final Project project, final VcsRevisionNumber revision, final VirtualFile virtualFile,
                                       final VcsKey vcsKey, final RepositoryLocation location, final boolean isNonLocal) {
  final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).findVcsByName(vcsKey.getName());
  if (vcs == null) return;
  if (isNonLocal && ! canPresentNonLocal(project, vcsKey, virtualFile)) return;

  final String title = VcsBundle.message("paths.affected.in.revision",
                                         revision instanceof ShortVcsRevisionNumber
                                             ? ((ShortVcsRevisionNumber) revision).toShortString()
                                             :  revision.asString());
  final CommittedChangeList[] list = new CommittedChangeList[1];
  final VcsException[] exc = new VcsException[1];
  Task.Backgroundable task = new Task.Backgroundable(project, title, true, BackgroundFromStartOption.getInstance()) {
    @Override
    public void run(@Nonnull ProgressIndicator indicator) {
      try {
        final CommittedChangesProvider provider = vcs.getCommittedChangesProvider();
        if (!isNonLocal) {
          final Pair<CommittedChangeList, FilePath> pair = provider.getOneList(virtualFile, revision);
          if (pair != null) {
            list[0] = pair.getFirst();
          }
        }
        else {
          if (location != null) {
            final ChangeBrowserSettings settings = provider.createDefaultSettings();
            settings.USE_CHANGE_BEFORE_FILTER = true;
            settings.CHANGE_BEFORE = revision.asString();
            final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, location, 1);
            if (changes != null && changes.size() == 1) {
              list[0] = changes.get(0);
            }
            return;
          }
          else {
            list[0] = getRemoteList(vcs, revision, virtualFile);
            /*final RepositoryLocation local = provider.getForNonLocal(virtualFile);
            if (local != null) {
              final String number = revision.asString();
              final ChangeBrowserSettings settings = provider.createDefaultSettings();
              final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, local, provider.getUnlimitedCountValue());
              if (changes != null) {
                for (CommittedChangeList change : changes) {
                  if (number.equals(String.valueOf(change.getNumber()))) {
                    list[0] = change;
                  }
                }
              }
            } */
          }
        }
      }
      catch (VcsException e) {
        exc[0] = e;
      }
    }

    @RequiredUIAccess
    @Override
    public void onSuccess() {
      final AbstractVcsHelper instance = AbstractVcsHelper.getInstance(project);
      if (exc[0] != null) {
        instance.showError(exc[0], failedText(virtualFile, revision));
      }
      else if (list[0] == null) {
        Messages.showErrorDialog(project, failedText(virtualFile, revision), getTitle());
      }
      else {
        instance.showChangesListBrowser(list[0], virtualFile, title);
      }
    }
  };
  ProgressManager.getInstance().run(task);
}
 
Example #28
Source File: AbstractVcsHelper.java    From consulo with Apache License 2.0 4 votes vote down vote up
public abstract void openCommittedChangesTab(CommittedChangesProvider provider,
RepositoryLocation location,
ChangeBrowserSettings settings,
int maxCount,
final String title);
 
Example #29
Source File: AbstractVcsHelper.java    From consulo with Apache License 2.0 4 votes vote down vote up
public abstract void openCommittedChangesTab(AbstractVcs vcs,
VirtualFile root,
ChangeBrowserSettings settings,
int maxCount,
final String title);
 
Example #30
Source File: AbstractVcsHelper.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
public abstract <T extends CommittedChangeList, U extends ChangeBrowserSettings> T chooseCommittedChangeList(@Nonnull CommittedChangesProvider<T, U> provider,
                                                                                                             RepositoryLocation location);