diff --git a/images/resources/META-INF/plugin.xml b/images/resources/META-INF/plugin.xml
index 0ce7a4313fe5..d5140c079be3 100644
--- a/images/resources/META-INF/plugin.xml
+++ b/images/resources/META-INF/plugin.xml
@@ -157,6 +157,8 @@
id="Images.CopyImageAction"
icon="AllIcons.Actions.Copy">
+
diff --git a/images/resources/messages/ImagesBundle.properties b/images/resources/messages/ImagesBundle.properties
index ff38e598a07b..3d8fe4b4b858 100644
--- a/images/resources/messages/ImagesBundle.properties
+++ b/images/resources/messages/ImagesBundle.properties
@@ -88,4 +88,8 @@ image.description={0}\u00D7{1}, {2}bpp
# scientific mode
dialog.title.save.image=Select File to Save Image
action.Images.SaveImageAction.text=Save Image
-action.Images.CopyImageAction.text=Copy Image
\ No newline at end of file
+action.Images.CopyImageAction.text=Copy Image
+group.Images.ImageOperationsGroup.text=Hi there
+image.color.mode.rgb=RGB
+image.color.mode.bgr=BGR
+image.color.mode.grayscale=Grayscale
\ No newline at end of file
diff --git a/images/src/org/intellij/images/scientific/action/ImageOperationsActionGroup.kt b/images/src/org/intellij/images/scientific/action/ImageOperationsActionGroup.kt
new file mode 100644
index 000000000000..762d6f083a1a
--- /dev/null
+++ b/images/src/org/intellij/images/scientific/action/ImageOperationsActionGroup.kt
@@ -0,0 +1,79 @@
+package org.intellij.images.scientific.action
+
+import com.intellij.openapi.actionSystem.*
+import com.intellij.openapi.actionSystem.ex.CustomComponentAction
+import com.intellij.openapi.project.DumbAware
+import com.intellij.openapi.project.DumbAwareAction
+import com.intellij.openapi.ui.ComboBox
+import com.intellij.openapi.ui.popup.JBPopupFactory
+import org.intellij.images.ImagesBundle
+import org.intellij.images.scientific.ScientificUtils
+import java.awt.BorderLayout
+import javax.swing.DefaultComboBoxModel
+import javax.swing.JComponent
+import javax.swing.JPanel
+
+class ImageOperationsActionGroup : DefaultActionGroup(), CustomComponentAction, DumbAware {
+
+ private var selectedMode: String = RGB
+ private val availableModes = listOf(RGB, BGR, GRAYSCALE)
+
+ init {
+ templatePresentation.apply {
+ isPerformGroup = true
+ isPopup = true
+ }
+ }
+
+ override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
+
+ override fun actionPerformed(e: AnActionEvent) {
+ val component = e.inputEvent?.source as? JComponent ?: return
+ JBPopupFactory.getInstance().createActionGroupPopup(
+ null,
+ createPopupActionGroup(),
+ e.dataContext,
+ null,
+ true,
+ null
+ ).showUnderneathOf(component)
+ }
+
+ override fun update(e: AnActionEvent) {
+ val imageFile = e.getData(CommonDataKeys.VIRTUAL_FILE)
+ e.presentation.isEnabledAndVisible = imageFile?.getUserData(ScientificUtils.SCIENTIFIC_MODE_KEY) != null
+ }
+
+ override fun createCustomComponent(presentation: Presentation, place: String): JComponent {
+ val comboBox = ComboBox(DefaultComboBoxModel(availableModes.toTypedArray())).apply {
+ selectedItem = selectedMode
+ isOpaque = false
+ addActionListener {
+ selectedMode = selectedItem as String
+ }
+ }
+ return JPanel(BorderLayout()).apply {
+ isOpaque = false
+ border = null
+ add(comboBox, BorderLayout.CENTER)
+ }
+ }
+
+ private fun createPopupActionGroup(): DefaultActionGroup {
+ val actionGroup = DefaultActionGroup()
+ availableModes.forEach { mode ->
+ actionGroup.add(
+ DumbAwareAction.create(mode) {
+ selectedMode = mode
+ }
+ )
+ }
+ return actionGroup
+ }
+
+ companion object {
+ private val RGB: String = ImagesBundle.message("image.color.mode.rgb")
+ private val BGR: String = ImagesBundle.message("image.color.mode.bgr")
+ private val GRAYSCALE: String = ImagesBundle.message("image.color.mode.grayscale")
+ }
+}
\ No newline at end of file