use of com.exalttech.trex.ui.util.TrexAlertBuilder in project trex-stateless-gui by cisco-system-traffic-generator.
the class ConnectDialogController method validateInput.
private boolean validateInput() {
boolean isValid = true;
TrexAlertBuilder errorBuilder = TrexAlertBuilder.build().setType(Alert.AlertType.ERROR);
if (connectionsCB.getEditor().getText() == null || !Util.isValidAddress(connectionsCB.getEditor().getText())) {
errorBuilder.setContent("Invalid TRex Host Name or IP address");
isValid = false;
} else if (!Util.isValidPort(rpcPortTextField.getText())) {
errorBuilder.setContent("Invalid TRex Sync Port Number(" + rpcPortTextField.getText() + ")");
isValid = false;
} else if (!Util.isValidPort(asyncPortTextField.getText())) {
errorBuilder.setContent("Invalid Async Port Number(" + asyncPortTextField.getText() + ")");
isValid = false;
} else if (!Util.isValidPort(scapyPortTextField.getText())) {
errorBuilder.setContent("Invalid Scapy Port Number(" + scapyPortTextField.getText() + ")");
isValid = false;
} else if (Util.isNullOrEmpty(nameTextField.getText())) {
try {
InetAddress ip = InetAddress.getLocalHost();
String username = System.getProperty("user.name");
nameTextField.setText(username + "@" + ip.getHostAddress());
} catch (UnknownHostException e) {
errorBuilder.setContent("Name should not be empty");
isValid = false;
}
}
if (!isValid) {
errorBuilder.getAlert().show();
}
return isValid;
}
use of com.exalttech.trex.ui.util.TrexAlertBuilder in project trex-stateless-gui by cisco-system-traffic-generator.
the class ImportedPacketPropertiesView method isValidAddresses.
/**
* Validate IP source/destination addresses
* @return
*/
private boolean isValidAddresses() {
boolean valid = true;
TrexAlertBuilder alertBuilder = TrexAlertBuilder.build().setType(Alert.AlertType.ERROR);
if (srcEnabledCB.isSelected() && !Util.isValidIPAddress(srcAddressTF.getText())) {
alertBuilder.setContent("Invalid source IP address");
valid = false;
} else if (dstEnabledCB.isSelected() && !Util.isValidIPAddress(dstAddressTF.getText())) {
alertBuilder.setContent("Invalid destination IP address");
valid = false;
}
if (!valid) {
alertBuilder.getAlert().showAndWait();
}
return valid;
}
use of com.exalttech.trex.ui.util.TrexAlertBuilder in project trex-stateless-gui by cisco-system-traffic-generator.
the class ImportedPacketPropertiesView method validateCount.
/**
* Validate source/destination count value
* @return
*/
private boolean validateCount() {
boolean valid = true;
TrexAlertBuilder errorBuilder = TrexAlertBuilder.build().setType(Alert.AlertType.ERROR);
if (srcEnabledCB.isSelected() && !isValidCount(srcCountTF.getText())) {
errorBuilder.setContent("Source count should be between 2 - 100M ");
valid = false;
} else if (dstEnabledCB.isSelected() && !isValidCount(dstCountTF.getText())) {
errorBuilder.setContent("Destination count should be between 2 - 100M ");
valid = false;
}
if (!valid) {
errorBuilder.getAlert().showAndWait();
}
return valid;
}
use of com.exalttech.trex.ui.util.TrexAlertBuilder in project trex-stateless-gui by cisco-system-traffic-generator.
the class ProfileStreamNameDialogController method validInput.
/**
* Validate input
*
* @return
*/
private boolean validInput() {
TrexAlertBuilder errorBuilder = TrexAlertBuilder.build().setType(Alert.AlertType.ERROR);
if (Util.isNullOrEmpty(nameTF.getText())) {
errorBuilder.setContent("Please fill the empty fields");
errorBuilder.getAlert().showAndWait();
return false;
} else if (profileList != null && !profileWindow) {
for (Profile p : profileList) {
if (p.getName().equals(nameTF.getText())) {
errorBuilder.setContent("Stream name already exists, please select a different Stream name");
errorBuilder.getAlert().showAndWait();
return false;
}
}
}
dataAvailabe = true;
return true;
}
Aggregations