use of com.exalttech.trex.ui.models.datastore.ConnectionsWrapper 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.ConnectionsWrapper in project trex-stateless-gui by cisco-system-traffic-generator.
the class ConnectDialogController method updateConnectionsList.
/**
* Save and update the connections list in external connection file
*/
private void updateConnectionsList() {
try {
ConnectionsWrapper connections = new ConnectionsWrapper();
connections.setConnectionList(new ArrayList<>(connectionMap.values()));
XMLFileManager.saveXML("connections.xml", connections, ConnectionsWrapper.class);
} catch (Exception ignored) {
}
}
use of com.exalttech.trex.ui.models.datastore.ConnectionsWrapper in project trex-stateless-gui by cisco-system-traffic-generator.
the class ConnectDialogController method initializeConnections.
/**
* Initialize and fill connections list from external connection file
*/
private void initializeConnections() {
connectionsCB.getItems().clear();
connectionsCB.valueProperty().addListener(this);
ConnectionsWrapper connection = (ConnectionsWrapper) XMLFileManager.loadXML("connections.xml", ConnectionsWrapper.class);
if (connection != null && connection.getConnectionList() != null) {
fillConnectionItem(connection.getConnectionList());
}
String username = System.getProperty("user.name");
nameTextField.setText(username);
}
Aggregations