diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectWizardJdkComboBox.kt b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectWizardJdkComboBox.kt index 47bc994c899c..371cb68a6b93 100644 --- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectWizardJdkComboBox.kt +++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectWizardJdkComboBox.kt @@ -1,4 +1,8 @@ // Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// +// Modified by Dmitry Lyubin at 2025 as part of the OpenIDE project(https://openide.ru). +// Any modifications are available on the same license terms as the original source code. +// package com.intellij.ide.projectWizard import com.intellij.icons.AllIcons @@ -100,6 +104,8 @@ import java.nio.file.Paths import javax.accessibility.AccessibleContext import javax.swing.Icon import javax.swing.JList +import kotlin.Comparator +import kotlin.io.path.Path import kotlin.reflect.KFunction1 private val selectedJdkProperty = "jdk.selected.JAVA_MODULE" @@ -276,6 +282,13 @@ class ProjectWizardJdkComboBox( } } + private fun appendJdkText(item: SimpleColoredComponent, text: String) { + if (text.contains("axiom", ignoreCase = true)) + item.append(text, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES) + else + item.append(text) + } + override fun customize(item: SimpleColoredComponent, value: ProjectWizardJdkIntent, index: Int, isSelected: Boolean, cellHasFocus: Boolean) { item.icon = when { value is NoJdk && index == -1 -> null @@ -286,10 +299,10 @@ class ProjectWizardJdkComboBox( is NoJdk -> item.append(JavaUiBundle.message("jdk.missing.item"), SimpleTextAttributes.ERROR_ATTRIBUTES) is ExistingJdk -> { if (value.jdk == projectJdk) { - item.append(JavaUiBundle.message("jdk.project.item")) + appendJdkText(item, JavaUiBundle.message("jdk.project.item")) item.append(" ${projectJdk.name}", SimpleTextAttributes.GRAYED_ATTRIBUTES) } else { - item.append(value.jdk.name) + appendJdkText(item, value.jdk.name) val version = value.jdk.versionString ?: (value.jdk.sdkType as SdkType).presentableName item.append(" $version", SimpleTextAttributes.GRAYED_ATTRIBUTES) } @@ -297,11 +310,11 @@ class ProjectWizardJdkComboBox( is DownloadJdk -> { when (value.task.productName) { null -> { - item.append(JavaUiBundle.message("jdk.download.predefined.item", value.task.suggestedSdkName)) + appendJdkText(item, JavaUiBundle.message("jdk.download.predefined.item", value.task.suggestedSdkName)) item.append(" ${value.task.plannedVersion}", SimpleTextAttributes.GRAYED_ATTRIBUTES) } else -> { - item.append(JavaUiBundle.message("jdk.download.predefined.item", value.task.productName)) + appendJdkText(item, JavaUiBundle.message("jdk.download.predefined.item", value.task.productName)) } } } @@ -310,7 +323,7 @@ class ProjectWizardJdkComboBox( is AddJdkFromPath -> item.append(JavaUiBundle.message("action.AddJdkAction.text")) is DetectedJdk -> { - item.append(value.version) + appendJdkText(item, value.version) item.append(" ${value.home}", SimpleTextAttributes.GRAYED_ATTRIBUTES) } } @@ -532,7 +545,18 @@ private fun selectAndAddJdk(combo: ProjectWizardJdkComboBox) { private fun containsSymbolicLink(path: String): Boolean { val p = Paths.get(path) return try { p.toRealPath() != p } - catch (_: IOException) { false } + catch (_: IOException) { false } +} + +private fun compareJdkStrings(s1: String?, s2: String?): Int { + val b1 = s1?.contains("axiom", ignoreCase = true) ?: false + val b2 = s2?.contains("axiom", ignoreCase = true) ?: false + if (b1 && b2) + return 0 + else if (b2) + return 1 + else + return -1 } private fun computeRegisteredSdks(key: EelDescriptor?): List { @@ -544,6 +568,7 @@ private fun computeRegisteredSdks(key: EelDescriptor?): List { (key == null || ProjectSdksModel.sdkMatchesEel(key.getResolvedEelMachine() ?: LocalEelMachine, jdk)) } .map { ExistingJdk(it) } + .sortedWith(Comparator { o1, o2 -> compareJdkStrings(o1?.jdk?.versionString, o2?.jdk?.versionString) }) } private fun computeHelperJdks(registered: List): List { @@ -561,10 +586,7 @@ private fun computeHelperJdks(registered: List): List compareJdkStrings(o1?.version, o2?.version) })) } } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/SdkListModelBuilder.java b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/SdkListModelBuilder.java index 391abfbc961d..ac3e582a735f 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/SdkListModelBuilder.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/SdkListModelBuilder.java @@ -1,4 +1,8 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// +// Modified by Dmitry Lyubin at 2025 as part of the OpenIDE project(https://openide.ru). +// Any modifications are available on the same license terms as the original source code. +// package com.intellij.openapi.roots.ui.configuration; import com.google.common.collect.ImmutableList; @@ -198,7 +202,19 @@ public final class SdkListModelBuilder { newModel.addAll(subItems); } - for (SuggestedItem item : mySuggestions) { + List mySortedSuggestions = new ArrayList<>(mySuggestions); + mySortedSuggestions.sort((o1, o2) -> { + boolean b1 = o1 != null && o1.version.toLowerCase(Locale.ROOT).contains("axiom"); + boolean b2 = o2 != null && o2.version.toLowerCase(Locale.ROOT).contains("axiom"); + if (b1 && b2) + return 0; + else if (b2) + return 1; + else + return -1; + }); + + for (SuggestedItem item : mySortedSuggestions) { if (!isApplicableSuggestedItem(item)) continue; newModel.add(item); } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/SdkListPresenter.java b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/SdkListPresenter.java index d752780bd1be..73ae59a63c70 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/SdkListPresenter.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/SdkListPresenter.java @@ -1,4 +1,8 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// +// Modified by Dmitry Lyubin at 2025 as part of the OpenIDE project(https://openide.ru). +// Any modifications are available on the same license terms as the original source code. +// package com.intellij.openapi.roots.ui.configuration; import com.intellij.icons.AllIcons; @@ -34,9 +38,8 @@ import javax.swing.JList; import javax.swing.JPanel; import javax.swing.ListCellRenderer; import javax.swing.border.Border; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Container; +import java.awt.*; +import java.util.Locale; import java.util.function.Function; import java.util.function.Supplier; @@ -133,6 +136,15 @@ public class SdkListPresenter extends ColoredListCellRenderer { return panel; } + private void appendJdkText(String text) { + if (text != null) { + if (text.toLowerCase(Locale.ROOT).contains("axiom")) + append(text, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES); + else + append(text); + } + } + @Override protected void customizeCellRenderer(@NotNull JList list, @Nullable SdkListItem value, @@ -165,7 +177,7 @@ public class SdkListPresenter extends ColoredListCellRenderer { Icon icon = type.getIcon(); if (icon == null) icon = IconUtil.getAddIcon(); setIcon(icon); - append(presentDetectedSdkPath(home)); + appendJdkText(presentDetectedSdkPath(home)); append(" "); append(version, SimpleTextAttributes.GRAYED_ATTRIBUTES); } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/SdkListPresenter2.kt b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/SdkListPresenter2.kt index f4b6b123c58d..c16456cd2796 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/SdkListPresenter2.kt +++ b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/SdkListPresenter2.kt @@ -1,4 +1,8 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// +// Modified by Dmitry Lyubin at 2025 as part of the OpenIDE project(https://openide.ru). +// Any modifications are available on the same license terms as the original source code. +// package com.intellij.openapi.roots.ui.configuration import com.intellij.icons.AllIcons @@ -77,7 +81,15 @@ internal class SdkListPresenter2( return component } + private fun appendJdkText(item: SimpleColoredComponent, text: String) { + if (text.contains("axiom", ignoreCase = true)) + item.append(text, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES) + else + item.append(text) + } + override fun customize(item: SimpleColoredComponent, value: T, index: Int, isSelected: Boolean, cellHasFocus: Boolean) { + when (val sdkListItem = listItemProducer.apply(value)) { is SdkListItem.InvalidSdkItem -> { item.append(ProjectBundle.message("jdk.combo.box.invalid.item", sdkListItem.sdkName), SimpleTextAttributes.ERROR_ATTRIBUTES) @@ -94,7 +106,7 @@ internal class SdkListPresenter2( } item.icon = icon ?: IconUtil.addIcon - item.append(sdkListItem.version) + appendJdkText(item, sdkListItem.version) item.append(" ${SdkListPresenter.presentDetectedSdkPath(sdkListItem.homePath)}", SimpleTextAttributes.GRAYED_ATTRIBUTES) } diff --git a/platform/platform-impl/src/com/intellij/openapi/roots/ui/SdkAppearanceServiceImpl.java b/platform/platform-impl/src/com/intellij/openapi/roots/ui/SdkAppearanceServiceImpl.java index 0459f0f441e1..ffd08ca9c95d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/roots/ui/SdkAppearanceServiceImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/roots/ui/SdkAppearanceServiceImpl.java @@ -1,4 +1,8 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// +// Modified by Dmitry Lyubin at 2025 as part of the OpenIDE project(https://openide.ru). +// Any modifications are available on the same license terms as the original source code. +// package com.intellij.openapi.roots.ui; import com.intellij.openapi.project.ProjectBundle; @@ -18,6 +22,8 @@ import org.jetbrains.annotations.Nullable; import javax.swing.UIManager; +import java.util.Locale; + import static com.intellij.ui.SimpleTextAttributes.GRAY_ATTRIBUTES; import static com.intellij.ui.SimpleTextAttributes.STYLE_PLAIN; @@ -53,7 +59,9 @@ public final class SdkAppearanceServiceImpl extends SdkAppearanceService { appearance.setIcon(((SdkType)sdkType).getIcon()); } - SimpleTextAttributes attributes = getTextAttributes(hasValidPath, selected); + boolean bold = name.toLowerCase(Locale.ROOT).contains("axiom"); + + SimpleTextAttributes attributes = getTextAttributes(hasValidPath, selected, bold); CompositeAppearance.DequeEnd ending = appearance.getEnding(); ending.addText(StringUtil.shortenTextWithEllipsis(name, 50, 0), attributes); @@ -71,15 +79,15 @@ public final class SdkAppearanceServiceImpl extends SdkAppearanceService { return ending.getAppearance(); } - private static SimpleTextAttributes getTextAttributes(final boolean valid, final boolean selected) { + private static SimpleTextAttributes getTextAttributes(final boolean valid, final boolean selected, final boolean bold) { if (!valid) { return SimpleTextAttributes.ERROR_ATTRIBUTES; } else if (selected && !(SystemInfoRt.isWindows && UIManager.getLookAndFeel().getName().contains("Windows"))) { - return SimpleTextAttributes.SELECTED_SIMPLE_CELL_ATTRIBUTES; + return bold ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.SELECTED_SIMPLE_CELL_ATTRIBUTES; } else { - return SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES; + return bold ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES; } } }