Skip to content

Commit

Permalink
Fix deprecated API usage (#224)
Browse files Browse the repository at this point in the history
* 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 <mrgalleta@gmail.com>
  • Loading branch information
AbrilRBS and czoido authored Jan 21, 2025
1 parent 7184ab2 commit b51d230
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

## [Unreleased]

### Changed

- Fix deprecated API usages

## [2.0.8] - 2025-01-16

### Changed
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = com.jfrog.conan.clion
pluginName = Conan
pluginRepositoryUrl = https://github.com/conan-io/conan-clion-plugin/
# SemVer format -> https://semver.org
pluginVersion = 2.0.8
pluginVersion = 2.0.9

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 241
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package com.jfrog.conan.clion.conan.extensions

import com.intellij.openapi.diagnostic.thisLogger
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import java.io.File
import java.net.URL
import java.net.URI

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

try {
val fileUrl = URL(url)
val fileUrl = URI(url).toURL()
fileUrl.openStream().use { input ->
targetFile.outputStream().use { output ->
input.copyTo(output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@ import javax.swing.BoxLayout
import javax.swing.JComponent
import javax.swing.JPanel

object ConanExecutableChooserDescriptor : FileChooserDescriptor(true, true, false, false, false, false) {
object ConanExecutableChooserDescriptor : FileChooserDescriptor(true, false, false, false, false, false) {
init {
withFileFilter { it.isConanExecutable }
withTitle("Select Conan executable")

Check warning on line 27 in src/main/kotlin/com/jfrog/conan/clion/dialogs/ConanExecutableDialog.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Incorrect string capitalization

String 'Select Conan executable' is not properly capitalized. It should have title capitalization
}

override fun isFileSelectable(file: VirtualFile?): Boolean {
return super.isFileSelectable(file) && file != null && !file.isDirectory
}
}

val VirtualFile.isConanExecutable: Boolean
Expand Down Expand Up @@ -128,7 +124,8 @@ class ConanExecutableDialogWrapper(val project: Project) : DialogWrapper(true) {
updateOkButtonState()
updateOkButtonState()
}
conanExecutablePathField.textField.whenTextChanged {

conanExecutablePathField.whenTextChanged {
updateOkButtonState()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ConanService(val project: Project) {

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

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

try {
val parsedJson = Json{ignoreUnknownKeys=true}.decodeFromString<LibraryData>(libraryData)
val parsedJson = jsoner.decodeFromString<LibraryData>(libraryData)
fireOnLibraryDataChanged(parsedJson)
} catch (e: SerializationException) {
thisLogger().error(e)
Expand All @@ -202,7 +203,7 @@ class ConanService(val project: Project) {
fun getTargetData(): LibraryData {
return try {
val targetData = getTargetDataText()
Json { ignoreUnknownKeys = true }.decodeFromString<LibraryData>(targetData)
jsoner.decodeFromString<LibraryData>(targetData)
} catch (e: SerializationException) {
thisLogger().error(e)
LibraryData(hashMapOf())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,9 @@ class ReadmePanel(val project: Project) {
}

private fun generateThemeStyles(): String {
val themeScheme = LafManager.getInstance().currentLookAndFeel
val themeScheme = LafManager.getInstance().currentUIThemeLookAndFeel

Check warning on line 115 in src/main/kotlin/com/jfrog/conan/clion/toolWindow/ReadmePanel.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'getCurrentUIThemeLookAndFeel()' is unstable because its signature references unstable 'com.intellij.ide.ui.laf.UIThemeLookAndFeelInfo' marked with @ApiStatus.Experimental

val lafClassName = themeScheme.className ?: "com.intellij.ide.ui.laf.intellij.IntelliJLookAndFeel"
// TODO: make more advanced theme detection?
val isDarkTheme = lafClassName.contains("Darcula", ignoreCase = true)
val isDarkTheme = themeScheme.isDark

Check warning on line 117 in src/main/kotlin/com/jfrog/conan/clion/toolWindow/ReadmePanel.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'isDark()' is declared in unstable 'com.intellij.ide.ui.laf.UIThemeLookAndFeelInfo' marked with @ApiStatus.Experimental
val foregroundColor = if (isDarkTheme) Color(187, 187, 187) else Color(0, 0, 0)
val backgroundColor = if (isDarkTheme) Color(60, 63, 65) else Color(242, 242, 242)
val linkColor = if (isDarkTheme) Color(187, 134, 252) else Color(0, 0, 238)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,9 @@ class UsedPackagesPanel(val project: Project) {
}

private fun generateThemeStyles(): String {
val themeScheme = LafManager.getInstance().currentLookAndFeel
val themeScheme = LafManager.getInstance().currentUIThemeLookAndFeel

Check warning on line 116 in src/main/kotlin/com/jfrog/conan/clion/toolWindow/UsedPackagesPanel.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'getCurrentUIThemeLookAndFeel()' is unstable because its signature references unstable 'com.intellij.ide.ui.laf.UIThemeLookAndFeelInfo' marked with @ApiStatus.Experimental

val lafClassName = themeScheme.className ?: "com.intellij.ide.ui.laf.intellij.IntelliJLookAndFeel"
// TODO: make more advanced theme detection?
val isDarkTheme = lafClassName.contains("Darcula", ignoreCase = true)
val isDarkTheme = themeScheme.isDark

Check warning on line 118 in src/main/kotlin/com/jfrog/conan/clion/toolWindow/UsedPackagesPanel.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'isDark()' is declared in unstable 'com.intellij.ide.ui.laf.UIThemeLookAndFeelInfo' marked with @ApiStatus.Experimental
val foregroundColor = if (isDarkTheme) Color(187, 187, 187) else Color(0, 0, 0)
val backgroundColor = if (isDarkTheme) Color(60, 63, 65) else Color(242, 242, 242)
val linkColor = if (isDarkTheme) Color(187, 134, 252) else Color(0, 0, 238)
Expand Down

0 comments on commit b51d230

Please sign in to comment.