1 // Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2 package com.intellij.openapi.vcs.history.actions;
4 import com.intellij.openapi.actionSystem.AnActionEvent;
5 import com.intellij.openapi.ide.CopyPasteManager;
6 import com.intellij.openapi.project.DumbAwareAction;
7 import com.intellij.openapi.util.text.StringUtil;
8 import com.intellij.openapi.vcs.VcsDataKeys;
9 import org.jetbrains.annotations.NotNull;
11 import java.awt.datatransfer.StringSelection;
13 public class CopyCommitSubjectAction extends DumbAwareAction {
16 public void actionPerformed(@NotNull AnActionEvent e) {
17 String[] subjects = e.getData(VcsDataKeys.VCS_COMMIT_SUBJECTS);
18 if (subjects == null || subjects.length == 0) return;
19 CopyPasteManager.getInstance().setContents(new StringSelection(StringUtil.join(subjects, "\n")));
23 public void update(@NotNull AnActionEvent e) {
24 String[] subjects = e.getData(VcsDataKeys.VCS_COMMIT_SUBJECTS);
25 e.getPresentation().setEnabled(subjects != null && subjects.length > 0);