Add mimetype based icons
|
@ -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();
|
||||||
|
|
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 683 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 683 B |
After Width: | Height: | Size: 691 B |
After Width: | Height: | Size: 691 B |
After Width: | Height: | Size: 697 B |
After Width: | Height: | Size: 745 B |
After Width: | Height: | Size: 691 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 683 B |
After Width: | Height: | Size: 683 B |
After Width: | Height: | Size: 697 B |
After Width: | Height: | Size: 647 B |
After Width: | Height: | Size: 989 B |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 621 B |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1017 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 647 B |
After Width: | Height: | Size: 824 B |
After Width: | Height: | Size: 636 B |
After Width: | Height: | Size: 636 B |
After Width: | Height: | Size: 874 B |
After Width: | Height: | Size: 697 B |
After Width: | Height: | Size: 809 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 813 B |
After Width: | Height: | Size: 885 B |
After Width: | Height: | Size: 885 B |
After Width: | Height: | Size: 885 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 885 B |
After Width: | Height: | Size: 885 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 634 B |
After Width: | Height: | Size: 634 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 729 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 636 B |
After Width: | Height: | Size: 796 B |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 978 B |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 697 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 796 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 636 B |
After Width: | Height: | Size: 886 B |
After Width: | Height: | Size: 646 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 739 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 780 B |
After Width: | Height: | Size: 647 B |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 636 B |
After Width: | Height: | Size: 886 B |
After Width: | Height: | Size: 646 B |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 1.3 KiB |