This commit is contained in:
crschnick
2024-08-24 12:42:06 +00:00
parent d6cb3bf2bd
commit 27e6fc10e0
40 changed files with 284 additions and 177 deletions
@@ -7,9 +7,11 @@ import io.xpipe.app.browser.fs.OpenFileSystemModel;
import io.xpipe.app.core.AppI18n;
import io.xpipe.core.process.CommandBuilder;
import io.xpipe.core.process.OsType;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import javafx.scene.Node;
import org.kordamp.ikonli.javafx.FontIcon;
import java.util.List;
@@ -40,8 +42,13 @@ public class ChgrpAction implements BranchAction {
@Override
public List<LeafAction> getBranchingActions(OpenFileSystemModel model, List<BrowserEntry> entries) {
return model.getCache().getGroups().entrySet().stream()
.filter(e -> !e.getValue().equals("nohome") && !e.getValue().equals("nogroup") && !e.getValue().equals("nobody") && (e.getKey().equals(0) || e.getKey() >= 1000))
.map(e -> e.getValue()).map(s -> (LeafAction) new Chgrp(s)).toList();
.filter(e -> !e.getValue().equals("nohome")
&& !e.getValue().equals("nogroup")
&& !e.getValue().equals("nobody")
&& (e.getKey().equals(0) || e.getKey() >= 1000))
.map(e -> e.getValue())
.map(s -> (LeafAction) new Chgrp(s))
.toList();
}
private static class Chgrp implements LeafAction {
@@ -7,9 +7,11 @@ import io.xpipe.app.browser.fs.OpenFileSystemModel;
import io.xpipe.app.core.AppI18n;
import io.xpipe.core.process.CommandBuilder;
import io.xpipe.core.process.OsType;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import javafx.scene.Node;
import org.kordamp.ikonli.javafx.FontIcon;
import java.util.List;
@@ -40,8 +42,12 @@ public class ChownAction implements BranchAction {
@Override
public List<LeafAction> getBranchingActions(OpenFileSystemModel model, List<BrowserEntry> entries) {
return model.getCache().getUsers().entrySet().stream()
.filter(e -> !e.getValue().equals("nohome") && !e.getValue().equals("nobody") && (e.getKey().equals(0) || e.getKey() >= 1000))
.map(e -> e.getValue()).map(s -> (LeafAction) new Chown(s)).toList();
.filter(e -> !e.getValue().equals("nohome")
&& !e.getValue().equals("nobody")
&& (e.getKey().equals(0) || e.getKey() >= 1000))
.map(e -> e.getValue())
.map(s -> (LeafAction) new Chown(s))
.toList();
}
private static class Chown implements LeafAction {
@@ -4,8 +4,8 @@ import io.xpipe.app.browser.action.BrowserActionFormatter;
import io.xpipe.app.browser.file.BrowserEntry;
import io.xpipe.app.browser.fs.OpenFileSystemModel;
import io.xpipe.app.browser.icon.BrowserIconFileType;
import io.xpipe.core.store.FileNames;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
@@ -35,6 +35,7 @@ public class JavapAction extends ToFileCommandAction implements FileTypeAction,
@Override
protected String createCommand(OpenFileSystemModel model, BrowserEntry entry) {
return "javap -c -p " + FileNames.quoteIfNecessary(entry.getRawFileEntry().getPath());
return "javap -c -p "
+ FileNames.quoteIfNecessary(entry.getRawFileEntry().getPath());
}
}
@@ -71,7 +71,8 @@ public abstract class MultiExecuteSelectionAction implements BranchAction {
long exitCode;
try (var command = pc.command(cmd)
.withWorkingDirectory(
model.getCurrentDirectory().getPath()).start()) {
model.getCurrentDirectory().getPath())
.start()) {
var r = command.readStdoutAndStderr();
out.set(r[0]);
err.set(r[1]);
@@ -79,7 +80,8 @@ public abstract class MultiExecuteSelectionAction implements BranchAction {
}
// Only throw actual error output
if (exitCode != 0) {
throw ErrorEvent.expected(ProcessOutputException.of(exitCode, out.get(), err.get()));
throw ErrorEvent.expected(
ProcessOutputException.of(exitCode, out.get(), err.get()));
}
},
false);
@@ -10,10 +10,12 @@ import io.xpipe.app.fxcomps.impl.DataStoreChoiceComp;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.util.OptionsBuilder;
import io.xpipe.core.store.DataStore;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import lombok.SneakyThrows;
import java.util.List;
@@ -35,20 +35,22 @@ public abstract class AbstractServiceGroupStoreProvider implements DataStoreProv
}
private StoreToggleComp createToggleComp(StoreSection sec) {
var t = StoreToggleComp.<AbstractServiceGroupStore<?>>enableToggle(null, sec, new SimpleBooleanProperty(false), (g, aBoolean) -> {
var children = DataStorage.get().getStoreChildren(sec.getWrapper().getEntry());
ThreadHelper.runFailableAsync(() -> {
for (DataStoreEntry child : children) {
if (child.getStore() instanceof AbstractServiceStore serviceStore) {
if (aBoolean) {
serviceStore.startSessionIfNeeded();
} else {
serviceStore.stopSessionIfNeeded();
var t = StoreToggleComp.<AbstractServiceGroupStore<?>>enableToggle(
null, sec, new SimpleBooleanProperty(false), (g, aBoolean) -> {
var children =
DataStorage.get().getStoreChildren(sec.getWrapper().getEntry());
ThreadHelper.runFailableAsync(() -> {
for (DataStoreEntry child : children) {
if (child.getStore() instanceof AbstractServiceStore serviceStore) {
if (aBoolean) {
serviceStore.startSessionIfNeeded();
} else {
serviceStore.stopSessionIfNeeded();
}
}
}
}
}
});
});
});
});
t.setCustomVisibility(Bindings.createBooleanBinding(
() -> {
var children =