Various small improvements

This commit is contained in:
crschnick 2023-07-04 01:28:33 +00:00
parent d84789b995
commit 313cc922ee
44 changed files with 523 additions and 166 deletions

View file

@ -90,7 +90,7 @@ bash <(curl -sL https://raw.githubusercontent.com/xpipe-io/xpipe/master/get-xpip
##### Windows (Experimental)
```
powershell -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/xpipe-io/xpipe/master/get-xpipe.ps1'))"
powershell -ExecutionPolicy Bypass -Command iwr "https://raw.githubusercontent.com/xpipe-io/xpipe/master/get-xpipe.ps1" -OutFile "$env:TEMP\get-xpipe.ps1" ";" "&" "$env:TEMP\get-xpipe.ps1"
```
## Further information

View file

@ -47,6 +47,12 @@ public class FileSystemHelper {
return null;
}
if (path.startsWith("\"") && path.endsWith("\"")) {
path = path.substring(1, path.length() - 1);
} else if (path.startsWith("'") && path.endsWith("'")) {
path = path.substring(1, path.length() - 1);
}
// Handle special case when file system creation has failed
if (model.getFileSystem() == null) {
return path;
@ -100,6 +106,10 @@ public class FileSystemHelper {
throw new IllegalArgumentException(String.format("Directory %s is not absolute", resolved));
}
if (model.getFileSystem().fileExists(path)) {
return FileNames.toDirectory(FileNames.getParent(path));
}
return FileNames.toDirectory(resolved);
}

View file

@ -1,93 +1,58 @@
package io.xpipe.app.comp;
import io.xpipe.app.browser.BrowserComp;
import io.xpipe.app.browser.BrowserModel;
import io.xpipe.app.comp.base.SideMenuBarComp;
import io.xpipe.app.comp.storage.store.StoreLayoutComp;
import io.xpipe.app.core.*;
import io.xpipe.app.core.AppActionLinkDetector;
import io.xpipe.app.core.AppFont;
import io.xpipe.app.core.AppLayoutModel;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.CompStructure;
import io.xpipe.app.fxcomps.SimpleCompStructure;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.prefs.PrefsComp;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Region;
import lombok.SneakyThrows;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class AppLayoutComp extends Comp<CompStructure<BorderPane>> {
private final List<SideMenuBarComp.Entry> entries;
private final Property<SideMenuBarComp.Entry> selected;
private final AppLayoutModel model = AppLayoutModel.get();
public AppLayoutComp() {
entries = createEntryList();
selected = new SimpleObjectProperty<>(AppState.get().isInitialLaunch() ? entries.get(1) : entries.get(0));
shortcut(new KeyCodeCombination(KeyCode.V, KeyCombination.SHORTCUT_DOWN), structure -> {
AppActionLinkDetector.detectOnPaste();
});
}
@SneakyThrows
private List<SideMenuBarComp.Entry> createEntryList() {
var l = new ArrayList<>(List.of(
new SideMenuBarComp.Entry(
AppI18n.observable("browser"), "mdi2f-file-cabinet", new BrowserComp(BrowserModel.DEFAULT)),
new SideMenuBarComp.Entry(AppI18n.observable("connections"), "mdi2c-connection", new StoreLayoutComp()),
// new SideMenuBarComp.Entry(AppI18n.observable("data"), "mdsal-dvr", new SourceCollectionLayoutComp()),
new SideMenuBarComp.Entry(
AppI18n.observable("settings"), "mdsmz-miscellaneous_services", new PrefsComp(this))));
// new SideMenuBarComp.Entry(AppI18n.observable("help"), "mdi2b-book-open-variant", new
// StorageLayoutComp()),
// new SideMenuBarComp.Entry(AppI18n.observable("account"), "mdi2a-account", new StorageLayoutComp())
if (AppProperties.get().isDeveloperMode() && !AppProperties.get().isImage()) {
l.add(new SideMenuBarComp.Entry(
AppI18n.observable("developer"), "mdi2b-book-open-variant", new DeveloperTabComp()));
}
// l.add(new SideMenuBarComp.Entry(AppI18n.observable("abc"), "mdi2b-book-open-variant", Comp.of(() -> {
// var fi = new FontIcon("mdsal-dvr");
// fi.setIconSize(30);
// fi.setIconColor(Color.valueOf("#111C"));
// JfxHelper.addEffect(fi);
// return new StackPane(fi);
// })));
return l;
}
@Override
public CompStructure<BorderPane> createBase() {
var map = new HashMap<SideMenuBarComp.Entry, Region>();
getRegion(entries.get(0), map);
getRegion(entries.get(1), map);
var map = new HashMap<AppLayoutModel.Entry, Region>();
getRegion(model.getEntries().get(0), map);
getRegion(model.getEntries().get(1), map);
var pane = new BorderPane();
var sidebar = new SideMenuBarComp(selected, entries);
pane.setCenter(getRegion(selected.getValue(), map));
var sidebar = new SideMenuBarComp(model.getSelected(), model.getEntries());
pane.setCenter(getRegion(model.getSelected().getValue(), map));
pane.setRight(sidebar.createRegion());
selected.addListener((c, o, n) -> {
if (o != null && o.equals(entries.get(2))) {
model.getSelected().addListener((c, o, n) -> {
if (o != null && o.equals(model.getEntries().get(2))) {
AppPrefs.get().save();
}
pane.setCenter(getRegion(n, map));
PlatformThread.runLaterIfNeeded(() -> {
pane.setCenter(getRegion(n, map));
});
});
AppFont.normal(pane);
return new SimpleCompStructure<>(pane);
}
private Region getRegion(SideMenuBarComp.Entry entry, Map<SideMenuBarComp.Entry, Region> map) {
private Region getRegion(AppLayoutModel.Entry entry, Map<AppLayoutModel.Entry, Region> map) {
if (map.containsKey(entry)) {
return map.get(entry);
}
@ -96,16 +61,4 @@ public class AppLayoutComp extends Comp<CompStructure<BorderPane>> {
map.put(entry, r);
return r;
}
public List<SideMenuBarComp.Entry> getEntries() {
return entries;
}
public SideMenuBarComp.Entry getSelected() {
return selected.getValue();
}
public Property<SideMenuBarComp.Entry> selectedProperty() {
return selected;
}
}

View file

@ -1,6 +1,7 @@
package io.xpipe.app.comp.base;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppLayoutModel;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.CompStructure;
import io.xpipe.app.fxcomps.SimpleCompStructure;
@ -10,7 +11,6 @@ import io.xpipe.app.update.UpdateAvailableAlert;
import io.xpipe.app.update.XPipeDistributionType;
import javafx.beans.binding.Bindings;
import javafx.beans.property.Property;
import javafx.beans.value.ObservableValue;
import javafx.css.PseudoClass;
import javafx.scene.control.Button;
import javafx.scene.layout.Priority;
@ -21,10 +21,10 @@ import java.util.List;
public class SideMenuBarComp extends Comp<CompStructure<VBox>> {
private final Property<SideMenuBarComp.Entry> value;
private final List<Entry> entries;
private final Property<AppLayoutModel.Entry> value;
private final List<AppLayoutModel.Entry> entries;
public SideMenuBarComp(Property<Entry> value, List<Entry> entries) {
public SideMenuBarComp(Property<AppLayoutModel.Entry> value, List<AppLayoutModel.Entry> entries) {
this.value = value;
this.entries = entries;
}
@ -42,14 +42,15 @@ public class SideMenuBarComp extends Comp<CompStructure<VBox>> {
b.apply(struc -> {
struc.get().pseudoClassStateChanged(selected, value.getValue().equals(e));
value.addListener((c, o, n) -> {
struc.get().pseudoClassStateChanged(selected, n.equals(e));
PlatformThread.runLaterIfNeeded(() -> {
struc.get().pseudoClassStateChanged(selected, n.equals(e));
});
});
});
vbox.getChildren().add(b.createRegion());
});
{
// vbox.getChildren().add(new Spacer(Orientation.VERTICAL));
var fi = new FontIcon("mdi2u-update");
var b = new BigIconButton(AppI18n.observable("update"), fi, () -> UpdateAvailableAlert.showIfNeeded());
b.apply(GrowAugment.create(true, false));
@ -76,5 +77,4 @@ public class SideMenuBarComp extends Comp<CompStructure<VBox>> {
return new SimpleCompStructure<>(vbox);
}
public record Entry(ObservableValue<String> name, String icon, Comp<?> comp) {}
}

View file

@ -31,15 +31,13 @@ public class DenseStoreEntryComp extends StoreEntryComp {
grid.getColumnConstraints().add(new ColumnConstraints(0));
}
var custom = new ColumnConstraints(content != null ? 300 : 0);
var customSize = content != null ? 300 : 0;
var custom = new ColumnConstraints(0, customSize, customSize);
custom.setHalignment(HPos.RIGHT);
custom.setMinWidth(Region.USE_PREF_SIZE);
custom.setMaxWidth(Region.USE_PREF_SIZE);
var info = new ColumnConstraints(content != null ? 300 : 600);
var infoSize = content != null ? 300 : 600;
var info = new ColumnConstraints(0, infoSize, infoSize);
info.setHalignment(HPos.LEFT);
info.setMinWidth(Region.USE_PREF_SIZE);
info.setMaxWidth(Region.USE_PREF_SIZE);
var nameCC = new ColumnConstraints();
nameCC.setMinWidth(100);

View file

@ -31,16 +31,14 @@ public class StandardStoreEntryComp extends StoreEntryComp {
grid.getColumnConstraints().addAll(nameCC);
grid.add(createInformation(), 2, 0, 1, 2);
var info = new ColumnConstraints(content != null ? 300 : 600);
var infoSize = content != null ? 300 : 600;
var info = new ColumnConstraints(0, infoSize, infoSize);
info.setHalignment(HPos.LEFT);
info.setMinWidth(Region.USE_PREF_SIZE);
info.setMaxWidth(Region.USE_PREF_SIZE);
grid.getColumnConstraints().add(info);
var custom = new ColumnConstraints(content != null ? 300 : 0);
var customSize = content != null ? 300 : 0;
var custom = new ColumnConstraints(0, customSize, customSize);
custom.setHalignment(HPos.RIGHT);
custom.setMinWidth(Region.USE_PREF_SIZE);
custom.setMaxWidth(Region.USE_PREF_SIZE);
var cr = content != null ? content.createRegion() : new Region();
var bb = createButtonBar().createRegion();
var controls = new HBox(cr, bb);

View file

@ -175,8 +175,12 @@ public abstract class StoreEntryComp extends SimpleComp {
var list = new ArrayList<Comp<?>>();
for (var p : wrapper.getActionProviders().entrySet()) {
var actionProvider = p.getKey().getDataStoreCallSite();
if (!actionProvider.isMajor()
|| p.getKey().equals(wrapper.getDefaultActionProvider().getValue())) {
if (!actionProvider.isMajor(wrapper.getEntry().getStore().asNeeded())) {
continue;
}
var def = p.getKey().getDefaultDataStoreCallSite();
if (def != null && def.equals(wrapper.getDefaultActionProvider().getValue())) {
continue;
}
@ -234,7 +238,7 @@ public abstract class StoreEntryComp extends SimpleComp {
for (var p : wrapper.getActionProviders().entrySet()) {
var actionProvider = p.getKey().getDataStoreCallSite();
if (actionProvider.isMajor()) {
if (actionProvider.isMajor(wrapper.getEntry().getStore().asNeeded())) {
continue;
}
@ -269,7 +273,6 @@ public abstract class StoreEntryComp extends SimpleComp {
}
var refresh = new MenuItem(AppI18n.get("refresh"), new FontIcon("mdal-360"));
refresh.disableProperty().bind(wrapper.getRefreshable().not());
refresh.setOnAction(event -> {
DataStorage.get().refreshAsync(wrapper.getEntry(), true);
});

View file

@ -32,9 +32,6 @@ public class StoreEntryWrapper implements StorageFilter.Filterable {
private final StringProperty summary = new SimpleStringProperty();
private final Map<ActionProvider, BooleanProperty> actionProviders;
private final Property<ActionProvider.DefaultDataStoreCallSite<?>> defaultActionProvider;
private final BooleanProperty editable = new SimpleBooleanProperty();
private final BooleanProperty renamable = new SimpleBooleanProperty();
private final BooleanProperty refreshable = new SimpleBooleanProperty();
private final BooleanProperty deletable = new SimpleBooleanProperty();
private final BooleanProperty expanded = new SimpleBooleanProperty();
@ -108,13 +105,6 @@ public class StoreEntryWrapper implements StorageFilter.Filterable {
}
}
editable.setValue(entry.getState() != DataStoreEntry.State.LOAD_FAILED
&& (entry.getConfiguration().isEditable()
|| AppPrefs.get().developerDisableGuiRestrictions().get()));
renamable.setValue(entry.getConfiguration().isRenameable()
|| AppPrefs.get().developerDisableGuiRestrictions().getValue());
refreshable.setValue(entry.getConfiguration().isRefreshable()
|| AppPrefs.get().developerDisableGuiRestrictions().getValue());
deletable.setValue(entry.getConfiguration().isDeletable()
|| AppPrefs.get().developerDisableGuiRestrictions().getValue());

View file

@ -168,7 +168,7 @@ public class AppI18n {
var key = getKey(s);
if (translations == null) {
TrackEvent.warn("Translations not initialized for" + key);
TrackEvent.warn("Translations not initialized for " + key);
return s;
}

View file

@ -0,0 +1,74 @@
package io.xpipe.app.core;
import io.xpipe.app.browser.BrowserComp;
import io.xpipe.app.browser.BrowserModel;
import io.xpipe.app.comp.DeveloperTabComp;
import io.xpipe.app.comp.storage.store.StoreLayoutComp;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.prefs.PrefsComp;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ObservableValue;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
@Getter
public class AppLayoutModel {
private static AppLayoutModel INSTANCE;
public static AppLayoutModel get() {
return INSTANCE;
}
public static void init() {
INSTANCE = new AppLayoutModel();
}
private final List<Entry> entries;
private final Property<Entry> selected;
public AppLayoutModel() {
this.entries = createEntryList();
this.selected = new SimpleObjectProperty<>(entries.get(1));
}
public void selectBrowser() {
selected.setValue(entries.get(0));
}
public void selectConnections() {
selected.setValue(entries.get(1));
}
private List<Entry> createEntryList() {
var l = new ArrayList<>(List.of(
new Entry(
AppI18n.observable("browser"), "mdi2f-file-cabinet", new BrowserComp(BrowserModel.DEFAULT)),
new Entry(AppI18n.observable("connections"), "mdi2c-connection", new StoreLayoutComp()),
// new SideMenuBarComp.Entry(AppI18n.observable("data"), "mdsal-dvr", new SourceCollectionLayoutComp()),
new Entry(
AppI18n.observable("settings"), "mdsmz-miscellaneous_services", new PrefsComp(this))));
// new SideMenuBarComp.Entry(AppI18n.observable("help"), "mdi2b-book-open-variant", new
// StorageLayoutComp()),
// new SideMenuBarComp.Entry(AppI18n.observable("account"), "mdi2a-account", new StorageLayoutComp())
if (AppProperties.get().isDeveloperMode() && !AppProperties.get().isImage()) {
l.add(new Entry(
AppI18n.observable("developer"), "mdi2b-book-open-variant", new DeveloperTabComp()));
}
// l.add(new SideMenuBarComp.Entry(AppI18n.observable("abc"), "mdi2b-book-open-variant", Comp.of(() -> {
// var fi = new FontIcon("mdsal-dvr");
// fi.setIconSize(30);
// fi.setIconColor(Color.valueOf("#111C"));
// JfxHelper.addEffect(fi);
// return new StackPane(fi);
// })));
return l;
}
public record Entry(ObservableValue<String> name, String icon, Comp<?> comp) {}
}

View file

@ -240,6 +240,9 @@ public class AppMainWindow {
stage.getScene().setRoot(contentR);
TrackEvent.debug("Set content scene");
contentR.prefWidthProperty().bind(stage.getScene().widthProperty());
contentR.prefHeightProperty().bind(stage.getScene().heightProperty());
stage.getScene().addEventHandler(KeyEvent.KEY_PRESSED, event -> {
if (AppProperties.get().isDeveloperMode() && event.getCode().equals(KeyCode.F6)) {
var newR = content.createRegion();

View file

@ -83,9 +83,6 @@ public class AppTheme {
PlatformThread.runLaterIfNeeded(() -> {
for (Window window : Window.getWindows()) {
// Fix scene content not taking the correct size after style seed change
window.setWidth(window.getWidth() - 1);
var scene = window.getScene();
Image snapshot = scene.snapshot(null);
Pane root = (Pane) scene.getRoot();

View file

@ -62,6 +62,7 @@ public abstract class PlatformMode extends OperationMode {
AppTheme.init();
AppStyle.init();
AppImages.init();
AppLayoutModel.init();
TrackEvent.info("mode", "Finished essential component initialization before platform");
TrackEvent.info("mode", "Launching application ...");

View file

@ -4,14 +4,14 @@ import io.xpipe.beacon.RequestMessage;
import io.xpipe.beacon.ResponseMessage;
import io.xpipe.beacon.exchange.MessageExchanges;
import java.util.List;
import java.util.Optional;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.stream.Collectors;
public class MessageExchangeImpls {
private static Set<MessageExchangeImpl<?, ?>> ALL;
private static List<MessageExchangeImpl<?, ?>> ALL;
public static void loadAll() {
ALL = ServiceLoader.load(MessageExchangeImpl.class).stream()
@ -20,7 +20,7 @@ public class MessageExchangeImpls {
// TrackEvent.trace("init", "Loaded exchange implementation " + ex.getId());
return ex;
})
.collect(Collectors.toSet());
.collect(Collectors.toList());
ALL.forEach(messageExchange -> {
if (MessageExchanges.byId(messageExchange.getId()).isEmpty()) {
@ -51,7 +51,7 @@ public class MessageExchangeImpls {
return Optional.ofNullable((MessageExchangeImpl<RQ, RS>) r.orElse(null));
}
public static Set<MessageExchangeImpl<?, ?>> getAll() {
public static List<MessageExchangeImpl<?, ?>> getAll() {
return ALL;
}
}

View file

@ -99,7 +99,7 @@ public interface ActionProvider {
Class<T> getApplicableClass();
default boolean isMajor() {
default boolean isMajor(T o) {
return false;
}

View file

@ -42,8 +42,12 @@ public interface DataStoreProvider {
return new StoreSectionComp(section);
}
default String failureInfo() {
return null;
default boolean canHaveSubShells() {
return true;
}
default boolean shouldHaveSubShells() {
return canHaveSubShells();
}
default Comp<?> stateDisplay(StoreEntryWrapper w) {

View file

@ -4,13 +4,13 @@ import com.dlsc.formsfx.model.structure.Field;
import io.xpipe.core.util.ModuleLayerLoader;
import javafx.beans.value.ObservableBooleanValue;
import java.util.List;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.stream.Collectors;
public abstract class PrefsProvider {
private static Set<PrefsProvider> ALL;
private static List<PrefsProvider> ALL;
public static class Loader implements ModuleLayerLoader {
@ -18,7 +18,7 @@ public abstract class PrefsProvider {
public void init(ModuleLayer layer) {
ALL = ServiceLoader.load(layer, PrefsProvider.class).stream()
.map(ServiceLoader.Provider::get)
.collect(Collectors.toSet());
.collect(Collectors.toList());
}
@Override
@ -32,7 +32,7 @@ public abstract class PrefsProvider {
}
}
public static Set<PrefsProvider> getAll() {
public static List<PrefsProvider> getAll() {
return ALL;
}

View file

@ -7,7 +7,6 @@ import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.util.CustomComboBoxBuilder;
import io.xpipe.core.store.DataStore;
import io.xpipe.core.store.LeafShellStore;
import io.xpipe.core.store.ShellStore;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleStringProperty;
@ -23,6 +22,10 @@ import java.util.function.Predicate;
@AllArgsConstructor
public class DataStoreChoiceComp<T extends DataStore> extends SimpleComp {
public static <T extends DataStore> DataStoreChoiceComp<T> other(Property<T> selected, Class<T> clazz, Predicate<T> filter) {
return new DataStoreChoiceComp<T>(Mode.OTHER, null, selected, clazz, filter);
}
public static DataStoreChoiceComp<ShellStore> proxy(Property<ShellStore> selected) {
return new DataStoreChoiceComp<>(Mode.PROXY, null, selected, ShellStore.class, shellStore -> true);
}
@ -107,7 +110,7 @@ public class DataStoreChoiceComp<T extends DataStore> extends SimpleComp {
}
var s = e.getEntry().getStore();
if (!(mode == Mode.ENVIRONMENT) && s instanceof LeafShellStore) {
if (!(mode == Mode.ENVIRONMENT) && e.getEntry().getProvider() != null && !e.getEntry().getProvider().canHaveSubShells()) {
continue;
}

View file

@ -102,7 +102,7 @@ public class SvgView {
wv.setFocusTraversable(false);
wv.setAccessibleRole(AccessibleRole.IMAGE_VIEW);
wv.getEngine().loadContent(getHtml(svgContent.getValue()));
wv.getEngine().loadContent(svgContent.getValue() != null ? getHtml(svgContent.getValue()) : null);
svgContent.addListener((c, o, n) -> {
if (n == null) {
wv.getEngine().loadContent("");

View file

@ -149,6 +149,19 @@ public class AppPrefs {
StringField.ofStringType(customTerminalCommand).render(() -> new SimpleTextControl()),
terminalType.isEqualTo(ExternalTerminalType.CUSTOM));
private final BooleanProperty preferTerminalTabs = typed(new SimpleBooleanProperty(true), Boolean.class);
private final BooleanField preferTerminalTabsField =
BooleanField.ofBooleanType(preferTerminalTabs).render(() -> new CustomToggleControl());
// Start behaviour
// ===============
private final ObjectProperty<ExternalStartupBehaviour> externalStartupBehaviour =
typed(new SimpleObjectProperty<>(ExternalStartupBehaviour.TRAY), ExternalStartupBehaviour.class);
private final SingleSelectionField<ExternalStartupBehaviour> externalStartupBehaviourControl =
Field.ofSingleSelectionType(externalStartupBehaviourList, externalStartupBehaviour)
.render(() -> new TranslatableComboBoxControl<>());
// Close behaviour
// ===============
private final ObjectProperty<CloseBehaviour> closeBehaviour =
@ -170,12 +183,10 @@ public class AppPrefs {
StringField.ofStringType(customEditorCommand).render(() -> new SimpleTextControl()),
externalEditor.isEqualTo(ExternalEditorType.CUSTOM));
private final IntegerProperty editorReloadTimeout = typed(new SimpleIntegerProperty(1000), Integer.class);
private final ObjectProperty<ExternalStartupBehaviour> externalStartupBehaviour =
typed(new SimpleObjectProperty<>(ExternalStartupBehaviour.TRAY), ExternalStartupBehaviour.class);
private final SingleSelectionField<ExternalStartupBehaviour> externalStartupBehaviourControl =
Field.ofSingleSelectionType(externalStartupBehaviourList, externalStartupBehaviour)
.render(() -> new TranslatableComboBoxControl<>());
private final BooleanProperty preferEditorTabs = typed(new SimpleBooleanProperty(true), Boolean.class);
private final BooleanField preferEditorTabsField =
BooleanField.ofBooleanType(preferEditorTabs).render(() -> new CustomToggleControl());
// Automatically update
// ====================
@ -529,15 +540,14 @@ public class AppPrefs {
"appearance",
Group.of(
"uiOptions",
Setting.of("language", languageControl, languageInternal),
Setting.of("theme", themeControl, theme),
Setting.of("useSystemFont", useSystemFontInternal),
Setting.of("tooltipDelay", tooltipDelayInternal, tooltipDelayMin, tooltipDelayMax)),
Setting.of("tooltipDelay", tooltipDelayInternal, tooltipDelayMin, tooltipDelayMax),
Setting.of("language", languageControl, languageInternal)),
Group.of("windowOptions", Setting.of("saveWindowLocation", saveWindowLocationInternal))),
Category.of(
"integrations",
"editor",
Group.of(
"editor",
Setting.of("editorProgram", externalEditorControl, externalEditor),
Setting.of("customEditorCommand", customEditorCommandControl, customEditorCommand)
.applyVisibility(VisibilityProperty.of(
@ -546,13 +556,15 @@ public class AppPrefs {
"editorReloadTimeout",
editorReloadTimeout,
editorReloadTimeoutMin,
editorReloadTimeoutMax)),
Group.of(
"terminal",
Setting.of("terminalProgram", terminalTypeControl, terminalType),
Setting.of("customTerminalCommand", customTerminalCommandControl, customTerminalCommand)
.applyVisibility(VisibilityProperty.of(
terminalType.isEqualTo(ExternalTerminalType.CUSTOM))))),
editorReloadTimeoutMax),
Setting.of("preferEditorTabs", preferEditorTabsField, preferEditorTabs))),
Category.of("terminal",
Group.of(
Setting.of("terminalProgram", terminalTypeControl, terminalType),
Setting.of("customTerminalCommand", customTerminalCommandControl, customTerminalCommand)
.applyVisibility(VisibilityProperty.of(
terminalType.isEqualTo(ExternalTerminalType.CUSTOM))),
Setting.of("preferTerminalTabs", preferTerminalTabsField, preferTerminalTabs))),
Category.of(
"developer",
Setting.of(

View file

@ -1,7 +1,7 @@
package io.xpipe.app.prefs;
import io.xpipe.app.comp.AppLayoutComp;
import io.xpipe.app.core.AppFont;
import io.xpipe.app.core.AppLayoutModel;
import io.xpipe.app.fxcomps.SimpleComp;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
@ -9,9 +9,9 @@ import org.controlsfx.control.MasterDetailPane;
public class PrefsComp extends SimpleComp {
private final AppLayoutComp layout;
private final AppLayoutModel layout;
public PrefsComp(AppLayoutComp layout) {
public PrefsComp(AppLayoutModel layout) {
this.layout = layout;
}

View file

@ -122,12 +122,9 @@ public abstract class StorageElement {
@Value
public static class Configuration {
boolean deletable;
boolean renameable;
boolean editable;
boolean refreshable;
public static Configuration defaultConfiguration() {
return new Configuration(true, true, true, true);
return new Configuration(true);
}
}
}

View file

@ -6,6 +6,7 @@ import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.impl.*;
import io.xpipe.core.util.SecretValue;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ObservableValue;
import javafx.geometry.Orientation;
@ -64,6 +65,11 @@ public class OptionsBuilder {
return this;
}
public OptionsBuilder disable() {
comp.disable(new SimpleBooleanProperty(true));
return this;
}
public OptionsBuilder nonNull(Validator v) {
var e = name;
var p = props.get(props.size() - 1);

View file

@ -42,7 +42,7 @@ clean=Clean
refresh=Refresh
remove=Remove
addDatabase=Add Database ...
addHost=Add Host ...
addHost=Add Remote Host ...
addShell=Add Environment ...
addCommand=Add Command ...
addOther=Add Other ...

View file

@ -64,6 +64,8 @@ developerMode=Developer mode
developerModeDescription=When enabled, you will have access to a variety of additional options that are useful for development.
editor=Editor
custom=Custom
preferEditorTabs=Prefer to open new tabs
preferEditorTabsDescription=Controls whether XPipe will try to open new tabs in your chosen editor instead of new windows.
customEditorCommand=Custom editor command
customEditorCommandDescription=The command to execute to open the custom editor. The placeholder string $file will be replaced by the quoted absolute file name when called.
editorReloadTimeout=Editor reload timeout
@ -97,6 +99,8 @@ terminalProgramDescription=The default terminal to use when opening any kind of
program=Program
customTerminalCommand=Custom terminal command
customTerminalCommandDescription=The command to execute to open the custom terminal. The placeholder string $cmd will be replaced by the quoted shell script file name when called.
preferTerminalTabs=Prefer to open new tabs
preferTerminalTabsDescription=Controls whether XPipe will try to open new tabs in your chosen terminal instead of new windows.
cmd=cmd.exe
powershell=Powershell
pwsh=Powershell Core

View file

@ -43,7 +43,7 @@
}
.store-entry-section-comp:expanded:even-depth {
-fx-background-color: -color-bg-subtle;
-fx-background-color: -color-neutral-subtle;
-fx-background-radius: 4px;
}

View file

@ -3,14 +3,14 @@ package io.xpipe.beacon.exchange;
import io.xpipe.beacon.RequestMessage;
import io.xpipe.beacon.ResponseMessage;
import java.util.List;
import java.util.Optional;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.stream.Collectors;
public class MessageExchanges {
private static Set<MessageExchange> ALL;
private static List<MessageExchange> ALL;
public static void loadAll() {
if (ALL == null) {
@ -19,7 +19,7 @@ public class MessageExchanges {
var ex = (MessageExchange) s.get();
return ex;
})
.collect(Collectors.toSet());
.collect(Collectors.toList());
}
}
@ -42,7 +42,7 @@ public class MessageExchanges {
.findAny();
}
public static Set<MessageExchange> getAll() {
public static List<MessageExchange> getAll() {
loadAll();
return ALL;
}

View file

@ -11,6 +11,10 @@ public class FileNames {
}
public static String toDirectory(String path) {
if (path == null) {
return null;
}
if (path.endsWith("/") || path.endsWith("\\")) {
return path;
}

View file

@ -1,3 +0,0 @@
package io.xpipe.core.store;
public interface LeafShellStore extends DataStore {}

View file

@ -1,4 +1,4 @@
package io.xpipe.ext.base.actions;
package io.xpipe.ext.base.action;
import io.xpipe.app.comp.store.GuiDsStoreCreator;
import io.xpipe.app.ext.ActionProvider;

View file

@ -0,0 +1,63 @@
package io.xpipe.ext.base.action;
import io.xpipe.app.browser.BrowserModel;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppLayoutModel;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.core.store.ShellStore;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ObservableValue;
import lombok.Value;
public class BrowseStoreAction implements ActionProvider {
@Value
static class Action implements ActionProvider.Action {
DataStoreEntry entry;
@Override
public boolean requiresJavaFXPlatform() {
return true;
}
@Override
public void execute() {
BrowserModel.DEFAULT.openFileSystemAsync(entry.getName(), entry.getStore().asNeeded(),null, new SimpleBooleanProperty());
AppLayoutModel.get().selectBrowser();
}
}
@Override
public DataStoreCallSite<?> getDataStoreCallSite() {
return new DataStoreCallSite<ShellStore>() {
@Override
public boolean isMajor(ShellStore o) {
return true;
}
@Override
public ObservableValue<String> getName(ShellStore store) {
return AppI18n.observable("browseFiles");
}
@Override
public String getIcon(ShellStore store) {
return "mdi2f-folder-open-outline";
}
@Override
public ActionProvider.Action createAction(ShellStore store) {
return new Action(DataStorage.get().getStoreEntry(store));
}
@Override
public Class<ShellStore> getApplicableClass() {
return ShellStore.class;
}
};
}
}

View file

@ -1,4 +1,4 @@
package io.xpipe.ext.base.actions;
package io.xpipe.ext.base.action;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
@ -32,7 +32,7 @@ public class DeleteStoreChildrenAction implements ActionProvider {
return new DataStoreCallSite<>() {
@Override
public boolean isMajor() {
public boolean isMajor(DataStore o) {
return false;
}

View file

@ -1,4 +1,4 @@
package io.xpipe.ext.base.actions;
package io.xpipe.ext.base.action;
import io.xpipe.app.comp.store.GuiDsStoreCreator;
import io.xpipe.app.core.AppI18n;
@ -57,7 +57,7 @@ public class EditStoreAction implements ActionProvider {
return new DataStoreCallSite<>() {
@Override
public boolean isMajor() {
public boolean isMajor(DataStore o) {
return false;
}
@ -76,11 +76,6 @@ public class EditStoreAction implements ActionProvider {
return DataStore.class;
}
@Override
public boolean isApplicable(DataStore o) {
return DataStorage.get().getStoreEntry(o).getConfiguration().isEditable();
}
@Override
public ObservableValue<String> getName(DataStore store) {
return AppI18n.observable("base.edit");

View file

@ -1,4 +1,4 @@
package io.xpipe.ext.base.actions;
package io.xpipe.ext.base.action;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;

View file

@ -1,4 +1,4 @@
package io.xpipe.ext.base.actions;
package io.xpipe.ext.base.action;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;

View file

@ -0,0 +1,117 @@
package io.xpipe.ext.base.action;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.util.TerminalHelper;
import io.xpipe.core.store.LaunchableStore;
import lombok.Value;
import java.util.List;
import java.util.UUID;
public class LaunchAction implements ActionProvider {
@Value
static class Action implements ActionProvider.Action {
DataStoreEntry entry;
@Override
public boolean requiresJavaFXPlatform() {
return false;
}
@Override
public void execute() throws Exception {
var storeName = entry.getName();
if (entry.getStore() instanceof LaunchableStore s) {
String command = s.prepareLaunchCommand(storeName);
if (command == null) {
return;
}
TerminalHelper.open(storeName, command);
}
}
}
@Override
public LauncherCallSite getLauncherCallSite() {
return new LauncherCallSite() {
@Override
public String getId() {
return "launch";
}
@Override
public ActionProvider.Action createAction(List<String> args) {
var entry = DataStorage.get()
.getStoreEntry(UUID.fromString(args.get(0)))
.orElseThrow();
return new Action(entry);
}
};
}
@Override
public DefaultDataStoreCallSite<?> getDefaultDataStoreCallSite() {
return new DefaultDataStoreCallSite<LaunchableStore>() {
@Override
public boolean isApplicable(LaunchableStore o) {
return DataStorage.get()
.getStoreEntryIfPresent(o)
.orElseThrow()
.getState()
.isUsable();
}
@Override
public ActionProvider.Action createAction(LaunchableStore store) {
return new Action(
DataStorage.get().getStoreEntryIfPresent(store).orElseThrow());
}
@Override
public Class<LaunchableStore> getApplicableClass() {
return LaunchableStore.class;
}
};
}
// @Override
// public DataStoreCallSite<?> getDataStoreCallSite() {
// return new DataStoreCallSite<LaunchableStore>() {
//
// @Override
// public boolean isApplicable(LaunchableStore o) throws Exception {
// return DataStorage.get().getStoreEntryIfPresent(o).orElseThrow().getState().isUsable();
// }
//
// @Override
// public ObservableValue<String> getName(LaunchableStore store) {
// return AppI18n.observable("openShell");
// }
//
// @Override
// public String getIcon(LaunchableStore store) {
// return "mdi2c-code-greater-than";
// }
//
// @Override
// public ActionProvider.Action createAction(LaunchableStore store) {
// return new Action(DataStorage.get().getStoreEntryIfPresent(store).orElseThrow());
// }
//
// @Override
// public Class<LaunchableStore> getApplicableClass() {
// return LaunchableStore.class;
// }
//
// @Override
// public boolean isMajor() {
// return true;
// }
// };
// }
}

View file

@ -0,0 +1,60 @@
package io.xpipe.ext.base.action;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.util.DesktopShortcuts;
import io.xpipe.core.store.ShellStore;
import javafx.beans.value.ObservableValue;
import lombok.Value;
public class LaunchShortcutAction implements ActionProvider {
@Value
static class Action implements ActionProvider.Action {
DataStoreEntry entry;
@Override
public boolean requiresJavaFXPlatform() {
return false;
}
@Override
public void execute() throws Exception {
DesktopShortcuts.create("xpipe://launch/" + entry.getUuid().toString(), entry.getName());
}
}
@Override
public DataStoreCallSite<?> getDataStoreCallSite() {
return new DataStoreCallSite<ShellStore>() {
@Override
public Action createAction(ShellStore store) {
return new Action(DataStorage.get().getStoreEntry(store));
}
@Override
public Class<ShellStore> getApplicableClass() {
return ShellStore.class;
}
@Override
public ObservableValue<String> getName(ShellStore store) {
return AppI18n.observable("createShortcut");
}
@Override
public String getIcon(ShellStore store) {
return "mdi2c-code-greater-than";
}
@Override
public boolean isMajor(ShellStore o) {
return false;
}
};
}
}

View file

@ -1,4 +1,4 @@
package io.xpipe.ext.base.actions;
package io.xpipe.ext.base.action;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
@ -31,7 +31,7 @@ public class RefreshStoreAction implements ActionProvider {
return new ActionProvider.DataStoreCallSite<>() {
@Override
public boolean isMajor() {
public boolean isMajor(DataStore o) {
return true;
}

View file

@ -1,4 +1,4 @@
package io.xpipe.ext.base.actions;
package io.xpipe.ext.base.action;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;

View file

@ -0,0 +1,61 @@
package io.xpipe.ext.base.action;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.ext.DataStoreProviders;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.app.util.ScanAlert;
import io.xpipe.core.store.ShellStore;
import javafx.beans.value.ObservableValue;
import lombok.Value;
public class ScanAction implements ActionProvider {
@Value
static class Action implements ActionProvider.Action {
DataStoreEntry entry;
@Override
public boolean requiresJavaFXPlatform() {
return true;
}
@Override
public void execute() {
ScanAlert.showAsync(entry, false);
}
}
@Override
public DataStoreCallSite<?> getDataStoreCallSite() {
return new DataStoreCallSite<ShellStore>() {
@Override
public boolean isMajor(ShellStore o) {
return DataStoreProviders.byStore(o).shouldHaveSubShells();
}
@Override
public ObservableValue<String> getName(ShellStore store) {
return AppI18n.observable("scanConnections");
}
@Override
public String getIcon(ShellStore store) {
return "mdi2p-playlist-plus";
}
@Override
public ActionProvider.Action createAction(ShellStore store) {
return new Action(DataStorage.get().getStoreEntry(store));
}
@Override
public Class<ShellStore> getApplicableClass() {
return ShellStore.class;
}
};
}
}

View file

@ -1,4 +1,4 @@
package io.xpipe.ext.base.actions;
package io.xpipe.ext.base.action;
import io.xpipe.app.core.AppActionLinkDetector;
import io.xpipe.app.core.AppI18n;

View file

@ -1,4 +1,4 @@
package io.xpipe.ext.base.actions;
package io.xpipe.ext.base.action;
import io.xpipe.app.browser.StandaloneFileBrowser;
import io.xpipe.app.core.AppI18n;

View file

@ -3,12 +3,12 @@ import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.ext.DataSourceProvider;
import io.xpipe.app.ext.DataStoreProvider;
import io.xpipe.ext.base.*;
import io.xpipe.ext.base.actions.*;
import io.xpipe.ext.base.action.*;
import io.xpipe.ext.base.browser.*;
open module io.xpipe.ext.base {
exports io.xpipe.ext.base;
exports io.xpipe.ext.base.actions;
exports io.xpipe.ext.base.action;
requires java.desktop;
requires io.xpipe.core;
@ -48,10 +48,14 @@ open module io.xpipe.ext.base {
JavapAction,
JarAction;
provides ActionProvider with
ScanAction,
LaunchAction,
LaunchShortcutAction,
AddStoreAction,
EditStoreAction,
ShareStoreAction,
FileBrowseAction,
BrowseStoreAction,
FileEditAction;
provides DataSourceProvider with
TextSourceProvider,

View file

@ -12,6 +12,9 @@ options=Options
newFile=New file
newLink=New link
linkName=Link name
scanConnections=Add connections ...
createShortcut=Create desktop shortcut
browseFiles=Browse Files
targetPath=Target path
newDirectory=New directory
terminator=Terminator