Development Guide

PDU Metadata Pane

PDU Metadata Pane is abstract class used to expand the PDU Editor by adding new components to it.

PDU Metadata Pane class

com.warxim.petep.gui.component.PduMetadataPane
/**
 * Configuration pane for PDU meta data configuration.
 * <p>Can be used to create custom controls for specific PDU types.</p>
 */
@PetepAPI
public abstract class PduMetadataPane extends AnchorPane {
    /**
     * Creates configuration pane from specified template and sets the object as controller.
     * @param template Path to FXML template
     * @throws IOException If the template could not be loaded
     */
    protected PduMetadataPane(String template) throws IOException {
        var loader = new FXMLLoader(getClass().getResource(template));
        loader.setRoot(this);
        loader.setController(this);
        loader.load();
        getStylesheets().add(GuiConstant.MAIN_CSS_PATH);
    }

    /**
     * Creates PDU using provided data and data in metadata pane inputs.
     * @param proxy Proxy of the PDU
     * @param connection Connection for sending the PDU
     * @param destination Destination of the PDU
     * @param buffer Data buffer
     * @param size Size of the data in the buffer
     * @param charset Charset of the data in the buffer
     * @param tags Set of PDU tags
     * @return Created PDU
     */
    public abstract Optional<PDU> createPdu(
            Proxy proxy,
            Connection connection,
            PduDestination destination,
            byte[] buffer,
            int size,
            Charset charset,
            Set<String> tags);

    /**
     * Sets PDU to the pane.
     * @param pdu PDU to be set
     */
    public abstract void setPdu(PDU pdu);

    /**
     * Clears metadata content.
     */
    public abstract void clear();

    /**
     * Checks whether the metadata are valid.
     * @return {@code true} if metadata are valid
     */
    public abstract boolean isValid();

}

PDU Metadata Pane fxml

Since PduMetadataPane is based on AnchorPane, your FXML template has look something like this (notice the root element):

/fxml/ExamplePduMetadataPane.fxml
<?xml version="1.0" encoding="UTF-8"?>

<fx:root prefHeight="69.0" prefWidth="249.0" type="javafx.scene.layout.AnchorPane" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
    <children>
        [...]
    </children>
</fx:root>