Search in sources :

Example 1 with StatsStorage

use of com.cisco.trex.stl.gui.storages.StatsStorage in project trex-stateless-gui by cisco-system-traffic-generator.

the class MainViewController method initialize.

@Override
public void initialize(URL url, ResourceBundle rb) {
    portManager = PortsManager.getInstance();
    portManager.setPortManagerHandler(this);
    statsTableGenerator = new StatsTableGenerator();
    leftArrow = new Image("/icons/arrow_left.png");
    rightArrow = new Image("/icons/arrow_right.png");
    initializeInlineComponent();
    logsContainer.setDisable(false);
    eventBus = TrexApp.injector.getInstance(EventBus.class);
    statsStorage = TrexApp.injector.getInstance(StatsStorage.class);
    portView.visibleProperty().bind(portViewVisibilityProperty);
    statTableContainer.visibleProperty().bindBidirectional(systemInfoVisibilityProperty);
    ConnectionManager.getInstance().addDisconnectListener(() -> resetApplication(true));
    // Handle update port state event
    AsyncResponseManager.getInstance().asyncEventObjectProperty().addListener((observable, oldValue, newVal) -> {
        switch(newVal.getType()) {
            case PORT_RELEASED:
            case PORT_ACQUIRED:
            case PORT_ATTR_CHANGED:
            case PORT_STARTED:
            case PORT_STOPPED:
                final int portId = newVal.getData().getAsJsonPrimitive("port_id").getAsInt();
                PortModel portModel = portManager.getPortModel(portId);
                if (ConnectionManager.getInstance().isConnected()) {
                    Platform.runLater(() -> {
                        portManager.updatedPorts(Arrays.asList(portModel.getIndex()));
                        onPortListUpdated(true);
                    });
                }
                break;
            case SERVER_STOPPED:
                resetApplication(true);
                break;
        }
    });
}
Also used : StatsStorage(com.cisco.trex.stl.gui.storages.StatsStorage) PortModel(com.exalttech.trex.ui.models.PortModel) StatsTableGenerator(com.exalttech.trex.ui.views.statistics.StatsTableGenerator) EventBus(com.google.common.eventbus.EventBus) Image(javafx.scene.image.Image)

Aggregations

StatsStorage (com.cisco.trex.stl.gui.storages.StatsStorage)1 PortModel (com.exalttech.trex.ui.models.PortModel)1 StatsTableGenerator (com.exalttech.trex.ui.views.statistics.StatsTableGenerator)1 EventBus (com.google.common.eventbus.EventBus)1 Image (javafx.scene.image.Image)1