Implement launch functionality [release]

This commit is contained in:
crschnick 2023-02-11 14:22:07 +00:00
parent 8e7969de74
commit d4f3ff8001
16 changed files with 104 additions and 25 deletions

View file

@ -35,6 +35,7 @@ It comes with the following main features:
- Comes with integrations for all commonly used terminals for all operating systems
- Exclusively uses established CLI tools and therefore works out of the box on most systems and doesn't require any additional setup
- Allows you to customize the launched shell's init environment
- Launch connections from the GUI or commandline
#### All your connections in one place
@ -43,7 +44,7 @@ It comes with the following main features:
- Share connection configurations to any other trusted party through shareable URLs
- Create desktop shortcuts to open your connections
<img src="https://user-images.githubusercontent.com/72509152/213240153-3f742f03-1289-44c3-bf4d-626d9886ffcf.png" alt="drawing" height="450"/>
<img src="https://user-images.githubusercontent.com/72509152/218159305-64e2ac2c-2d01-4087-89d2-907f2e3a6bed.png" alt="drawing" height="450"/>
## Data Explorer
@ -65,7 +66,7 @@ allows you to manage and work with all kinds of data sources:
your favorite programming languages using the X-Pipe APIs
- Connect select third party applications directly to X-Pipe through extensions
<img src="https://user-images.githubusercontent.com/72509152/218159305-64e2ac2c-2d01-4087-89d2-907f2e3a6bed.png" alt="drawing" height="450"/>
<img src="https://user-images.githubusercontent.com/72509152/213240736-7a27fb3c-e8c3-4c92-bcea-2a782e53dc31.png" alt="drawing" height="450"/>
## Repository Structure

View file

@ -136,7 +136,7 @@ run {
systemProperty 'io.xpipe.app.writeSysOut', "true"
systemProperty 'io.xpipe.app.developerMode', "true"
systemProperty 'io.xpipe.app.logLevel', "trace"
systemProperty "io.xpipe.beacon.port", "21724"
// systemProperty "io.xpipe.beacon.port", "21724"
// systemProperty "io.xpipe.beacon.printMessages", "true"
systemProperty "io.xpipe.app.extensions", extensionDirList
// systemProperty 'io.xpipe.app.debugPlatform', "true"

View file

@ -0,0 +1,24 @@
package io.xpipe.app.exchange;
import io.xpipe.beacon.BeaconHandler;
import io.xpipe.beacon.exchange.LaunchExchange;
import io.xpipe.core.store.LaunchableStore;
import org.apache.commons.exec.CommandLine;
import java.util.List;
public class LaunchExchangeImpl extends LaunchExchange
implements MessageExchangeImpl<LaunchExchange.Request, LaunchExchange.Response> {
@Override
public Response handleRequest(BeaconHandler handler, Request msg) throws Exception {
var store = getStoreEntryByName(msg.getName(), false);
if (store.getStore() instanceof LaunchableStore s) {
var command = s.prepareLaunchCommand();
var split = CommandLine.parse(command);
return Response.builder().command(List.of(split.toStrings())).build();
}
throw new IllegalArgumentException();
}
}

View file

@ -66,6 +66,7 @@ open module io.xpipe.app {
requires com.jfoenix;
requires org.kordamp.ikonli.javafx;
requires org.kordamp.ikonli.material;
requires commons.exec;
requires org.controlsfx.controls;
requires io.sentry;
requires io.xpipe.beacon;
@ -125,6 +126,7 @@ open module io.xpipe.app {
StoreProviderListExchangeImpl,
ListCollectionsExchangeImpl,
OpenExchangeImpl,
LaunchExchangeImpl,
FocusExchangeImpl,
ListEntriesExchangeImpl,
ProxyReadConnectionExchangeImpl,

View file

@ -0,0 +1,33 @@
package io.xpipe.beacon.exchange;
import io.xpipe.beacon.RequestMessage;
import io.xpipe.beacon.ResponseMessage;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;
import lombok.extern.jackson.Jacksonized;
import java.util.List;
public class LaunchExchange implements MessageExchange {
@Override
public String getId() {
return "launch";
}
@Jacksonized
@Builder
@Value
public static class Request implements RequestMessage {
@NonNull
String name;
}
@Jacksonized
@Builder
@Value
public static class Response implements ResponseMessage {
@NonNull List<String> command;
}
}

View file

@ -43,6 +43,7 @@ module io.xpipe.beacon {
provides Module with
BeaconJacksonModule;
provides io.xpipe.beacon.exchange.MessageExchange with
LaunchExchange,
ForwardExchange,
InstanceExchange,
EditStoreExchange,

View file

@ -53,7 +53,7 @@ public class ShellTypes {
@Override
public String getSetEnvironmentVariableCommand(String variableName, String value) {
return ("set \"" + variableName + "=" + value.replaceAll("[&^|<>\"]", "^$0") + "\"");
return ("set \"" + variableName + "=" + value.replaceAll("\"", "^$0") + "\"");
}
@Override

View file

@ -2,7 +2,12 @@ package io.xpipe.core.store;
import io.xpipe.core.process.CommandProcessControl;
public interface CommandExecutionStore extends DataStore {
public interface CommandExecutionStore extends DataStore, LaunchableStore {
@Override
default String prepareLaunchCommand() throws Exception {
return create().prepareTerminalOpen();
}
CommandProcessControl create() throws Exception;
}

View file

@ -0,0 +1,6 @@
package io.xpipe.core.store;
public interface LaunchableStore extends DataStore {
String prepareLaunchCommand() throws Exception;
}

View file

@ -8,7 +8,7 @@ import io.xpipe.core.process.ShellType;
import java.nio.charset.Charset;
public interface ShellStore extends DataStore, StatefulDataStore {
public interface ShellStore extends DataStore, StatefulDataStore, LaunchableStore {
public static MachineStore local() {
return new LocalStore();
@ -24,6 +24,11 @@ public interface ShellStore extends DataStore, StatefulDataStore {
return s instanceof LocalStore;
}
@Override
default String prepareLaunchCommand() throws Exception {
return create().prepareTerminalOpen();
}
default ShellProcessControl create() {
var pc = createControl();
pc.onInit(processControl -> {

View file

@ -26,7 +26,6 @@ dependencies {
testImplementation project(':app')
testImplementation project(':procx')
testImplementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'org.apache.commons:commons-exec:1.3'
compileOnly group: 'com.dlsc.preferencesfx', name: 'preferencesfx-core', version: '11.15.0'
compileOnly group: 'com.dlsc.formsfx', name: 'formsfx-core', version: '11.6.0'
}

View file

@ -3,8 +3,7 @@ package io.xpipe.ext.proc.action;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.util.TerminalProvider;
import io.xpipe.core.store.DataStore;
import io.xpipe.core.store.ShellStore;
import io.xpipe.core.store.LaunchableStore;
import io.xpipe.extension.I18n;
import io.xpipe.extension.util.ActionProvider;
import javafx.beans.value.ObservableValue;
@ -28,8 +27,8 @@ public class LaunchAction implements ActionProvider {
@Override
public void execute() throws Exception {
var storeName = entry.getName();
if (entry.getStore() instanceof ShellStore s) {
String command = s.create().prepareTerminalOpen();
if (entry.getStore() instanceof LaunchableStore s) {
String command = s.prepareLaunchCommand();
TerminalProvider.open(storeName, command);
}
}
@ -55,7 +54,7 @@ public class LaunchAction implements ActionProvider {
@Override
public DataStoreCallSite<?> getDataStoreCallSite() {
return new DataStoreCallSite<DataStore>() {
return new DataStoreCallSite<LaunchableStore>() {
@Override
public boolean showIfDisabled() {
@ -63,28 +62,23 @@ public class LaunchAction implements ActionProvider {
}
@Override
public boolean isApplicable(DataStore o) throws Exception {
return o instanceof ShellStore;
}
@Override
public ObservableValue<String> getName(DataStore store) {
public ObservableValue<String> getName(LaunchableStore store) {
return I18n.observable("openShell");
}
@Override
public String getIcon(DataStore store) {
public String getIcon(LaunchableStore store) {
return "mdi2c-code-greater-than";
}
@Override
public ActionProvider.Action createAction(DataStore store) {
public ActionProvider.Action createAction(LaunchableStore store) {
return new Action(DataStorage.get().getEntryByStore(store).orElseThrow());
}
@Override
public Class<DataStore> getApplicableClass() {
return DataStore.class;
public Class<LaunchableStore> getApplicableClass() {
return LaunchableStore.class;
}
@Override

View file

@ -6,7 +6,7 @@ file.displayName=File
file.displayDescription=Specify a file input
inMemory.displayName=In Memory
inMemory.displayDescription=Store binary data in memory
shellCommand.displayName=Shell Command
shellCommand.displayName=Shell Opener Command
shellCommand.displayDescription=Open a shell with a custom command
shellEnvironment.displayName=Shell Environment
shellEnvironment.displayDescription=Run custom init commands on the shell connection

View file

@ -25,7 +25,7 @@ public enum ShellCheckTestItem {
}),
INIT_FILE(shellProcessControl -> {
var content = "<contentß>";
var content = "contentß";
try (var c = shellProcessControl
.subShell(shellProcessControl.getShellType())
.initWith(List.of(

View file

@ -6,6 +6,7 @@ dependencies {
dep files("$buildDir/generated-modules/commons-lang3-3.12.0.jar")
dep files("$buildDir/generated-modules/commons-io-2.11.0.jar")
dep files("$buildDir/generated-modules/commons-math3-3.6.1.jar")
dep files("$buildDir/generated-modules/commons-exec-1.3.jar")
}
addDependenciesModuleInfo {
@ -40,6 +41,14 @@ addDependenciesModuleInfo {
}
'''
}
module {
artifact 'org.apache.commons:commons-exec:1.3'
moduleInfoSource = '''
module commons.exec {
exports org.apache.commons.exec;
}
'''
}
module {
artifact 'org.apache.commons:commons-collections4:4.4'
moduleInfoSource = '''

View file

@ -1 +1 @@
0.4.27
0.4.28