Shell environmentally factoring and default option implementation

This commit is contained in:
crschnick 2024-09-08 22:07:53 +00:00
parent 19086e57d8
commit f1c5337355
44 changed files with 79 additions and 53 deletions

View file

@ -3,7 +3,7 @@ package io.xpipe.app.beacon.impl;
import com.sun.net.httpserver.HttpExchange;
import io.xpipe.app.util.TerminalLauncherManager;
import io.xpipe.beacon.api.SshLaunchExchange;
import io.xpipe.core.process.ProcessControlProvider;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.core.process.ShellDialects;
import java.util.List;

View file

@ -5,7 +5,7 @@ import io.xpipe.app.browser.file.BrowserFileTransferMode;
import io.xpipe.app.browser.file.LocalFileSystem;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.process.ProcessControlProvider;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.core.store.FileEntry;
import io.xpipe.core.util.FailableRunnable;

View file

@ -3,7 +3,7 @@ package io.xpipe.app.browser.file;
import io.xpipe.core.store.FileEntry;
import io.xpipe.core.store.FileKind;
import io.xpipe.core.store.FileSystem;
import io.xpipe.core.store.LocalStore;
import io.xpipe.app.ext.LocalStore;
import java.nio.file.Files;
import java.nio.file.Path;

View file

@ -18,7 +18,7 @@ import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.util.BooleanScope;
import io.xpipe.app.util.TerminalLauncher;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.process.ProcessControlProvider;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.core.process.ShellControl;
import io.xpipe.core.process.ShellDialects;
import io.xpipe.core.process.ShellOpenFunction;

View file

@ -4,7 +4,7 @@ import io.xpipe.app.ext.ExtensionException;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ProcessControlProvider;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.core.util.ModuleHelper;
import io.xpipe.core.util.ModuleLayerLoader;
import io.xpipe.core.util.XPipeInstallation;

View file

@ -3,7 +3,7 @@ package io.xpipe.app.core.check;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.util.LocalShell;
import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ProcessControlProvider;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.core.process.ProcessOutputException;
import lombok.Value;

View file

@ -1,8 +1,11 @@
package io.xpipe.core.store;
package io.xpipe.app.ext;
import io.xpipe.core.process.ProcessControlProvider;
import io.xpipe.core.process.ShellControl;
import io.xpipe.core.process.ShellStoreState;
import io.xpipe.core.store.DataStore;
import io.xpipe.core.store.NetworkTunnelStore;
import io.xpipe.core.store.ShellStore;
import io.xpipe.core.store.StatefulDataStore;
import io.xpipe.core.util.JacksonizedValue;
import com.fasterxml.jackson.annotation.JsonTypeName;

View file

@ -1,5 +1,8 @@
package io.xpipe.core.process;
package io.xpipe.app.ext;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.core.process.*;
import io.xpipe.core.store.DataStore;
import lombok.NonNull;
import java.util.ServiceLoader;
@ -37,4 +40,6 @@ public abstract class ProcessControlProvider {
public abstract ShellDialect getDefaultLocalDialect();
public abstract ShellDialect getFallbackDialect();
public abstract <T extends DataStore> DataStoreEntryRef<T> replace(DataStoreEntryRef<T> ref);
}

View file

@ -11,7 +11,7 @@ import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.util.DataStoreCategoryChoiceComp;
import io.xpipe.core.store.DataStore;
import io.xpipe.core.store.LocalStore;
import io.xpipe.app.ext.LocalStore;
import io.xpipe.core.store.ShellStore;
import javafx.beans.binding.Bindings;

View file

@ -12,8 +12,8 @@ import io.xpipe.app.util.TerminalLauncher;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.process.CommandBuilder;
import io.xpipe.core.process.CommandControl;
import io.xpipe.core.process.ProcessControlProvider;
import io.xpipe.core.store.LocalStore;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.ext.LocalStore;
import javafx.beans.property.SimpleStringProperty;
import javafx.geometry.Insets;

View file

@ -13,7 +13,7 @@ import io.xpipe.app.util.Hyperlinks;
import io.xpipe.app.util.OptionsBuilder;
import io.xpipe.app.util.TerminalLauncher;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.store.LocalStore;
import io.xpipe.app.ext.LocalStore;
import javafx.beans.binding.Bindings;
import javafx.geometry.Insets;

View file

@ -8,7 +8,7 @@ import io.xpipe.app.util.FixedHierarchyStore;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.store.DataStore;
import io.xpipe.core.store.FixedChildStore;
import io.xpipe.core.store.LocalStore;
import io.xpipe.app.ext.LocalStore;
import io.xpipe.core.store.StorePath;
import io.xpipe.core.util.UuidHelper;

View file

@ -1,6 +1,6 @@
package io.xpipe.app.storage;
import io.xpipe.core.process.ProcessControlProvider;
import io.xpipe.app.ext.ProcessControlProvider;
import java.nio.file.Path;

View file

@ -1,7 +1,7 @@
package io.xpipe.app.storage;
import io.xpipe.app.comp.store.StoreSortMode;
import io.xpipe.core.store.LocalStore;
import io.xpipe.app.ext.LocalStore;
import java.time.Instant;
import java.util.UUID;

View file

@ -5,7 +5,7 @@ import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.core.process.OsType;
import io.xpipe.core.store.LocalStore;
import io.xpipe.app.ext.LocalStore;
import io.xpipe.core.util.JacksonMapper;
import com.fasterxml.jackson.core.JacksonException;

View file

@ -5,6 +5,7 @@ import io.xpipe.app.core.AppCache;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.window.AppWindowHelper;
import io.xpipe.app.ext.PrefsChoiceValue;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.prefs.ExternalApplicationType;
import io.xpipe.app.storage.DataColor;

View file

@ -12,7 +12,7 @@ import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ShellDialects;
import io.xpipe.core.store.FileNames;
import io.xpipe.core.store.LocalStore;
import io.xpipe.app.ext.LocalStore;
import io.xpipe.core.util.FailableRunnable;
import io.xpipe.core.util.XPipeInstallation;

View file

@ -3,7 +3,7 @@ package io.xpipe.app.update;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.fxcomps.impl.CodeSnippet;
import io.xpipe.app.fxcomps.impl.CodeSnippetComp;
import io.xpipe.core.store.LocalStore;
import io.xpipe.app.ext.LocalStore;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.layout.Region;

View file

@ -2,7 +2,7 @@ package io.xpipe.app.util;
import io.xpipe.app.storage.*;
import io.xpipe.app.terminal.ExternalTerminalType;
import io.xpipe.core.store.LocalStore;
import io.xpipe.app.ext.LocalStore;
import io.xpipe.core.util.EncryptedSecretValue;
import io.xpipe.core.util.JacksonMapper;
import io.xpipe.core.util.SecretValue;

View file

@ -3,7 +3,7 @@ package io.xpipe.app.util;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.core.store.FileSystemStore;
import io.xpipe.core.store.LocalStore;
import io.xpipe.app.ext.LocalStore;
import io.xpipe.core.util.JacksonizedValue;
import com.fasterxml.jackson.annotation.JsonTypeName;

View file

@ -1,6 +1,6 @@
package io.xpipe.app.util;
import io.xpipe.core.process.ProcessControlProvider;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.core.process.ShellControl;
import io.xpipe.core.process.ShellDialects;

View file

@ -3,7 +3,7 @@ package io.xpipe.app.util;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.DataStoreSecret;
import io.xpipe.core.store.LocalStore;
import io.xpipe.app.ext.LocalStore;
import io.xpipe.core.util.InPlaceSecretValue;
import com.fasterxml.jackson.annotation.JsonSubTypes;

View file

@ -5,7 +5,7 @@ import io.xpipe.app.core.AppProperties;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.core.process.CommandBuilder;
import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ProcessControlProvider;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.core.process.ShellControl;
import io.xpipe.core.util.XPipeInstallation;

View file

@ -1,6 +1,7 @@
package io.xpipe.app.util;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.DataStorage;

View file

@ -110,6 +110,7 @@ open module io.xpipe.app {
uses io.xpipe.app.util.LicensedFeature;
uses io.xpipe.beacon.BeaconInterface;
uses DataStorageExtensionProvider;
uses ProcessControlProvider;
provides Module with
AppJacksonModule;

View file

@ -220,10 +220,7 @@ public interface ShellControl extends ProcessControl {
return command(b);
}
default CommandControl command(CommandBuilder builder) {
var sc = ProcessControlProvider.get().command(this, builder, builder);
return sc;
}
CommandControl command(CommandBuilder builder);
void exitAndWait() throws IOException;
}

View file

@ -11,15 +11,16 @@ import lombok.extern.jackson.Jacksonized;
@EqualsAndHashCode(callSuper = true)
@SuperBuilder(toBuilder = true)
@Jacksonized
public class ShellNameStoreState extends ShellStoreState {
public class ShellEnvironmentStoreState extends ShellStoreState {
String shellName;
Boolean setDefault;
@Override
public DataStoreState mergeCopy(DataStoreState newer) {
var n = (ShellNameStoreState) newer;
var n = (ShellEnvironmentStoreState) newer;
var b = toBuilder();
mergeBuilder(n, b);
return b.shellName(useNewer(shellName, n.shellName)).build();
return b.shellName(useNewer(shellName, n.shellName)).setDefault(useNewer(setDefault,n.setDefault)).build();
}
}

View file

@ -5,10 +5,6 @@ import io.xpipe.core.process.ShellControl;
public interface ShellStore extends DataStore, FileSystemStore, ValidatableStore {
static boolean isLocal(ShellStore s) {
return s instanceof LocalStore;
}
@Override
default FileSystem createFileSystem() {
return new ConnectionFileSystem(control());

View file

@ -1,16 +1,5 @@
package io.xpipe.core.util;
import io.xpipe.core.dialog.BaseQueryElement;
import io.xpipe.core.dialog.BusyElement;
import io.xpipe.core.dialog.ChoiceElement;
import io.xpipe.core.dialog.HeaderElement;
import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ShellDialect;
import io.xpipe.core.process.ShellDialects;
import io.xpipe.core.store.FilePath;
import io.xpipe.core.store.LocalStore;
import io.xpipe.core.store.StorePath;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.fasterxml.jackson.core.JsonGenerator;
@ -19,6 +8,15 @@ import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.jsontype.NamedType;
import com.fasterxml.jackson.databind.module.SimpleModule;
import io.xpipe.core.dialog.BaseQueryElement;
import io.xpipe.core.dialog.BusyElement;
import io.xpipe.core.dialog.ChoiceElement;
import io.xpipe.core.dialog.HeaderElement;
import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ShellDialect;
import io.xpipe.core.process.ShellDialects;
import io.xpipe.core.store.FilePath;
import io.xpipe.core.store.StorePath;
import java.io.IOException;
import java.nio.charset.Charset;
@ -32,7 +30,6 @@ public class CoreJacksonModule extends SimpleModule {
public void setupModule(SetupContext context) {
context.registerSubtypes(
new NamedType(InPlaceSecretValue.class),
new NamedType(LocalStore.class),
new NamedType(BaseQueryElement.class),
new NamedType(ChoiceElement.class),
new NamedType(BusyElement.class),

View file

@ -1,4 +1,3 @@
import io.xpipe.core.process.ProcessControlProvider;
import io.xpipe.core.process.ShellDialect;
import io.xpipe.core.process.ShellDialects;
import io.xpipe.core.util.CoreJacksonModule;
@ -19,7 +18,6 @@ open module io.xpipe.core {
requires static lombok;
uses com.fasterxml.jackson.databind.Module;
uses ProcessControlProvider;
uses io.xpipe.core.util.ProxyManagerProvider;
uses io.xpipe.core.util.DataStateProvider;
uses ModuleLayerLoader;

View file

@ -4,8 +4,10 @@ import io.xpipe.app.browser.session.BrowserSessionModel;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppLayoutModel;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.ext.ProcessControlProvider;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.core.store.FileSystemStore;
import io.xpipe.core.store.ShellStore;
import javafx.beans.property.SimpleBooleanProperty;
@ -53,7 +55,8 @@ public class BrowseStoreAction implements ActionProvider {
@Override
public void execute() {
BrowserSessionModel.DEFAULT.openFileSystemAsync(entry.ref(), null, new SimpleBooleanProperty());
DataStoreEntryRef<FileSystemStore> replacement = ProcessControlProvider.get().replace(entry.ref());
BrowserSessionModel.DEFAULT.openFileSystemAsync(replacement, null, new SimpleBooleanProperty());
AppLayoutModel.get().selectBrowser();
}
}

View file

@ -8,7 +8,7 @@ import io.xpipe.core.process.CommandControl;
import io.xpipe.core.process.ElevationFunction;
import io.xpipe.core.process.ShellControl;
import io.xpipe.core.process.ShellDialects;
import io.xpipe.core.store.LocalStore;
import io.xpipe.app.ext.LocalStore;
import io.xpipe.core.store.ShellStore;
import javafx.beans.value.ObservableValue;
@ -40,8 +40,7 @@ public class SampleStoreAction implements ActionProvider {
@Override
public boolean isApplicable(DataStoreEntryRef<ShellStore> o) {
// Allows you to individually check whether this action should be available for the specific store.
// In this case it should only be available for remote shell connections, not local ones.
return !ShellStore.isLocal(o.getStore());
return true;
}
@Override

View file

@ -405,3 +405,5 @@ vncDirect.displayName=Direkte VNC-forbindelse
vncDirect.displayDescription=Opret direkte forbindelse til et system via VNC
editConfiguration=Rediger konfiguration
viewInDashboard=Visning i dashboard
setDefault=Indstil standard
removeDefault=Fjern standard

View file

@ -383,3 +383,5 @@ vncDirect.displayName=Direkte VNC-Verbindung
vncDirect.displayDescription=Über VNC direkt mit einem System verbinden
editConfiguration=Konfiguration bearbeiten
viewInDashboard=Ansicht im Dashboard
setDefault=Standard einstellen
removeDefault=Standard entfernen

View file

@ -381,3 +381,5 @@ vncDirect.displayName=Direct VNC connection
vncDirect.displayDescription=Connect to a system via VNC directly
editConfiguration=Edit configuration
viewInDashboard=View in dashboard
setDefault=Set default
removeDefault=Remove default

View file

@ -379,3 +379,5 @@ vncDirect.displayName=Conexión VNC directa
vncDirect.displayDescription=Conectarse directamente a un sistema mediante VNC
editConfiguration=Editar configuración
viewInDashboard=Vista en el panel de control
setDefault=Establecer por defecto
removeDefault=Eliminar por defecto

View file

@ -379,3 +379,5 @@ vncDirect.displayName=Connexion directe VNC
vncDirect.displayDescription=Se connecter directement à un système via VNC
editConfiguration=Modifier la configuration
viewInDashboard=Vue dans le tableau de bord
setDefault=Définir par défaut
removeDefault=Supprimer la valeur par défaut

View file

@ -379,3 +379,5 @@ vncDirect.displayName=Connessione diretta VNC
vncDirect.displayDescription=Connettersi direttamente a un sistema tramite VNC
editConfiguration=Modifica la configurazione
viewInDashboard=Vista nel cruscotto
setDefault=Imposta predefinito
removeDefault=Rimuovi l'impostazione predefinita

View file

@ -379,3 +379,5 @@ vncDirect.displayName=直接VNC接続
vncDirect.displayDescription=VNC経由でシステムに直接接続する
editConfiguration=設定を編集する
viewInDashboard=ダッシュボードで見る
setDefault=デフォルトを設定する
removeDefault=デフォルトを削除する

View file

@ -379,3 +379,5 @@ vncDirect.displayName=Directe VNC-verbinding
vncDirect.displayDescription=Rechtstreeks verbinding maken met een systeem via VNC
editConfiguration=Configuratie bewerken
viewInDashboard=Weergave in dashboard
setDefault=Standaard instellen
removeDefault=Standaard verwijderen

View file

@ -379,3 +379,5 @@ vncDirect.displayName=Ligação VNC direta
vncDirect.displayDescription=Liga-te diretamente a um sistema através do VNC
editConfiguration=Edita a configuração
viewInDashboard=Ver no painel de controlo
setDefault=Definir predefinição
removeDefault=Remover predefinição

View file

@ -379,3 +379,5 @@ vncDirect.displayName=Прямое VNC-соединение
vncDirect.displayDescription=Подключись к системе через VNC напрямую
editConfiguration=Редактирование конфигурации
viewInDashboard=Вид в приборной панели
setDefault=Установить по умолчанию
removeDefault=Убрать значение по умолчанию

View file

@ -379,3 +379,5 @@ vncDirect.displayName=Doğrudan VNC bağlantısı
vncDirect.displayDescription=Doğrudan VNC aracılığıyla bir sisteme bağlanma
editConfiguration=Yapılandırmayı düzenle
viewInDashboard=Gösterge tablosunda görüntüle
setDefault=Varsayılanı ayarla
removeDefault=Varsayılanı kaldır

View file

@ -379,3 +379,5 @@ vncDirect.displayName=直接 VNC 连接
vncDirect.displayDescription=直接通过 VNC 连接到系统
editConfiguration=编辑配置
viewInDashboard=在仪表板中查看
setDefault=设置默认值
removeDefault=删除默认值