mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 09:00:26 +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 {
|
try {
|
||||||
DataStorage.get().addStoreEntryIfNotPresent(e);
|
DataStorage.get().addStoreEntryIfNotPresent(e);
|
||||||
if (validated
|
if (validated
|
||||||
&& e.getProvider().shouldHaveChildren()
|
&& e.getProvider().shouldShowScan()
|
||||||
&& AppPrefs.get()
|
&& AppPrefs.get()
|
||||||
.openConnectionSearchWindowOnConnectionCreation()
|
.openConnectionSearchWindowOnConnectionCreation()
|
||||||
.get()) {
|
.get()) {
|
||||||
|
|
|
@ -96,14 +96,10 @@ public interface DataStoreProvider {
|
||||||
return new StoreSectionComp(section, topLevel);
|
return new StoreSectionComp(section, topLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean canHaveSubShells() {
|
default boolean shouldShowScan() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean shouldHaveChildren() {
|
|
||||||
return canHaveSubShells();
|
|
||||||
}
|
|
||||||
|
|
||||||
default Comp<?> stateDisplay(StoreEntryWrapper w) {
|
default Comp<?> stateDisplay(StoreEntryWrapper w) {
|
||||||
return Comp.empty();
|
return Comp.empty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,10 @@ public class ScanAlert {
|
||||||
|
|
||||||
public static void showForShellStore(DataStoreEntry initial) {
|
public static void showForShellStore(DataStoreEntry initial) {
|
||||||
show(initial, (DataStoreEntry entry, ShellControl sc) -> {
|
show(initial, (DataStoreEntry entry, ShellControl sc) -> {
|
||||||
|
if (!sc.canHaveSubshells()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!sc.getShellDialect().getDumbMode().supportsAnyPossibleInteraction()) {
|
if (!sc.getShellDialect().getDumbMode().supportsAnyPossibleInteraction()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,10 @@ public interface ShellControl extends ProcessControl {
|
||||||
|
|
||||||
boolean isLocal();
|
boolean isLocal();
|
||||||
|
|
||||||
|
default boolean canHaveSubshells() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ShellControl getMachineRootSession();
|
ShellControl getMachineRootSession();
|
||||||
|
|
||||||
ShellControl withoutLicenseCheck();
|
ShellControl withoutLicenseCheck();
|
||||||
|
|
|
@ -146,7 +146,11 @@ public interface ShellDialect {
|
||||||
|
|
||||||
String getPrintWorkingDirectoryCommand();
|
String getPrintWorkingDirectoryCommand();
|
||||||
|
|
||||||
StreamCharset getScriptCharset();
|
StreamCharset getTextCharset();
|
||||||
|
|
||||||
|
default StreamCharset getScriptCharset() {
|
||||||
|
return getTextCharset();
|
||||||
|
}
|
||||||
|
|
||||||
CommandControl getFileCopyCommand(ShellControl parent, String oldFile, String newFile);
|
CommandControl getFileCopyCommand(ShellControl parent, String oldFile, String newFile);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package io.xpipe.core.util;
|
||||||
|
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
@ -158,6 +159,20 @@ public class StreamCharset {
|
||||||
return detected.reader(inputStream);
|
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 {
|
public InputStreamReader reader(InputStream stream) throws Exception {
|
||||||
if (hasByteOrderMark()) {
|
if (hasByteOrderMark()) {
|
||||||
var bom = stream.readNBytes(getByteOrderMark().length);
|
var bom = stream.readNBytes(getByteOrderMark().length);
|
||||||
|
|
|
@ -31,15 +31,11 @@ public class ScanStoreAction implements ActionProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isMajor(DataStoreEntryRef<ShellStore> o) {
|
public boolean isMajor(DataStoreEntryRef<ShellStore> o) {
|
||||||
return o.get().getProvider().shouldHaveChildren();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isApplicable(DataStoreEntryRef<ShellStore> o) {
|
public boolean isApplicable(DataStoreEntryRef<ShellStore> o) {
|
||||||
if (!o.get().getProvider().canHaveSubShells()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var state = o.get().getStorePersistentState();
|
var state = o.get().getStorePersistentState();
|
||||||
if (state instanceof ShellStoreState shellStoreState) {
|
if (state instanceof ShellStoreState shellStoreState) {
|
||||||
return (shellStoreState.getShellDialect() == null
|
return (shellStoreState.getShellDialect() == null
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class SimpleScriptStoreProvider implements EnabledParentStoreProvider, Da
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldHaveChildren() {
|
public boolean shouldShowScan() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue