The add ability to expand and collapse connections

This commit is contained in:
crschnick 2023-04-23 14:30:45 +00:00
parent 6d415c6fe3
commit 4e124466f8
4 changed files with 26 additions and 13 deletions

View file

@ -159,6 +159,7 @@ public class StoreEntryComp extends SimpleComp {
var found = entry.getDefaultActionProvider().getValue(); var found = entry.getDefaultActionProvider().getValue();
if (entry.getState().getValue().equals(DataStoreEntry.State.COMPLETE_BUT_INVALID) || found == null) { if (entry.getState().getValue().equals(DataStoreEntry.State.COMPLETE_BUT_INVALID) || found == null) {
entry.getEntry().refresh(true); entry.getEntry().refresh(true);
entry.getExpanded().set(true);
} }
if (found != null) { if (found != null) {

View file

@ -5,12 +5,12 @@ import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.CompStructure; import io.xpipe.app.fxcomps.CompStructure;
import io.xpipe.app.fxcomps.augment.GrowAugment; import io.xpipe.app.fxcomps.augment.GrowAugment;
import io.xpipe.app.fxcomps.impl.HorizontalComp; import io.xpipe.app.fxcomps.impl.HorizontalComp;
import io.xpipe.app.fxcomps.impl.IconButtonComp;
import io.xpipe.app.fxcomps.impl.VerticalComp; import io.xpipe.app.fxcomps.impl.VerticalComp;
import io.xpipe.app.fxcomps.util.BindingsHelper; import io.xpipe.app.fxcomps.util.BindingsHelper;
import javafx.beans.binding.Bindings; import javafx.beans.binding.Bindings;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import org.kordamp.ikonli.javafx.FontIcon;
import java.util.List; import java.util.List;
@ -27,15 +27,21 @@ public class StoreEntrySection extends Comp<CompStructure<VBox>> {
@Override @Override
public CompStructure<VBox> createBase() { public CompStructure<VBox> createBase() {
var root = new StoreEntryComp(section.getWrapper()).apply(struc -> HBox.setHgrow(struc.get(), Priority.ALWAYS)); var root = new StoreEntryComp(section.getWrapper()).apply(struc -> HBox.setHgrow(struc.get(), Priority.ALWAYS));
var icon = Comp.of(() -> { var button = new IconButtonComp(
var padding = new FontIcon("mdi2c-circle-double"); Bindings.createStringBinding(
padding.setIconSize(14); () -> section.getWrapper().getExpanded().get()
var pain = new StackPane(padding); && section.getChildren().size() > 0
pain.setMinWidth(20); ? "mdal-keyboard_arrow_down"
pain.setMaxHeight(20); : "mdal-keyboard_arrow_right",
return pain; section.getWrapper().getExpanded()),
}); () -> {
List<Comp<?>> topEntryList = top ? List.of(root) : List.of(icon, root); section.getWrapper().toggleExpanded();
})
.apply(struc -> struc.get().setPrefWidth(40))
.disable(BindingsHelper.persist(
Bindings.size(section.getChildren()).isEqualTo(0)))
.grow(false, true);
List<Comp<?>> topEntryList = List.of(button, root);
var all = section.getChildren(); var all = section.getChildren();
var shown = BindingsHelper.filteredContentBinding( var shown = BindingsHelper.filteredContentBinding(
@ -58,8 +64,9 @@ public class StoreEntrySection extends Comp<CompStructure<VBox>> {
new HorizontalComp(topEntryList), new HorizontalComp(topEntryList),
new HorizontalComp(List.of(spacer, content)) new HorizontalComp(List.of(spacer, content))
.apply(struc -> struc.get().setFillHeight(true)) .apply(struc -> struc.get().setFillHeight(true))
.hide(BindingsHelper.persist( .hide(BindingsHelper.persist(Bindings.or(
Bindings.size(section.getChildren()).isEqualTo(0))))) Bindings.not(section.getWrapper().getExpanded()),
Bindings.size(section.getChildren()).isEqualTo(0))))))
.createStructure(); .createStructure();
} }
} }

View file

@ -33,6 +33,7 @@ public class StoreEntryWrapper implements StorageFilter.Filterable {
private final BooleanProperty renamable = new SimpleBooleanProperty(); private final BooleanProperty renamable = new SimpleBooleanProperty();
private final BooleanProperty refreshable = new SimpleBooleanProperty(); private final BooleanProperty refreshable = new SimpleBooleanProperty();
private final BooleanProperty deletable = new SimpleBooleanProperty(); private final BooleanProperty deletable = new SimpleBooleanProperty();
private final BooleanProperty expanded = new SimpleBooleanProperty(true);
public StoreEntryWrapper(DataStoreEntry entry) { public StoreEntryWrapper(DataStoreEntry entry) {
this.entry = entry; this.entry = entry;
@ -157,6 +158,10 @@ public class StoreEntryWrapper implements StorageFilter.Filterable {
}); });
} }
public void toggleExpanded() {
this.expanded.set(!expanded.getValue());
}
@Override @Override
public boolean shouldShow(String filter) { public boolean shouldShow(String filter) {
return getName().toLowerCase().contains(filter.toLowerCase()) return getName().toLowerCase().contains(filter.toLowerCase())

View file

@ -23,7 +23,7 @@
-fx-opacity: 0.5; -fx-opacity: 0.5;
} }
.store-entry-comp { .store-entry-comp {
-fx-padding: 6px; -fx-padding: 6px 6px 6px 0;
} }