content: /**
   * Copied and adapted from plugin
   * <a href="https://github.com/neueda/jetbrains-plugin-graph-database-support">Graph Database Support</a>
   * by Neueda Technologies, Ltd.
   * Modified by Alberto Venturini, 2022
   */
  package com.albertoventurini.graphdbplugin.jetbrains.ui.console.graph;
  
  import com.albertoventurini.graphdbplugin.jetbrains.ui.helpers.SerialisationHelper;
  import com.intellij.openapi.actionSystem.AnAction;
  import com.intellij.openapi.actionSystem.AnActionEvent;
  import org.jetbrains.annotations.NotNull;
  
  import javax.swing.*;
  import java.awt.*;
  import java.awt.datatransfer.Clipboard;
  import java.awt.datatransfer.StringSelection;
  
  public class CopyToClipboardAction extends AnAction {
      private Object object;
  
      CopyToClipboardAction(String title, String description, Icon icon, Object object) {
          super(title, description, icon);
          this.object = object;
      }
  
      @Override
      public void actionPerformed(@NotNull AnActionEvent e) {
          StringSelection selection = new StringSelection(SerialisationHelper.convertToCsv(object));
          Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
          clipboard.setContents(selection, selection);
      }
  }
  