[ByteCodeViewer] IDEA-375222 Respect app-wide setting "Show directory for non-unique file names"

GitOrigin-RevId: 335b0c5ef30ef2e7795ab43fac4411e2825b04c0
This commit is contained in:
Bartek Pacia
2025-07-01 20:02:05 +00:00
committed by intellij-monorepo-bot
parent c5ac9f7c77
commit 016f729df4
2 changed files with 9 additions and 6 deletions
@@ -1,6 +1,7 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.byteCodeViewer
import com.intellij.ide.ui.UISettings
import com.intellij.openapi.components.Service
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
@@ -35,17 +36,22 @@ class BytecodeToolWindowService(private val project: Project) {
val listener = object : ContentManagerListener {
override fun contentAdded(event: ContentManagerEvent) {
deduplicateTabNames(toolWindow)
if (UISettings.getInstance().showDirectoryForNonUniqueFilenames) {
deduplicateTabNames(toolWindow)
}
}
override fun contentRemoved(event: ContentManagerEvent) {
deduplicateTabNames(toolWindow)
if (UISettings.getInstance().showDirectoryForNonUniqueFilenames) {
deduplicateTabNames(toolWindow)
}
}
}
contentManager.addContentManagerListener(listener)
registeredListeners[toolWindow] = listener
Disposer.register(toolWindow.disposable) {
// The bytecode tool window cannot be "closed"
contentManager.removeContentManagerListener(listener)
registeredListeners.remove(toolWindow)
}
@@ -31,9 +31,7 @@ internal class ShowBytecodeAction : AnAction() {
hideOnEmptyContent = true
canCloseContent = true
}
val service = BytecodeToolWindowService.getInstance(project)
service.ensureContentManagerListenerRegistered(toolWindow)
BytecodeToolWindowService.getInstance(project).ensureContentManagerListenerRegistered(toolWindow)
val editor = event.getData(CommonDataKeys.EDITOR) ?: return
val psiFile = event.getData(CommonDataKeys.PSI_FILE) ?: return
@@ -77,7 +75,6 @@ internal class ShowBytecodeAction : AnAction() {
toolWindow.contentManager.addContent(content)
service.deduplicateTabNames(toolWindow)
content.setDisposer(panel)
toolWindow.contentManager.setSelectedContent(content)
toolWindow.setAdditionalGearActions(createActionGroup())