mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[platform][eel] IJ-CR-194030 IJPL-236399 Use fastGetIcon() for Dev Container as well
(cherry picked from commit bc5b8b8aa2ea4848273474ac3c6d4931874cf71a) IJ-CR-194030 GitOrigin-RevId: 9dca90524a4f39a764a71bd6a15fa1ac725360f7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
612132e84c
commit
1fa1a828ce
@@ -1,7 +1,10 @@
|
||||
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.fileChooser;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.fileTypes.UnknownFileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -9,6 +12,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public interface FileChooserCustomizer {
|
||||
@@ -25,6 +29,12 @@ public interface FileChooserCustomizer {
|
||||
*/
|
||||
default @Nullable Icon fastGetIcon(@Nullable Project project, @NotNull Path filePath) { return null; }
|
||||
|
||||
static @NotNull Icon getFileIconByName(@NotNull Path filePath) {
|
||||
final var fileName = filePath.getFileName();
|
||||
final var fileType = fileName != null ? FileTypeManager.getInstance().getFileTypeByFileName(fileName.toString()) : UnknownFileType.INSTANCE;
|
||||
return Objects.requireNonNullElse(fileType instanceof UnknownFileType ? AllIcons.Empty : fileType.getIcon(), AllIcons.Empty);
|
||||
}
|
||||
|
||||
final class Util {
|
||||
public static boolean isPathVisible(@Nullable Project project, @NotNull Path path) {
|
||||
for (final var ex : EP_NAME.getExtensionList()) {
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.ide.impl.wsl.fileChooser
|
||||
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.openapi.fileChooser.FileChooserCustomizer
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager
|
||||
import com.intellij.openapi.fileTypes.UnknownFileType
|
||||
import com.intellij.openapi.fileChooser.FileChooserCustomizer.getFileIconByName
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.platform.eel.provider.getEelDescriptor
|
||||
import com.intellij.platform.ide.impl.wsl.WslEelDescriptor
|
||||
import java.nio.file.Path
|
||||
import javax.swing.Icon
|
||||
import kotlin.io.path.name
|
||||
|
||||
internal class WslFileChooserCustomizer : FileChooserCustomizer {
|
||||
|
||||
override fun fastGetIcon(project: Project?, filePath: Path): Icon? {
|
||||
return if (filePath.toString().startsWith("\\\\wsl") && filePath.getEelDescriptor() is WslEelDescriptor) {
|
||||
val fileType = FileTypeManager.getInstance().getFileTypeByFileName(filePath.name)
|
||||
if (fileType is UnknownFileType) AllIcons.Empty else fileType.icon ?: AllIcons.Empty
|
||||
getFileIconByName(filePath)
|
||||
}
|
||||
else null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user