Search in sources :

Example 1 with Connection

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;
        }
    }
}
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 Connection

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

Example 3 with Connection

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);
}
Also used : Connection(com.exalttech.trex.ui.models.datastore.Connection) Alert(javafx.scene.control.Alert)

Aggregations

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