DBE-22700: Prepare Grid modules for platformization

grid.impl depended on platform.images. Platform module can't depend on a plugin, and it's risky to make platform.images a platform module now. So decision is to separate the part of grid.impl that depended on platform.images to a dedicated module which will NOT be a platform one.

Also, intellij.grid API module was converted to V2 that will simplify platformization

GitOrigin-RevId: 3dea3dd0b5e05a283ee3c26b5806fa33822b3e8a
This commit is contained in:
Ilya Muradyan
2025-01-29 13:27:46 +00:00
committed by intellij-monorepo-bot
parent 3bb1efda22
commit 5b550504fa
12 changed files with 63 additions and 11 deletions
+1
View File
@@ -407,6 +407,7 @@
<module fileurl="file://$PROJECT_DIR$/grid/api/intellij.grid.iml" filepath="$PROJECT_DIR$/grid/api/intellij.grid.iml" />
<module fileurl="file://$PROJECT_DIR$/grid/core-impl/intellij.grid.core.impl.iml" filepath="$PROJECT_DIR$/grid/core-impl/intellij.grid.core.impl.iml" />
<module fileurl="file://$PROJECT_DIR$/grid/csv/intellij.grid.csv.core.impl.iml" filepath="$PROJECT_DIR$/grid/csv/intellij.grid.csv.core.impl.iml" />
<module fileurl="file://$PROJECT_DIR$/grid/images/intellij.grid.images.impl.iml" filepath="$PROJECT_DIR$/grid/images/intellij.grid.images.impl.iml" />
<module fileurl="file://$PROJECT_DIR$/grid/impl/intellij.grid.impl.iml" filepath="$PROJECT_DIR$/grid/impl/intellij.grid.impl.iml" />
<module fileurl="file://$PROJECT_DIR$/grid/json/intellij.grid.impl.json.iml" filepath="$PROJECT_DIR$/grid/json/intellij.grid.impl.json.iml" />
<module fileurl="file://$PROJECT_DIR$/grid/types/intellij.grid.types.iml" filepath="$PROJECT_DIR$/grid/types/intellij.grid.types.iml" />
+1
View File
@@ -3,6 +3,7 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="com.intellij.database" />
</content>
<orderEntry type="inheritedJdk" />
+2
View File
@@ -0,0 +1,2 @@
<idea-plugin>
</idea-plugin>
+1 -1
View File
@@ -11,7 +11,7 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="intellij.grid.types" exported="" />
<orderEntry type="module" module-name="intellij.grid.csv.core.impl" exported="" />
<orderEntry type="module" module-name="intellij.grid" exported="" />
<orderEntry type="module" module-name="intellij.grid" />
<orderEntry type="module" module-name="intellij.platform.util" />
<orderEntry type="module" module-name="intellij.platform.util.coroutines" />
<orderEntry type="module" module-name="intellij.platform.util.jdom" />
@@ -1,5 +1,6 @@
<idea-plugin>
<dependencies>
<module name="intellij.grid"/>
<module name="intellij.grid.types"/>
<module name="intellij.grid.csv.core.impl"/>
</dependencies>
+19
View File
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="kotlin-stdlib" level="project" />
<orderEntry type="module" module-name="intellij.grid.impl" />
<orderEntry type="module" module-name="intellij.grid.core.impl" />
<orderEntry type="module" module-name="intellij.platform.util" />
<orderEntry type="module" module-name="intellij.platform.core" />
<orderEntry type="module" module-name="intellij.platform.ide.core" />
<orderEntry type="module" module-name="intellij.platform.images" />
</component>
</module>
@@ -0,0 +1,13 @@
<idea-plugin package="com.intellij.grid.images.impl">
<dependencies>
<plugin id="com.intellij.platform.images"/>
<module name="intellij.grid.core.impl"/>
<module name="intellij.grid.csv.core.impl"/>
<module name="intellij.platform.navbar.frontend"/>
<module name="intellij.libraries.microba"/>
</dependencies>
<extensions defaultExtensionNs="com.intellij.database.datagrid">
<cellViewerFactory implementation="com.intellij.grid.images.impl.ImageCellViewerFactory"/>
</extensions>
</idea-plugin>
@@ -1,10 +1,15 @@
package com.intellij.database.run.ui
package com.intellij.grid.images.impl
import com.intellij.database.datagrid.DataGrid
import com.intellij.database.datagrid.GridColumn
import com.intellij.database.datagrid.GridRow
import com.intellij.database.datagrid.ModelIndex
import com.intellij.database.extractors.ImageInfo
import com.intellij.database.run.ui.CellViewer
import com.intellij.database.run.ui.CellViewerFactory
import com.intellij.database.run.ui.DataAccessType
import com.intellij.database.run.ui.Suitability
import com.intellij.database.run.ui.UpdateEvent
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.util.CheckedDisposable
@@ -28,8 +33,10 @@ class ImageCellViewer(private val grid: DataGrid) : CellViewer, CheckedDisposabl
override fun update(event: UpdateEvent?) {
if (event is UpdateEvent.ValueChanged) {
if (event.value is ImageInfo) update(event.value)
else clearContent()
when(val eventValue = event.value) {
is ImageInfo -> update(eventValue)
else -> clearContent()
}
return
}
@@ -82,7 +89,7 @@ class ImageCellViewer(private val grid: DataGrid) : CellViewer, CheckedDisposabl
override fun dispose() { }
}
object ImageCellViewerFactory : CellViewerFactory {
class ImageCellViewerFactory : CellViewerFactory {
override fun getSuitability(grid: DataGrid, row: ModelIndex<GridRow>, column: ModelIndex<GridColumn>): Suitability {
if (!row.isValid(grid) || !column.isValid(grid)) return Suitability.NONE
val value = grid.getDataModel(DataAccessType.DATA_WITH_MUTATIONS).getValueAt(row, column)
@@ -90,4 +97,4 @@ object ImageCellViewerFactory : CellViewerFactory {
}
override fun createViewer(grid: DataGrid): CellViewer = ImageCellViewer(grid)
}
}
-1
View File
@@ -21,7 +21,6 @@
<orderEntry type="module" module-name="intellij.xml.psi" />
<orderEntry type="module" module-name="intellij.platform.editor.ex" />
<orderEntry type="module" module-name="intellij.platform.ide.core.plugins" />
<orderEntry type="module" module-name="intellij.platform.images" />
<orderEntry type="module" module-name="intellij.platform.execution.impl" />
<orderEntry type="module" module-name="intellij.platform.ide" />
<orderEntry type="module" module-name="intellij.platform.util.jdom" />
+1 -2
View File
@@ -1,7 +1,5 @@
<idea-plugin>
<dependencies>
<plugin id="intellij.grid.core.plugin"/>
<plugin id="com.intellij.platform.images"/>
<module name="intellij.grid.core.impl"/>
<module name="intellij.grid.csv.core.impl"/>
<module name="intellij.platform.navbar.frontend"/>
@@ -10,6 +8,7 @@
<extensionPoints>
<extensionPoint qualifiedName="com.intellij.database.datagrid.valueEditorTab" interface="com.intellij.database.run.ui.ValueEditorTab" dynamic="true"/>
<extensionPoint qualifiedName="com.intellij.database.datagrid.cellViewerFactory" interface="com.intellij.database.run.ui.CellViewerFactory" dynamic="true"/>
<extensionPoint qualifiedName="com.intellij.database.minimizedFormatDetector" interface="com.intellij.database.run.ui.MinimizedFormatDetector" dynamic="true"/>
</extensionPoints>
+6
View File
@@ -5,6 +5,7 @@ import com.intellij.database.datagrid.GridColumn
import com.intellij.database.datagrid.GridRow
import com.intellij.database.datagrid.ModelIndex
import com.intellij.openapi.Disposable
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.openapi.util.Key
import javax.swing.JComponent
@@ -27,6 +28,11 @@ interface CellViewer : Disposable {
interface CellViewerFactory {
fun getSuitability(grid: DataGrid, row: ModelIndex<GridRow>, column: ModelIndex<GridColumn>): Suitability
fun createViewer(grid: DataGrid): CellViewer
companion object {
private val EP_NAME = ExtensionPointName<CellViewerFactory>("com.intellij.database.datagrid.cellViewerFactory")
fun getExternalFactories(): List<CellViewerFactory> = EP_NAME.extensionList
}
}
sealed interface UpdateEvent {
+6 -2
View File
@@ -19,8 +19,12 @@ class EditorValueEditorTab : ValueEditorTab {
class ValueTabInfoProvider(private val grid: DataGrid) : TabInfoProvider(DataGridBundle.message("EditMaximized.ValueEditor.text"),
ActionManager.getInstance().getAction("Console.TableResult.EditMaximized.Value.Group") as? ActionGroup) {
private var currentViewerFactory: CellViewerFactory
private val viewerFactories = listOf(EditorCellViewerFactory, ReadonlyEditorCellViewerFactory, EmptyCellViewerFactory,
ImageCellViewerFactory)
private val viewerFactories = buildList {
add(EditorCellViewerFactory)
add(ReadonlyEditorCellViewerFactory)
add(EmptyCellViewerFactory)
addAll(CellViewerFactory.getExternalFactories())
}
private var viewer: CellViewer
init {