io.github.quellatalo.fx.explr.propdisplay.ObjectDisplay Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of object-explorer Show documentation
Show all versions of object-explorer Show documentation
A javafx control for browsing object structure and data.
package io.github.quellatalo.fx.explr.propdisplay;
import javafx.fxml.FXML;
import javafx.scene.control.Hyperlink;
import java.util.Collection;
import java.util.Map;
import java.util.function.Consumer;
public class ObjectDisplay extends PropertyDisplay {
@FXML
private Hyperlink hplValue;
private T value;
private Consumer> actionConsumer;
public ObjectDisplay() {
hplValue = new Hyperlink();
getChildren().add(hplValue);
hplValue.setOnAction(event -> actionConsumer.accept(this));
}
@Override
public String getText() {
return hplValue.getText();
}
public void setText(String text) {
hplValue.setText(text);
}
public T getValue() {
return value;
}
@Override
public void setValue(T value) {
this.value = value;
if (value == null) {
hplValue.setText("NULL");
} else if (!(value instanceof Map || value instanceof Collection || value.getClass().isArray())) {
hplValue.setText(value.toString());
}
}
public Consumer> getActionConsumer() {
return actionConsumer;
}
public void setActionConsumer(Consumer> actionConsumer) {
this.actionConsumer = actionConsumer;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy