summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOluwatobi Bashir-Bello <nbashirbello@google.com>2014-08-07 16:05:21 -0400
committerOluwatobi Bashir-Bello <nbashirbello@google.com>2014-08-07 17:02:38 -0400
commitbdd6cd772d2c2428984f63235117b4246f37de2c (patch)
tree19cc8e1e9c00cbb6c0319b2663cda8c8816a7371
parenta90316fd5c1d0e2a1e3075cc293631706dc812b3 (diff)
downloadcloud-bdd6cd772d2c2428984f63235117b4246f37de2c.tar.gz
Updates to the signed-in with a single user ui
- Change the background color to white (#ffffff), currently is gray - Change “Open Cloud Console” to “Open Google Developers Console” - Align the links to the bottom of the avatar image - Increase the vertical spacing between links and the vertical spacing between the name/e-mail by 3 px - Ensure that the hover icon for the hyperlinks is “hand” Change-Id: Ie9ea4590207091d3f8721071f75792c885aa5c94
-rw-r--r--login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java36
-rw-r--r--login/src/com/google/gct/login/ui/UsersListCellRenderer.java33
2 files changed, 58 insertions, 11 deletions
diff --git a/login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java b/login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java
index 6211e52..764880d 100644
--- a/login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java
+++ b/login/src/com/google/gct/login/ui/GoogleLoginUsersPanel.java
@@ -33,11 +33,13 @@ import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.BorderLayout;
+import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionListener;
import java.util.LinkedHashMap;
/**
@@ -118,6 +120,40 @@ public class GoogleLoginUsersPanel extends JPanel implements ListSelectionListen
}
});
+ list.addMouseMotionListener(new MouseMotionListener() {
+ @Override
+ public void mouseMoved(MouseEvent mouseEvent) {
+ // Determine if the user under the cursor is an active user, a non-active user or a non-user
+ int index = list.locationToIndex(mouseEvent.getPoint());
+ if (index >= 0) {
+ // If current object is the non-user list item, use default cursor
+ Object currentObject = listModel.get(index);
+ if(currentObject instanceof NoUsersListItem) {
+ list.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
+ return;
+ }
+
+ if (((UsersListItem)currentObject).isActiveUser()) {
+ // Active user
+ boolean inPlayUrl = usersListCellRenderer.inPlayConsoleUrl(mouseEvent.getPoint(), index);
+ boolean inCloudUrl = usersListCellRenderer.inCloudConsoleUrl(mouseEvent.getPoint(), index);
+ if(inPlayUrl || inCloudUrl){
+ list.setCursor(new Cursor(Cursor.HAND_CURSOR));
+ } else {
+ list.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
+ }
+ } else {
+ // For non-active user
+ list.setCursor(new Cursor(Cursor.HAND_CURSOR));
+ }
+ }
+ }
+
+ @Override
+ public void mouseDragged(MouseEvent e) {
+ }
+ });
+
boolean noUsersAvailable = (listModel.getSize() == 1) && (listModel.get(0) instanceof NoUsersListItem);
addAccountButton = new JButton(noUsersAvailable ? signInString : addAccountString);
AddAccountListener addAccountListener = new AddAccountListener();
diff --git a/login/src/com/google/gct/login/ui/UsersListCellRenderer.java b/login/src/com/google/gct/login/ui/UsersListCellRenderer.java
index 9c10ec0..0a239b4 100644
--- a/login/src/com/google/gct/login/ui/UsersListCellRenderer.java
+++ b/login/src/com/google/gct/login/ui/UsersListCellRenderer.java
@@ -48,12 +48,13 @@ import java.net.URL;
* how each user item in the Google Login panel would be displayed.
*/
public class UsersListCellRenderer extends JComponent implements ListCellRenderer {
- private final static String CLOUD_LABEL_TEXT = "Open Cloud Console";
+ private final static String CLOUD_LABEL_TEXT = "Open Google Developers Console";
private final static String PLAY_LABEL_TEXT = "Open Play Developer Console";
private final static String DEFAULT_AVATAR = "/icons/loginAvatar@2x.png";
private final static String GOOGLE_IMG = "/icons/google.png";
private final static String SIGN_IN_TEXT = "Sign in with your Google account";
- private final Color ACTIVE_COLOR = JBColor.LIGHT_GRAY;
+ private final Color ACTIVE_COLOR;
+ private final Color INACTIVE_COLOR;
private final int PLAIN_USER_IMAGE_WIDTH = 48;
private final int PLAIN_USER_IMAGE_HEIGHT = 48;
private final int ACTIVE_USER_IMAGE_WIDTH = 96;
@@ -66,8 +67,10 @@ public class UsersListCellRenderer extends JComponent implements ListCellRendere
private final int WELCOME_LABEL_SOUTH = 25;
private final int WELCOME_LABEL_EAST = 19;
private final int WELCOME_LABEL_WEST = 21;
+ private final int USER_LABEL_VERTICAL_STRUT = 3;
private final int HGAP = 10;
private final int VGAP = 10;
+ private final int GENERAL_FONT_HEIGHT;
private final Font NAME_FONT;
private final Font GENERAL_FONT;
private final Dimension MAIN_PANEL_DIMENSION;
@@ -81,9 +84,13 @@ public class UsersListCellRenderer extends JComponent implements ListCellRendere
MAIN_PANEL_DIMENSION = new Dimension(250, 68);
ACTIVE_MAIN_PANEL_DIMENSION = new Dimension(250, 116);
+ ACTIVE_COLOR = new Color(0xffffff);
+ INACTIVE_COLOR = new Color(0xf5f5f5);
+
FontMetrics fontMetrics = getFontMetrics(GENERAL_FONT);
- CLOUD_LABEL_DIMENSION = new Dimension(fontMetrics.stringWidth(CLOUD_LABEL_TEXT), fontMetrics.getHeight());
- PLAY_LABEL_DIMENSION = new Dimension(fontMetrics.stringWidth(PLAY_LABEL_TEXT), fontMetrics.getHeight());
+ GENERAL_FONT_HEIGHT = fontMetrics.getHeight();
+ CLOUD_LABEL_DIMENSION = new Dimension(fontMetrics.stringWidth(CLOUD_LABEL_TEXT), GENERAL_FONT_HEIGHT);
+ PLAY_LABEL_DIMENSION = new Dimension(fontMetrics.stringWidth(PLAY_LABEL_TEXT), GENERAL_FONT_HEIGHT);
}
@Override
@@ -109,7 +116,7 @@ public class UsersListCellRenderer extends JComponent implements ListCellRendere
mainPanel.setAlignmentX(LEFT_ALIGNMENT);
// Update colors
- final Color bg = calcIsSelected ? ACTIVE_COLOR : UIUtil.getListBackground();
+ final Color bg = calcIsSelected ? ACTIVE_COLOR : INACTIVE_COLOR;
final Color fg = calcIsSelected ? UIUtil.getListSelectionForeground() : UIUtil.getListForeground();
mainPanel.setBackground(bg);
mainPanel.setForeground(fg);
@@ -143,7 +150,8 @@ public class UsersListCellRenderer extends JComponent implements ListCellRendere
public boolean inPlayConsoleUrl(Point point, int activeIndex) {
// 2 is for the number of labels before this one
double playYStart = VGAP + ACTIVE_USER_IMAGE_HEIGHT - PLAY_LABEL_DIMENSION.getHeight()
- - CLOUD_LABEL_DIMENSION.getHeight() - 2 + (MAIN_PANEL_DIMENSION.getHeight() * activeIndex);
+ - CLOUD_LABEL_DIMENSION.getHeight() - 2 + (MAIN_PANEL_DIMENSION.getHeight() * activeIndex)
+ + USER_LABEL_VERTICAL_STRUT;
double playYEnd = playYStart + PLAY_LABEL_DIMENSION.getHeight();
double playXStart = ACTIVE_USER_IMAGE_WIDTH + HGAP + VGAP;
double playXEnd = playXStart + PLAY_LABEL_DIMENSION.getWidth();
@@ -159,7 +167,7 @@ public class UsersListCellRenderer extends JComponent implements ListCellRendere
public boolean inCloudConsoleUrl(Point point, int activeIndex) {
// 3 is for the number of labels before this one
double playYStart = VGAP + ACTIVE_USER_IMAGE_HEIGHT - CLOUD_LABEL_DIMENSION.getHeight()
- - 3 + (MAIN_PANEL_DIMENSION.getHeight() * activeIndex);
+ - 3 + (MAIN_PANEL_DIMENSION.getHeight() * activeIndex) + (USER_LABEL_VERTICAL_STRUT * 2);
double playYEnd = playYStart + CLOUD_LABEL_DIMENSION.getHeight();
double playXStart = ACTIVE_USER_IMAGE_WIDTH + HGAP + VGAP;
double playXEnd = playXStart + CLOUD_LABEL_DIMENSION.getWidth();
@@ -182,16 +190,18 @@ public class UsersListCellRenderer extends JComponent implements ListCellRendere
private JComponent createTextDisplay(boolean isSelected, UsersListItem usersListItem) {
final JPanel panel = new JPanel();
- panel.setLayout(new GridLayout(2,1));
+ panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
- final Color bg = isSelected ? ACTIVE_COLOR : UIUtil.getListBackground();
+ final Color bg = isSelected ? ACTIVE_COLOR : INACTIVE_COLOR;
final Color fg = isSelected ? UIUtil.getListSelectionForeground() : UIUtil.getListForeground();
panel.setBackground(bg);
panel.setForeground(fg);
JLabel nameLabel = new JLabel( usersListItem.getUserName());
nameLabel.setFont(NAME_FONT);
+ nameLabel.setForeground(JBColor.BLACK);
panel.add(nameLabel);
+ panel.add(Box.createVerticalStrut(USER_LABEL_VERTICAL_STRUT));
JLabel emailLabel = new JLabel(usersListItem.getUserEmail());
emailLabel.setFont(GENERAL_FONT);
@@ -206,19 +216,20 @@ public class UsersListCellRenderer extends JComponent implements ListCellRendere
mainPanel.setBackground(ACTIVE_COLOR);
mainPanel.setForeground(UIUtil.getListSelectionForeground());
- mainPanel.setPreferredSize(new Dimension(200, 96));
+ mainPanel.setPreferredSize(new Dimension(220, ACTIVE_USER_IMAGE_HEIGHT));
JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.PAGE_AXIS));
bottomPanel.setBackground(ACTIVE_COLOR);
bottomPanel.setForeground(UIUtil.getListSelectionForeground());
- bottomPanel.setPreferredSize(new Dimension(200, 40));
+ bottomPanel.setPreferredSize(new Dimension(220, (GENERAL_FONT_HEIGHT * 2) + USER_LABEL_VERTICAL_STRUT));
JLabel playLabel = new JLabel(PLAY_LABEL_TEXT);
playLabel.setFont(GENERAL_FONT);
playLabel.setForeground(JBColor.BLUE);
playLabel.setPreferredSize(PLAY_LABEL_DIMENSION);
bottomPanel.add(playLabel, BOTTOM_ALIGNMENT);
+ bottomPanel.add(Box.createVerticalStrut(USER_LABEL_VERTICAL_STRUT));
JLabel cloudLabel = new JLabel(CLOUD_LABEL_TEXT);
cloudLabel.setFont(GENERAL_FONT);