com.intellij.vcs.log.VcsLogDataKeys Java Examples

The following examples show how to use com.intellij.vcs.log.VcsLogDataKeys. 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: VcsLogAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent e) {
  Project project = e.getProject();
  VcsLog log = e.getData(VcsLogDataKeys.VCS_LOG);
  if (project == null || log == null) {
    e.getPresentation().setEnabledAndVisible(false);
    return;
  }

  List<VcsFullCommitDetails> details = log.getSelectedDetails();
  MultiMap<Repo, VcsFullCommitDetails> grouped = groupByRootWithCheck(project, details);
  if (grouped == null) {
    e.getPresentation().setEnabledAndVisible(false);
  }
  else {
    e.getPresentation().setVisible(isVisible(project, grouped));
    e.getPresentation().setEnabled(!grouped.isEmpty() && isEnabled(grouped));
  }
}
 
Example #2
Source File: OpenCommitInBrowserAction.java    From azure-devops-intellij with MIT License 6 votes vote down vote up
@Override
public void actionPerformed(@NotNull final AnActionEvent anActionEvent) {
    final Project project = anActionEvent.getRequiredData(CommonDataKeys.PROJECT);
    final VcsFullCommitDetails commit = anActionEvent.getRequiredData(VcsLogDataKeys.VCS_LOG).getSelectedDetails().get(0);

    final GitRepository gitRepository = GitUtil.getRepositoryManager(project).getRepositoryForRootQuick(commit.getRoot());
    if (gitRepository == null)
        return;

    final GitRemote remote = TfGitHelper.getTfGitRemote(gitRepository);

    // guard for null so findbugs doesn't complain
    if (remote == null) {
        return;
    }

    final String remoteUrl = remote.getFirstUrl();
    if (remoteUrl == null) {
        return;
    }

    final URI urlToBrowseTo = UrlHelper.getCommitURI(remoteUrl, commit.getId().toString());
    logger.info("Browsing to url " + urlToBrowseTo.getPath());
    BrowserUtil.browse(urlToBrowseTo);
}
 
Example #3
Source File: IntelliSortChooserPopupAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  VcsLogUi logUI = e.getRequiredData(VcsLogDataKeys.VCS_LOG_UI);
  VcsLogUiProperties properties = e.getRequiredData(VcsLogInternalDataKeys.LOG_UI_PROPERTIES);

  ActionGroup settingsGroup = new DefaultActionGroup(
          ContainerUtil.map(PermanentGraph.SortType.values(), (Function<PermanentGraph.SortType, AnAction>)sortType -> new SelectIntelliSortTypeAction(logUI, properties, sortType)));


  ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, settingsGroup, e.getDataContext(), JBPopupFactory.ActionSelectionAid.MNEMONICS, true, ToolWindowContentUI.POPUP_PLACE);
  Component component = e.getInputEvent().getComponent();
  if (component instanceof ActionButtonComponent) {
    popup.showUnderneathOf(component);
  }
  else {
    popup.showInCenterOf(component);
  }
}
 
Example #4
Source File: RefreshLogAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  VcsLogUtil.triggerUsage(e);

  VcsLogManager logManager = e.getRequiredData(VcsLogInternalDataKeys.LOG_MANAGER);

  // diagnostic for possible refresh problems
  VcsLogUi ui = e.getRequiredData(VcsLogDataKeys.VCS_LOG_UI);
  if (ui instanceof VcsLogUiImpl) {
    VcsLogFilterer filterer = ((VcsLogUiImpl)ui).getFilterer();
    if (!filterer.isValid()) {
      String message = "Trying to refresh invalid log tab.";
      if (!logManager.getDataManager().getProgress().isRunning()) {
        LOG.error(message);
      } else {
        LOG.warn(message);
      }
      filterer.setValid(true);
    }
  }

  logManager.getDataManager().refreshSoftly();
}
 
Example #5
Source File: IntelliSortChooserToggleAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent e) {
  super.update(e);

  VcsLogUi logUI = e.getData(VcsLogDataKeys.VCS_LOG_UI);
  VcsLogUiProperties properties = e.getData(VcsLogInternalDataKeys.LOG_UI_PROPERTIES);
  e.getPresentation().setVisible(BekUtil.isBekEnabled());
  e.getPresentation().setEnabled(BekUtil.isBekEnabled() && logUI != null);

  if (properties != null && properties.exists(MainVcsLogUiProperties.BEK_SORT_TYPE)) {
    boolean off = properties.get(MainVcsLogUiProperties.BEK_SORT_TYPE) == PermanentGraph.SortType.Normal;
    String description = "Turn IntelliSort " + (off ? "on" : "off") + ": " +
                         (off
                          ? PermanentGraph.SortType.Bek.getDescription().toLowerCase()
                          : PermanentGraph.SortType.Normal.getDescription().toLowerCase()) + ".";
    e.getPresentation().setDescription(description);
    e.getPresentation().setText(description);
  }
  else {
    e.getPresentation().setText(DEFAULT_TEXT);
    e.getPresentation().setDescription(DEFAULT_DESCRIPTION);
  }
}
 
Example #6
Source File: FocusTextFilterAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  Project project = e.getRequiredData(CommonDataKeys.PROJECT);
  MainFrame mainFrame = ((VcsLogUiImpl)e.getRequiredData(VcsLogDataKeys.VCS_LOG_UI)).getMainFrame();
  if (mainFrame.getTextFilter().getTextEditor().hasFocus()) {
    IdeFocusManager.getInstance(project).requestFocus(mainFrame.getGraphTable(), true);
  }
  else {
    IdeFocusManager.getInstance(project).requestFocus(mainFrame.getTextFilter(), true);
  }
}
 
Example #7
Source File: VcsCherryPickAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent e) {
  super.update(e);
  e.getPresentation().setVisible(true);

  final VcsLog log = e.getData(VcsLogDataKeys.VCS_LOG);
  Project project = e.getProject();
  if (project == null) {
    e.getPresentation().setEnabledAndVisible(false);
    return;
  }
  VcsCherryPickManager cherryPickManager = VcsCherryPickManager.getInstance(project);

  List<VcsCherryPicker> cherryPickers = getActiveCherryPickersForProject(project);
  if (log == null || cherryPickers.isEmpty()) {
    e.getPresentation().setEnabledAndVisible(false);
    return;
  }

  List<CommitId> commits = VcsLogUtil.collectFirstPack(log.getSelectedCommits(), VcsLogUtil.MAX_SELECTED_COMMITS);
  if (commits.isEmpty() || cherryPickManager.isCherryPickAlreadyStartedFor(commits)) {
    e.getPresentation().setEnabled(false);
    return;
  }

  final Map<VirtualFile, List<Hash>> groupedByRoot = groupByRoot(commits);
  VcsCherryPicker activeCherryPicker = getActiveCherryPicker(cherryPickers, groupedByRoot.keySet());
  String description = activeCherryPicker != null ? activeCherryPicker.getInfo(log, groupedByRoot) : SEVERAL_VCS_DESCRIPTION;
  e.getPresentation().setEnabled(description == null);
  e.getPresentation()
          .setText(activeCherryPicker == null ? concatActionNamesForAllAvailable(cherryPickers) : activeCherryPicker.getActionTitle());
  e.getPresentation().setDescription(description == null ? "" : description);
}
 
Example #8
Source File: VcsCherryPickAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  FileDocumentManager.getInstance().saveAllDocuments();

  Project project = e.getRequiredData(CommonDataKeys.PROJECT);
  VcsLog log = e.getRequiredData(VcsLogDataKeys.VCS_LOG);

  VcsCherryPickManager.getInstance(project).cherryPick(log);
}
 
Example #9
Source File: ShowCommitTooltipAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  VcsLogGraphTable table = ((VcsLogUiImpl)e.getRequiredData(VcsLogDataKeys.VCS_LOG_UI)).getTable();
  int row = table.getSelectedRow();
  if (ScrollingUtil.isVisible(table, row)) {
    table.showTooltip(row);
  }
}
 
Example #10
Source File: ShowCommitTooltipAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent e) {
  Project project = e.getProject();
  VcsLogUi ui = e.getData(VcsLogDataKeys.VCS_LOG_UI);
  if (project == null || ui == null) {
    e.getPresentation().setEnabledAndVisible(false);
  }
  else {
    e.getPresentation().setEnabledAndVisible(ui instanceof VcsLogUiImpl && ((VcsLogUiImpl)ui).getTable().getSelectedRowCount() == 1);
  }
}
 
Example #11
Source File: CollapseOrExpandGraphAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent e) {
  VcsLogUi ui = e.getData(VcsLogDataKeys.VCS_LOG_UI);
  VcsLogUiProperties properties = e.getData(VcsLogInternalDataKeys.LOG_UI_PROPERTIES);

  if (ui != null && ui.areGraphActionsEnabled() && properties != null && !properties.exists(MainVcsLogUiProperties.BEK_SORT_TYPE)) {
    e.getPresentation().setEnabled(true);
    if (!ui.getFilterUi().getFilters().getDetailsFilters().isEmpty()) {
      e.getPresentation().setEnabled(false);
    }

    if (properties.get(MainVcsLogUiProperties.BEK_SORT_TYPE) == PermanentGraph.SortType.LinearBek) {
      e.getPresentation().setText(getPrefix() + MERGES);
      e.getPresentation().setDescription(getPrefix() + MERGES_DESCRIPTION);
    }
    else {
      e.getPresentation().setText(getPrefix() + LINEAR_BRANCHES);
      e.getPresentation().setDescription(getPrefix() + LINEAR_BRANCHES_DESCRIPTION);
    }
  }
  else {
    e.getPresentation().setEnabled(false);
  }

  e.getPresentation().setText(getPrefix() + LINEAR_BRANCHES);
  e.getPresentation().setDescription(getPrefix() + LINEAR_BRANCHES_DESCRIPTION);
  if (isIconHidden(e)) {
    e.getPresentation().setIcon(null);
  }
  else {
    e.getPresentation().setIcon(
            properties != null &&
            properties.exists(MainVcsLogUiProperties.BEK_SORT_TYPE) &&
            properties.get(MainVcsLogUiProperties.BEK_SORT_TYPE) == PermanentGraph.SortType.LinearBek ? getMergesIcon() : getBranchesIcon());
  }
}
 
Example #12
Source File: CollapseOrExpandGraphAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  VcsLogUtil.triggerUsage(e);

  VcsLogUi ui = e.getRequiredData(VcsLogDataKeys.VCS_LOG_UI);
  executeAction((VcsLogUiImpl)ui);
}
 
Example #13
Source File: VcsLogAction.java    From GitLink with MIT License 5 votes vote down vote up
@Override
public void actionPerformed(@NotNull final Project project, @NotNull final AnActionEvent event)
{
    VcsLog vcsLog = event.getData(VcsLogDataKeys.VCS_LOG);

    if (vcsLog == null) {
        return;
    }

    VcsFullCommitDetails vcsCommit = vcsLog.getSelectedDetails().get(0);

    Commit commit = new Commit(vcsCommit.getId().toShortString());

    this.perform(project, commit, vcsCommit.getRoot());
}
 
Example #14
Source File: EnableMatchCaseAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent e) {
  super.update(e);

  VcsLogUi ui = e.getData(VcsLogDataKeys.VCS_LOG_UI);
  VcsLogUiProperties properties = e.getData(VcsLogInternalDataKeys.LOG_UI_PROPERTIES);
  if (ui != null && properties != null && properties.exists(MainVcsLogUiProperties.TEXT_FILTER_MATCH_CASE)) {
    boolean regexEnabled =
            properties.exists(MainVcsLogUiProperties.TEXT_FILTER_REGEX) && properties.get(MainVcsLogUiProperties.TEXT_FILTER_REGEX);
    if (!regexEnabled) {
      e.getPresentation().setText(MATCH_CASE);
    }
    else {
      Collection<VcsLogProvider> providers = ContainerUtil.newLinkedHashSet(ui.getDataPack().getLogProviders().values());
      List<VcsLogProvider> supported =
              ContainerUtil.filter(providers, p -> VcsLogProperties.get(p, VcsLogProperties.CASE_INSENSITIVE_REGEX));
      e.getPresentation().setVisible(true);
      e.getPresentation().setEnabled(!supported.isEmpty());
      if (providers.size() == supported.size() || supported.isEmpty()) {
        e.getPresentation().setText(MATCH_CASE);
      }
      else {
        String supportedText = StringUtil.join(ContainerUtil.map(supported, p -> p.getSupportedVcs().getName().toLowerCase()), ", ");
        e.getPresentation().setText(MATCH_CASE + " (" + supportedText + " only)");
      }
    }
  }
}
 
Example #15
Source File: OpenCommitInBrowserAction.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
@Override
public void update(@NotNull final AnActionEvent anActionEvent) {

    final Presentation presentation = anActionEvent.getPresentation();

    final Project project = anActionEvent.getData(CommonDataKeys.PROJECT);
    final VcsLog log = anActionEvent.getData(VcsLogDataKeys.VCS_LOG);
    if (project == null || project.isDisposed() || log == null) {
        presentation.setEnabledAndVisible(false);
        return;
    }

    final List<VcsFullCommitDetails> commits = log.getSelectedDetails();
    if (commits.size() == 0) {
        presentation.setEnabledAndVisible(false);
        return;
    }

    final VcsFullCommitDetails commit = commits.get(0);

    final GitRepository repository = GitUtil.getRepositoryManager(project).getRepositoryForRootQuick(commit.getRoot());

    if (repository == null || !TfGitHelper.isTfGitRepository(repository)) {
        presentation.setEnabledAndVisible(false);
        return;
    } else if (commits.size() > 1) {
        // only one for now, leave it visible as a breadcrumb
        presentation.setVisible(true);
        presentation.setEnabled(false);
        return;
    }

    presentation.setEnabledAndVisible(true);
}
 
Example #16
Source File: VcsLogAction.java    From GitLink with MIT License 5 votes vote down vote up
@Override
protected boolean shouldActionBeEnabled(@NotNull final AnActionEvent event)
{
    VcsLog log = event.getData(VcsLogDataKeys.VCS_LOG);

    if (log == null) {
        return false;
    }

    List<VcsFullCommitDetails> commits = log.getSelectedDetails();

    return commits.size() == 1;
}
 
Example #17
Source File: ShowRootsColumnAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent e) {
  super.update(e);
  VcsLogUi ui = e.getData(VcsLogDataKeys.VCS_LOG_UI);
  if (ui == null || !ui.isMultipleRoots()) e.getPresentation().setEnabledAndVisible(false);
}
 
Example #18
Source File: FocusTextFilterAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent e) {
  Project project = e.getProject();
  VcsLogUi ui = e.getData(VcsLogDataKeys.VCS_LOG_UI);
  e.getPresentation().setEnabledAndVisible(project != null && ui != null && ui instanceof VcsLogUiImpl);
}
 
Example #19
Source File: RefreshLogAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void update(AnActionEvent e) {
  VcsLogManager logManager = e.getData(VcsLogInternalDataKeys.LOG_MANAGER);
  e.getPresentation().setEnabledAndVisible(logManager != null && e.getData(VcsLogDataKeys.VCS_LOG_UI) != null);
}
 
Example #20
Source File: VcsLogGearActionGroup.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent e) {
  Project project = e.getProject();
  VcsLogUi logUi = e.getData(VcsLogDataKeys.VCS_LOG_UI);
  e.getPresentation().setEnabledAndVisible(project != null && logUi != null);
}
 
Example #21
Source File: ShowLongEdgesAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent e) {
  super.update(e);
  VcsLogUi ui = e.getData(VcsLogDataKeys.VCS_LOG_UI);
  if (ui != null && !ui.areGraphActionsEnabled()) e.getPresentation().setEnabled(false);
}