All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.quellatalo.fx.explr.propdisplay.ObjectDisplay Maven / Gradle / Ivy

There is a newer version: 1.1.0.0
Show newest version
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