243 feature/29/hightlight axiom jdk simple

This commit is contained in:
Nikita Iarychenko
2025-02-07 06:29:28 +00:00
parent 75fc4540dd
commit cae7776d66
2 changed files with 21 additions and 2 deletions

View File

@@ -120,7 +120,11 @@ private class JdkVersionVendorCombobox: ComboBox<JdkVersionVendorItem>() {
}
override fun customize(item: SimpleColoredComponent, value: JdkVersionVendorItem, index: Int, isSelected: Boolean, hasFocus: Boolean) {
item.append(value.item.product.packagePresentationText, SimpleTextAttributes.REGULAR_ATTRIBUTES)
val title = value.item.product.packagePresentationText.replace("Axiom JSC", "").trim()
if (isLicenseAcceptedJDK(value))
item.append(title, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES)
else
item.append(title, SimpleTextAttributes.REGULAR_ATTRIBUTES)
val additionalInfo = mutableListOf<String>()
val jdkVersion = value.item.jdkVersion
@@ -133,7 +137,18 @@ private class JdkVersionVendorCombobox: ComboBox<JdkVersionVendorItem>() {
}
}
private fun List<JdkVersionVendorItem>.sortedForUI() = this.sortedBy { it.item.product.packagePresentationText.lowercase() }
private fun List<JdkVersionVendorItem>.sortedForUI() = this
.sortedWith(
Comparator { i1, i2 ->
val s1: String = i1.item.product.packagePresentationText
val s2: String = i2.item.product.packagePresentationText
if (s1.contains("Axiom", ignoreCase = true)) -1
else s1.compareTo(s2)
}
)
private fun isLicenseAcceptedJDK(vendor: JdkVersionVendorItem): Boolean = vendor.item.isLicenseAccepted
@VisibleForTesting
@Internal

View File

@@ -77,6 +77,8 @@ data class JdkItem(
val jdkVendorVersion: String?,
val suggestedSdkName: String,
val isLicenseAccepted: Boolean,
val os: String,
/**
* @see presentableArchIfNeeded
@@ -434,6 +436,8 @@ object JdkListParser {
jdkVendorVersion = (item["jdk_vendor_version"] as? JsonPrimitive)?.contentOrNull,
suggestedSdkName = (item["suggested_sdk_name"] as? JsonPrimitive)?.contentOrNull ?: return emptyList(),
isLicenseAccepted = item["is_license_accepted"]?.let { filters.testPredicate(it) == true } ?: false,
os = (pkg["os"] as? JsonPrimitive)?.contentOrNull ?: return emptyList(),
arch = (pkg["arch"] as? JsonPrimitive)?.contentOrNull ?: return emptyList(),
packageType = (pkg["package_type"] as? JsonPrimitive)?.contentOrNull?.let(JdkPackageType.Companion::findType) ?: return emptyList(),