Search in sources :

Example 1 with InitPacketEditorEvent

use of com.xored.javafx.packeteditor.events.InitPacketEditorEvent 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)

Aggregations

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