Search in sources :

Example 1 with PktCaptureService

use of com.cisco.trex.stl.gui.services.capture.PktCaptureService in project trex-stateless-gui by cisco-system-traffic-generator.

the class PacketCaptureDashboardController method initialize.

@Override
public void initialize(URL location, ResourceBundle resources) {
    final PktCaptureService pktCaptureService = new PktCaptureService();
    monitorController.setPktCaptureService(pktCaptureService);
    recordController.setPktCaptureService(pktCaptureService);
    monitorController.setStartHandler(() -> {
        startMonitorBtn.setDisable(true);
        stopMonitorBtn.setDisable(false);
        monitorIsActive = true;
    });
    monitorController.setStopHandler(() -> {
        stopMonitorBtn.setDisable(true);
        startMonitorBtn.setDisable(false);
        monitorIsActive = false;
    });
    startMonitorBtn.setOnMouseClicked(event -> {
        monitorController.startCapture();
    });
    stopMonitorBtn.setOnMouseClicked(event -> {
        monitorController.stopCapture();
    });
    clearMonitorBtn.setOnMouseClicked(event -> monitorController.clearCapture());
    startWiresharkBtn.setOnMouseClicked(event -> monitorController.startWireshark());
    startRecorderBtn.setOnMouseClicked(event -> {
        Dialog<AddRecordPojo> dialog = createAddRecorderDialog("Add Recorder", new AddRecorderController());
        Optional<AddRecordPojo> addRecordPojo = dialog.showAndWait();
        addRecordPojo.ifPresent(pojo -> {
            try {
                monitorController.startRecorder(pojo.rxPorts, pojo.txPorts, pojo.filter, pojo.pktLimit);
            } catch (PktCaptureServiceException e) {
                TrexAlertBuilder.build().setType(Alert.AlertType.ERROR).setTitle("Recorder error").setHeader("Unable to start the recorder").setContent(e.getLocalizedMessage()).getAlert().showAndWait();
            }
        });
    });
    captureTabPane.getSelectionModel().selectedItemProperty().addListener((o, oldVal, newVal) -> {
        boolean isMonitorTabSelected = newVal.getText().equalsIgnoreCase("Monitor");
        updateButtonBar(isMonitorTabSelected);
    });
    updateButtonBar(true);
}
Also used : PktCaptureService(com.cisco.trex.stl.gui.services.capture.PktCaptureService) PktCaptureServiceException(com.cisco.trex.stl.gui.services.capture.PktCaptureServiceException)

Aggregations

PktCaptureService (com.cisco.trex.stl.gui.services.capture.PktCaptureService)1 PktCaptureServiceException (com.cisco.trex.stl.gui.services.capture.PktCaptureServiceException)1