mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
IDEA-347934 'Language Services' widget: improve headers in popup
GitOrigin-RevId: aa8fb49c657765912f91b17e3b5334a0acfc3cf1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0dc8ca83be
commit
fbd932d4f9
@@ -605,8 +605,9 @@ show.more=Show more
|
||||
show.less=Show less
|
||||
|
||||
language.services.widget=Language Services
|
||||
language.services.widget.for.current.file=For Current File
|
||||
language.services.widget.for.other.files=Other
|
||||
language.services.widget.section.running.on.current.file=Running on Current File
|
||||
language.services.widget.section.running.on.other.files=Running on Other Files
|
||||
language.services.widget.no.services=No Services
|
||||
language.services.widget.item.initializing={0} | Initializing\u2026
|
||||
language.services.widget.item.shutdown.normally={0} | Stopped
|
||||
language.services.widget.item.shutdown.unexpectedly={0} | Terminated
|
||||
|
||||
@@ -21,21 +21,21 @@ abstract class LanguageServiceWidgetItem {
|
||||
* The default label for the status bar widget is the generic one: "Language Services".
|
||||
*
|
||||
* But if
|
||||
* - this [LanguageServiceWidgetItem] is the only one in the `For Current File` popup section
|
||||
* - this [LanguageServiceWidgetItem] is the only one in the [LanguageServicePopupSection.ForCurrentFile] popup section
|
||||
* (only for this item the [widgetActionLocation] value is [LanguageServicePopupSection.ForCurrentFile])
|
||||
* - and the [statusBarText] value is not `null`
|
||||
*
|
||||
* then the service-specific text will be shown in the status bar.
|
||||
*
|
||||
* If this item is not the only one in the `For Current File` popup section,
|
||||
* or it is not in the `For Current File` popup section at all,
|
||||
* If this item is not the only one in the [LanguageServicePopupSection.ForCurrentFile] popup section,
|
||||
* or it is not in the [LanguageServicePopupSection.ForCurrentFile] popup section at all,
|
||||
* then the [statusBarText] value is ignored.
|
||||
*/
|
||||
open val statusBarText: @NlsContexts.StatusBarText String? = null
|
||||
|
||||
/**
|
||||
* A tooltip for the status bar widget label.
|
||||
* Used only if this item appears to be the only one in the `For Current File` popup section.
|
||||
* Used only if this item appears to be the only one in the [LanguageServicePopupSection.ForCurrentFile] popup section.
|
||||
* Otherwise, it's ignored.
|
||||
* @see statusBarText
|
||||
*/
|
||||
|
||||
@@ -3,9 +3,8 @@ package com.intellij.platform.lang.lsWidget.impl
|
||||
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.lang.LangBundle
|
||||
import com.intellij.openapi.actionSystem.ActionGroup
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup
|
||||
import com.intellij.openapi.actionSystem.*
|
||||
import com.intellij.openapi.project.DumbAware
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory
|
||||
import com.intellij.openapi.ui.popup.ListPopup
|
||||
@@ -75,20 +74,35 @@ internal class LanguageServiceWidget(project: Project, scope: CoroutineScope) :
|
||||
val allItems = cachedWidgetItems
|
||||
val fileSpecificItems = allItems.filter { it.widgetActionLocation == ForCurrentFile }
|
||||
val otherItems = allItems - fileSpecificItems.toSet()
|
||||
// The '---Other---' separator doesn't look great if it's the only separator in the popup, so check only `fileSpecificStates.isNotEmpty()`
|
||||
val needSeparators = fileSpecificItems.isNotEmpty()
|
||||
|
||||
val group = DefaultActionGroup()
|
||||
|
||||
if (needSeparators) group.addSeparator(LangBundle.message("language.services.widget.for.current.file"))
|
||||
fileSpecificItems.forEach { group.add(it.createWidgetAction()) }
|
||||
group.addSeparator(LangBundle.message("language.services.widget.section.running.on.current.file"))
|
||||
if (fileSpecificItems.isNotEmpty()) {
|
||||
fileSpecificItems.forEach { group.add(it.createWidgetAction()) }
|
||||
}
|
||||
else {
|
||||
group.add(NoServices)
|
||||
}
|
||||
|
||||
if (needSeparators) group.addSeparator(LangBundle.message("language.services.widget.for.other.files"))
|
||||
group.addSeparator(LangBundle.message("language.services.widget.section.running.on.other.files"))
|
||||
otherItems.forEach { group.add(it.createWidgetAction()) }
|
||||
|
||||
return group
|
||||
}
|
||||
|
||||
|
||||
private object NoServices : AnAction(LangBundle.messagePointer("language.services.widget.no.services")), DumbAware {
|
||||
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
e.presentation.isEnabled = false
|
||||
}
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {}
|
||||
}
|
||||
|
||||
|
||||
private companion object {
|
||||
private val normalIcon: Icon = AllIcons.Json.Object
|
||||
private val errorIcon: Icon = LayeredIcon.layeredIcon { arrayOf(AllIcons.Json.Object, AllIcons.Nodes.ErrorMark) }
|
||||
|
||||
Reference in New Issue
Block a user