summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOluwatobi Bashir-Bello <nbashirbello@google.com>2014-08-06 20:53:54 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-08-05 00:41:34 +0000
commita90316fd5c1d0e2a1e3075cc293631706dc812b3 (patch)
treed7e60a7fc48949539b0d33b3f7e2cee2dbdae74e
parent982597a585eca959cede0f26ecda3a0936ef1a81 (diff)
parent847cce981a5c304ba6970ffc917a092abfecbe0b (diff)
downloadcloud-a90316fd5c1d0e2a1e3075cc293631706dc812b3.tar.gz
Merge "In the Google Login widget, change the non-signed in buttons from "Add Account" and "Sign Out" to a single "Sign in..." button" into idea133
-rw-r--r--login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java25
1 files changed, 7 insertions, 18 deletions
diff --git a/login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java b/login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java
index 71c0627..6211e52 100644
--- a/login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java
+++ b/login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java
@@ -51,6 +51,7 @@ public class GoogleLoginUsersPanel extends JPanel implements ListSelectionListen
private DefaultListModel listModel;
private static final int MAX_VISIBLE_ROW_COUNT = 3;
private static final String addAccountString = "Add Account";
+ private static final String signInString = "Sign In";
private static final String signOutString = "Sign Out";
private JButton signOutButton;
private JButton addAccountButton;
@@ -117,7 +118,8 @@ public class GoogleLoginUsersPanel extends JPanel implements ListSelectionListen
}
});
- addAccountButton = new JButton(addAccountString);
+ boolean noUsersAvailable = (listModel.getSize() == 1) && (listModel.get(0) instanceof NoUsersListItem);
+ addAccountButton = new JButton(noUsersAvailable ? signInString : addAccountString);
AddAccountListener addAccountListener = new AddAccountListener();
addAccountButton.addActionListener(addAccountListener);
addAccountButton.setHorizontalAlignment(SwingConstants.LEFT);
@@ -129,9 +131,9 @@ public class GoogleLoginUsersPanel extends JPanel implements ListSelectionListen
signOutButton.setEnabled(false);
} else {
// If list contains the NoUsersListItem place holder
- // sign out button should be disabled
- if(listModel.get(0) instanceof NoUsersListItem) {
- signOutButton.setEnabled(false);
+ // sign out button should be hidden
+ if(noUsersAvailable) {
+ signOutButton.setVisible(false);
} else {
signOutButton.setEnabled(true);
}
@@ -155,20 +157,7 @@ public class GoogleLoginUsersPanel extends JPanel implements ListSelectionListen
class SignOutListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
- //This method can be called only if there's a valid selection
- int index = list.getSelectedIndex();
-
- boolean signedOut = GoogleLogin.getInstance().logOut();
- if(signedOut) {
- // remove logged out user
- listModel.remove(index);
- if (listModel.getSize() == 0) {
- signOutButton.setEnabled(false);
-
- // Add no user panel
- listModel.addElement(NoUsersListItem.INSTANCE);
- }
- }
+ GoogleLogin.getInstance().logOut();
}
}