Add mimetype based icons

This commit is contained in:
Oystein Kristoffer Tveit 2021-04-23 00:10:33 +02:00
parent eb7f89c932
commit 92fa16891c
914 changed files with 56 additions and 8 deletions

View File

@ -17,6 +17,8 @@ import javafx.scene.image.ImageView;
public class FiletreeOperations { public class FiletreeOperations {
private static int iconSize = 20;
// FIXME: File specific icons not working properly // FIXME: File specific icons not working properly
// TODO: Clean up code that is not in use // TODO: Clean up code that is not in use
// TODO: Error check for recursiveness, and files without icons // TODO: Error check for recursiveness, and files without icons
@ -33,7 +35,11 @@ public class FiletreeOperations {
Image folder = new Image(FiletreeOperations.class.getResourceAsStream("/graphics/folder.png")); Image folder = new Image(FiletreeOperations.class.getResourceAsStream("/graphics/folder.png"));
if (file.isDirectory()) { if (file.isDirectory()) {
CheckBoxTreeItem<String> element = new CheckBoxTreeItem<>(file.getName(), new ImageView(folder)); ImageView icon = new ImageView(folder);
icon.setFitHeight(iconSize);
icon.setFitWidth(iconSize);
CheckBoxTreeItem<String> element = new CheckBoxTreeItem<>(file.getName(), icon);
parent.getChildren().add(element); parent.getChildren().add(element);
List<File> dirList = new ArrayList<>(); List<File> dirList = new ArrayList<>();
@ -48,10 +54,15 @@ public class FiletreeOperations {
} else { } else {
try { try {
CheckBoxTreeItem<String> element = ImageView icon = new ImageView(getIconForFile(file));
new CheckBoxTreeItem<>(file.getName(), new ImageView(getIconForFile(file))); icon.setFitHeight(iconSize);
icon.setFitWidth(iconSize);
CheckBoxTreeItem<String> element = new CheckBoxTreeItem<>(file.getName(), icon);
parent.getChildren().add(element); parent.getChildren().add(element);
} catch (Exception e) { } catch (Exception e) {
System.err.print(e);
System.err.println("[ERROR]: DEFAULT FILE ICON NOT FOUND"); System.err.println("[ERROR]: DEFAULT FILE ICON NOT FOUND");
} }
} }
@ -76,21 +87,20 @@ public class FiletreeOperations {
Image icon; Image icon;
try { try {
String mimeType = Files.probeContentType(file.toPath()).replace('/', '-'); String mimeType = Files.probeContentType(file.toPath());
String iconPath = "/graphics/filetreeicons/" + mimeType + ".png";
if (mimeType == null) throw new IOException(); if (mimeType == null) throw new IOException();
String iconPath = "/graphics/filetreeicons/" + mimeType.replace('/', '-') + ".png";
InputStream imageData = FiletreeOperations.class.getResourceAsStream(iconPath); InputStream imageData = FiletreeOperations.class.getResourceAsStream(iconPath);
if (imageData == null) throw new IOException(); if (imageData == null) throw new IOException();
icon = new Image(imageData); icon = new Image(imageData);
} catch (IOException e) { } catch (IOException e) {
System.err.println("[ERROR]: ICON NOT FOUND: " + file.getPath()); System.err.println("[WARNING]: ICON NOT FOUND: " + file.getPath());
// String iconPath = "/graphics/filetreeicons/file.png"; // String iconPath = "/graphics/filetreeicons/file.png";
String iconPath = "/graphics/placeholder.png"; String iconPath = "/graphics/filetreeicons/unknown.png";
InputStream imageData = FileOperations.class.getResourceAsStream(iconPath); InputStream imageData = FileOperations.class.getResourceAsStream(iconPath);
if (imageData == null) throw new IOException(); if (imageData == null) throw new IOException();

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 691 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 691 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 745 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 691 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 989 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 874 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 809 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 813 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 885 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 885 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 885 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 885 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 885 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 729 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 796 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 978 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 796 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 886 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 739 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 780 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 886 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Some files were not shown because too many files have changed in this diff Show More