mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 00:50:31 +00:00
Powershell fixes
This commit is contained in:
parent
eec51705d1
commit
c5f99af866
8 changed files with 32 additions and 13 deletions
|
@ -197,7 +197,7 @@ public class StoreCreationComp extends DialogComp {
|
|||
try {
|
||||
DataStorage.get().addStoreEntryIfNotPresent(e);
|
||||
if (validated
|
||||
&& e.getProvider().shouldHaveChildren()
|
||||
&& e.getProvider().shouldShowScan()
|
||||
&& AppPrefs.get()
|
||||
.openConnectionSearchWindowOnConnectionCreation()
|
||||
.get()) {
|
||||
|
|
|
@ -96,14 +96,10 @@ public interface DataStoreProvider {
|
|||
return new StoreSectionComp(section, topLevel);
|
||||
}
|
||||
|
||||
default boolean canHaveSubShells() {
|
||||
default boolean shouldShowScan() {
|
||||
return true;
|
||||
}
|
||||
|
||||
default boolean shouldHaveChildren() {
|
||||
return canHaveSubShells();
|
||||
}
|
||||
|
||||
default Comp<?> stateDisplay(StoreEntryWrapper w) {
|
||||
return Comp.empty();
|
||||
}
|
||||
|
|
|
@ -49,6 +49,10 @@ public class ScanAlert {
|
|||
|
||||
public static void showForShellStore(DataStoreEntry initial) {
|
||||
show(initial, (DataStoreEntry entry, ShellControl sc) -> {
|
||||
if (!sc.canHaveSubshells()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!sc.getShellDialect().getDumbMode().supportsAnyPossibleInteraction()) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,10 @@ public interface ShellControl extends ProcessControl {
|
|||
|
||||
boolean isLocal();
|
||||
|
||||
default boolean canHaveSubshells() {
|
||||
return true;
|
||||
}
|
||||
|
||||
ShellControl getMachineRootSession();
|
||||
|
||||
ShellControl withoutLicenseCheck();
|
||||
|
|
|
@ -146,7 +146,11 @@ public interface ShellDialect {
|
|||
|
||||
String getPrintWorkingDirectoryCommand();
|
||||
|
||||
StreamCharset getScriptCharset();
|
||||
StreamCharset getTextCharset();
|
||||
|
||||
default StreamCharset getScriptCharset() {
|
||||
return getTextCharset();
|
||||
}
|
||||
|
||||
CommandControl getFileCopyCommand(ShellControl parent, String oldFile, String newFile);
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.xpipe.core.util;
|
|||
|
||||
import lombok.Value;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
|
@ -158,6 +159,20 @@ public class StreamCharset {
|
|||
return detected.reader(inputStream);
|
||||
}
|
||||
|
||||
public String read(byte[] b) throws Exception {
|
||||
return read(new ByteArrayInputStream(b));
|
||||
}
|
||||
|
||||
public String read(InputStream inputStream) throws Exception {
|
||||
if (hasByteOrderMark()) {
|
||||
var bom = inputStream.readNBytes(getByteOrderMark().length);
|
||||
if (bom.length != 0 && !Arrays.equals(bom, getByteOrderMark())) {
|
||||
throw new IllegalStateException("Charset does not match: " + charset.toString());
|
||||
}
|
||||
}
|
||||
return new String(inputStream.readAllBytes(), charset);
|
||||
}
|
||||
|
||||
public InputStreamReader reader(InputStream stream) throws Exception {
|
||||
if (hasByteOrderMark()) {
|
||||
var bom = stream.readNBytes(getByteOrderMark().length);
|
||||
|
|
|
@ -31,15 +31,11 @@ public class ScanStoreAction implements ActionProvider {
|
|||
|
||||
@Override
|
||||
public boolean isMajor(DataStoreEntryRef<ShellStore> o) {
|
||||
return o.get().getProvider().shouldHaveChildren();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(DataStoreEntryRef<ShellStore> o) {
|
||||
if (!o.get().getProvider().canHaveSubShells()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var state = o.get().getStorePersistentState();
|
||||
if (state instanceof ShellStoreState shellStoreState) {
|
||||
return (shellStoreState.getShellDialect() == null
|
||||
|
|
|
@ -46,7 +46,7 @@ public class SimpleScriptStoreProvider implements EnabledParentStoreProvider, Da
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldHaveChildren() {
|
||||
public boolean shouldShowScan() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue