mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 07:30:24 +00:00
Fix link issues when deleting
This commit is contained in:
parent
322acbe39c
commit
5414b55361
2 changed files with 47 additions and 0 deletions
|
@ -0,0 +1,46 @@
|
|||
package io.xpipe.ext.base.browser;
|
||||
|
||||
import io.xpipe.app.browser.BrowserEntry;
|
||||
import io.xpipe.app.browser.FileSystemHelper;
|
||||
import io.xpipe.app.browser.OpenFileSystemModel;
|
||||
import io.xpipe.app.browser.action.LeafAction;
|
||||
import io.xpipe.core.store.FileKind;
|
||||
import javafx.scene.Node;
|
||||
import org.kordamp.ikonli.javafx.FontIcon;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DeleteLinkAction implements LeafAction {
|
||||
|
||||
@Override
|
||||
public boolean automaticallyResolveLinks() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||
return entries.stream().allMatch(browserEntry -> browserEntry.getRawFileEntry().getKind() == FileKind.LINK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
|
||||
var toDelete = entries.stream().map(entry -> entry.getRawFileEntry()).toList();
|
||||
FileSystemHelper.delete(toDelete);
|
||||
model.refreshSync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||
return new FontIcon("mdi2d-delete");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory() {
|
||||
return Category.MUTATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||
return "Delete link";
|
||||
}
|
||||
}
|
|
@ -47,6 +47,7 @@ open module io.xpipe.ext.base {
|
|||
NewItemAction,
|
||||
RenameAction,
|
||||
DeleteAction,
|
||||
DeleteLinkAction,
|
||||
UnzipAction,
|
||||
JavapAction,
|
||||
JarAction;
|
||||
|
|
Loading…
Reference in a new issue