mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-24 08:30:27 +00:00
Various small fixes [stage]
This commit is contained in:
parent
52eb584c9c
commit
c9a07dd061
11 changed files with 42 additions and 43 deletions
|
@ -40,7 +40,7 @@ public class OpenFileSystemCache extends ShellControlCache {
|
|||
|
||||
private void loadUsers() throws Exception {
|
||||
var sc = model.getFileSystem().getShell().orElseThrow();
|
||||
if (sc.getOsType() == OsType.WINDOWS) {
|
||||
if (sc.getOsType() == OsType.WINDOWS || sc.getOsType() == OsType.MACOS) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public class StoreToggleComp extends SimpleComp {
|
|||
}
|
||||
|
||||
public static <T extends DataStore> StoreToggleComp enableToggle(
|
||||
String nameKey, StoreSection section, Function<T, Boolean> initial, BiConsumer<T, Boolean> setter) {
|
||||
String nameKey, StoreSection section, BooleanProperty value, BiConsumer<T, Boolean> setter) {
|
||||
var val = new SimpleBooleanProperty();
|
||||
ObservableValue<LabelGraphic> g = val.map(aBoolean -> aBoolean
|
||||
? new LabelGraphic.IconGraphic("mdi2c-circle-slice-8")
|
||||
|
@ -62,8 +62,7 @@ public class StoreToggleComp extends SimpleComp {
|
|||
nameKey,
|
||||
g,
|
||||
section,
|
||||
new SimpleBooleanProperty(
|
||||
initial.apply(section.getWrapper().getEntry().getStore().asNeeded())),
|
||||
value,
|
||||
v -> {
|
||||
setter.accept(section.getWrapper().getEntry().getStore().asNeeded(), v);
|
||||
});
|
||||
|
|
|
@ -7,6 +7,7 @@ import io.xpipe.app.fxcomps.util.PlatformThread;
|
|||
import javafx.beans.property.Property;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.css.PseudoClass;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.Region;
|
||||
|
@ -32,6 +33,7 @@ public class ToggleSwitchComp extends SimpleComp {
|
|||
event.consume();
|
||||
}
|
||||
});
|
||||
s.setAlignment(Pos.CENTER);
|
||||
s.getStyleClass().add("toggle-switch-comp");
|
||||
s.setSelected(selected.getValue());
|
||||
s.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
||||
|
|
|
@ -7,8 +7,10 @@ import io.xpipe.app.comp.store.StoreViewState;
|
|||
import io.xpipe.app.fxcomps.util.BindingsHelper;
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
import io.xpipe.app.storage.DataStoreEntry;
|
||||
import io.xpipe.app.util.ThreadHelper;
|
||||
import io.xpipe.core.store.EnabledStoreState;
|
||||
import io.xpipe.core.store.StatefulDataStore;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
|
||||
public interface EnabledParentStoreProvider extends DataStoreProvider {
|
||||
|
||||
|
@ -18,10 +20,26 @@ public interface EnabledParentStoreProvider extends DataStoreProvider {
|
|||
return StoreEntryComp.create(sec, null, preferLarge);
|
||||
}
|
||||
|
||||
var enabled = StoreToggleComp.<StatefulDataStore<EnabledStoreState>>enableToggle(
|
||||
null, sec, s -> s.getState().isEnabled(), (s, aBoolean) -> {
|
||||
EnabledStoreState initialState = sec.getWrapper().getEntry().getStorePersistentState();
|
||||
var enabled = new SimpleBooleanProperty(initialState.isEnabled());
|
||||
sec.getWrapper().getPersistentState().subscribe((newValue) -> {
|
||||
EnabledStoreState s = sec.getWrapper().getEntry().getStorePersistentState();
|
||||
enabled.set(s.isEnabled());
|
||||
});
|
||||
|
||||
var toggle = StoreToggleComp.<StatefulDataStore<EnabledStoreState>>enableToggle(
|
||||
null, sec, enabled, (s, aBoolean) -> {
|
||||
var state = s.getState().toBuilder().enabled(aBoolean).build();
|
||||
s.setState(state);
|
||||
|
||||
var children = DataStorage.get().getStoreChildren(sec.getWrapper().getEntry());
|
||||
ThreadHelper.runFailableAsync(() -> {
|
||||
for (DataStoreEntry child : children) {
|
||||
if (child.getStorePersistentState() instanceof EnabledStoreState enabledStoreState) {
|
||||
child.setStorePersistentState(enabledStoreState.toBuilder().enabled(aBoolean).build());
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var e = sec.getWrapper().getEntry();
|
||||
|
@ -29,12 +47,12 @@ public interface EnabledParentStoreProvider extends DataStoreProvider {
|
|||
if (parent.isPresent()) {
|
||||
var parentWrapper = StoreViewState.get().getEntryWrapper(parent.get());
|
||||
// Disable selection if parent is already made enabled
|
||||
enabled.setCustomVisibility(BindingsHelper.map(parentWrapper.getPersistentState(), o -> {
|
||||
toggle.setCustomVisibility(BindingsHelper.map(parentWrapper.getPersistentState(), o -> {
|
||||
EnabledStoreState state = (EnabledStoreState) o;
|
||||
return !state.isEnabled();
|
||||
}));
|
||||
}
|
||||
|
||||
return StoreEntryComp.create(sec, enabled, preferLarge);
|
||||
return StoreEntryComp.create(sec, toggle, preferLarge);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package io.xpipe.app.ext;
|
||||
|
||||
import io.xpipe.app.comp.base.StoreToggleComp;
|
||||
import io.xpipe.app.comp.store.StoreEntryComp;
|
||||
import io.xpipe.app.comp.store.StoreSection;
|
||||
import io.xpipe.app.storage.DataStoreEntry;
|
||||
import io.xpipe.core.store.EnabledStoreState;
|
||||
import io.xpipe.core.store.StatefulDataStore;
|
||||
|
||||
public interface EnabledStoreProvider extends DataStoreProvider {
|
||||
|
||||
@Override
|
||||
default StoreEntryComp customEntryComp(StoreSection sec, boolean preferLarge) {
|
||||
if (sec.getWrapper().getValidity().getValue() == DataStoreEntry.Validity.LOAD_FAILED) {
|
||||
return StoreEntryComp.create(sec, null, preferLarge);
|
||||
}
|
||||
|
||||
var enabled = StoreToggleComp.<StatefulDataStore<EnabledStoreState>>enableToggle(
|
||||
null, sec, s -> s.getState().isEnabled(), (s, aBoolean) -> {
|
||||
var state = s.getState().toBuilder().enabled(aBoolean).build();
|
||||
s.setState(state);
|
||||
});
|
||||
return StoreEntryComp.create(sec, enabled, preferLarge);
|
||||
}
|
||||
}
|
|
@ -31,7 +31,9 @@ public abstract class LabelGraphic {
|
|||
|
||||
@Override
|
||||
public Node createGraphicNode() {
|
||||
return new FontIcon(icon);
|
||||
var fi = new FontIcon(icon);
|
||||
fi.getStyleClass().add("graphic");
|
||||
return fi;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,7 +46,7 @@ public abstract class LabelGraphic {
|
|||
|
||||
@Override
|
||||
public Node createGraphicNode() {
|
||||
return PrettyImageHelper.ofFixedSizeSquare(file, size).createRegion();
|
||||
return PrettyImageHelper.ofFixedSizeSquare(file, size).styleClass("graphic").createRegion();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +58,7 @@ public abstract class LabelGraphic {
|
|||
|
||||
@Override
|
||||
public Node createGraphicNode() {
|
||||
return comp.createRegion();
|
||||
return comp.styleClass("graphic").createRegion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,14 +67,18 @@
|
|||
-fx-border-radius: 0 6 0 0;
|
||||
}
|
||||
|
||||
.toggle-switch:has-graphic .label {
|
||||
.toggle-switch-comp:has-graphic .label {
|
||||
-fx-font-size: 1.7em;
|
||||
}
|
||||
|
||||
.toggle-switch:has-graphic {
|
||||
.toggle-switch-comp:has-graphic {
|
||||
-fx-font-size: 0.75em;
|
||||
}
|
||||
|
||||
.toggle-switch-comp .label-container {
|
||||
-fx-padding: -0.2em 0 0 0;
|
||||
}
|
||||
|
||||
.store-layout .split-pane-divider {
|
||||
-fx-background-color: transparent;
|
||||
}
|
||||
|
|
|
@ -10,17 +10,15 @@ import io.xpipe.app.fxcomps.impl.DataStoreChoiceComp;
|
|||
import io.xpipe.app.storage.DataStoreEntry;
|
||||
import io.xpipe.app.util.OptionsBuilder;
|
||||
import io.xpipe.core.store.DataStore;
|
||||
|
||||
import javafx.beans.property.Property;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ScriptGroupStoreProvider implements EnabledStoreProvider, DataStoreProvider {
|
||||
public class ScriptGroupStoreProvider implements EnabledParentStoreProvider, DataStoreProvider {
|
||||
|
||||
@Override
|
||||
public DataStoreUsageCategory getUsageCategory() {
|
||||
|
|
|
@ -17,6 +17,7 @@ import io.xpipe.app.util.ThreadHelper;
|
|||
import io.xpipe.core.store.DataStore;
|
||||
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
|
||||
|
@ -34,7 +35,7 @@ public abstract class AbstractServiceGroupStoreProvider implements DataStoreProv
|
|||
}
|
||||
|
||||
private StoreToggleComp createToggleComp(StoreSection sec) {
|
||||
var t = StoreToggleComp.<AbstractServiceGroupStore<?>>enableToggle(null, sec, g -> false, (g, aBoolean) -> {
|
||||
var t = StoreToggleComp.<AbstractServiceGroupStore<?>>enableToggle(null, sec, new SimpleBooleanProperty(false), (g, aBoolean) -> {
|
||||
var children = DataStorage.get().getStoreChildren(sec.getWrapper().getEntry());
|
||||
ThreadHelper.runFailableAsync(() -> {
|
||||
for (DataStoreEntry child : children) {
|
||||
|
|
Binary file not shown.
2
version
2
version
|
@ -1 +1 @@
|
|||
11.0-13
|
||||
11.0-14
|
||||
|
|
Loading…
Reference in a new issue