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();
if (entry.getState().getValue().equals(DataStoreEntry.State.COMPLETE_BUT_INVALID) || found == null) {
entry.getEntry().refresh(true);
entry.getExpanded().set(true);
}
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.augment.GrowAugment;
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.util.BindingsHelper;
import javafx.beans.binding.Bindings;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import org.kordamp.ikonli.javafx.FontIcon;
import java.util.List;
@ -27,15 +27,21 @@ public class StoreEntrySection extends Comp<CompStructure<VBox>> {
@Override
public CompStructure<VBox> createBase() {
var root = new StoreEntryComp(section.getWrapper()).apply(struc -> HBox.setHgrow(struc.get(), Priority.ALWAYS));
var icon = Comp.of(() -> {
var padding = new FontIcon("mdi2c-circle-double");
padding.setIconSize(14);
var pain = new StackPane(padding);
pain.setMinWidth(20);
pain.setMaxHeight(20);
return pain;
});
List<Comp<?>> topEntryList = top ? List.of(root) : List.of(icon, root);
var button = new IconButtonComp(
Bindings.createStringBinding(
() -> section.getWrapper().getExpanded().get()
&& section.getChildren().size() > 0
? "mdal-keyboard_arrow_down"
: "mdal-keyboard_arrow_right",
section.getWrapper().getExpanded()),
() -> {
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 shown = BindingsHelper.filteredContentBinding(
@ -58,8 +64,9 @@ public class StoreEntrySection extends Comp<CompStructure<VBox>> {
new HorizontalComp(topEntryList),
new HorizontalComp(List.of(spacer, content))
.apply(struc -> struc.get().setFillHeight(true))
.hide(BindingsHelper.persist(
Bindings.size(section.getChildren()).isEqualTo(0)))))
.hide(BindingsHelper.persist(Bindings.or(
Bindings.not(section.getWrapper().getExpanded()),
Bindings.size(section.getChildren()).isEqualTo(0))))))
.createStructure();
}
}

View file

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

View file

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