From aa3132b81008cb61baa3394791160dd779c6c5c3 Mon Sep 17 00:00:00 2001 From: leitianjian <185049857@qq.com> Date: Wed, 8 Apr 2020 22:46:45 +0800 Subject: [PATCH 1/5] Showing correct icon on main table linked files column --- .../org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java index 471af98aa2f..f9297f5f891 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java @@ -94,7 +94,7 @@ public static LinkedFile fromFile(Path file, List fileDirectories, Externa .getExternalFileTypeByExt(fileExtension) .orElse(new UnknownExternalFileType(fileExtension)); Path relativePath = FileUtil.relativize(file, fileDirectories); - return new LinkedFile("", relativePath.toString(), suggestedFileType.getName()); + return new LinkedFile("", relativePath.toString(), suggestedFileType.getExtension()); } public LinkedFileViewModel fromFile(Path file) { From 9c9b7c1fcf5b7a90f71254df3c6a4ef59967c861 Mon Sep 17 00:00:00 2001 From: leitianjian <185049857@qq.com> Date: Wed, 15 Apr 2020 17:43:36 +0800 Subject: [PATCH 2/5] Showing correct icon on both main table and linked files column --- .../org/jabref/gui/externalfiletype/ExternalFileTypes.java | 2 +- .../java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java index 7e7d2836f1b..9283c7e7fde 100644 --- a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java +++ b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java @@ -56,7 +56,7 @@ public Set getExternalFileTypeSelection() { * @return The ExternalFileType registered, or null if none. */ public Optional getExternalFileTypeByName(String name) { - Optional externalFileType = externalFileTypes.stream().filter(type -> type.getExtension().equals(name)).findFirst(); + Optional externalFileType = externalFileTypes.stream().filter(type -> type.getName().equals(name)).findFirst(); if (externalFileType.isPresent()) { return externalFileType; } diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java index d52a24b9f95..36e59e1d9fd 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java @@ -140,7 +140,9 @@ public Optional findIn(List directories) { * org.jabref.gui.externalfiletype.ExternalFileTypes#getExternalFileTypeByName(String)} */ public JabRefIcon getTypeIcon() { - return IconTheme.JabRefIcons.PDF_FILE; + return externalFileTypes.fromLinkedFile(linkedFile, false) + .map(ExternalFileType::getIcon) + .orElse(IconTheme.JabRefIcons.FILE); } public void markAsAutomaticallyFound() { From 8090ea51ced82fa2ea514ff4258ab23f59ff92a2 Mon Sep 17 00:00:00 2001 From: leitianjian <185049857@qq.com> Date: Wed, 15 Apr 2020 17:51:24 +0800 Subject: [PATCH 3/5] Showing correct icon on both main table and linked file editor list --- .../org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java index f9297f5f891..471af98aa2f 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java @@ -94,7 +94,7 @@ public static LinkedFile fromFile(Path file, List fileDirectories, Externa .getExternalFileTypeByExt(fileExtension) .orElse(new UnknownExternalFileType(fileExtension)); Path relativePath = FileUtil.relativize(file, fileDirectories); - return new LinkedFile("", relativePath.toString(), suggestedFileType.getExtension()); + return new LinkedFile("", relativePath.toString(), suggestedFileType.getName()); } public LinkedFileViewModel fromFile(Path file) { From 72fc91c114dc57dd1e41f189cb0bc4b1b7341102 Mon Sep 17 00:00:00 2001 From: leitianjian <185049857@qq.com> Date: Wed, 15 Apr 2020 19:32:50 +0800 Subject: [PATCH 4/5] delete the TODO comments --- .../java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java index 36e59e1d9fd..d8c42054544 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java @@ -135,10 +135,6 @@ public Optional findIn(List directories) { return linkedFile.findIn(directories); } - /** - * TODO: Be a bit smarter and try to infer correct icon, for example using {@link - * org.jabref.gui.externalfiletype.ExternalFileTypes#getExternalFileTypeByName(String)} - */ public JabRefIcon getTypeIcon() { return externalFileTypes.fromLinkedFile(linkedFile, false) .map(ExternalFileType::getIcon) From e9796642b245badbd100cf83289cfa61ca0f4609 Mon Sep 17 00:00:00 2001 From: leitianjian <185049857@qq.com> Date: Wed, 15 Apr 2020 19:46:24 +0800 Subject: [PATCH 5/5] add record in CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 149ea8d8bc7..65666240e0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where opening a library from the recent libraries menu was not possible. [#5939](https://github.com/JabRef/jabref/issues/5939) - We fixed an issue with inconsistent capitalization of file extensions when downloading files [#6115](https://github.com/JabRef/jabref/issues/6115) - We fixed the display of language and encoding in the preferences dialog. [#6130](https://github.com/JabRef/jabref/pull/6130) +- We fixed the display of icon both in the main table and linked file editor. [#6169](https://github.com/JabRef/jabref/issues/6169) ### Removed