package com.exalttech.trex.ui.controllers.ports;

import com.exalttech.trex.ui.controllers.ports.tabs.PortAttributes;
import com.exalttech.trex.ui.controllers.ports.tabs.PortHardwareCounters;
import com.exalttech.trex.ui.controllers.ports.tabs.PortLayerConfiguration;
import com.exalttech.trex.ui.models.PortModel;
import com.exalttech.trex.util.Initialization;
import javafx.fxml.FXML;
import javafx.scene.control.TabPane;

public class PortView extends TabPane {
    
    @FXML
    private PortAttributes portAttributes;
    
    @FXML
    private PortLayerConfiguration layerConfig;
    
    @FXML
    PortHardwareCounters hardwareCounters;
    
    public PortView() {
        Initialization.initializeFXML(this, "/fxml/ports/Port.fxml");
        getSelectionModel().selectedItemProperty().addListener((observable, prevTab, currentTab) -> {
            if (currentTab.getId().equals("hardwareCountersTab")) {
                hardwareCounters.startPolling();
            } else {
                hardwareCounters.stopPolling();
            }
        });
    }

    public void loadModel(PortModel model) {
        portAttributes.bindModel(model);
        layerConfig.bindModel(model);
        boolean runPolling = getSelectionModel().selectedItemProperty().get().getId().equals("hardwareCountersTab");
        hardwareCounters.bindModel(model, runPolling);

        layerConfig.disableProperty().unbind();
        layerConfig.setDisable(model.isOwnedProperty().get());
        layerConfig.disableProperty().bind(model.isOwnedProperty().not());
    }
}

@@ -351,24 +351,62 @@
 ialization;%0A
+import javafx.beans.binding.Bindings;%0A
 import javaf
@@ -1471,16 +1471,17 @@
 Disable(
+!
 model.is
@@ -1547,16 +1547,41 @@
 ().bind(
+Bindings.or(%0A            
 model.is
@@ -1601,16 +1601,69 @@
 ().not()
+,%0A            model.transmitStateProperty())%0A        
 );%0A    %7D

Disable port configuration tab while Port in TX state