mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Various fixes
This commit is contained in:
parent
66f6b69cbe
commit
ec20025141
4 changed files with 29 additions and 32 deletions
|
@ -31,9 +31,7 @@ import javafx.scene.Node;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.control.skin.TableViewSkin;
|
import javafx.scene.control.skin.TableViewSkin;
|
||||||
import javafx.scene.control.skin.VirtualFlow;
|
import javafx.scene.control.skin.VirtualFlow;
|
||||||
import javafx.scene.input.DragEvent;
|
import javafx.scene.input.*;
|
||||||
import javafx.scene.input.MouseButton;
|
|
||||||
import javafx.scene.input.MouseEvent;
|
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.Priority;
|
import javafx.scene.layout.Priority;
|
||||||
import javafx.scene.layout.Region;
|
import javafx.scene.layout.Region;
|
||||||
|
@ -79,7 +77,7 @@ public final class BrowserFileListComp extends SimpleComp {
|
||||||
: null));
|
: null));
|
||||||
filenameCol.setComparator(Comparator.comparing(String::toLowerCase));
|
filenameCol.setComparator(Comparator.comparing(String::toLowerCase));
|
||||||
filenameCol.setSortType(ASCENDING);
|
filenameCol.setSortType(ASCENDING);
|
||||||
filenameCol.setCellFactory(col -> new FilenameCell(fileList.getEditing()));
|
filenameCol.setCellFactory(col -> new FilenameCell(fileList.getEditing(), col.getTableView()));
|
||||||
|
|
||||||
var sizeCol = new TableColumn<BrowserEntry, Number>();
|
var sizeCol = new TableColumn<BrowserEntry, Number>();
|
||||||
sizeCol.textProperty().bind(AppI18n.observable("size"));
|
sizeCol.textProperty().bind(AppI18n.observable("size"));
|
||||||
|
@ -170,8 +168,8 @@ public final class BrowserFileListComp extends SimpleComp {
|
||||||
ThreadHelper.runFailableAsync(() -> {
|
ThreadHelper.runFailableAsync(() -> {
|
||||||
browserAction.execute(fileList.getFileSystemModel(), selected);
|
browserAction.execute(fileList.getFileSystemModel(), selected);
|
||||||
});
|
});
|
||||||
|
event.consume();
|
||||||
});
|
});
|
||||||
event.consume();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,12 +316,10 @@ public final class BrowserFileListComp extends SimpleComp {
|
||||||
TableColumn<BrowserEntry, String> modeCol) {
|
TableColumn<BrowserEntry, String> modeCol) {
|
||||||
var lastDir = new SimpleObjectProperty<FileSystem.FileEntry>();
|
var lastDir = new SimpleObjectProperty<FileSystem.FileEntry>();
|
||||||
Runnable updateHandler = () -> {
|
Runnable updateHandler = () -> {
|
||||||
PlatformThread.runLaterIfNeeded(() -> {
|
Platform.runLater(() -> {
|
||||||
var newItems = new ArrayList<>(fileList.getShown().getValue());
|
var newItems = new ArrayList<>(fileList.getShown().getValue());
|
||||||
|
|
||||||
var hasModifiedDate = newItems.size() == 0
|
var hasModifiedDate = newItems.size() == 0 || newItems.stream().anyMatch(entry -> entry.getRawFileEntry().getDate() != null);
|
||||||
|| newItems.stream()
|
|
||||||
.anyMatch(entry -> entry.getRawFileEntry().getDate() != null);
|
|
||||||
if (!hasModifiedDate) {
|
if (!hasModifiedDate) {
|
||||||
table.getColumns().remove(mtimeCol);
|
table.getColumns().remove(mtimeCol);
|
||||||
} else {
|
} else {
|
||||||
|
@ -333,10 +329,7 @@ public final class BrowserFileListComp extends SimpleComp {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileList.getFileSystemModel().getFileSystem() != null) {
|
if (fileList.getFileSystemModel().getFileSystem() != null) {
|
||||||
var shell = fileList.getFileSystemModel()
|
var shell = fileList.getFileSystemModel().getFileSystem().getShell().orElseThrow();
|
||||||
.getFileSystem()
|
|
||||||
.getShell()
|
|
||||||
.orElseThrow();
|
|
||||||
var hasAttributes = !OsType.WINDOWS.equals(shell.getOsType());
|
var hasAttributes = !OsType.WINDOWS.equals(shell.getOsType());
|
||||||
if (!hasAttributes) {
|
if (!hasAttributes) {
|
||||||
table.getColumns().remove(modeCol);
|
table.getColumns().remove(modeCol);
|
||||||
|
@ -358,10 +351,8 @@ public final class BrowserFileListComp extends SimpleComp {
|
||||||
if (!Objects.equals(lastDir.get(), currentDirectory)) {
|
if (!Objects.equals(lastDir.get(), currentDirectory)) {
|
||||||
TableViewSkin<?> skin = (TableViewSkin<?>) table.getSkin();
|
TableViewSkin<?> skin = (TableViewSkin<?>) table.getSkin();
|
||||||
if (skin != null) {
|
if (skin != null) {
|
||||||
VirtualFlow<?> flow =
|
VirtualFlow<?> flow = (VirtualFlow<?>) skin.getChildren().get(1);
|
||||||
(VirtualFlow<?>) skin.getChildren().get(1);
|
ScrollBar vbar = (ScrollBar) flow.getChildrenUnmodifiable().get(2);
|
||||||
ScrollBar vbar =
|
|
||||||
(ScrollBar) flow.getChildrenUnmodifiable().get(2);
|
|
||||||
if (vbar.getValue() != 0.0) {
|
if (vbar.getValue() != 0.0) {
|
||||||
table.scrollTo(0);
|
table.scrollTo(0);
|
||||||
}
|
}
|
||||||
|
@ -466,7 +457,7 @@ public final class BrowserFileListComp extends SimpleComp {
|
||||||
|
|
||||||
private final BooleanProperty updating = new SimpleBooleanProperty();
|
private final BooleanProperty updating = new SimpleBooleanProperty();
|
||||||
|
|
||||||
public FilenameCell(Property<BrowserEntry> editing) {
|
public FilenameCell(Property<BrowserEntry> editing, TableView<BrowserEntry> tableView) {
|
||||||
accessibleTextProperty()
|
accessibleTextProperty()
|
||||||
.bind(Bindings.createStringBinding(
|
.bind(Bindings.createStringBinding(
|
||||||
() -> {
|
() -> {
|
||||||
|
@ -496,6 +487,10 @@ public final class BrowserFileListComp extends SimpleComp {
|
||||||
itemProperty())
|
itemProperty())
|
||||||
.not()
|
.not()
|
||||||
.not())
|
.not())
|
||||||
|
.focusTraversable(false)
|
||||||
|
.apply(struc -> struc.get().focusedProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
|
getTableRow().requestFocus();
|
||||||
|
}))
|
||||||
.createRegion();
|
.createRegion();
|
||||||
|
|
||||||
editing.addListener((observable, oldValue, newValue) -> {
|
editing.addListener((observable, oldValue, newValue) -> {
|
||||||
|
@ -524,6 +519,16 @@ public final class BrowserFileListComp extends SimpleComp {
|
||||||
HBox.setHgrow(textField, Priority.ALWAYS);
|
HBox.setHgrow(textField, Priority.ALWAYS);
|
||||||
graphic.setAlignment(Pos.CENTER_LEFT);
|
graphic.setAlignment(Pos.CENTER_LEFT);
|
||||||
setGraphic(graphic);
|
setGraphic(graphic);
|
||||||
|
|
||||||
|
tableView.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
|
||||||
|
if (event.getCode() == KeyCode.RIGHT) {
|
||||||
|
var selected = fileList.getSelection();
|
||||||
|
if (selected.size() == 1 && selected.getFirst() == getTableRow().getItem()) {
|
||||||
|
((ButtonBase) quickAccess).fire();
|
||||||
|
event.consume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -42,11 +42,13 @@ public class BrowserFileListCompEntry {
|
||||||
// Only clear for normal clicks
|
// Only clear for normal clicks
|
||||||
if (t.isStillSincePress()) {
|
if (t.isStillSincePress()) {
|
||||||
model.getSelection().clear();
|
model.getSelection().clear();
|
||||||
|
tv.requestFocus();
|
||||||
}
|
}
|
||||||
t.consume();
|
t.consume();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
row.requestFocus();
|
||||||
if (t.getClickCount() == 2 && t.getButton() == MouseButton.PRIMARY) {
|
if (t.getClickCount() == 2 && t.getButton() == MouseButton.PRIMARY) {
|
||||||
model.onDoubleClick(item);
|
model.onDoubleClick(item);
|
||||||
t.consume();
|
t.consume();
|
||||||
|
@ -56,7 +58,7 @@ public class BrowserFileListCompEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onMouseShiftClick(MouseEvent t) {
|
public void onMouseShiftClick(MouseEvent t) {
|
||||||
if (isSynthetic()) {
|
if (t.getButton() != MouseButton.PRIMARY) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,11 +87,6 @@ public class BrowserFileListCompEntry {
|
||||||
t.consume();
|
t.consume();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSynthetic() {
|
|
||||||
return item != null
|
|
||||||
&& item.getRawFileEntry().equals(model.getFileSystemModel().getCurrentParentDirectory());
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean acceptsDrop(DragEvent event) {
|
private boolean acceptsDrop(DragEvent event) {
|
||||||
// Accept drops from outside the app window
|
// Accept drops from outside the app window
|
||||||
if (event.getGestureSource() == null) {
|
if (event.getGestureSource() == null) {
|
||||||
|
@ -121,7 +118,7 @@ public class BrowserFileListCompEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent dropping items onto themselves
|
// Prevent dropping items onto themselves
|
||||||
if (item != null && cb.getEntries().contains(item.getRawFileEntry())) {
|
if (item != null && cb.getEntries().contains(item)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,11 +169,10 @@ public class BrowserFileListCompEntry {
|
||||||
|
|
||||||
public void startDrag(MouseEvent event) {
|
public void startDrag(MouseEvent event) {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
row.startFullDrag();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSynthetic()) {
|
if (event.getButton() != MouseButton.PRIMARY) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +218,7 @@ public class BrowserFileListCompEntry {
|
||||||
model.getFileSystemModel().cdAsync(item.getRawFileEntry().getPath());
|
model.getFileSystemModel().cdAsync(item.getRawFileEntry().getPath());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
DROP_TIMER.schedule(activeTask, 1000);
|
DROP_TIMER.schedule(activeTask, 1200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDragEntered(DragEvent event) {
|
public void onDragEntered(DragEvent event) {
|
||||||
|
|
|
@ -120,7 +120,6 @@ public abstract class DataStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void dispose() {
|
private synchronized void dispose() {
|
||||||
onReset();
|
|
||||||
save(true);
|
save(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,8 +182,6 @@ public abstract class DataStorage {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onReset() {}
|
|
||||||
|
|
||||||
protected Path getStoresDir() {
|
protected Path getStoresDir() {
|
||||||
return dir.resolve("stores");
|
return dir.resolve("stores");
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,6 @@ project.ext {
|
||||||
authors = 'Christopher Schnick'
|
authors = 'Christopher Schnick'
|
||||||
javafxVersion = '22.0.1'
|
javafxVersion = '22.0.1'
|
||||||
platformName = getPlatformName()
|
platformName = getPlatformName()
|
||||||
artifactChecksums = new HashMap<String, String>()
|
|
||||||
languages = ["en", "nl", "es", "fr", "de", "it", "pt", "ru", "ja", "zh", "tr", "da"]
|
languages = ["en", "nl", "es", "fr", "de", "it", "pt", "ru", "ja", "zh", "tr", "da"]
|
||||||
jvmRunArgs = [
|
jvmRunArgs = [
|
||||||
"--add-opens", "java.base/java.lang=io.xpipe.app",
|
"--add-opens", "java.base/java.lang=io.xpipe.app",
|
||||||
|
|
Loading…
Reference in a new issue