connection = new Connection();
connection.setHost(this.txtServer.getText().trim());
connection.setPort(Integer.valueOf(this.txtPort.getText().trim()));
connection.setUsername(this.txtUserName.getText().trim());
ProxyType configProxyType = Connection.ProxyType.valueByText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_PROXY_TYPE, "None"));
if (configProxyType != null) {
connection.setProxyType(configProxyType);
if (!configProxyType.equals(ProxyType.NONE)) {
String host = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_PROXY_ADDRESS, "");
String port = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_PROXY_PORT, "");
if (!host.isEmpty() && !port.isEmpty()) {
connection.setProxyHost(host);
connection.setProxyPort(Integer.valueOf(port));