Refactor and cleanup

This commit is contained in:
crschnick
2025-01-06 06:36:55 +00:00
parent 80b9dbf4d9
commit b4543c9bb6
71 changed files with 156 additions and 165 deletions
@@ -193,7 +193,7 @@ public class BeaconRequestHandler<T> implements HttpHandler {
&& method.getParameters()[0].getType().equals(byte[].class))
.findFirst()
.orElseThrow();
setMethod.invoke(b, s);
setMethod.invoke(b, (Object) s);
var m = b.getClass().getDeclaredMethod("build");
m.setAccessible(true);
@@ -4,7 +4,6 @@ import io.xpipe.app.browser.action.BrowserAction;
import io.xpipe.app.comp.SimpleComp;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.util.*;
import io.xpipe.app.util.PlatformThread;
import io.xpipe.core.process.OsType;
import io.xpipe.core.store.FileEntry;
import io.xpipe.core.store.FileInfo;
@@ -585,11 +585,11 @@ public final class BrowserFileSystemTabModel extends BrowserStoreSessionTab<File
});
}
public void backSync(int i) throws Exception {
public void backSync(int i) {
cdSync(history.back(i));
}
public void forthSync(int i) throws Exception {
public void forthSync(int i) {
cdSync(history.forth(i));
}
@@ -26,7 +26,7 @@ public final class BrowserHistoryTabModel extends BrowserSessionTab {
}
@Override
public void init() throws Exception {}
public void init() {}
@Override
public void close() {}
@@ -7,8 +7,8 @@ import io.xpipe.app.core.AppFont;
import io.xpipe.app.core.AppLayoutModel;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.util.PlatformThread;
import javafx.beans.binding.Bindings;
import javafx.beans.value.ObservableValue;
import javafx.scene.Node;
@@ -73,7 +73,8 @@ public class AppLayoutComp extends Comp<AppLayoutComp.Structure> {
return new Structure(pane, multiR, sidebarR, new ArrayList<>(multiR.getChildren()));
}
public static record Structure(BorderPane pane, StackPane stack, Region sidebar, List<Node> children) implements CompStructure<BorderPane> {
public record Structure(BorderPane pane, StackPane stack, Region sidebar, List<Node> children)
implements CompStructure<BorderPane> {
public void prepareAddition() {
stack.getChildren().clear();
@@ -19,12 +19,9 @@ import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.util.Duration;
import atlantafx.base.util.Animations;
import java.time.Instant;
public class AppMainWindowContentComp extends SimpleComp {
private final Stage stage;
@@ -42,7 +42,8 @@ public class MarkdownComp extends Comp<CompStructure<StackPane>> {
this.bodyPadding = bodyPadding;
}
public MarkdownComp(ObservableValue<String> markdown, UnaryOperator<String> htmlTransformation, boolean bodyPadding) {
public MarkdownComp(
ObservableValue<String> markdown, UnaryOperator<String> htmlTransformation, boolean bodyPadding) {
this.markdown = markdown;
this.htmlTransformation = htmlTransformation;
this.bodyPadding = bodyPadding;
@@ -137,8 +137,7 @@ public abstract class StoreEntryComp extends SimpleComp {
.augment(button);
var loading = LoadingOverlayComp.noProgress(
Comp.of(() -> button),
getWrapper().getEffectiveBusy());
Comp.of(() -> button), getWrapper().getEffectiveBusy());
AppFont.normal(button);
return loading.createRegion();
}
@@ -14,9 +14,7 @@ import io.xpipe.core.store.DataStore;
import io.xpipe.core.store.SingletonSessionStore;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.BooleanBinding;
import javafx.beans.property.*;
import javafx.beans.value.ObservableBooleanValue;
import javafx.beans.value.ObservableStringValue;
import javafx.collections.FXCollections;
@@ -15,7 +15,6 @@ import javafx.application.Platform;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleStringProperty;
import javafx.event.ActionEvent;
import javafx.geometry.Insets;
import javafx.scene.control.Button;
import javafx.scene.paint.Color;
@@ -107,7 +107,7 @@ public class AppArguments {
}
@Override
public Integer call() throws Exception {
public Integer call() {
return 0;
}
}
@@ -8,7 +8,6 @@ import javafx.scene.Node;
import javafx.scene.text.Font;
import org.kordamp.ikonli.javafx.FontIcon;
import org.kordamp.ikonli.javafx.IkonResolver;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
@@ -39,7 +39,7 @@ public class AppLayoutModel {
public AppLayoutModel(SavedState savedState) {
this.savedState = savedState;
this.entries = createEntryList();
this.selected = new SimpleObjectProperty<>(entries.get(0));
this.selected = new SimpleObjectProperty<>(entries.getFirst());
}
public static AppLayoutModel get() {
@@ -73,7 +73,7 @@ public class AppLayoutModel {
}
public void selectConnections() {
selected.setValue(entries.get(0));
selected.setValue(entries.getFirst());
}
private List<Entry> createEntryList() {
@@ -28,7 +28,7 @@ public class AppAvCheck {
return Optional.empty();
}
public static void check() throws Throwable {
public static void check() {
// Only show this on first launch on windows
if (OsType.getLocal() != OsType.WINDOWS || !AppProperties.get().isInitialLaunch()) {
return;
@@ -42,16 +42,19 @@ public class AppAvCheck {
var modal = ModalOverlay.of(Comp.of(() -> {
AtomicReference<Region> markdown = new AtomicReference<>();
AppResources.with(AppResources.XPIPE_MODULE, "misc/antivirus.md", file -> {
markdown.set(new MarkdownComp(Files.readString(file), s -> {
var t = found.get();
return s.formatted(
t.getName(),
t.getName(),
t.getDescription(),
AppProperties.get().getVersion(),
AppProperties.get().getVersion(),
t.getName());
}, false)
markdown.set(new MarkdownComp(
Files.readString(file),
s -> {
var t = found.get();
return s.formatted(
t.getName(),
t.getName(),
t.getDescription(),
AppProperties.get().getVersion(),
AppProperties.get().getVersion(),
t.getName());
},
false)
.prefWidth(550)
.prefHeight(600)
.createRegion());
@@ -6,8 +6,6 @@ import io.xpipe.app.util.LocalShell;
import io.xpipe.app.util.ScriptHelper;
import io.xpipe.core.process.ProcessOutputException;
import io.xpipe.core.process.ShellDialect;
import io.xpipe.core.process.ShellDialects;
import lombok.Value;
import java.util.Optional;
@@ -88,7 +86,8 @@ public abstract class AppShellChecker {
var scriptFile = ScriptHelper.getExecScriptFile(sc);
var scriptContent = sc.getShellDialect().prepareScriptContent("echo test");
sc.view().writeScriptFile(scriptFile, scriptContent);
var out = sc.command(sc.getShellDialect().runScriptCommand(sc, scriptFile.toString())).readStdoutOrThrow();
var out = sc.command(sc.getShellDialect().runScriptCommand(sc, scriptFile.toString()))
.readStdoutOrThrow();
if (!out.equals("test")) {
return Optional.of(new FailureResult(
"Expected output \"test\", got output \"" + out + "\" when running test script", true));
@@ -1,6 +1,5 @@
package io.xpipe.app.core.mode;
import io.xpipe.app.core.*;
import io.xpipe.app.util.PlatformInit;
public abstract class PlatformMode extends OperationMode {
@@ -25,7 +25,6 @@ import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.Region;
import javafx.scene.paint.Color;
import javafx.stage.Screen;
import javafx.stage.Stage;
@@ -18,5 +18,5 @@ public enum DataStoreUsageCategory {
@JsonProperty("serial")
SERIAL,
@JsonProperty("identity")
IDENTITY;
IDENTITY
}
@@ -23,7 +23,7 @@ public class LocalStore implements NetworkTunnelStore, ShellStore, StatefulDataS
public ShellControlFunction shellFunction() {
return new ShellControlFunction() {
@Override
public ShellControl control() throws Exception {
public ShellControl control() {
var pc = ProcessControlProvider.get().createLocalProcessControl(true);
pc.withSourceStore(LocalStore.this);
pc.withShellStateInit(LocalStore.this);
@@ -39,7 +39,7 @@ public class LocalStore implements NetworkTunnelStore, ShellStore, StatefulDataS
}
@Override
public NetworkTunnelSession createTunnelSession(int localPort, int remotePort, String address) throws Exception {
public NetworkTunnelSession createTunnelSession(int localPort, int remotePort, String address) {
throw new UnsupportedOperationException();
}
}
@@ -2,5 +2,5 @@ package io.xpipe.app.ext;
public interface UserScopeStore {
public boolean isPerUser();
boolean isPerUser();
}
@@ -52,13 +52,17 @@ public class PasswordManagerCategory extends AppPrefsCategory {
choices.add(new Choice(
externalPasswordManagerTemplate.getId(),
externalPasswordManagerTemplate.getTemplate(),
externalPasswordManagerTemplate.getDocsLink(),
externalPasswordManagerTemplate.getDocsLink(),
ExternalPasswordManager.COMMAND));
});
ExternalPasswordManager.ALL.stream()
.filter(externalPasswordManager -> externalPasswordManager != ExternalPasswordManager.COMMAND)
.forEach(externalPasswordManager -> {
choices.add(new Choice(externalPasswordManager.getId(), null, externalPasswordManager.getDocsLink(), externalPasswordManager));
choices.add(new Choice(
externalPasswordManager.getId(),
null,
externalPasswordManager.getDocsLink(),
externalPasswordManager));
});
var prefs = AppPrefs.get();
@@ -84,12 +88,13 @@ public class PasswordManagerCategory extends AppPrefsCategory {
};
var docsLinkProperty = new SimpleStringProperty();
var docsLinkButton = new ButtonComp(AppI18n.observable("documentation"), new FontIcon("mdi2h-help-circle-outline"), () -> {
var l = docsLinkProperty.get();
if (l != null) {
Hyperlinks.open(l);
}
});
var docsLinkButton =
new ButtonComp(AppI18n.observable("documentation"), new FontIcon("mdi2h-help-circle-outline"), () -> {
var l = docsLinkProperty.get();
if (l != null) {
Hyperlinks.open(l);
}
});
docsLinkButton.disable(docsLinkProperty.isNull());
var command = new IntegratedTextAreaComp(
@@ -16,7 +16,7 @@ import java.util.Locale;
@Getter
public class SupportedLocale implements PrefsChoiceValue {
public static List<SupportedLocale> ALL = AppProperties.get().getLanguages().stream()
public static final List<SupportedLocale> ALL = AppProperties.get().getLanguages().stream()
.map(s -> {
var split = s.split("-");
var loc = split.length == 2 ? Locale.of(split[0], split[1]) : Locale.of(s);
@@ -21,7 +21,7 @@ public class WorkspaceCreationAlert {
});
}
private static void show() throws Exception {
private static void show() {
var name = new SimpleObjectProperty<>("New workspace");
var path = new SimpleObjectProperty<>(AppProperties.get().getDataDir());
var content = new OptionsBuilder()
@@ -177,8 +177,8 @@ public abstract class DataStorage {
}
if (getStoreCategoryIfPresent(PREDEFINED_SCRIPTS_CATEGORY_UUID).isEmpty()) {
var cat = DataStoreCategory.createNew(
ALL_SCRIPTS_CATEGORY_UUID, PREDEFINED_SCRIPTS_CATEGORY_UUID, "Samples");
var cat =
DataStoreCategory.createNew(ALL_SCRIPTS_CATEGORY_UUID, PREDEFINED_SCRIPTS_CATEGORY_UUID, "Samples");
cat.setDirectory(categoriesDir.resolve(PREDEFINED_SCRIPTS_CATEGORY_UUID.toString()));
storeCategories.add(cat);
}
@@ -296,7 +296,7 @@ public abstract class DataStorage {
&& storeCategories.stream()
.filter(dataStoreCategory ->
!dataStoreCategory.getUuid().equals(SYNCED_IDENTITIES_CATEGORY_UUID))
.allMatch(dataStoreCategory -> !shouldSync(dataStoreCategory))) {
.noneMatch(dataStoreCategory -> shouldSync(dataStoreCategory))) {
return false;
}
@@ -454,10 +454,9 @@ public abstract class DataStorage {
e.incrementBusyCounter();
List<? extends DataStoreEntryRef<? extends FixedChildStore>> newChildren;
try {
newChildren = ((FixedHierarchyStore) h)
.listChildren().stream()
.filter(dataStoreEntryRef -> dataStoreEntryRef != null && dataStoreEntryRef.get() != null)
.toList();
newChildren = h.listChildren().stream()
.filter(dataStoreEntryRef -> dataStoreEntryRef != null && dataStoreEntryRef.get() != null)
.toList();
} catch (Exception ex) {
if (throwOnFail) {
throw ex;
@@ -766,9 +765,11 @@ public abstract class DataStorage {
return false;
}
if (cat.getUuid().equals(DEFAULT_CATEGORY_UUID) || cat.getUuid().equals(PREDEFINED_SCRIPTS_CATEGORY_UUID) || cat.getUuid().equals(
LOCAL_IDENTITIES_CATEGORY_UUID) || cat.getUuid().equals(CUSTOM_SCRIPTS_CATEGORY_UUID) || cat.getUuid().equals(
SYNCED_IDENTITIES_CATEGORY_UUID)) {
if (cat.getUuid().equals(DEFAULT_CATEGORY_UUID)
|| cat.getUuid().equals(PREDEFINED_SCRIPTS_CATEGORY_UUID)
|| cat.getUuid().equals(LOCAL_IDENTITIES_CATEGORY_UUID)
|| cat.getUuid().equals(CUSTOM_SCRIPTS_CATEGORY_UUID)
|| cat.getUuid().equals(SYNCED_IDENTITIES_CATEGORY_UUID)) {
return false;
}
@@ -20,7 +20,7 @@ public interface DataStorageUserHandler {
SecretKey getEncryptionKey();
public Comp<?> createOverview();
Comp<?> createOverview();
String getActiveUser();
}
@@ -46,7 +46,7 @@ public class DataStoreEntryRef<T extends DataStore> {
}
@SuppressWarnings("unchecked")
public <T extends DataStore> DataStoreEntryRef<T> asNeeded() {
return (DataStoreEntryRef<T>) this;
public <S extends DataStore> DataStoreEntryRef<S> asNeeded() {
return (DataStoreEntryRef<S>) this;
}
}
@@ -47,5 +47,4 @@ public class GnomeTerminalType extends ExternalTerminalType.PathCheckType implem
pc.executeSimpleCommand(toExecute);
}
}
}
@@ -7,12 +7,12 @@ import java.nio.file.Path;
public interface TerminalLaunchResult {
@Value
public static class ResultSuccess implements TerminalLaunchResult {
class ResultSuccess implements TerminalLaunchResult {
Path targetScript;
}
@Value
public static class ResultFailure implements TerminalLaunchResult {
class ResultFailure implements TerminalLaunchResult {
Throwable throwable;
}
}
@@ -34,8 +34,7 @@ public class TerminalLauncherManager {
}
public static CountDownLatch submitAsync(
UUID request, ProcessControl processControl, TerminalInitScriptConfig config, String directory)
throws BeaconClientException {
UUID request, ProcessControl processControl, TerminalInitScriptConfig config, String directory) {
synchronized (entries) {
var req = entries.get(request);
if (req == null) {
@@ -3,5 +3,5 @@ package io.xpipe.app.terminal;
public enum TerminalOpenFormat {
NEW_WINDOW,
TABBED,
NEW_WINDOW_OR_TABBED;
NEW_WINDOW_OR_TABBED
}
@@ -47,19 +47,15 @@ public class TerminalView {
}
}
public static interface Listener {
public interface Listener {
default void onSessionOpened(ShellSession session) {}
;
default void onSessionClosed(ShellSession session) {}
;
default void onTerminalOpened(TerminalSession instance) {}
;
default void onTerminalClosed(TerminalSession instance) {}
;
}
private final List<ShellSession> sessions = new ArrayList<>();
@@ -2,7 +2,7 @@ package io.xpipe.app.terminal;
public interface TrackableTerminalType {
public default int getProcessHierarchyOffset() {
default int getProcessHierarchyOffset() {
return 0;
}
}
@@ -26,9 +26,9 @@ public interface WindowsTerminalType extends ExternalTerminalType, TrackableTerm
ExternalTerminalType WINDOWS_TERMINAL_PREVIEW = new Preview();
ExternalTerminalType WINDOWS_TERMINAL_CANARY = new Canary();
static AtomicInteger windowCounter = new AtomicInteger(2);
AtomicInteger windowCounter = new AtomicInteger(2);
private static CommandBuilder toCommand(TerminalLaunchConfiguration configuration) throws Exception {
private static CommandBuilder toCommand(TerminalLaunchConfiguration configuration) {
var cmd = CommandBuilder.of()
.addIf(configuration.isPreferTabs(), "-w", "1", "nt")
.addIf(!configuration.isPreferTabs(), "-w", "" + windowCounter.getAndIncrement());
@@ -87,7 +87,7 @@ public class AppJacksonModule extends SimpleModule {
// Preserve same output if not changed
if (value.getOriginalNode() != null && !value.requiresRewrite()) {
tree.set("secret", (JsonNode) value.getOriginalNode());
tree.set("secret", value.getOriginalNode());
jgen.writeTree(tree);
return;
}
@@ -35,7 +35,7 @@ public class FileReference {
return new FileReference(DataStorage.get().local().ref(), p);
}
public final boolean isLocal() {
public boolean isLocal() {
return fileSystem.getStore() instanceof LocalStore;
}
}
@@ -12,11 +12,11 @@ public interface LicensedFeature {
ObservableValue<String> suffixObservable(ObservableValue<String> s);
public default ObservableValue<String> suffixObservable(String key) {
default ObservableValue<String> suffixObservable(String key) {
return suffixObservable(AppI18n.observable(key));
}
public default String suffix(String s) {
default String suffix(String s) {
return getDescriptionSuffix().map(suffix -> s + " (" + suffix + "+)").orElse(s);
}
@@ -3,7 +3,6 @@ package io.xpipe.app.util;
import io.xpipe.app.core.check.AppSystemFontCheck;
import io.xpipe.app.core.window.ModifiedStage;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.core.process.OsType;
@@ -15,7 +14,6 @@ import lombok.Setter;
import org.apache.commons.lang3.SystemUtils;
import java.awt.*;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
public enum PlatformState {
@@ -71,7 +71,7 @@ public class RdpConfig {
}
public RdpConfig withRemoved(String key) {
var map = new LinkedHashMap<String, TypedValue>(content);
var map = new LinkedHashMap<>(content);
map.remove(key);
return new RdpConfig(map);
}
@@ -37,8 +37,12 @@ public class SecretRetrievalStrategyHelper {
var changed = !Arrays.equals(
newSecret != null ? newSecret.getSecret() : new char[0],
original != null ? original.getSecret() : new char[0]);
var val = changed ? (allowUserSecretKey ? DataStorageSecret.ofCurrentSecret(secretProperty.getValue()) :
DataStorageSecret.ofSecret(secretProperty.getValue(), EncryptionToken.ofVaultKey())) : original;
var val = changed
? (allowUserSecretKey
? DataStorageSecret.ofCurrentSecret(secretProperty.getValue())
: DataStorageSecret.ofSecret(
secretProperty.getValue(), EncryptionToken.ofVaultKey()))
: original;
return new SecretRetrievalStrategy.InPlace(val);
},
p);
@@ -86,7 +90,8 @@ public class SecretRetrievalStrategyHelper {
p);
}
public static OptionsBuilder comp(Property<SecretRetrievalStrategy> s, boolean allowNone, boolean allowUserSecretKey) {
public static OptionsBuilder comp(
Property<SecretRetrievalStrategy> s, boolean allowNone, boolean allowUserSecretKey) {
SecretRetrievalStrategy strat = s.getValue();
var inPlace = new SimpleObjectProperty<>(strat instanceof SecretRetrievalStrategy.InPlace i ? i : null);
var passwordManager =
@@ -28,7 +28,7 @@ public class ShellStoreFormat {
var def = Boolean.TRUE.equals(s.getSetDefault()) ? AppI18n.get("default") : null;
var name = DataStoreFormatter.join(
(includeOsName ? formattedOsName(s.getOsName()) : null), s.getShellName());
return new ShellStoreFormat(null, name, new String[] {def}).format();
return new ShellStoreFormat(null, name, def).format();
},
AppPrefs.get().language(),
section.getWrapper().getPersistentState());
@@ -46,28 +46,27 @@ public class ShellStoreFormat {
return new ShellStoreFormat(
LicenseProvider.get().checkOsName(s.getOsName()),
formattedOsName(s.getOsName()),
new String[] {info})
info)
.format();
}
if (s.getShellDialect().equals(ShellDialects.NO_INTERACTION)) {
return new ShellStoreFormat(null, null, new String[] {info}).format();
return new ShellStoreFormat(null, null, info).format();
}
return new ShellStoreFormat(
LicenseProvider.get()
.getFeature(s.getShellDialect().getLicenseFeatureId()),
s.getShellDialect().getDisplayName(),
new String[] {info})
info)
.format();
}
return new ShellStoreFormat(
LicenseProvider.get().checkOsName(s.getOsName()),
formattedOsName(s.getOsName()),
new String[] {
s.getTtyState() != null && s.getTtyState() != ShellTtyState.NONE ? "TTY" : null, info
})
s.getTtyState() != null && s.getTtyState() != ShellTtyState.NONE ? "TTY" : null,
info)
.format();
});
}
@@ -9,7 +9,6 @@ import lombok.EqualsAndHashCode;
import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;
import java.security.spec.InvalidKeySpecException;
import javax.crypto.SecretKey;
@JsonTypeName("vault")
@@ -27,7 +26,7 @@ public class VaultKeySecretValue extends AesSecretValue {
}
@Override
protected SecretKey getSecretKey() throws InvalidKeySpecException {
protected SecretKey getSecretKey() {
return DataStorage.getSecretKey();
}
@@ -12,5 +12,5 @@ public class StubShellControl extends WrapperShellControl {
}
@Override
public void close() throws Exception {}
public void close() {}
}
@@ -137,7 +137,7 @@ public class CoreJacksonModule extends SimpleModule {
public ShellDialect deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
JsonNode tree = JacksonMapper.getDefault().readTree(p);
if (tree.isObject()) {
var t = (JsonNode) tree.get("type");
var t = tree.get("type");
if (t == null) {
return null;
}
@@ -204,8 +204,8 @@ public abstract class BaseCompressAction implements BrowserAction, BrowserBranch
var base = new FilePath(model.getCurrentDirectory().getPath());
var target = base.join(fileName);
var command = CommandBuilder.of().add("zip", "-r", "-");
for (int i = 0; i < entries.size(); i++) {
var rel = new FilePath(entries.get(i).getRawFileEntry().getPath())
for (BrowserEntry entry : entries) {
var rel = new FilePath(entry.getRawFileEntry().getPath())
.relativize(base)
.toUnix();
if (directory) {
@@ -261,8 +261,8 @@ public abstract class BaseCompressAction implements BrowserAction, BrowserBranch
.add("a")
.add("-r")
.addFile(target);
for (int i = 0; i < entries.size(); i++) {
var rel = new FilePath(entries.get(i).getRawFileEntry().getPath()).relativize(base);
for (BrowserEntry entry : entries) {
var rel = new FilePath(entry.getRawFileEntry().getPath()).relativize(base);
if (directory) {
command.addQuoted(".\\" + rel.toDirectory().toWindows() + "*");
} else {
@@ -36,7 +36,7 @@ public class BaseUntarAction implements BrowserApplicationPathAction, BrowserLea
}
@Override
public void execute(BrowserFileSystemTabModel model, List<BrowserEntry> entries) throws Exception {
public void execute(BrowserFileSystemTabModel model, List<BrowserEntry> entries) {
model.runAsync(
() -> {
ShellControl sc = model.getFileSystem().getShell().orElseThrow();
@@ -30,7 +30,7 @@ public abstract class BaseUnzipWindowsAction implements BrowserLeafAction {
}
@Override
public void execute(BrowserFileSystemTabModel model, List<BrowserEntry> entries) throws Exception {
public void execute(BrowserFileSystemTabModel model, List<BrowserEntry> entries) {
model.runAsync(
() -> {
var sc = model.getFileSystem().getShell().orElseThrow();
@@ -16,9 +16,9 @@ import lombok.extern.jackson.Jacksonized;
@JsonTypeName("desktopApplication")
public class DesktopApplicationStore implements DataStore {
private final DataStoreEntryRef<DesktopBaseStore> desktop;
private final String path;
private final String arguments;
DataStoreEntryRef<DesktopBaseStore> desktop;
String path;
String arguments;
@Override
public void checkComplete() throws Throwable {
@@ -1,8 +1,6 @@
package io.xpipe.ext.base.identity;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.deser.std.DelegatingDeserializer;
@@ -30,17 +28,16 @@ public class IdentityMigrationDeserializer extends DelegatingDeserializer {
}
@Override
public Object deserialize(JsonParser p, DeserializationContext ctxt, Object intoValue)
throws IOException, JsonProcessingException {
public Object deserialize(JsonParser p, DeserializationContext ctxt, Object intoValue) throws IOException {
return super.deserialize(restructure(p), ctxt, intoValue);
}
public Object deserializeWithType(JsonParser jp, DeserializationContext ctxt, TypeDeserializer typeDeserializer)
throws IOException, JsonProcessingException {
throws IOException {
return super.deserializeWithType(restructure(jp), ctxt, typeDeserializer);
}
public JsonParser restructure(JsonParser p) throws IOException, JsonParseException {
public JsonParser restructure(JsonParser p) throws IOException {
var node = p.readValueAsTree();
if (!node.isObject()) {
return p;
@@ -43,7 +43,9 @@ public class LocalIdentityStoreProvider extends IdentityStoreProvider {
.name("keyAuthentication")
.description("keyAuthenticationDescription")
.longDescription("base:sshKey")
.sub(SshIdentityStrategyHelper.identity(new SimpleObjectProperty<>(), identity, null,false, true), identity)
.sub(
SshIdentityStrategyHelper.identity(new SimpleObjectProperty<>(), identity, null, false, true),
identity)
.bind(
() -> {
return LocalIdentityStore.builder()
@@ -56,7 +56,10 @@ public class SshIdentityStrategyHelper {
? fileProperty.getValue().getFile().toAbsoluteFilePath(null)
: null);
fileProperty.addListener((observable, oldValue, newValue) -> {
keyPath.setValue(newValue != null && newValue.getFile() != null ? newValue.getFile().toAbsoluteFilePath(null) : null);
keyPath.setValue(
newValue != null && newValue.getFile() != null
? newValue.getFile().toAbsoluteFilePath(null)
: null);
});
var keyPasswordProperty = new SimpleObjectProperty<>(
fileProperty.getValue() != null ? fileProperty.getValue().getPassword() : null);
@@ -73,7 +76,9 @@ public class SshIdentityStrategyHelper {
.nonNull()
.name("keyPassword")
.description("sshConfigHost.identityPassphraseDescription")
.sub(SecretRetrievalStrategyHelper.comp(keyPasswordProperty, true, allowUserSecretKey), keyPasswordProperty)
.sub(
SecretRetrievalStrategyHelper.comp(keyPasswordProperty, true, allowUserSecretKey),
keyPasswordProperty)
.nonNull()
.bind(
() -> {
@@ -103,7 +108,9 @@ public class SshIdentityStrategyHelper {
var map = new LinkedHashMap<ObservableValue<String>, OptionsBuilder>();
map.put(AppI18n.observable("base.none"), new OptionsBuilder());
map.put(AppI18n.observable("base.keyFile"), fileIdentity(proxy, file, perUserFile, allowSync, allowUserSecretKey));
map.put(
AppI18n.observable("base.keyFile"),
fileIdentity(proxy, file, perUserFile, allowSync, allowUserSecretKey));
map.put(AppI18n.observable("base.sshAgent"), agent(agent));
map.put(AppI18n.observable("base.pageant"), new OptionsBuilder());
map.put(gpgFeature.suffixObservable("base.gpgAgent"), new OptionsBuilder());
@@ -65,7 +65,7 @@ public class SyncedIdentityStoreProvider extends IdentityStoreProvider {
.longDescription("base:sshKey")
.sub(
SshIdentityStrategyHelper.identity(
new SimpleObjectProperty<>(), identity, path -> perUser.get(),true, true),
new SimpleObjectProperty<>(), identity, path -> perUser.get(), true, true),
identity)
.check(val -> Validator.create(val, AppI18n.observable("keyNotSynced"), identity, i -> {
var wrong = i instanceof SshIdentityStrategy.File f
@@ -52,7 +52,7 @@ public class RunScriptAction implements BrowserAction, BrowserBranchAction {
if (actions.isEmpty()) {
actions = List.of(new BrowserLeafAction() {
@Override
public void execute(BrowserFileSystemTabModel model, List<BrowserEntry> entries) throws Exception {
public void execute(BrowserFileSystemTabModel model, List<BrowserEntry> entries) {
StoreViewState.get().getAllScriptsCategory().select();
AppLayoutModel.get().selectConnections();
}
@@ -31,12 +31,12 @@ import java.util.stream.Collectors;
@ToString(callSuper = true)
public class SimpleScriptStore extends ScriptStore implements ShellInitCommand.Terminal, SelfReferentialStore {
private final ShellDialect minimumDialect;
private final String commands;
private final boolean initScript;
private final boolean shellScript;
private final boolean fileScript;
private final boolean runnableScript;
ShellDialect minimumDialect;
String commands;
boolean initScript;
boolean shellScript;
boolean fileScript;
boolean runnableScript;
public String getCommands() {
return commands != null ? commands : "";
@@ -3,7 +3,6 @@ package io.xpipe.ext.base.service;
import io.xpipe.app.comp.Comp;
import io.xpipe.app.comp.store.*;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.ext.DataStoreProvider;
import io.xpipe.app.ext.DataStoreUsageCategory;
import io.xpipe.app.ext.SingletonSessionStoreProvider;
@@ -115,8 +114,8 @@ public abstract class AbstractServiceStoreProvider implements SingletonSessionSt
var desc = s.getLocalPort() != null
? "localhost:" + s.getLocalPort() + " <- :" + s.getRemotePort()
: s.isSessionRunning()
? "localhost:" + s.getSession().getLocalPort() + " <- :" + s.getRemotePort()
: AppI18n.get("servicePort", s.getRemotePort());
? "localhost:" + s.getSession().getLocalPort() + " <- :" + s.getRemotePort()
: AppI18n.get("servicePort", s.getRemotePort());
return desc;
}
@@ -1,9 +1,7 @@
package io.xpipe.ext.base.service;
import io.xpipe.app.comp.store.StoreChoiceComp;
import io.xpipe.app.comp.store.StoreSection;
import io.xpipe.app.comp.store.StoreViewState;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.GuiDialog;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
@@ -13,8 +11,6 @@ import io.xpipe.core.store.NetworkTunnelStore;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import java.util.List;
@@ -15,7 +15,7 @@ import lombok.extern.jackson.Jacksonized;
@JsonTypeName("mappedService")
public class MappedServiceStore extends FixedServiceStore {
private final int containerPort;
int containerPort;
@Override
public boolean licenseRequired() {
@@ -1,20 +1,16 @@
package io.xpipe.ext.base.service;
import io.xpipe.app.comp.store.StoreChoiceComp;
import io.xpipe.app.comp.store.StoreSection;
import io.xpipe.app.comp.store.StoreViewState;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.GuiDialog;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.util.OptionsBuilder;
import io.xpipe.core.store.DataStore;
import io.xpipe.core.store.NetworkTunnelStore;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import java.util.List;
@@ -35,8 +31,9 @@ public class MappedServiceStoreProvider extends FixedServiceStoreProvider {
var desc = s.getLocalPort() != null
? "localhost:" + s.getLocalPort() + " <- :" + m.getRemotePort() + " <- :" + m.getContainerPort()
: s.isSessionRunning()
? "localhost:" + s.getSession().getLocalPort() + " <- :" + m.getRemotePort() + " <- :" + m.getContainerPort()
: ":" + m.getRemotePort() + " <- :" + m.getContainerPort();
? "localhost:" + s.getSession().getLocalPort() + " <- :" + m.getRemotePort() + " <- :"
+ m.getContainerPort()
: ":" + m.getRemotePort() + " <- :" + m.getContainerPort();
return desc;
}
@@ -45,7 +42,6 @@ public class MappedServiceStoreProvider extends FixedServiceStoreProvider {
return List.of(MappedServiceStore.class);
}
@Override
public GuiDialog guiDialog(DataStoreEntry entry, Property<DataStore> store) {
MappedServiceStore st = store.getValue().asNeeded();
@@ -17,17 +17,17 @@ import lombok.extern.jackson.Jacksonized;
})
public interface ServiceProtocolType {
public abstract String formatUrl(String base);
String formatUrl(String base);
public abstract void open(String url);
void open(String url);
public abstract String getTranslationKey();
String getTranslationKey();
@JsonTypeName("none")
@Value
@Jacksonized
@Builder
public static class None implements ServiceProtocolType {
class None implements ServiceProtocolType {
@Override
public String formatUrl(String base) {
@@ -47,7 +47,7 @@ public interface ServiceProtocolType {
@Value
@Jacksonized
@Builder
public static class Http implements ServiceProtocolType {
class Http implements ServiceProtocolType {
String path;
@@ -75,7 +75,7 @@ public interface ServiceProtocolType {
@Value
@Jacksonized
@Builder
public static class Https implements ServiceProtocolType {
class Https implements ServiceProtocolType {
String path;
@@ -53,7 +53,7 @@ public class ServiceRefreshAction implements ActionProvider {
DataStoreEntryRef<FixedServiceCreatorStore> ref;
@Override
public void execute() throws Exception {
public void execute() {
ref.get().setExpanded(true);
var e = DataStorage.get()
.addStoreIfNotPresent(
@@ -13,7 +13,7 @@ public class StoreRestartAction implements ActionProvider {
@Override
public LeafDataStoreCallSite<?> getLeafDataStoreCallSite() {
return new LeafDataStoreCallSite<DataStore>() {
return new LeafDataStoreCallSite<>() {
@Override
public ActionProvider.Action createAction(DataStoreEntryRef<DataStore> store) {
+1 -1
View File
@@ -5,6 +5,7 @@ import io.xpipe.app.ext.DataStoreProvider;
import io.xpipe.ext.base.action.*;
import io.xpipe.ext.base.browser.*;
import io.xpipe.ext.base.browser.compress.*;
import io.xpipe.ext.base.desktop.DesktopApplicationStoreProvider;
import io.xpipe.ext.base.identity.*;
import io.xpipe.ext.base.script.*;
import io.xpipe.ext.base.service.*;
@@ -12,7 +13,6 @@ import io.xpipe.ext.base.store.StorePauseAction;
import io.xpipe.ext.base.store.StoreRestartAction;
import io.xpipe.ext.base.store.StoreStartAction;
import io.xpipe.ext.base.store.StoreStopAction;
import io.xpipe.ext.base.desktop.DesktopApplicationStoreProvider;
open module io.xpipe.ext.base {
exports io.xpipe.ext.base;
@@ -98,11 +98,11 @@ public class IncusCommandView extends CommandViewBase {
.execute();
}
public CommandControl console(String containerName) throws Exception {
public CommandControl console(String containerName) {
return build(commandBuilder -> commandBuilder.add("console").addQuoted(containerName));
}
public CommandControl configEdit(String containerName) throws Exception {
public CommandControl configEdit(String containerName) {
return build(commandBuilder -> commandBuilder.add("config", "edit").addQuoted(containerName));
}
@@ -73,7 +73,7 @@ public class IncusContainerStore
}
@Override
public ShellControl control(ShellControl parent) throws Exception {
public ShellControl control(ShellControl parent) {
var user = identity != null ? identity.unwrap().getUsername() : null;
var sc = new IncusCommandView(parent).exec(containerName, user);
sc.withSourceStore(IncusContainerStore.this);
@@ -18,7 +18,7 @@ public class IncusScanProvider extends ScanProvider {
}
@Override
public void scan(DataStoreEntry entry, ShellControl sc) throws Throwable {
public void scan(DataStoreEntry entry, ShellControl sc) {
var e = DataStorage.get()
.addStoreIfNotPresent(
entry,
@@ -25,7 +25,7 @@ import java.util.regex.Pattern;
@Value
public class LxdCmdStore implements FixedHierarchyStore, StatefulDataStore<LxdCmdStore.State>, SelfReferentialStore {
private final DataStoreEntryRef<ShellStore> host;
DataStoreEntryRef<ShellStore> host;
public LxdCmdStore(DataStoreEntryRef<ShellStore> host) {
this.host = host;
@@ -106,11 +106,11 @@ public class LxdCommandView extends CommandViewBase {
.execute();
}
public CommandControl console(String containerName) throws Exception {
public CommandControl console(String containerName) {
return build(commandBuilder -> commandBuilder.add("console").addQuoted(containerName));
}
public CommandControl configEdit(String containerName) throws Exception {
public CommandControl configEdit(String containerName) {
return build(commandBuilder -> commandBuilder.add("config", "edit").addQuoted(containerName));
}
@@ -36,8 +36,8 @@ public class LxdContainerStore
StoppableStore,
PauseableStore {
private final DataStoreEntryRef<LxdCmdStore> cmd;
private final String containerName;
DataStoreEntryRef<LxdCmdStore> cmd;
String containerName;
IdentityValue identity;
@Override
@@ -71,7 +71,7 @@ public class LxdContainerStore
}
@Override
public ShellControl control(ShellControl parent) throws Exception {
public ShellControl control(ShellControl parent) {
var user = identity != null ? identity.unwrap().getUsername() : null;
var base = new LxdCommandView(parent).exec(containerName, user);
if (identity != null && identity.unwrap().getPassword() != null) {
@@ -18,7 +18,7 @@ public class LxdScanProvider extends ScanProvider {
}
@Override
public void scan(DataStoreEntry entry, ShellControl sc) throws Throwable {
public void scan(DataStoreEntry entry, ShellControl sc) {
var e = DataStorage.get()
.addStoreIfNotPresent(
entry,
@@ -28,7 +28,7 @@ import java.util.regex.Pattern;
public class PodmanCmdStore
implements FixedHierarchyStore, StatefulDataStore<PodmanCmdStore.State>, SelfReferentialStore {
private final DataStoreEntryRef<ShellStore> host;
DataStoreEntryRef<ShellStore> host;
public PodmanCmdStore(DataStoreEntryRef<ShellStore> host) {
this.host = host;
@@ -16,7 +16,7 @@ public class PodmanContainerAttachAction implements ActionProvider {
@Override
public Action createAction(DataStoreEntryRef<PodmanContainerStore> store) {
return () -> {
var d = (PodmanContainerStore) store.getStore();
var d = store.getStore();
var view = d.commandView(
d.getCmd().getStore().getHost().getStore().getOrStartSession());
TerminalLauncher.open(store.get().getName(), view.attach(d.getContainerName()));
@@ -45,8 +45,8 @@ public class PodmanContainerStore
SelfReferentialStore,
ContainerImageStore {
private final DataStoreEntryRef<PodmanCmdStore> cmd;
private final String containerName;
DataStoreEntryRef<PodmanCmdStore> cmd;
String containerName;
@Override
public String getImageName() {