diff --git a/images/resources/META-INF/plugin.xml b/images/resources/META-INF/plugin.xml
index d5140c079be3..c558da0afefe 100644
--- a/images/resources/META-INF/plugin.xml
+++ b/images/resources/META-INF/plugin.xml
@@ -47,6 +47,8 @@
+
diff --git a/images/src/org/intellij/images/scientific/action/GrayscaleImageAction.kt b/images/src/org/intellij/images/scientific/action/GrayscaleImageAction.kt
index 25135cb4342e..7482038ad8c9 100644
--- a/images/src/org/intellij/images/scientific/action/GrayscaleImageAction.kt
+++ b/images/src/org/intellij/images/scientific/action/GrayscaleImageAction.kt
@@ -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 {
diff --git a/images/src/org/intellij/images/scientific/action/ImageOperationsActionGroup.kt b/images/src/org/intellij/images/scientific/action/ImageOperationsActionGroup.kt
index 160d09f299c5..2adf80ebb933 100644
--- a/images/src/org/intellij/images/scientific/action/ImageOperationsActionGroup.kt
+++ b/images/src/org/intellij/images/scientific/action/ImageOperationsActionGroup.kt
@@ -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
}
diff --git a/images/src/org/intellij/images/scientific/action/InvertChannelsAction.kt b/images/src/org/intellij/images/scientific/action/InvertChannelsAction.kt
index f582db2a341e..8bd2f83ed5aa 100644
--- a/images/src/org/intellij/images/scientific/action/InvertChannelsAction.kt
+++ b/images/src/org/intellij/images/scientific/action/InvertChannelsAction.kt
@@ -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
}
diff --git a/images/src/org/intellij/images/scientific/action/RestoreOriginalImageAction.kt b/images/src/org/intellij/images/scientific/action/RestoreOriginalImageAction.kt
index b1f3c33dc643..c59b0bdc8f53 100644
--- a/images/src/org/intellij/images/scientific/action/RestoreOriginalImageAction.kt
+++ b/images/src/org/intellij/images/scientific/action/RestoreOriginalImageAction.kt
@@ -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
}
}
\ No newline at end of file