protected void addChildren(DefaultConfiguration newConfig) { if (!externalConfigEnabled) { DefaultConfiguration smtpPort = new DefaultConfiguration("smtp-port"); DefaultConfiguration smtpServer = new DefaultConfiguration("smtp-host"); DefaultConfiguration ssl = new DefaultConfiguration("ssl"); smtpPort.setValue(smtpPortField.getNumber().intValue()); smtpServer.setValue(mailServer.getValue()); ssl.setValue(useSsl.isSelected()); newConfig.addChild(smtpPort); newConfig.addChild(smtpServer); newConfig.addChild(ssl); DefaultConfiguration username = new DefaultConfiguration("username"); DefaultConfiguration password = new DefaultConfiguration("password"); String usernameValue = this.username.getText(); if (usernameValue != null && usernameValue.trim().length() > 0) { username.setValue(usernameValue); } newConfig.addChild(username); String passwordString = new String(this.password.getPassword()); if (passwordString.trim().length() > 0) { password.setValue(passwordString); } newConfig.addChild(password); } }
protected void readConfig(Configuration config) { listenersEnabled = false; try { useSsl.setSelected(config.getChild("ssl").getValueAsBoolean(false)); mailServer.setValue(config.getChild("smtp-host").getValue("localhost")); smtpPortField.setNumber(new Integer(config.getChild("smtp-port").getValueAsInteger(25))); username.setText(config.getChild("username").getValue("")); password.setText(config.getChild("password").getValue("")); } finally { listenersEnabled = true; } }