Prevent empty dragboards

This commit is contained in:
crschnick 2023-12-23 20:19:49 +00:00
parent 0eaa928441
commit 07964f4bef
2 changed files with 10 additions and 1 deletions

View file

@ -73,6 +73,10 @@ public class BrowserClipboard {
@SneakyThrows
public static ClipboardContent startDrag(FileSystem.FileEntry base, List<FileSystem.FileEntry> selected) {
if (selected.isEmpty()) {
return null;
}
var content = new ClipboardContent();
var id = UUID.randomUUID();
currentDragClipboard = new Instance(id, base, new ArrayList<>(selected));
@ -82,6 +86,11 @@ public class BrowserClipboard {
@SneakyThrows
public static void startCopy(FileSystem.FileEntry base, List<FileSystem.FileEntry> selected) {
if (selected.isEmpty()) {
currentCopyClipboard.setValue(null);
return;
}
var id = UUID.randomUUID();
currentCopyClipboard.setValue(new Instance(id, base, new ArrayList<>(selected)));
}

View file

@ -293,7 +293,7 @@ public final class OpenFileSystemModel {
var abs = FileNames.join(getCurrentDirectory().getPath(), name);
if (fileSystem.directoryExists(abs)) {
throw new IllegalStateException(String.format("Directory %s already exists", abs));
throw ErrorEvent.unreportable(new IllegalStateException(String.format("Directory %s already exists", abs)));
}
fileSystem.mkdirs(abs);