Skip to content

Commit 683dfeb

Browse files
committed
Merge branch 'feature/custom-dialog' into develop
- Add a new notification type: CodeXP notification - Add configuration for notification type (IntelliJ notification or CodeXP notification)
2 parents 4bfb972 + 173efca commit 683dfeb

23 files changed

+834
-261
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
### Added
88
- Organize CodeXP configuration options by type for easier readability.
9+
- Add a new notification type: CodeXP notification
10+
- Add configuration for notification type (Intellij notification or CodeXP notification)
911

1012
### Changed
1113

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,20 @@ Completed challenges are added under the "Completed Challenges" section. Also, m
6969

7070
![Completed Challenges](https://github.com/ILoveGameCoding/intellij-codexp/blob/main/images/completed_challenges.png)
7171

72+
You can toggle the visibility of completed challenges in the CodeXP tool window.
73+
74+
![Toggle Completed Challenges](https://github.com/ILoveGameCoding/intellij-codexp/blob/main/images/toggle_completed_challenges.gif)
75+
7276
<br>
7377

7478
## Notification
75-
Whenever a challenge is completed or a level up occurs, a notification is provided to inform you of the details.
79+
Whenever a challenge is completed or a level up occurs, a notification is provided to inform you of the details. You can choose to display the notification as an IntelliJ notification or a CodeXP notification.
80+
81+
#### IntelliJ Notification
82+
![IntelliJ Notification](https://github.com/ILoveGameCoding/intellij-codexp/blob/main/images/intellij_notification.jpg)
7683

77-
![Notification](https://github.com/ILoveGameCoding/intellij-codexp/blob/main/images/notification.jpg)
84+
#### CodeXP Notification
85+
![CodeXP Notification](https://github.com/ILoveGameCoding/intellij-codexp/blob/main/images/codexp_notification.png)
7886

7987
---
8088
Plugin based on the [IntelliJ Platform Plugin Template][template].

images/codexp_notification.png

17.6 KB
Loading
File renamed without changes.
675 KB
Loading

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

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
1414
</constraints>
1515
</vspacer>
16-
<grid id="2b0a2" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
16+
<grid id="2b0a2" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
1717
<margin top="0" left="0" bottom="0" right="0"/>
1818
<constraints>
1919
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -32,20 +32,74 @@
3232
</component>
3333
<component id="9ae23" class="javax.swing.JCheckBox" binding="cbShowLevelUpNotification">
3434
<constraints>
35-
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
35+
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
3636
</constraints>
3737
<properties>
3838
<text resource-bundle="messages/CodeXPBundle" key="TEXT_SHOW_LEVEL_UP_NOTIFICATION"/>
3939
</properties>
4040
</component>
4141
<component id="629a5" class="javax.swing.JCheckBox" binding="cbShowCompleteChallengeNotification">
4242
<constraints>
43-
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
43+
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
4444
</constraints>
4545
<properties>
4646
<text resource-bundle="messages/CodeXPBundle" key="TEXT_SHOW_COMPLETE_CHALLENGE_NOTIFICATION"/>
4747
</properties>
4848
</component>
49+
<grid id="58d24" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
50+
<margin top="0" left="0" bottom="0" right="0"/>
51+
<constraints>
52+
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
53+
</constraints>
54+
<properties/>
55+
<border type="none"/>
56+
<children>
57+
<component id="56816" class="javax.swing.JLabel">
58+
<constraints>
59+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
60+
</constraints>
61+
<properties>
62+
<text resource-bundle="messages/CodeXPBundle" key="TEXT_TYPE"/>
63+
</properties>
64+
</component>
65+
<hspacer id="15805">
66+
<constraints>
67+
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
68+
</constraints>
69+
</hspacer>
70+
<component id="67b68" class="javax.swing.JComboBox" binding="cbNotificationType">
71+
<constraints>
72+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
73+
</constraints>
74+
<properties>
75+
<model/>
76+
</properties>
77+
</component>
78+
<grid id="5212a" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
79+
<margin top="0" left="0" bottom="0" right="0"/>
80+
<constraints>
81+
<grid row="1" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
82+
</constraints>
83+
<properties/>
84+
<border type="none"/>
85+
<children>
86+
<component id="41dc4" class="javax.swing.JLabel" binding="lblTypeDescription">
87+
<constraints>
88+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
89+
</constraints>
90+
<properties>
91+
<text value="Label"/>
92+
</properties>
93+
</component>
94+
<hspacer id="90b24">
95+
<constraints>
96+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
97+
</constraints>
98+
</hspacer>
99+
</children>
100+
</grid>
101+
</children>
102+
</grid>
49103
</children>
50104
</grid>
51105
<grid id="be17d" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ public class CodeXPConfigurationForm {
99
public JPanel pMain;
1010
public JCheckBox cbShowGainedXP;
1111
public JComboBox cbPositionToDisplayGainedXP;
12+
public JComboBox cbNotificationType;
13+
public JLabel lblTypeDescription;
1214
}

src/main/kotlin/com/github/ilovegamecoding/intellijcodexp/activities/CodeXPStartupActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.ilovegamecoding.intellijcodexp.activities
22

3+
import com.github.ilovegamecoding.intellijcodexp.managers.CodeXPUIManager
34
import com.github.ilovegamecoding.intellijcodexp.services.CodeXPService
45
import com.intellij.openapi.application.ApplicationManager
56
import com.intellij.openapi.project.Project
@@ -8,5 +9,6 @@ import com.intellij.openapi.startup.StartupActivity
89
class CodeXPStartupActivity : StartupActivity {
910
override fun runActivity(project: Project) {
1011
ApplicationManager.getApplication().getService(CodeXPService::class.java)
12+
CodeXPUIManager.createDialogArea()
1113
}
1214
}
Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,27 @@
11
package com.github.ilovegamecoding.intellijcodexp.listeners
22

33
import com.github.ilovegamecoding.intellijcodexp.enums.Event
4-
import com.intellij.openapi.actionSystem.AnAction
5-
import com.intellij.openapi.actionSystem.AnActionEvent
6-
import com.intellij.openapi.actionSystem.AnActionResult
74
import com.intellij.openapi.actionSystem.DataContext
8-
import com.intellij.openapi.actionSystem.ex.AnActionListener
9-
import com.intellij.openapi.application.ApplicationManager
5+
import com.intellij.util.messages.Topic
106

117
/**
12-
* CodeXPEventListener class
8+
* CodeXPEventListener interface
139
*
14-
* This class listens to events from the IDE and fires them to the message bus.
10+
* This interface is used to manage events from the CodeXP plugin.
1511
*/
16-
internal class CodeXPEventListener : AnActionListener {
17-
override fun afterEditorTyping(c: Char, dataContext: DataContext) {
18-
super.afterEditorTyping(c, dataContext)
19-
20-
fireEvent(Event.TYPING, dataContext)
21-
}
22-
23-
override fun afterActionPerformed(action: AnAction, event: AnActionEvent, result: AnActionResult) {
24-
super.afterActionPerformed(action, event, result)
25-
26-
when (action.templateText) {
27-
"Run" -> fireEvent(Event.RUN)
28-
"Save All" -> fireEvent(Event.SAVE)
29-
"Debug" -> fireEvent(Event.DEBUG)
30-
"Build Project" -> fireEvent(Event.BUILD)
31-
"Rebuild Project" -> fireEvent(Event.BUILD)
32-
"Cut" -> fireEvent(Event.CUT, event.dataContext)
33-
"Copy" -> fireEvent(Event.COPY, event.dataContext)
34-
"Paste" -> fireEvent(Event.PASTE, event.dataContext)
35-
"Backspace" -> fireEvent(Event.BACKSPACE, event.dataContext)
36-
"Tab" -> fireEvent(Event.TAB, event.dataContext)
37-
"Enter" -> fireEvent(Event.ENTER, event.dataContext)
38-
else -> fireEvent(Event.ACTION)
39-
}
12+
interface CodeXPEventListener {
13+
companion object {
14+
/**
15+
* Topic for CodeXP events.
16+
*/
17+
val CODEXP_EVENT: Topic<CodeXPEventListener> = Topic.create("CodeXP Event", CodeXPEventListener::class.java)
4018
}
4119

4220
/**
43-
* Fire event to the message bus.
21+
* Function that is called when an event occurs.
4422
*
45-
* @param event The event to fire.
23+
* @param event The event that occurred.
4624
* @param dataContext The data context of the event.
4725
*/
48-
private fun fireEvent(event: Event, dataContext: DataContext? = null) {
49-
ApplicationManager.getApplication().messageBus.syncPublisher(CodeXPListener.CODEXP_EVENT)
50-
.eventOccurred(event, dataContext)
51-
}
26+
fun eventOccurred(event: Event, dataContext: DataContext? = null)
5227
}
Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,48 @@
11
package com.github.ilovegamecoding.intellijcodexp.listeners
22

33
import com.github.ilovegamecoding.intellijcodexp.enums.Event
4-
import com.intellij.openapi.actionSystem.DataContext
4+
import com.github.ilovegamecoding.intellijcodexp.models.CodeXPChallenge
5+
import com.github.ilovegamecoding.intellijcodexp.models.CodeXPLevel
56
import com.intellij.util.messages.Topic
67

78
/**
89
* CodeXPListener interface
910
*
10-
* This interface is used to listen to events from the CodeXP plugin.
11+
* This interface is used to manage xp and challenge update from the CodeXP plugin.
1112
*/
1213
interface CodeXPListener {
1314
companion object {
1415
/**
1516
* Topic for CodeXP events.
1617
*/
17-
val CODEXP_EVENT: Topic<CodeXPListener> = Topic.create("CodeXP Event", CodeXPListener::class.java)
18+
val CODEXP: Topic<CodeXPListener> = Topic.create("CodeXP", CodeXPListener::class.java)
1819
}
1920

2021
/**
21-
* Function that is called when an event occurs.
22+
* Function that is called when xp updated.
2223
*
23-
* @param event The event that occurred.
24-
* @param dataContext The data context of the event.
24+
* @param levelInfo Level info.
2525
*/
26-
fun eventOccurred(event: Event, dataContext: DataContext? = null)
26+
fun xpUpdated(levelInfo: CodeXPLevel)
27+
28+
/**
29+
* Function that is called when level up.
30+
*
31+
* @param levelInfo Level info.
32+
*/
33+
fun levelUp(levelInfo: CodeXPLevel)
34+
35+
/**
36+
* Function that is called when challenge updated.
37+
*
38+
* @param challenge Updated challenge.
39+
*/
40+
fun challengeUpdated(event: Event, challenge: CodeXPChallenge, newChallenge: CodeXPChallenge? = null)
41+
42+
/**
43+
* Function that is called when challenge completed.
44+
*
45+
* @param challenge Completed challenge.
46+
*/
47+
fun challengeCompleted(event: Event, challenge: CodeXPChallenge)
2748
}

0 commit comments

Comments
 (0)