package com.cisco.trex.stl.gui.controllers.capture;

import com.exalttech.trex.ui.PortsManager;
import com.exalttech.trex.util.Initialization;
import javafx.fxml.FXML;
import javafx.scene.layout.HBox;
import org.controlsfx.control.CheckComboBox;

import java.util.List;

import static java.util.stream.Collectors.toList;

public class PortFilterController extends HBox {
    
    @FXML
    private CheckComboBox<String> rxFilter;
    
    @FXML
    private CheckComboBox<String> txFilter;

    public PortFilterController() {
        Initialization.initializeFXML(this, "/fxml/pkt_capture/PortFilter.fxml");

        List<String> choices = PortsManager.getInstance().getPortList().stream().map(port -> String.format("Port %s", port.getIndex())).collect(toList());
        
        rxFilter.getItems().addAll(choices);
        txFilter.getItems().addAll(choices);
    }

    public List<Integer> getRxPorts() {
        return rxFilter.getCheckModel().getCheckedIndices();
    }
    public List<Integer> getTxPorts() {
        return txFilter.getCheckModel().getCheckedIndices();
    }
}

@@ -89,16 +89,58 @@
 anager;%0A
+import com.exalttech.trex.ui.models.Port;%0A
 import c
@@ -647,89 +647,417 @@
 %22);%0A
-%0A        List%3CString%3E choices = PortsManager.getInstance().getPortList().stream()
+        PortsManager.getInstance().addPortServiceModeChangedListener(this::updateFilters);%0A        updateFilters();%0A    %7D%0A%0A    private void updateFilters() %7B%0A        rxFilter.getItems().clear();%0A        txFilter.getItems().clear();%0A        List%3CString%3E choices = PortsManager.getInstance()%0A                .getPortList()%0A                .stream()%0A                .filter(Port::getServiceMode)%0A                
 .map
@@ -1107,16 +1107,33 @@
 ndex()))
+%0A                
 .collect
@@ -1144,24 +1144,16 @@
 ist());%0A
-        
 %0A       
@@ -1237,24 +1237,28 @@
 ces);%0A    %7D%0A
+    
 %0A    public 

Update port filter on each service mode change