Skip to content

Commit 5ade19b

Browse files
committed
Merge branch 'feature/design-plugin-tool-window' into develop
- Create CodeXP tool window with gui designer and move into src/main/java/ - Add bundle properties for ui text - Change to include 'CodeXP' in the default filenames
2 parents 28122df + 7a150eb commit 5ade19b

File tree

7 files changed

+444
-19
lines changed

7 files changed

+444
-19
lines changed

src/main/java/com/github/ilovegamecoding/intellijcodexp/form/CodeXPDashboard.form

Lines changed: 395 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.github.ilovegamecoding.intellijcodexp.form;
2+
3+
import com.github.ilovegamecoding.intellijcodexp.services.CodeXPService;
4+
import com.intellij.openapi.application.ApplicationManager;
5+
6+
import javax.swing.*;
7+
8+
public class CodeXPDashboard {
9+
private CodeXPService codeXPService = ApplicationManager.getApplication().getService(CodeXPService.class);
10+
public JPanel pMain;
11+
public JProgressBar pbCurrentLevelProgress;
12+
public JLabel lblNextLabel;
13+
public JLabel lblCurrentLevel;
14+
public JLabel tvCurrentLevelXP;
15+
public JTextField nicknameTextField;
16+
public JPanel lblCompletedChallenges;
17+
public JLabel lblTotalXP;
18+
public JLabel lblLevel;
19+
public JButton resetButton;
20+
public JPanel pEventStatistics;
21+
public JPanel pCompletedChallenges;
22+
public JPanel pChallenges;
23+
24+
public CodeXPDashboard() {
25+
resetButton.addActionListener(e -> {
26+
codeXPService.resetPlugin();
27+
});
28+
}
29+
}

src/main/kotlin/com/github/ilovegamecoding/intellijcodexp/MyBundle.kt renamed to src/main/kotlin/com/github/ilovegamecoding/intellijcodexp/CodeXPBundle.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import org.jetbrains.annotations.NonNls
55
import org.jetbrains.annotations.PropertyKey
66

77
@NonNls
8-
private const val BUNDLE = "messages.MyBundle"
8+
private const val BUNDLE = "messages.CodeXPBundle"
99

10-
object MyBundle : DynamicBundle(BUNDLE) {
10+
object CodeXPBundle : DynamicBundle(BUNDLE) {
1111

1212
@Suppress("SpreadOperator")
1313
@JvmStatic
Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
package com.github.ilovegamecoding.intellijcodexp.toolWindow
22

3-
import com.github.ilovegamecoding.intellijcodexp.services.CodeXPService
4-
import com.intellij.openapi.components.service
3+
import com.github.ilovegamecoding.intellijcodexp.form.CodeXPDashboard
54
import com.intellij.openapi.diagnostic.thisLogger
65
import com.intellij.openapi.project.Project
76
import com.intellij.openapi.wm.ToolWindow
87
import com.intellij.openapi.wm.ToolWindowFactory
9-
import com.intellij.ui.components.JBPanel
108
import com.intellij.ui.content.ContentFactory
119

1210

1311
class CodeXPToolWindowFactory : ToolWindowFactory {
12+
private var codeXPDashboard = CodeXPDashboard()
1413

1514
init {
1615
thisLogger().warn("Don't forget to remove all non-needed sample code files with their corresponding registration entries in `plugin.xml`.")
@@ -19,22 +18,13 @@ class CodeXPToolWindowFactory : ToolWindowFactory {
1918
private val contentFactory = ContentFactory.SERVICE.getInstance()
2019

2120
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
22-
val codeXPDashboard = CodeXPDashboard()
23-
val content = contentFactory.createContent(codeXPDashboard.getContent(), null, false)
21+
val content = contentFactory.createContent(codeXPDashboard.pMain, null, false)
2422
toolWindow.contentManager.addContent(content)
2523
}
2624

2725
override fun shouldBeAvailable(project: Project) = true
2826

29-
class CodeXPDashboard() {
30-
private val service = service<CodeXPService>()
31-
32-
init {
33-
34-
}
35-
36-
fun getContent() = JBPanel<JBPanel<*>>().apply {
37-
// TODO: Implement the UI for this feature
38-
}
27+
fun setXP(xp: Int) {
28+
codeXPDashboard.lblLevel.text = "$xp"
3929
}
4030
}

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<depends>com.intellij.modules.platform</depends>
88

9-
<resource-bundle>messages.MyBundle</resource-bundle>
9+
<resource-bundle>messages.CodeXPBundle</resource-bundle>
1010

1111
<extensions defaultExtensionNs="com.intellij">
1212
<toolWindow factoryClass="com.github.ilovegamecoding.intellijcodexp.toolWindow.CodeXPToolWindowFactory"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name=CodeXP
2+
TEXT_+=+
3+
TEXT_CHALLENGES=Challenges
4+
TEXT_CODEXP_DASHBOARD=CodeXP Dashboard
5+
TEXT_COMPLETED_CHALLENGES=Completed Challenges
6+
TEXT_EVENT_STATISTICS=Event Statistics
7+
TEXT_LEVEL=Level
8+
TEXT_LV=LV
9+
TEXT_NAME=Name
10+
TEXT_RESET=Reset
11+
TEXT_TOTAL_XP=Total XP
12+
TEXT_XP=XP

src/main/resources/messages/MyBundle.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)