From 170d39bc5c994d24d5d50389b041c24686e4c68b Mon Sep 17 00:00:00 2001 From: Alex Plate Date: Mon, 8 Sep 2025 15:19:13 +0300 Subject: [PATCH] [DataSpell] Remove the hack to support png copy on macos This hack was introduced due to JDK issue JBR-9044, but it was fixed in Java 21 JBR JBR-8952 GitOrigin-RevId: 14b7c7eac18540df913ffef18ccb251ed2602c5a --- .../visualization/r/inlays/ClipboardUtils.kt | 35 +------------------ 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/notebooks/visualization/src/com/intellij/notebooks/visualization/r/inlays/ClipboardUtils.kt b/notebooks/visualization/src/com/intellij/notebooks/visualization/r/inlays/ClipboardUtils.kt index 769837d67ad0..528137e58cc5 100644 --- a/notebooks/visualization/src/com/intellij/notebooks/visualization/r/inlays/ClipboardUtils.kt +++ b/notebooks/visualization/src/com/intellij/notebooks/visualization/r/inlays/ClipboardUtils.kt @@ -1,19 +1,12 @@ -/* - * Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - */ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.notebooks.visualization.r.inlays import com.intellij.openapi.ide.CopyPasteManager -import com.intellij.openapi.util.io.FileUtil -import com.intellij.util.system.OS import java.awt.Image import java.awt.datatransfer.DataFlavor import java.awt.datatransfer.Transferable import java.awt.datatransfer.UnsupportedFlavorException -import java.awt.image.BufferedImage -import java.io.File -import javax.imageio.ImageIO // TODO: Some problems with getting "event.isControlDown" on component placed on top of Idea Editor content. /** Clipboard utils to realize Ctrl+C functionality in Table and Plots. */ @@ -23,32 +16,6 @@ object ClipboardUtils { CopyPasteManager.getInstance().setContents(ImageTransferable(image)) } - // We have a situation that on some MacOS the image is copied as TIFF. - // To avoid this situation on Mac, we have a special transferable which copies image as png. - // https://bugs.openjdk.org/browse/JDK-8313706 - // https://youtrack.jetbrains.com/issue/PY-69919/Result-of-Copy-plot-command-results-in-Unsupported-image-type-in-Google-Slides - fun copyPngImageToClipboard(image: BufferedImage) { - val tempImage = FileUtil.createTempFile("clipboard", ".png") - ImageIO.write(image, "png", tempImage) - - CopyPasteManager.getInstance().setContents(FileTransferable(listOf(tempImage))) - } - - // Standard copy works incorrectly on Mac, see JBR-6788, - // But it seemingly was fixed in the newer (15 and later) Mac versions - fun isIntermediateFileWorkaroundNeeded(): Boolean = OS.CURRENT == OS.macOS && !OS.CURRENT.isAtLeast(15, 0) - - private class FileTransferable(private val files: List) : Transferable { - override fun getTransferDataFlavors(): Array = arrayOf(DataFlavor.javaFileListFlavor) - override fun isDataFlavorSupported(flavor: DataFlavor): Boolean = DataFlavor.javaFileListFlavor.equals(flavor) - override fun getTransferData(flavor: DataFlavor): List { - if (!isDataFlavorSupported(flavor)) - throw UnsupportedFlavorException(flavor) - - return files - } - } - private class ImageTransferable(private val image: Image) : Transferable { override fun getTransferDataFlavors(): Array { return arrayOf(DataFlavor.imageFlavor)