From af8904ea7adc94ae65c93f0f01a7070f5df28c2c Mon Sep 17 00:00:00 2001 From: crschnick Date: Fri, 22 Dec 2023 12:20:35 +0000 Subject: [PATCH] Add setting to debug local shell --- .../java/io/xpipe/app/prefs/AppPrefs.java | 43 +++------- .../io/xpipe/app/prefs/DeveloperCategory.java | 81 +++++++++++++++++++ .../resources/lang/preferences_en.properties | 1 + 3 files changed, 93 insertions(+), 32 deletions(-) create mode 100644 app/src/main/java/io/xpipe/app/prefs/DeveloperCategory.java diff --git a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java index f23dc263..0e02c56d 100644 --- a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java +++ b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java @@ -231,35 +231,35 @@ public class AppPrefs { .editable(System.getProperty(DEVELOPER_MODE_PROP) == null) .render(() -> new CustomToggleControl()); - private final BooleanProperty developerDisableUpdateVersionCheck = + final BooleanProperty developerDisableUpdateVersionCheck = typed(new SimpleBooleanProperty(false), Boolean.class); - private final BooleanField developerDisableUpdateVersionCheckField = + final BooleanField developerDisableUpdateVersionCheckField = BooleanField.ofBooleanType(developerDisableUpdateVersionCheck).render(() -> new CustomToggleControl()); private final ObservableBooleanValue developerDisableUpdateVersionCheckEffective = bindDeveloperTrue(developerDisableUpdateVersionCheck); - private final BooleanProperty developerDisableGuiRestrictions = + final BooleanProperty developerDisableGuiRestrictions = typed(new SimpleBooleanProperty(false), Boolean.class); - private final BooleanField developerDisableGuiRestrictionsField = + final BooleanField developerDisableGuiRestrictionsField = BooleanField.ofBooleanType(developerDisableGuiRestrictions).render(() -> new CustomToggleControl()); private final ObservableBooleanValue developerDisableGuiRestrictionsEffective = bindDeveloperTrue(developerDisableGuiRestrictions); - private final BooleanProperty developerShowHiddenProviders = typed(new SimpleBooleanProperty(false), Boolean.class); - private final BooleanField developerShowHiddenProvidersField = + final BooleanProperty developerShowHiddenProviders = typed(new SimpleBooleanProperty(false), Boolean.class); + final BooleanField developerShowHiddenProvidersField = BooleanField.ofBooleanType(developerShowHiddenProviders).render(() -> new CustomToggleControl()); private final ObservableBooleanValue developerShowHiddenProvidersEffective = bindDeveloperTrue(developerShowHiddenProviders); - private final BooleanProperty developerShowHiddenEntries = typed(new SimpleBooleanProperty(false), Boolean.class); - private final BooleanField developerShowHiddenEntriesField = + final BooleanProperty developerShowHiddenEntries = typed(new SimpleBooleanProperty(false), Boolean.class); + final BooleanField developerShowHiddenEntriesField = BooleanField.ofBooleanType(developerShowHiddenEntries).render(() -> new CustomToggleControl()); private final ObservableBooleanValue developerShowHiddenEntriesEffective = bindDeveloperTrue(developerShowHiddenEntries); - private final BooleanProperty developerDisableConnectorInstallationVersionCheck = + final BooleanProperty developerDisableConnectorInstallationVersionCheck = typed(new SimpleBooleanProperty(false), Boolean.class); - private final BooleanField developerDisableConnectorInstallationVersionCheckField = BooleanField.ofBooleanType( + final BooleanField developerDisableConnectorInstallationVersionCheckField = BooleanField.ofBooleanType( developerDisableConnectorInstallationVersionCheck) .render(() -> new CustomToggleControl()); private final ObservableBooleanValue developerDisableConnectorInstallationVersionCheckEffective = @@ -627,28 +627,7 @@ public class AppPrefs { .applyVisibility(VisibilityProperty.of( terminalType.isEqualTo(ExternalTerminalType.CUSTOM))), Setting.of("preferTerminalTabs", preferTerminalTabsField, preferTerminalTabs))), - Category.of( - "developer", - Setting.of( - "developerDisableUpdateVersionCheck", - developerDisableUpdateVersionCheckField, - developerDisableUpdateVersionCheck), - Setting.of( - "developerDisableGuiRestrictions", - developerDisableGuiRestrictionsField, - developerDisableGuiRestrictions), - Setting.of( - "developerDisableConnectorInstallationVersionCheck", - developerDisableConnectorInstallationVersionCheckField, - developerDisableConnectorInstallationVersionCheck), - Setting.of( - "developerShowHiddenEntries", - developerShowHiddenEntriesField, - developerShowHiddenEntries), - Setting.of( - "developerShowHiddenProviders", - developerShowHiddenProvidersField, - developerShowHiddenProviders)), + new DeveloperCategory(this).create(), Category.of("troubleshoot", Group.of(troubleshoot)))); categories.get(categories.size() - 2).setVisibilityProperty(VisibilityProperty.of(developerMode())); diff --git a/app/src/main/java/io/xpipe/app/prefs/DeveloperCategory.java b/app/src/main/java/io/xpipe/app/prefs/DeveloperCategory.java new file mode 100644 index 00000000..576055af --- /dev/null +++ b/app/src/main/java/io/xpipe/app/prefs/DeveloperCategory.java @@ -0,0 +1,81 @@ +package io.xpipe.app.prefs; + +import atlantafx.base.theme.Styles; +import com.dlsc.preferencesfx.model.Category; +import com.dlsc.preferencesfx.model.Group; +import com.dlsc.preferencesfx.model.Setting; +import io.xpipe.app.comp.base.ButtonComp; +import io.xpipe.app.fxcomps.impl.HorizontalComp; +import io.xpipe.app.fxcomps.impl.TextFieldComp; +import io.xpipe.app.util.LocalShell; +import io.xpipe.app.util.ThreadHelper; +import javafx.beans.property.SimpleStringProperty; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import lombok.SneakyThrows; +import org.kordamp.ikonli.javafx.FontIcon; + +import java.util.List; + +public class DeveloperCategory extends AppPrefsCategory { + + public DeveloperCategory(AppPrefs prefs) { + super(prefs); + } + + @SneakyThrows + public Category create() { + var localCommand = new SimpleStringProperty(); + Runnable test = () -> { + prefs.save(); + var cmd = localCommand.get(); + if (cmd == null) { + return; + } + + ThreadHelper.runFailableAsync(() -> { + LocalShell.getShell().executeSimpleStringCommandAndCheck(cmd); + }); + }; + + var runLocalCommand = lazyNode( + "shellCommandTest", + new HorizontalComp(List.of( + new TextFieldComp(localCommand) + .apply(struc -> struc.get().setPromptText("Local command")) + .styleClass(Styles.LEFT_PILL) + .grow(false, true), + new ButtonComp(null, new FontIcon("mdi2p-play"), test) + .styleClass(Styles.RIGHT_PILL) + .grow(false, true))) + .padding(new Insets(15, 0, 0, 0)) + .apply(struc -> struc.get().setAlignment(Pos.CENTER_LEFT)) + .apply(struc -> struc.get().setFillHeight(true)), + null); + return Category.of( + "developer", Group.of( + Setting.of( + "developerDisableUpdateVersionCheck", + prefs.developerDisableUpdateVersionCheckField, + prefs.developerDisableUpdateVersionCheck), + Setting.of( + "developerDisableGuiRestrictions", + prefs.developerDisableGuiRestrictionsField, + prefs.developerDisableGuiRestrictions), + Setting.of( + "developerDisableConnectorInstallationVersionCheck", + prefs.developerDisableConnectorInstallationVersionCheckField, + prefs.developerDisableConnectorInstallationVersionCheck), + Setting.of( + "developerShowHiddenEntries", + prefs.developerShowHiddenEntriesField, + prefs.developerShowHiddenEntries), + Setting.of( + "developerShowHiddenProviders", + prefs.developerShowHiddenProvidersField, + prefs.developerShowHiddenProviders)), + Group.of("shellCommandTest", + runLocalCommand) + ); + } +} diff --git a/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties b/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties index 778bfb76..4969289f 100644 --- a/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties +++ b/app/src/main/resources/io/xpipe/app/resources/lang/preferences_en.properties @@ -108,6 +108,7 @@ developerShowHiddenProviders=Show hidden providers developerShowHiddenProvidersDescription=Controls whether hidden and internal connection and data source providers will be shown in the creation dialog. developerDisableConnectorInstallationVersionCheck=Disable Connector Version Check developerDisableConnectorInstallationVersionCheckDescription=Controls whether the update checker will ignore the version number when inspecting the version of an XPipe connector installed on a remote machine. +shellCommandTest=Shell Command Test konsole=Konsole xfce=Xfce 4 elementaryTerminal=Elementary Terminal