File tree Expand file tree Collapse file tree 8 files changed +121
-2
lines changed
kotlin/com/github/yusufugurozbek/testcontainers/port/updater Expand file tree Collapse file tree 8 files changed +121
-2
lines changed Original file line number Diff line number Diff line change 1
1
# Testcontainers Port Updater Changelog
2
2
3
3
## [ Unreleased]
4
+ - Bump dependencies to their latest versions
5
+ - Make it possible to enable/disable 'Updated data source URL' notifications via plugin settings
4
6
5
7
## [ 0.1.2]
6
8
- Improve regex pattern
42
44
43
45
## [ 0.0.2]
44
46
### Added
45
- - Create the plugin
47
+ - Create the plugin
Original file line number Diff line number Diff line change @@ -40,6 +40,14 @@ Example log;
40
40
41
41
After covering these 2 requirements, the plugin automatically will catch the log and update the matched data source URL with the Testcontainers' one.
42
42
43
+ ### Plugin Settings
44
+
45
+ To adjust Testcontainers Port Updater plugin settings, open IntelliJ preferences and navigate to ** Tools | Testcontainers Port Updater** .
46
+
47
+ Currently, there is only one setting is possible:
48
+
49
+ - To enable/disable 'Updated data source URL' notifications, check/uncheck "Do you want to get notified from Testcontainers Port Updater?" option.
50
+
43
51
---
44
52
Plugin based on the [ IntelliJ Platform Plugin Template] [ template ] .
45
53
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import com.github.yusufugurozbek.testcontainers.port.updater.DatasourceUrlExtrac
4
4
import com.github.yusufugurozbek.testcontainers.port.updater.api.DatasourceUpdater
5
5
import com.github.yusufugurozbek.testcontainers.port.updater.common.TpuNotifier
6
6
import com.github.yusufugurozbek.testcontainers.port.updater.common.equalsIgnoringPort
7
+ import com.github.yusufugurozbek.testcontainers.port.updater.settings.TpuSettingsState
7
8
import com.intellij.database.dataSource.LocalDataSource
8
9
import com.intellij.database.psi.DbPsiFacade
9
10
import com.intellij.database.util.DbImplUtil
@@ -24,6 +25,8 @@ class DatasourceUpdaterImpl(var project: Project) : DatasourceUpdater {
24
25
25
26
private fun update (localDataSource : LocalDataSource , newUrl : String ) {
26
27
localDataSource.url = newUrl
27
- TpuNotifier .notify(project, " Updated data source URL: $newUrl " )
28
+ if (TpuSettingsState .instance.isNotificationsEnabled) {
29
+ TpuNotifier .notify(project, " Updated data source URL: $newUrl " )
30
+ }
28
31
}
29
32
}
Original file line number Diff line number Diff line change
1
+ package com.github.yusufugurozbek.testcontainers.port.updater.settings
2
+
3
+ import com.github.yusufugurozbek.testcontainers.port.updater.common.TpuBundle
4
+ import com.intellij.ui.components.JBCheckBox
5
+ import com.intellij.util.ui.FormBuilder
6
+ import javax.swing.JComponent
7
+ import javax.swing.JPanel
8
+
9
+ class TpuSettingsComponent {
10
+ val panel: JPanel
11
+ private val isNotificationsEnabledCheckbox = JBCheckBox (TpuBundle .message(" settings.isNotificationsEnabledText" ))
12
+
13
+ init {
14
+ panel = FormBuilder .createFormBuilder()
15
+ .addComponent(isNotificationsEnabledCheckbox, 1 )
16
+ .addComponentFillVertically(JPanel (), 0 )
17
+ .panel
18
+ }
19
+
20
+ val preferredFocusedComponent: JComponent
21
+ get() = isNotificationsEnabledCheckbox
22
+ var isNotificationsEnabled: Boolean
23
+ get() = isNotificationsEnabledCheckbox.isSelected
24
+ set(value) {
25
+ isNotificationsEnabledCheckbox.isSelected = value
26
+ }
27
+ }
Original file line number Diff line number Diff line change
1
+ package com.github.yusufugurozbek.testcontainers.port.updater.settings
2
+
3
+ import com.github.yusufugurozbek.testcontainers.port.updater.common.TpuBundle
4
+ import com.intellij.openapi.options.Configurable
5
+ import org.jetbrains.annotations.Nls
6
+ import javax.swing.JComponent
7
+
8
+ class TpuSettingsConfigurable : Configurable {
9
+ private var settingsComponent: TpuSettingsComponent ? = null
10
+
11
+ override fun getDisplayName (): @Nls (capitalization = Nls .Capitalization .Title ) String {
12
+ return TpuBundle .message(" name" )
13
+ }
14
+
15
+ override fun getPreferredFocusedComponent (): JComponent {
16
+ return settingsComponent!! .preferredFocusedComponent
17
+ }
18
+
19
+ override fun createComponent (): JComponent {
20
+ settingsComponent = TpuSettingsComponent ()
21
+ return settingsComponent!! .panel
22
+ }
23
+
24
+ override fun isModified (): Boolean {
25
+ val settings: TpuSettingsState = TpuSettingsState .instance
26
+ return settingsComponent!! .isNotificationsEnabled != settings.isNotificationsEnabled
27
+ }
28
+
29
+ override fun apply () {
30
+ val settings: TpuSettingsState = TpuSettingsState .instance
31
+ settings.isNotificationsEnabled = settingsComponent!! .isNotificationsEnabled
32
+ }
33
+
34
+ override fun reset () {
35
+ val settings: TpuSettingsState = TpuSettingsState .instance
36
+ settingsComponent!! .isNotificationsEnabled = settings.isNotificationsEnabled
37
+ }
38
+
39
+ override fun disposeUIResources () {
40
+ settingsComponent = null
41
+ }
42
+ }
Original file line number Diff line number Diff line change
1
+ package com.github.yusufugurozbek.testcontainers.port.updater.settings
2
+
3
+ import com.intellij.openapi.application.ApplicationManager
4
+ import com.intellij.openapi.components.PersistentStateComponent
5
+ import com.intellij.openapi.components.State
6
+ import com.intellij.openapi.components.Storage
7
+ import com.intellij.util.xmlb.XmlSerializerUtil
8
+
9
+ @State(
10
+ name = " com.github.yusufugurozbek.testcontainers.port.updater.settings.AppSettingsState" ,
11
+ storages = [Storage (" TestcontainersPortUpdaterPlugin.xml" )]
12
+ )
13
+ class TpuSettingsState : PersistentStateComponent <TpuSettingsState ?> {
14
+ var isNotificationsEnabled = true
15
+
16
+ override fun getState (): TpuSettingsState {
17
+ return this
18
+ }
19
+
20
+ override fun loadState (state : TpuSettingsState ) {
21
+ XmlSerializerUtil .copyBean(state, this )
22
+ }
23
+
24
+ companion object {
25
+ val instance: TpuSettingsState
26
+ get() = ApplicationManager .getApplication().getService(TpuSettingsState ::class .java)
27
+ }
28
+ }
Original file line number Diff line number Diff line change 15
15
<notificationGroup id =" Testcontainers Port Updater" displayType =" BALLOON" />
16
16
<consoleFilterProvider
17
17
implementation =" com.github.yusufugurozbek.testcontainers.port.updater.impl.ConsoleFilterProviderImpl" />
18
+ <applicationConfigurable
19
+ id =" com.github.yusufugurozbek.testcontainers.port.updater.settings.TpuSettingsConfigurable"
20
+ parentId =" tools"
21
+ instance =" com.github.yusufugurozbek.testcontainers.port.updater.settings.TpuSettingsConfigurable"
22
+ bundle =" messages.TpuBundle"
23
+ key =" name" />
24
+ <applicationService
25
+ serviceImplementation =" com.github.yusufugurozbek.testcontainers.port.updater.settings.TpuSettingsState" />
18
26
</extensions >
19
27
</idea-plugin >
Original file line number Diff line number Diff line change 1
1
name =Testcontainers Port Updater
2
+ settings.isNotificationsEnabledText =Do you want to get notified from Testcontainers Port Updater?
You can’t perform that action at this time.
0 commit comments