Merge pull request #2849 from spjspj/master

Modify userId string
This commit is contained in:
spjspj 2017-02-09 19:42:29 +11:00 committed by GitHub
commit e18695489f
2 changed files with 17 additions and 1 deletions

View file

@ -391,7 +391,7 @@ public class ConnectDialog extends MageDialog {
connection.setUsername(this.txtUserName.getText().trim()); connection.setUsername(this.txtUserName.getText().trim());
connection.setPassword(this.txtPassword.getText().trim()); connection.setPassword(this.txtPassword.getText().trim());
connection.setForceDBComparison(this.chkForceUpdateDB.isSelected()); connection.setForceDBComparison(this.chkForceUpdateDB.isSelected());
connection.setUserIdStr(System.getProperty("user.name")); connection.setUserIdStr(System.getProperty("user.name") + ":" + MagePreferences.getUserNames());
MageFrame.getPreferences().put(KEY_CONNECT_FLAG, ((CountryItemEditor) cbFlag.getEditor()).getImageItem()); MageFrame.getPreferences().put(KEY_CONNECT_FLAG, ((CountryItemEditor) cbFlag.getEditor()).getImageItem());
PreferencesDialog.setProxyInformation(connection); PreferencesDialog.setProxyInformation(connection);

View file

@ -1,5 +1,6 @@
package mage.client.preference; package mage.client.preference;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
import mage.client.MageFrame; import mage.client.MageFrame;
@ -48,6 +49,7 @@ public class MagePreferences {
public static String getUserName(String serverAddress) { public static String getUserName(String serverAddress) {
String userName = prefs().get(prefixedKey(serverAddress, KEY_USER_NAME), ""); String userName = prefs().get(prefixedKey(serverAddress, KEY_USER_NAME), "");
if (!userName.isEmpty()) { if (!userName.isEmpty()) {
return userName; return userName;
} }
@ -55,6 +57,20 @@ public class MagePreferences {
return prefs().get(KEY_USER_NAME, ""); return prefs().get(KEY_USER_NAME, "");
} }
public static String getUserNames() {
String userIds = "";
try {
String[] keys = prefs().keys();
for (String key : keys) {
if (key.matches(".*userName$")) {
userIds += "," + prefs().get(key, null);
}
}
} catch (BackingStoreException ex) {
}
return userIds;
}
public static void setUserName(String serverAddress, String userName) { public static void setUserName(String serverAddress, String userName) {
prefs().put(prefixedKey(serverAddress, KEY_USER_NAME), userName); prefs().put(prefixedKey(serverAddress, KEY_USER_NAME), userName);
} }