use of com.exalttech.trex.ui.models.PortModel in project trex-stateless-gui by cisco-system-traffic-generator.
the class MainViewController method loadPortModel.
/**
* Build port detail table
*/
private void loadPortModel() {
PortModel model = portManager.getPortModel(getSelectedPortIndex());
portManager.updatedPorts(Arrays.asList(getSelectedPortIndex()));
Optional<Integer> optional = portManager.getOwnedPortIndexes().stream().filter(idx -> idx.equals(getSelectedPortIndex())).findFirst();
optional.ifPresent(val -> model.setIsOwned(true));
portView.loadModel(model);
}
use of com.exalttech.trex.ui.models.PortModel 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);
portView.visibleProperty().bind(portViewVisibilityProperty);
statTableContainer.visibleProperty().bindBidirectional(systemInfoVisibilityProperty);
// Handle update port state event
AsyncResponseManager.getInstance().asyncEventObjectProperty().addListener((observable, oldValue, newVal) -> {
TrexEvent event = newVal;
int portId = event.getData().getAsJsonPrimitive("port_id").getAsInt();
PortModel portModel = portManager.getPortModel(portId);
switch(event.getType()) {
case PORT_RELEASED:
case PORT_ACQUIRED:
case PORT_ATTR_CHANGED:
case PORT_STARTED:
case PORT_STOPPED:
if (ConnectionManager.getInstance().isConnected()) {
Platform.runLater(() -> {
portManager.updatedPorts(Arrays.asList(portModel.getIndex()));
onPortListUpdated(true);
});
boolean isAllPortsStopped = true;
for (final Port port : portManager.getPortList()) {
if (port.getIndex() == port.getIndex()) {
continue;
}
final String portStatus = port.getStatus();
if (portStatus.equals("TX") || portStatus.equals("PAUSE")) {
isAllPortsStopped = false;
break;
}
}
}
break;
case SERVER_STOPPED:
resetApplication(true);
break;
}
});
}
use of com.exalttech.trex.ui.models.PortModel in project trex-stateless-gui by cisco-system-traffic-generator.
the class PortsManager method getPortModel.
public PortModel getPortModel(int portIndex) {
PortModel model = portModels.get(portIndex);
if (model == null) {
model = PortModel.createModelFrom(portList.get(portIndex));
portModels.put(portIndex, model);
}
return model;
}
Aggregations