Skip to content

Commit

Permalink
add JBTable with all data
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkAmi committed Mar 9, 2024
1 parent 72ba2bd commit b292c08
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
@@ -0,0 +1,14 @@
package com.github.thinkami.hellojetbrainsplugin.toolWindow

import com.github.thinkami.hellojetbrainsplugin.ui.AppleTableContent
import com.intellij.openapi.project.Project
import com.intellij.openapi.wm.ToolWindow
import com.intellij.openapi.wm.ToolWindowFactory
import com.intellij.ui.content.ContentFactory

class AppleTableToolWindowFactory: ToolWindowFactory {
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
val content = ContentFactory.getInstance().createContent(AppleTableContent().contentPanel, null, false)
toolWindow.contentManager.addContent(content)
}
}
@@ -0,0 +1,24 @@
package com.github.thinkami.hellojetbrainsplugin.ui

import com.intellij.openapi.ui.DialogPanel
import com.intellij.ui.dsl.builder.Cell
import com.intellij.ui.dsl.builder.panel
import com.intellij.ui.table.JBTable

class AppleTableContent {
var contentPanel : DialogPanel
lateinit var myTableModel: Cell<JBTable>

init {
contentPanel = panel {
row {

val table = JBTable()
val model = AppleTableModel()
table.model = model
myTableModel = cell(table)
}
}
}

}
@@ -0,0 +1,25 @@
package com.github.thinkami.hellojetbrainsplugin.ui

import javax.swing.table.AbstractTableModel

class AppleTableModel: AbstractTableModel() {
val allData: List<List<String>> = listOf(
listOf("1", "シナノゴールド", ""),
listOf("2", "シナノホッペ", ""),
listOf("3", "ジョナゴールド", ""),
)

val columns: List<String> = listOf("No", "Name", "Color")

override fun getRowCount(): Int {
return allData.size
}

override fun getColumnCount(): Int {
return columns.size
}

override fun getValueAt(rowIndex: Int, columnIndex: Int): Any {
return allData[rowIndex][columnIndex]
}
}
1 change: 1 addition & 0 deletions src/main/resources/META-INF/plugin.xml
Expand Up @@ -9,6 +9,7 @@
<resource-bundle>messages.MyBundle</resource-bundle>

<extensions defaultExtensionNs="com.intellij">
<toolWindow factoryClass="com.github.thinkami.hellojetbrainsplugin.toolWindow.AppleTableToolWindowFactory" id="AppleTable"/>
<toolWindow factoryClass="com.github.thinkami.hellojetbrainsplugin.toolWindow.MyToolWindowFactory" id="MyToolWindow"/>
<toolWindow factoryClass="com.github.thinkami.hellojetbrainsplugin.toolWindow.HelloToolWindowFactory" id="HelloToolWindow"/>
<toolWindow factoryClass="com.github.thinkami.hellojetbrainsplugin.toolWindow.UpdateInActionToolWindowFactory" id="UpdateInActionToolWindow"/>
Expand Down

0 comments on commit b292c08

Please sign in to comment.