Skip to content

Commit fa6755a

Browse files
committed
feat: Add configuration for selection of notification type
1 parent 303f323 commit fa6755a

File tree

5 files changed

+84
-5
lines changed

5 files changed

+84
-5
lines changed

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/models/CodeXPConfiguration.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ import com.github.ilovegamecoding.intellijcodexp.enums.PositionToDisplayGainedXP
88
* This class is used to store the configuration of the plugin.
99
*/
1010
data class CodeXPConfiguration(
11+
/**
12+
* Notification type.
13+
*/
14+
var notificationType: String = "CodeXP Notification",
15+
1116
/**
1217
* Show a notification when the user levels up.
1318
*/

src/main/kotlin/com/github/ilovegamecoding/intellijcodexp/toolWindow/CodeXPConfigurable.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ class CodeXPConfigurable : Configurable {
2727
override fun createComponent(): JComponent? {
2828
// Create the configuration form and set the values to the current configuration.
2929
codeXPConfigurationForm = CodeXPConfigurationForm().apply {
30+
cbNotificationType.addItem("Intellij Notification")
31+
cbNotificationType.addItem("CodeXP Notification")
32+
cbNotificationType.selectedItem = config.notificationType
33+
if(cbNotificationType.selectedItem == "Intellij Notification") {
34+
lblTypeDescription.text =
35+
"Default notification will appear in the bottom-right of the IDE and IDE notification tool window."
36+
} else {
37+
lblTypeDescription.text = "Customized notification will appear in the top-center of the IDE."
38+
}
3039
cbShowLevelUpNotification.isSelected = config.showLevelUpNotification
3140
cbShowCompleteChallengeNotification.isSelected = config.showCompleteChallengeNotification
3241
cbShowGainedXP.isSelected = config.showGainedXP
@@ -40,8 +49,15 @@ class CodeXPConfigurable : Configurable {
4049

4150
override fun isModified(): Boolean {
4251
return with(codeXPConfigurationForm) {
52+
if(cbNotificationType.selectedItem == "Intellij Notification") {
53+
lblTypeDescription.text =
54+
"Default notification will appear in the bottom-right of the IDE and IDE notification tool window."
55+
} else {
56+
lblTypeDescription.text = "Customized notification will appear in the top-center of the IDE."
57+
}
4358
cbPositionToDisplayGainedXP.isEnabled = cbShowGainedXP.isSelected
44-
cbShowLevelUpNotification.isSelected != config.showLevelUpNotification ||
59+
cbNotificationType.selectedItem != config.notificationType ||
60+
cbShowLevelUpNotification.isSelected != config.showLevelUpNotification ||
4561
cbShowCompleteChallengeNotification.isSelected != config.showCompleteChallengeNotification ||
4662
cbShowGainedXP.isSelected != config.showGainedXP ||
4763
cbPositionToDisplayGainedXP.selectedItem != config.positionToDisplayGainedXP.name
@@ -50,6 +66,7 @@ class CodeXPConfigurable : Configurable {
5066

5167
override fun apply() {
5268
with(codeXPConfigurationForm) {
69+
config.notificationType = cbNotificationType.selectedItem as String
5370
config.showLevelUpNotification = cbShowLevelUpNotification.isSelected
5471
config.showCompleteChallengeNotification = cbShowCompleteChallengeNotification.isSelected
5572
config.showGainedXP = cbShowGainedXP.isSelected

src/main/resources/messages/CodeXPBundle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ TEXT_SHOW_COMPLETED_CHALLENGES=Show completed challenges
1717
TEXT_SHOW_GAINED_XP=Show gained xp
1818
TEXT_SHOW_GAINED_XP_DESCRIPTION=<html>Gained XP is only displayed for typing-related tasks (characters, Tab, Backspace, Enter, etc.).<br>It is not displayed for other tasks such as Build, Run, Debug.</html>
1919
TEXT_CARETS=Caret's
20-
TEXT_EFFECT=Effect
20+
TEXT_EFFECT=Effect
21+
TEXT_TYPE=Type

0 commit comments

Comments
 (0)