diff options
author | Oluwatobi Bashir-Bello <nbashirbello@google.com> | 2014-07-17 20:59:05 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-07-17 19:13:41 +0000 |
commit | f5c5d5195c3edfdd99114cabce1c8e1f1d837cad (patch) | |
tree | bbe6ed28c781b7221821f272efbee83c48bf45fe | |
parent | a9f0f343e269f82ed0fc3f757edcfab5dd527a43 (diff) | |
parent | c68a8fc8cbb81ed9d267769ab40b442693a629a7 (diff) | |
download | cloud-f5c5d5195c3edfdd99114cabce1c8e1f1d837cad.tar.gz |
Merge "Fix the order of the users in the Google login panel - maintain the insertion order." into idea133
4 files changed, 16 insertions, 12 deletions
diff --git a/login/src/com/google/gct/login/CredentialedUserRoster.java b/login/src/com/google/gct/login/CredentialedUserRoster.java index 152382e..7d50c70 100644 --- a/login/src/com/google/gct/login/CredentialedUserRoster.java +++ b/login/src/com/google/gct/login/CredentialedUserRoster.java @@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Collection; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; /** @@ -29,7 +29,7 @@ import java.util.Map; * {@link CredentialedUser} objects. */ public class CredentialedUserRoster { - private final Map<String, CredentialedUser> allUsers = new HashMap<String, CredentialedUser>(); + private final LinkedHashMap<String, CredentialedUser> allUsers = new LinkedHashMap<String, CredentialedUser>(); private CredentialedUser activeUser; private Collection<GoogleLoginListener> listeners; @@ -41,9 +41,9 @@ public class CredentialedUserRoster { * Returns a copy of the map of the current logged in users. * @return Copy of current logged in users. */ - public Map<String, CredentialedUser> getAllUsers() { + public LinkedHashMap<String, CredentialedUser> getAllUsers() { synchronized (this) { - Map<String, CredentialedUser> clone = new HashMap<String, CredentialedUser>(); + LinkedHashMap<String, CredentialedUser> clone = new LinkedHashMap<String, CredentialedUser>(); clone.putAll(allUsers); return clone; } diff --git a/login/src/com/google/gct/login/GoogleLogin.java b/login/src/com/google/gct/login/GoogleLogin.java index b139343..d97b68e 100644 --- a/login/src/com/google/gct/login/GoogleLogin.java +++ b/login/src/com/google/gct/login/GoogleLogin.java @@ -45,6 +45,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.SortedSet; @@ -401,7 +403,7 @@ public class GoogleLogin { * Returns a copy of the map of the current logged in users. * @return Copy of current logged in users. */ - public Map<String, CredentialedUser> getAllUsers() { + public LinkedHashMap<String, CredentialedUser> getAllUsers() { return users.getAllUsers(); } @@ -607,7 +609,7 @@ public class GoogleLogin { public void initializeUsers() { String activeUserString = GoogleLoginPrefs.getActiveUser(); - SortedSet<String> allUsers = GoogleLoginPrefs.getStoredUsers(); + List<String> allUsers = GoogleLoginPrefs.getStoredUsers(); for(String aUser : allUsers) { // Add a new user, so that loadOAuth called from the GoogleLoginState constructor // will be able to create a customized key to get that user's OAuth data diff --git a/login/src/com/google/gct/login/GoogleLoginPrefs.java b/login/src/com/google/gct/login/GoogleLoginPrefs.java index 8795238..2279f99 100644 --- a/login/src/com/google/gct/login/GoogleLoginPrefs.java +++ b/login/src/com/google/gct/login/GoogleLoginPrefs.java @@ -23,6 +23,8 @@ import com.google.gdt.eclipse.login.common.OAuthData; import com.intellij.openapi.diagnostic.Logger; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; +import java.util.List; import java.util.SortedSet; import java.util.TreeSet; import java.util.prefs.BackingStoreException; @@ -163,10 +165,10 @@ public class GoogleLoginPrefs { * @return the stored list of users. */ @NotNull - public static SortedSet<String> getStoredUsers() { + public static List<String> getStoredUsers() { Preferences prefs = getPrefs(); String allUsersString = prefs.get(USERS, ""); - SortedSet<String> allUsers = new TreeSet<String>(); + List<String> allUsers = new ArrayList<String>(); if(allUsersString.isEmpty()) { return allUsers; } @@ -252,7 +254,7 @@ public class GoogleLoginPrefs { return; } - SortedSet<String> allUsers = new TreeSet<String>(); + List<String> allUsers = new ArrayList<String>(); Splitter splitter = Splitter.on(DELIMITER).omitEmptyStrings(); for (String scope : splitter.split(allUsersString)) { allUsers.add(scope); @@ -269,7 +271,7 @@ public class GoogleLoginPrefs { private static void removeUser(Preferences prefs, String user) {; String allUsersString = prefs.get(USERS, ""); - SortedSet<String> allUsers = new TreeSet<String>(); + List<String> allUsers = new ArrayList<String>(); for (String scope : allUsersString.split(DELIMITER)) { allUsers.add(scope); } diff --git a/login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java b/login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java index debc24e..71c0627 100644 --- a/login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java +++ b/login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java @@ -38,7 +38,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.util.Map; +import java.util.LinkedHashMap; /** * The Google Login Panel that displays the currently logged in users and buttons to @@ -206,7 +206,7 @@ public class GoogleLoginUsersPanel extends JPanel implements ListSelectionListen } private int initializeUsers() { - Map<String, CredentialedUser> allUsers = GoogleLogin.getInstance().getAllUsers(); + LinkedHashMap<String, CredentialedUser> allUsers = GoogleLogin.getInstance().getAllUsers(); listModel = new DefaultListModel(); int activeUserIndex = allUsers.size(); |