mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[pycharm] PY-79113 Debugger: add registry key for new actions
GitOrigin-RevId: 76682a9fa77496a51c9fd73a8b2cf76c9f895278
This commit is contained in:
committed by
intellij-monorepo-bot
parent
35147ce462
commit
e6bf961f86
@@ -47,6 +47,8 @@
|
||||
<registryKey key="ide.images.show.grid.after.every.x.pixels" defaultValue="1" description="Pixels between grid lines"/>
|
||||
<registryKey key="ide.images.change.background.action.enabled" defaultValue="false"
|
||||
description="Show action for changing background in the editor toolbar"/>
|
||||
<registryKey key="ide.images.sci.mode.channels.operations" defaultValue="false"
|
||||
description="Show combobox for image channels operations"/>
|
||||
</extensions>
|
||||
|
||||
<actions>
|
||||
|
||||
@@ -4,9 +4,10 @@ import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||
import com.intellij.openapi.project.DumbAwareAction
|
||||
import org.intellij.images.editor.ImageDocument
|
||||
import org.intellij.images.editor.ImageFileEditor
|
||||
import org.intellij.images.scientific.ScientificUtils
|
||||
import org.intellij.images.scientific.ScientificUtils.ORIGINAL_IMAGE_KEY
|
||||
import org.intellij.images.scientific.convertToByteArray
|
||||
import java.awt.image.BufferedImage
|
||||
|
||||
class GrayscaleImageAction : DumbAwareAction() {
|
||||
@@ -21,7 +22,9 @@ class GrayscaleImageAction : DumbAwareAction() {
|
||||
val imageFile = e.getData(CommonDataKeys.VIRTUAL_FILE) ?: return
|
||||
val originalImage = imageFile.getUserData(ORIGINAL_IMAGE_KEY) ?: return
|
||||
val grayscaleImage = applyGrayscale(originalImage)
|
||||
imageFile.setBinaryContent(convertToByteArray(grayscaleImage, imageFile.fileType.defaultExtension))
|
||||
//val editor = e.getData(IMAGE_DOCUMENT_DATA_KEY ) TODO: get editor?
|
||||
//val document = (editor as ImageFileEditor).imageEditor.document as ImageDocument
|
||||
//document.value = grayscaleImage
|
||||
}
|
||||
|
||||
private fun applyGrayscale(image: BufferedImage): BufferedImage {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.intellij.openapi.actionSystem.ex.CustomComponentAction
|
||||
import com.intellij.openapi.project.DumbAware
|
||||
import com.intellij.openapi.ui.ComboBox
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import org.intellij.images.ImagesBundle
|
||||
import org.intellij.images.scientific.ScientificUtils
|
||||
import java.awt.BorderLayout
|
||||
@@ -37,6 +38,11 @@ class ImageOperationsActionGroup : DefaultActionGroup(), CustomComponentAction,
|
||||
}
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
val shouldShowTheGroup = Registry.`is`("ide.images.sci.mode.channels.operations")
|
||||
if (!shouldShowTheGroup) {
|
||||
e.presentation.isVisible = false
|
||||
return
|
||||
}
|
||||
val imageFile = e.getData(CommonDataKeys.VIRTUAL_FILE)
|
||||
e.presentation.isEnabledAndVisible = imageFile?.getUserData(ScientificUtils.SCIENTIFIC_MODE_KEY) != null
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||
import com.intellij.openapi.project.DumbAwareAction
|
||||
import org.intellij.images.editor.ImageDocument
|
||||
import org.intellij.images.editor.ImageFileEditor
|
||||
import org.intellij.images.scientific.ScientificUtils
|
||||
import org.intellij.images.scientific.ScientificUtils.ORIGINAL_IMAGE_KEY
|
||||
import org.intellij.images.scientific.convertToByteArray
|
||||
@@ -24,7 +26,9 @@ class InvertChannelsAction : DumbAwareAction() {
|
||||
val imageFile = e.getData(CommonDataKeys.VIRTUAL_FILE) ?: return
|
||||
val originalImage = imageFile.getUserData(ORIGINAL_IMAGE_KEY) ?: return
|
||||
val invertedImage = applyInvertChannels(originalImage)
|
||||
imageFile.setBinaryContent(convertToByteArray(invertedImage, imageFile.fileType.defaultExtension))
|
||||
//val editor = e.getData(IMAGE_DOCUMENT_DATA_KEY ) TODO: get editor?
|
||||
//val document = (editor as ImageFileEditor).imageEditor.document as ImageDocument
|
||||
//document.value = invertedImage
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||
import com.intellij.openapi.project.DumbAwareAction
|
||||
import org.intellij.images.editor.ImageDocument
|
||||
import org.intellij.images.editor.ImageFileEditor
|
||||
import org.intellij.images.scientific.ScientificUtils
|
||||
import org.intellij.images.scientific.ScientificUtils.ORIGINAL_IMAGE_KEY
|
||||
import org.intellij.images.scientific.convertToByteArray
|
||||
@@ -23,6 +25,8 @@ class RestoreOriginalImageAction : DumbAwareAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val imageFile = e.getData(CommonDataKeys.VIRTUAL_FILE) ?: return
|
||||
val originalImage = imageFile.getUserData(ORIGINAL_IMAGE_KEY) ?: return
|
||||
imageFile.setBinaryContent(convertToByteArray(originalImage, imageFile.fileType.defaultExtension))
|
||||
//val editor = e.getData(IMAGE_DOCUMENT_DATA_KEY) TODO: get editor?
|
||||
//val document = (editor as ImageFileEditor).imageEditor.document as ImageDocument
|
||||
//document.value = originalImage
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user