This commit is contained in:
crschnick
2025-08-05 21:58:48 +00:00
parent a1e3c57fd7
commit c6a2d088b6
2 changed files with 11 additions and 10 deletions
@@ -5,17 +5,15 @@ import javafx.beans.property.*;
import javafx.collections.FXCollections;
import lombok.Builder;
import lombok.Value;
import lombok.val;
import java.util.ArrayList;
import java.util.List;
@Builder
@Value
public class HostAddressChoice {
Property<HostAddress> value;
boolean allowAdd;
boolean allowMutation;
String translationKey;
boolean includeDescription;
@@ -29,7 +27,7 @@ public class HostAddressChoice {
} else {
options.name(translationKey);
}
options.addComp(new HostAddressChoiceComp(val, list, allowAdd))
options.addComp(new HostAddressChoiceComp(val, list, allowMutation))
.addProperty(val);
options.bind(
() -> {
@@ -56,13 +56,14 @@ public class HostAddressChoiceComp extends Comp<CompStructure<HBox>> {
currentAddress.setValue(null);
});
addButton.disable(!mutable);
addButton.styleClass(Styles.CENTER_PILL).grow(false, true);
addButton.tooltipKey("addAnotherHostName");
var nodes = new ArrayList<Comp<?>>();
nodes.add(combo);
nodes.add(addButton);
if (mutable) {
nodes.add(addButton);
}
var layout = new InputGroupComp(nodes).apply(struc -> struc.get().setFillHeight(true));
layout.apply(struc -> {
@@ -103,9 +104,11 @@ public class HostAddressChoiceComp extends Comp<CompStructure<HBox>> {
var hbox = new HBox();
hbox.getChildren().add(new Label(item));
hbox.getChildren().add(new Spacer());
hbox.getChildren().add(new IconButtonComp("mdi2t-trash-can-outline", () -> {
allAddresses.remove(item);
}).createRegion());
if (mutable) {
hbox.getChildren().add(new IconButtonComp("mdi2t-trash-can-outline", () -> {
allAddresses.remove(item);
}).createRegion());
}
setGraphic(hbox);
setText(null);
@@ -133,7 +136,7 @@ public class HostAddressChoiceComp extends Comp<CompStructure<HBox>> {
});
struc.get().pseudoClassStateChanged(PseudoClass.getPseudoClass("empty"), allAddresses.isEmpty());
struc.get().disarm();
struc.get().setEditable(mutable);
});
combo.hgrow();
combo.styleClass(Styles.LEFT_PILL);