mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 00:50:31 +00:00
Add chmod browser action
This commit is contained in:
parent
d9e496f1cb
commit
fb70b6766b
4 changed files with 65 additions and 2 deletions
|
@ -5,6 +5,7 @@ import lombok.SneakyThrows;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.SequencedCollection;
|
||||
|
||||
public class CommandBuilder {
|
||||
|
||||
|
@ -121,6 +122,11 @@ public class CommandBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
public CommandBuilder addFiles(SequencedCollection<String> s) {
|
||||
s.forEach(this::addFile);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String build(ShellControl sc) throws Exception {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (Element element : elements) {
|
||||
|
|
2
dist/changelogs/1.7.9.md
vendored
2
dist/changelogs/1.7.9.md
vendored
|
@ -1,5 +1,3 @@
|
|||
## Changes in 1.7.9
|
||||
|
||||
### Git storage rework
|
||||
|
||||
The git storage functionality has been in a bad state, hopefully this update will change that.
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package io.xpipe.ext.base.browser;
|
||||
|
||||
import io.xpipe.app.browser.BrowserEntry;
|
||||
import io.xpipe.app.browser.OpenFileSystemModel;
|
||||
import io.xpipe.app.browser.action.BranchAction;
|
||||
import io.xpipe.app.browser.action.LeafAction;
|
||||
import io.xpipe.core.process.CommandBuilder;
|
||||
import io.xpipe.core.process.OsType;
|
||||
import javafx.scene.Node;
|
||||
import org.kordamp.ikonli.javafx.FontIcon;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ChmodAction implements BranchAction {
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||
return model.getFileSystem().getShell().orElseThrow().getOsType() != OsType.WINDOWS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategory() {
|
||||
return Category.MUTATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node getIcon(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||
return new FontIcon("mdi2w-wrench");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||
return "Chmod";
|
||||
}
|
||||
|
||||
private static class Chmod implements LeafAction {
|
||||
|
||||
private final String option;
|
||||
|
||||
private Chmod(String option) {this.option = option;}
|
||||
|
||||
@Override
|
||||
public String getName(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||
return option;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
|
||||
model.getFileSystem().getShell().orElseThrow().executeSimpleCommand(CommandBuilder.of().add("chmod", option)
|
||||
.addFiles(entries.stream().map(browserEntry -> browserEntry.getRawFileEntry().getPath()).toList()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LeafAction> getBranchingActions(OpenFileSystemModel model, List<BrowserEntry> entries) {
|
||||
return List.of(new Chmod("600"), new Chmod("644"), new Chmod("700"), new Chmod("777"), new Chmod("u+x"), new Chmod("a+x"));
|
||||
}
|
||||
}
|
|
@ -39,6 +39,7 @@ open module io.xpipe.ext.base {
|
|||
BrowseInNativeManagerAction,
|
||||
EditFileAction,
|
||||
RunAction,
|
||||
ChmodAction,
|
||||
CopyAction,
|
||||
CopyPathAction,
|
||||
PasteAction,
|
||||
|
|
Loading…
Reference in a new issue