Skip to content

Commit 1a0ab0f

Browse files
committed
Add playground tab
1 parent bbf00da commit 1a0ab0f

8 files changed

Lines changed: 70 additions & 27 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
pluginGroup = com.github.merlinths.codegolf
44
pluginName = Code-Golf
55
pluginRepositoryUrl = https://github.com/MerlinTHS/Code-Golf
6-
pluginVersion = 1.0.0
6+
pluginVersion = 1.0.2
77

88
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
99
pluginSinceBuild = 213

settings.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ rootProject.name = "Code-Golf"
33
pluginManagement {
44
repositories {
55
gradlePluginPortal()
6-
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
76
}
87
}
Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,36 @@
11
package com.github.merlinths.codegolf.windows
22

3-
import com.github.merlinths.codegolf.MyBundle
4-
import com.github.merlinths.codegolf.service.GolfService
3+
import com.github.merlinths.codegolf.windows.tabs.OnlineTab
4+
import com.github.merlinths.codegolf.windows.tabs.Tab
5+
import com.github.merlinths.codegolf.windows.tabs.PlaygroundTab
6+
import com.intellij.openapi.components.service
57
import com.intellij.openapi.project.Project
68
import com.intellij.openapi.wm.ToolWindow
79
import com.intellij.openapi.wm.ToolWindowFactory
810
import com.intellij.ui.content.ContentFactory
911
import javax.swing.JComponent
1012

11-
class GolfWindowFactory : ToolWindowFactory {
1213

14+
class GolfWindowFactory : ToolWindowFactory {
1315
/**
1416
* Creates the CodeGolf tool window.
1517
*
16-
* Contains an online tab.
18+
* Contains an [online][OnlineTab] and a [playground][PlaygroundTab] tab.
1719
*
1820
* @param[project] Current project
1921
* @param[window] Current tool window
2022
*
2123
*/
2224
override fun createToolWindowContent(
23-
project: Project,
24-
window: ToolWindow
25+
project: Project,
26+
window: ToolWindow
2527
) {
26-
val factory = ContentFactory.SERVICE.getInstance()
27-
val browserComponent = getBrowserComponent(project)
28+
val tabs = listOf(
29+
OnlineTab(project),
30+
PlaygroundTab()
31+
)
2832

29-
with(window.contentManager) {
30-
addContent(factory.createOnlineTab(browserComponent))
31-
}
33+
tabs.map(Tab::toContent)
34+
.forEach(window.contentManager::addContent)
3235
}
33-
34-
private fun getBrowserComponent(project: Project): JComponent =
35-
project
36-
.getService(GolfService::class.java)
37-
.golfEditor
38-
.component
39-
40-
private fun ContentFactory.createOnlineTab(component: JComponent) =
41-
createContent(
42-
component,
43-
MyBundle.message("online"),
44-
false
45-
)
4636
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.github.merlinths.codegolf.windows
2+
3+
import com.github.merlinths.codegolf.windows.tabs.Tab
4+
import com.intellij.ui.content.ContentFactory
5+
6+
internal fun Tab.toContent() =
7+
ContentFactory
8+
.SERVICE.getInstance()
9+
.createContent(
10+
component,
11+
title,
12+
false
13+
)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.github.merlinths.codegolf.windows.tabs
2+
3+
import com.github.merlinths.codegolf.MyBundle
4+
import com.github.merlinths.codegolf.service.GolfService
5+
import com.intellij.openapi.components.service
6+
import com.intellij.openapi.project.Project
7+
import javax.swing.JComponent
8+
9+
class OnlineTab(
10+
project: Project
11+
) : Tab {
12+
override val title = MyBundle.message("online")
13+
14+
override val component = project
15+
.service<GolfService>()
16+
.golfEditor
17+
.component
18+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.github.merlinths.codegolf.windows.tabs
2+
3+
import com.github.merlinths.codegolf.MyBundle
4+
import com.intellij.ui.dsl.builder.panel
5+
6+
class PlaygroundTab : Tab {
7+
override val title = MyBundle.message("playground")
8+
9+
override val component = panel {
10+
row {
11+
label("In progress...")
12+
}
13+
}
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.github.merlinths.codegolf.windows.tabs
2+
3+
import javax.swing.JComponent
4+
5+
interface Tab {
6+
val title: String
7+
val component: JComponent
8+
}

src/main/resources/messages/MyBundle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ title = Code Golf
22

33
hole = Hole
44

5-
online = Online
5+
online = Online
6+
playground = Playground

0 commit comments

Comments
 (0)