use of com.exalttech.trex.ui.models.datastore.Connection in project trex-stateless-gui by cisco-system-traffic-generator.
the class MainViewController method handleScapyClientNeedConnectEvent.
@Subscribe
public void handleScapyClientNeedConnectEvent(ScapyClientNeedConnectEvent event) {
LogsController.getInstance().getView().setDisable(false);
if (!ConnectionManager.getInstance().isScapyConnected()) {
ConnectionsWrapper connection = (ConnectionsWrapper) XMLFileManager.loadXML("connections.xml", ConnectionsWrapper.class);
Connection lastUsed = null;
for (Connection con : connection.getConnectionList()) {
if (con.isLastUsed()) {
lastUsed = con;
}
}
if (lastUsed == null) {
ConnectionManager.getInstance().connectScapy();
} else {
ConnectionManager.getInstance().connectScapy(lastUsed.getIp(), lastUsed.getScapyPort());
}
if (!ConnectionManager.getInstance().isScapyConnected()) {
openConnectDialog();
}
if (ConnectionManager.getInstance().isScapyConnected()) {
eventBus.post(new InitPacketEditorEvent());
return;
}
}
}
use of com.exalttech.trex.ui.models.datastore.Connection in project trex-stateless-gui by cisco-system-traffic-generator.
the class ConnectDialogController method fillConnectionItem.
/**
* Fill connections item
*
* @param connectionList
*/
private void fillConnectionItem(List<Connection> connectionList) {
connectionsCB.getItems().clear();
connectionMap.clear();
Connection lastUsed = null;
for (Connection con : connectionList) {
if (con.isLastUsed()) {
lastUsed = con;
}
con.setLastUsed(false);
connectionsCB.getItems().add(con.getIp());
connectionMap.put(con.getIp(), con);
}
if (lastUsed != null) {
connectionsCB.getSelectionModel().select(lastUsed.getIp());
}
}
use of com.exalttech.trex.ui.models.datastore.Connection in project trex-stateless-gui by cisco-system-traffic-generator.
the class ConnectDialogController method connectionValidationFinished.
private void connectionValidationFinished(final Stage stage, final String error) {
if (error != null) {
final Alert errMsg = Util.getAlert(Alert.AlertType.ERROR);
errMsg.setContentText(error);
errMsg.show();
} else {
final String ip = connectionsCB.getEditor().getText();
Connection con = new Connection(ip, rpcPortTextField.getText(), asyncPortTextField.getText(), scapyPortTextField.getText(), nameTextField.getText(), fullControlRB.isSelected());
con.setLastUsed(true);
connectionMap.put(ip, con);
updateConnectionsList();
ConnectionManager.getInstance().setConnected(true);
stage.hide();
}
isConnectionInProgress.set(false);
}
Aggregations