* Fixed a bug that some options in preferences were handled with the wrong state as long as never set manually.

This commit is contained in:
LevelX2 2015-09-29 17:26:29 +02:00
parent f5b411c516
commit e2453abbb5
2 changed files with 6 additions and 5 deletions

View file

@ -2565,6 +2565,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
private static void load(Preferences prefs, JCheckBox checkBox, String propName, String yesValue, String defaultValue) { private static void load(Preferences prefs, JCheckBox checkBox, String propName, String yesValue, String defaultValue) {
String prop = prefs.get(propName, defaultValue); String prop = prefs.get(propName, defaultValue);
checkBox.setSelected(prop.equals(yesValue)); checkBox.setSelected(prop.equals(yesValue));
updateCache(propName, prop);
} }
private static void load(Preferences prefs, JTextField field, String propName, String defaultValue) { private static void load(Preferences prefs, JTextField field, String propName, String defaultValue) {

View file

@ -92,15 +92,15 @@ public class Session {
return "User name Admin already in use"; return "User name Admin already in use";
} }
if (userName.length() > ConfigSettings.getInstance().getMaxUserNameLength()) { if (userName.length() > ConfigSettings.getInstance().getMaxUserNameLength()) {
return new StringBuilder("User name may not be longer than ").append(ConfigSettings.getInstance().getMaxUserNameLength()).append(" characters").toString(); return "User name may not be longer than " + ConfigSettings.getInstance().getMaxUserNameLength() + " characters";
} }
if (userName.length() < ConfigSettings.getInstance().getMinUserNameLength()) { if (userName.length() < ConfigSettings.getInstance().getMinUserNameLength()) {
return new StringBuilder("User name may not be shorter than ").append(ConfigSettings.getInstance().getMinUserNameLength()).append(" characters").toString(); return "User name may not be shorter than " + ConfigSettings.getInstance().getMinUserNameLength() + " characters";
} }
Pattern p = Pattern.compile(ConfigSettings.getInstance().getUserNamePattern(), Pattern.CASE_INSENSITIVE); Pattern p = Pattern.compile(ConfigSettings.getInstance().getUserNamePattern(), Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(userName); Matcher m = p.matcher(userName);
if (m.find()) { if (m.find()) {
return new StringBuilder("User name '").append(userName).append("' includes not allowed characters: use a-z, A-Z and 0-9").toString(); return "User name '" + userName + "' includes not allowed characters: use a-z, A-Z and 0-9";
} }
User user = UserManager.getInstance().createUser(userName, host); User user = UserManager.getInstance().createUser(userName, host);
boolean reconnect = false; boolean reconnect = false;
@ -118,11 +118,11 @@ public class Session {
SessionManager.getInstance().disconnect(user.getSessionId(), DisconnectReason.ConnectingOtherInstance); SessionManager.getInstance().disconnect(user.getSessionId(), DisconnectReason.ConnectingOtherInstance);
} }
} else { } else {
return new StringBuilder("User name ").append(userName).append(" already in use (or your IP address changed)").toString(); return "User name " + userName + " already in use (or your IP address changed)";
} }
} }
if (!UserManager.getInstance().connectToSession(sessionId, user.getId())) { if (!UserManager.getInstance().connectToSession(sessionId, user.getId())) {
return new StringBuilder("Error connecting ").append(userName).toString(); return "Error connecting " + userName;
} }
this.userId = user.getId(); this.userId = user.getId();
if (reconnect) { // must be connected to receive the message if (reconnect) { // must be connected to receive the message