Skip to content

Commit b51d230

Browse files
AbrilRBSczoido
andauthored
Fix deprecated API usage (#224)
* Fix FileChooserDescriptor.isFileSelectable unallowed overriding * Fix URL deprecated constructor * Dont choose folders * WhenTextChanged deprecated * Initialize json once * currentUIThemeLookandFeel deprecation * bump version --------- Co-authored-by: czoido <[email protected]>
1 parent 7184ab2 commit b51d230

File tree

7 files changed

+17
-22
lines changed

7 files changed

+17
-22
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
## [Unreleased]
66

7+
### Changed
8+
9+
- Fix deprecated API usages
10+
711
## [2.0.8] - 2025-01-16
812

913
### Changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pluginGroup = com.jfrog.conan.clion
44
pluginName = Conan
55
pluginRepositoryUrl = https://github.com/conan-io/conan-clion-plugin/
66
# SemVer format -> https://semver.org
7-
pluginVersion = 2.0.8
7+
pluginVersion = 2.0.9
88

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

src/main/kotlin/com/jfrog/conan/clion/conan/extensions/file.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
package com.jfrog.conan.clion.conan.extensions
22

33
import com.intellij.openapi.diagnostic.thisLogger
4-
import kotlinx.coroutines.Dispatchers
5-
import kotlinx.coroutines.GlobalScope
6-
import kotlinx.coroutines.launch
74
import java.io.File
8-
import java.net.URL
5+
import java.net.URI
96

107
fun File.downloadFromUrl(url: String) {
118
val targetFile = this
129

1310
try {
14-
val fileUrl = URL(url)
11+
val fileUrl = URI(url).toURL()
1512
fileUrl.openStream().use { input ->
1613
targetFile.outputStream().use { output ->
1714
input.copyTo(output)

src/main/kotlin/com/jfrog/conan/clion/dialogs/ConanExecutableDialog.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,11 @@ import javax.swing.BoxLayout
2121
import javax.swing.JComponent
2222
import javax.swing.JPanel
2323

24-
object ConanExecutableChooserDescriptor : FileChooserDescriptor(true, true, false, false, false, false) {
24+
object ConanExecutableChooserDescriptor : FileChooserDescriptor(true, false, false, false, false, false) {
2525
init {
2626
withFileFilter { it.isConanExecutable }
2727
withTitle("Select Conan executable")
2828
}
29-
30-
override fun isFileSelectable(file: VirtualFile?): Boolean {
31-
return super.isFileSelectable(file) && file != null && !file.isDirectory
32-
}
3329
}
3430

3531
val VirtualFile.isConanExecutable: Boolean
@@ -128,7 +124,8 @@ class ConanExecutableDialogWrapper(val project: Project) : DialogWrapper(true) {
128124
updateOkButtonState()
129125
updateOkButtonState()
130126
}
131-
conanExecutablePathField.textField.whenTextChanged {
127+
128+
conanExecutablePathField.whenTextChanged {
132129
updateOkButtonState()
133130
}
134131

src/main/kotlin/com/jfrog/conan/clion/services/ConanService.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class ConanService(val project: Project) {
2323

2424
private val onConfiguredListeners: HashMap<String, (isConfigured: Boolean) -> Unit> = hashMapOf()
2525
private val onLibraryDataChangeListeners: HashMap<String, (newLibraryData: LibraryData) -> Unit> = hashMapOf()
26+
private val jsoner = Json { ignoreUnknownKeys = true }
2627

2728
fun addOnConfiguredListener(name: String, callback: (isConfigured: Boolean)->Unit) {
2829
onConfiguredListeners[name] = callback
@@ -190,7 +191,7 @@ class ConanService(val project: Project) {
190191
val libraryData = targetFile.readText()
191192

192193
try {
193-
val parsedJson = Json{ignoreUnknownKeys=true}.decodeFromString<LibraryData>(libraryData)
194+
val parsedJson = jsoner.decodeFromString<LibraryData>(libraryData)
194195
fireOnLibraryDataChanged(parsedJson)
195196
} catch (e: SerializationException) {
196197
thisLogger().error(e)
@@ -202,7 +203,7 @@ class ConanService(val project: Project) {
202203
fun getTargetData(): LibraryData {
203204
return try {
204205
val targetData = getTargetDataText()
205-
Json { ignoreUnknownKeys = true }.decodeFromString<LibraryData>(targetData)
206+
jsoner.decodeFromString<LibraryData>(targetData)
206207
} catch (e: SerializationException) {
207208
thisLogger().error(e)
208209
LibraryData(hashMapOf())

src/main/kotlin/com/jfrog/conan/clion/toolWindow/ReadmePanel.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,9 @@ class ReadmePanel(val project: Project) {
112112
}
113113

114114
private fun generateThemeStyles(): String {
115-
val themeScheme = LafManager.getInstance().currentLookAndFeel
115+
val themeScheme = LafManager.getInstance().currentUIThemeLookAndFeel
116116

117-
val lafClassName = themeScheme.className ?: "com.intellij.ide.ui.laf.intellij.IntelliJLookAndFeel"
118-
// TODO: make more advanced theme detection?
119-
val isDarkTheme = lafClassName.contains("Darcula", ignoreCase = true)
117+
val isDarkTheme = themeScheme.isDark
120118
val foregroundColor = if (isDarkTheme) Color(187, 187, 187) else Color(0, 0, 0)
121119
val backgroundColor = if (isDarkTheme) Color(60, 63, 65) else Color(242, 242, 242)
122120
val linkColor = if (isDarkTheme) Color(187, 134, 252) else Color(0, 0, 238)

src/main/kotlin/com/jfrog/conan/clion/toolWindow/UsedPackagesPanel.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,9 @@ class UsedPackagesPanel(val project: Project) {
113113
}
114114

115115
private fun generateThemeStyles(): String {
116-
val themeScheme = LafManager.getInstance().currentLookAndFeel
116+
val themeScheme = LafManager.getInstance().currentUIThemeLookAndFeel
117117

118-
val lafClassName = themeScheme.className ?: "com.intellij.ide.ui.laf.intellij.IntelliJLookAndFeel"
119-
// TODO: make more advanced theme detection?
120-
val isDarkTheme = lafClassName.contains("Darcula", ignoreCase = true)
118+
val isDarkTheme = themeScheme.isDark
121119
val foregroundColor = if (isDarkTheme) Color(187, 187, 187) else Color(0, 0, 0)
122120
val backgroundColor = if (isDarkTheme) Color(60, 63, 65) else Color(242, 242, 242)
123121
val linkColor = if (isDarkTheme) Color(187, 134, 252) else Color(0, 0, 238)

0 commit comments

Comments
 (0)