Search in sources :

Example 1 with ConnectionsWrapper

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;
        }
    }
}
Also used : ConnectionsWrapper(com.exalttech.trex.ui.models.datastore.ConnectionsWrapper) Connection(com.exalttech.trex.ui.models.datastore.Connection) InitPacketEditorEvent(com.xored.javafx.packeteditor.events.InitPacketEditorEvent) Subscribe(com.google.common.eventbus.Subscribe)

Example 2 with ConnectionsWrapper

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) {
    }
}
Also used : ConnectionsWrapper(com.exalttech.trex.ui.models.datastore.ConnectionsWrapper) UnknownHostException(java.net.UnknownHostException)

Example 3 with ConnectionsWrapper

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);
}
Also used : ConnectionsWrapper(com.exalttech.trex.ui.models.datastore.ConnectionsWrapper)

Aggregations

ConnectionsWrapper (com.exalttech.trex.ui.models.datastore.ConnectionsWrapper)3 Connection (com.exalttech.trex.ui.models.datastore.Connection)1 Subscribe (com.google.common.eventbus.Subscribe)1 InitPacketEditorEvent (com.xored.javafx.packeteditor.events.InitPacketEditorEvent)1 UnknownHostException (java.net.UnknownHostException)1