diff --git a/app/src/main/java/io/xpipe/app/browser/FileListComp.java b/app/src/main/java/io/xpipe/app/browser/FileListComp.java index 0c9b6c4c7..50e1b8bcd 100644 --- a/app/src/main/java/io/xpipe/app/browser/FileListComp.java +++ b/app/src/main/java/io/xpipe/app/browser/FileListComp.java @@ -27,7 +27,6 @@ import javafx.scene.control.skin.TableViewSkin; import javafx.scene.control.skin.VirtualFlow; import javafx.scene.input.DragEvent; import javafx.scene.input.KeyCode; -import javafx.scene.input.MouseEvent; import javafx.scene.layout.*; import java.time.Instant; @@ -172,14 +171,8 @@ final class FileListComp extends AnchorPane { table.pseudoClassStateChanged(DRAG_INTO_CURRENT, newValue); }); - row.addEventHandler(MouseEvent.MOUSE_CLICKED, t -> { - listEntry.get().onMouseClick(t); - }); - row.setOnMouseClicked(e -> { - if (e.getClickCount() == 2 && !row.isEmpty()) { - fileList.onDoubleClick(row.getItem()); - } + listEntry.get().onMouseClick(e); }); row.setOnDragEntered(event -> { diff --git a/app/src/main/java/io/xpipe/app/browser/FileListCompEntry.java b/app/src/main/java/io/xpipe/app/browser/FileListCompEntry.java index 58f0a688b..cf6dffffa 100644 --- a/app/src/main/java/io/xpipe/app/browser/FileListCompEntry.java +++ b/app/src/main/java/io/xpipe/app/browser/FileListCompEntry.java @@ -5,6 +5,7 @@ import javafx.geometry.Point2D; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.SnapshotParameters; +import javafx.scene.control.TableView; import javafx.scene.image.WritableImage; import javafx.scene.input.*; import lombok.Getter; @@ -32,21 +33,41 @@ public class FileListCompEntry { this.model = model; } + @SuppressWarnings("unchecked") public void onMouseClick(MouseEvent t) { - t.consume(); if (item == null || isSynthetic()) { return; } + if (t.getClickCount() == 2 && t.getButton() == MouseButton.PRIMARY) { + model.onDoubleClick(item); + t.consume(); + return; + } + + if (t.getButton() == MouseButton.PRIMARY && t.isShiftDown()) { + var tv = ((TableView) row.getParent().getParent().getParent().getParent()); + var all = tv.getItems(); + var start = tv.getSelectionModel().getSelectedItems().stream().mapToInt(entry -> all.indexOf(entry)).min().orElse(1); + var end = all.indexOf(item); + model.getSelected().setAll(all.subList(start, end + 1)); + t.consume(); + return; + } + if (currentContextMenu != null) { currentContextMenu.hide(); currentContextMenu = null; + t.consume(); + return; } if (t.getButton() == MouseButton.SECONDARY) { var cm = new FileContextMenu(model.getFileSystemModel(), item, model.getEditing()); cm.show(row, t.getScreenX(), t.getScreenY()); currentContextMenu = cm; + t.consume(); + return; } } diff --git a/app/src/main/java/io/xpipe/app/browser/icon/FileIconFactory.java b/app/src/main/java/io/xpipe/app/browser/icon/FileIconFactory.java index 68bd1a709..d65aaf133 100644 --- a/app/src/main/java/io/xpipe/app/browser/icon/FileIconFactory.java +++ b/app/src/main/java/io/xpipe/app/browser/icon/FileIconFactory.java @@ -21,7 +21,7 @@ public interface FileIconFactory { return null; } - return Arrays.stream(endings).anyMatch(ending -> entry.getPath().endsWith(ending)) ? getIcon() : null; + return Arrays.stream(endings).anyMatch(ending -> entry.getPath().toLowerCase().endsWith(ending.toLowerCase())) ? getIcon() : null; } } diff --git a/app/src/main/java/io/xpipe/app/browser/icon/FileIcons.java b/app/src/main/java/io/xpipe/app/browser/icon/FileIcons.java index 3e6895c81..89992de7f 100644 --- a/app/src/main/java/io/xpipe/app/browser/icon/FileIcons.java +++ b/app/src/main/java/io/xpipe/app/browser/icon/FileIcons.java @@ -7,10 +7,6 @@ import javafx.beans.property.SimpleStringProperty; public class FileIcons { public static PrettyImageComp createIcon(FileSystem.FileEntry entry) { - return new PrettyImageComp(new SimpleStringProperty(getIcon(entry)), 22, 22); - } - - public static String getIcon(FileSystem.FileEntry entry) { - return FileIconManager.getFileIcon(entry, false); + return new PrettyImageComp(new SimpleStringProperty(FileIconManager.getFileIcon(entry, false)), 22, 22); } } diff --git a/app/src/main/resources/io/xpipe/app/resources/browser_icons/file_list.txt b/app/src/main/resources/io/xpipe/app/resources/browser_icons/file_list.txt index c4bd9a0c1..86d7bdf7c 100644 --- a/app/src/main/resources/io/xpipe/app/resources/browser_icons/file_list.txt +++ b/app/src/main/resources/io/xpipe/app/resources/browser_icons/file_list.txt @@ -389,7 +389,7 @@ lime | include.xml | file_type_lime.svg lintstagedrc | .lintstagedrc, .lintstagedrc.json, .lintstagedrc.yaml, .lintstagedrc.yml, .lintstagedrc.mjs, .lintstagedrc.js, .lintstagedrc.cjs, lint-staged.config.mjs, lint-staged.config.js, lint-staged.config.cjs | file_type_lintstagedrc.svg liquid | liquid | file_type_liquid.svg livescript | ls | file_type_livescript.svg -lnk | lnk | file_type_lnk.svg +lnk | url, lnk | file_type_lnk.svg locale | | file_type_locale.svg log | log, tlg | file_type_log.svg log | log, tlg, log | file_type_log.svg @@ -604,7 +604,7 @@ sas | SAS | file_type_sas.svg sass | sass | file_type_sass.svg sbt | sbt | file_type_sbt.svg scala | scala | file_type_scala.svg -script | vbscript | file_type_script.svg +script | vbs, vbscript | file_type_script.svg scss | scssm, scss | file_type_scss.svg scilab | scilab | file_type_scilab.svg sdlang | sdl | file_type_sdlang.svg diff --git a/dist/changelogs/0.5.31.md b/dist/changelogs/0.5.31.md new file mode 100644 index 000000000..7ce1bff91 --- /dev/null +++ b/dist/changelogs/0.5.31.md @@ -0,0 +1,3 @@ +- Add file type icons to file browser +- Add shift-select ability to select range of files to file browser +- Fix some bugs \ No newline at end of file diff --git a/version b/version index 576712369..23811e27b 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.5.30 \ No newline at end of file +0.5.31 \ No newline at end of file