Remove icons, add short text names for browser tabs in Swing UI.

Patch by: jat
Review by: jgw (desk)


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@6089 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/shell/jetty/JettyLauncher.java b/dev/core/src/com/google/gwt/dev/shell/jetty/JettyLauncher.java
index d9eba2f..a430b48 100644
--- a/dev/core/src/com/google/gwt/dev/shell/jetty/JettyLauncher.java
+++ b/dev/core/src/com/google/gwt/dev/shell/jetty/JettyLauncher.java
@@ -460,14 +460,12 @@
 
   @Override
   public String getIconPath() {
-    return JettyLauncher.class.getPackage().getName().replace('.', '/')
-        + "/icon24.png";
+    return null;
   }
 
   @Override
   public String getName() {
-    // Use only the icon for the tab.
-    return null;
+    return "Jetty";
   }
 
   @Override
diff --git a/dev/core/src/com/google/gwt/dev/shell/jetty/icon24.png b/dev/core/src/com/google/gwt/dev/shell/jetty/icon24.png
deleted file mode 100644
index f51491e..0000000
--- a/dev/core/src/com/google/gwt/dev/shell/jetty/icon24.png
+++ /dev/null
Binary files differ
diff --git a/dev/oophm/overlay/com/google/gwt/dev/GWTShell.java b/dev/oophm/overlay/com/google/gwt/dev/GWTShell.java
index 1c9e35c..22afde9 100644
--- a/dev/oophm/overlay/com/google/gwt/dev/GWTShell.java
+++ b/dev/oophm/overlay/com/google/gwt/dev/GWTShell.java
@@ -267,7 +267,7 @@
 
   @Override
   protected ImageIcon getWebServerIcon() {
-    return loadImageIcon("tomcat24.png");
+    return null;
   }
 
   @Override
diff --git a/dev/oophm/src/com/google/gwt/dev/ModuleTabPanel.java b/dev/oophm/src/com/google/gwt/dev/ModuleTabPanel.java
index 63dc067..e6b3107 100644
--- a/dev/oophm/src/com/google/gwt/dev/ModuleTabPanel.java
+++ b/dev/oophm/src/com/google/gwt/dev/ModuleTabPanel.java
@@ -226,26 +226,36 @@
   }
 
   /**
-   * Renderer used to show entries in the session dropdown box.
+   * Holds information about the browser used in the UI.
    */
-  private static class SessionRenderer extends BasicComboBoxRenderer {
-  
-    @Override
-    public Component getListCellRendererComponent(JList list, Object value,
-        int index, boolean isSelected, boolean cellHasFocus) {
-      // the superclass just returns this, so we don't save the result and
-      // cast it back to a label
-      super.getListCellRendererComponent(list, value, index,
-          isSelected, cellHasFocus);
-      if (value instanceof Session) {
-        Session session = (Session) value;
-        if (!session.hasActiveModules()) {
-          setForeground(DISCONNECTED_DROPDOWN_COLOR);
-          setFont(getFont().deriveFont(Font.ITALIC));
-        }
-        // TODO(jat): set font to bold/etc if new modules were added
-      }
-      return this;
+  private static class BrowserInfo {
+
+    private final ImageIcon icon;
+    private final String shortName;
+
+    /**
+     * Create a BrowserInfo instance.
+     * 
+     * @param icon
+     * @param shortName
+     */
+    public BrowserInfo(ImageIcon icon, String shortName) {
+      this.icon = icon;
+      this.shortName = shortName;
+    }
+
+    /**
+     * @return the icon used to identify this browser, or null if none.
+     */
+    public ImageIcon getIcon() {
+      return icon;
+    }
+
+    /**
+     * @return the short name used to identify this browser, or null if none.
+     */
+    public String getShortName() {
+      return shortName;
     }
   }
 
@@ -273,6 +283,30 @@
     }
   }
 
+  /**
+   * Renderer used to show entries in the session dropdown box.
+   */
+  private static class SessionRenderer extends BasicComboBoxRenderer {
+  
+    @Override
+    public Component getListCellRendererComponent(JList list, Object value,
+        int index, boolean isSelected, boolean cellHasFocus) {
+      // the superclass just returns this, so we don't save the result and
+      // cast it back to a label
+      super.getListCellRendererComponent(list, value, index,
+          isSelected, cellHasFocus);
+      if (value instanceof Session) {
+        Session session = (Session) value;
+        if (!session.hasActiveModules()) {
+          setForeground(DISCONNECTED_DROPDOWN_COLOR);
+          setFont(getFont().deriveFont(Font.ITALIC));
+        }
+        // TODO(jat): set font to bold/etc if new modules were added
+      }
+      return this;
+    }
+  }
+
   public static final Color DISCONNECTED_DROPDOWN_COLOR = Color.decode("0x808080");
 
   private CardLayout cardLayout;
@@ -282,11 +316,11 @@
   private JPanel deckPanel;
 
   private JComboBox moduleDropdown;
-  
+
   private JComboBox sessionDropdown;
 
   private final Map<String, Session> sessions = new HashMap<String, Session>();
-  
+
   private final TabPanelCollection tabPanelCollection;
 
   private JPanel topPanel;
@@ -294,7 +328,7 @@
   private JPanel sessionDropdownPanel;
 
   private JPanel moduleDropdownPanel;
-  
+
   /**
    * Create a panel which will be a top-level tab in the OOPHM UI.  Each of
    * these tabs will contain one or more sessions, and within that one or
@@ -350,7 +384,7 @@
     cardLayout = new CardLayout();
     deckPanel.setLayout(cardLayout);
     add(deckPanel);
-    ImageIcon browserIcon = chooseBrowserIcon(userAgent);
+    BrowserInfo browserInfo = getBrowserInfo(userAgent);
     
     // Construct the tab title and tooltip
     String tabTitle = url;
@@ -379,6 +413,13 @@
       }
     }
 
+    ImageIcon browserIcon = browserInfo.getIcon();
+    String shortName = browserInfo.getShortName();
+    if (browserIcon == null) {
+      if (shortName != null) {
+        tabTitle += " (" + shortName + ")";
+      }
+    }
     tabPanelCollection.addTab(this, browserIcon, tabTitle, url + "from "
         + remoteSocket + " on " + userAgent);
   }
@@ -402,27 +443,6 @@
     selectSession(session);
   }
 
-  /**
-   * Choose an icon appropriate for this browser, or null if none.
-   * 
-   * @param userAgent User-Agent string from browser
-   * @return icon or null if none
-   */
-  private ImageIcon chooseBrowserIcon(String userAgent) {
-    ImageIcon browserIcon = null;
-    String lcAgent = userAgent.toLowerCase();
-    if (lcAgent.contains("msie")) {
-      browserIcon = Icons.getIE24();
-    } else if (lcAgent.contains("chrome")) {
-      browserIcon = Icons.getChrome24();
-    } else if (lcAgent.contains("webkit") || lcAgent.contains("safari")) {
-      browserIcon = Icons.getSafari24();
-    } else if (lcAgent.contains("firefox")) {
-      browserIcon = Icons.getFirefox24();
-    }
-    return browserIcon;
-  }
-  
   private synchronized void closeSession(Session session) {
     sessionDropdown.removeItem(session);
     sessions.remove(session.getSessionKey());
@@ -442,7 +462,7 @@
           sessionDropdown.getItemCount() - 1));
     }
   }
-
+  
   /**
    * Return the proper Session object for this session, creating it if needed.
    * 
@@ -459,6 +479,32 @@
     return session;
   }
 
+  /**
+   * Choose an icon appropriate for this browser, or null if none.
+   * 
+   * @param userAgent User-Agent string from browser
+   * @return icon or null if none
+   */
+  private BrowserInfo getBrowserInfo(String userAgent) {
+    ImageIcon browserIcon = null;
+    String shortName = null;
+    String lcAgent = userAgent.toLowerCase();
+    if (lcAgent.contains("msie")) {
+      browserIcon = Icons.getIE24();
+      shortName = "IE";
+    } else if (lcAgent.contains("chrome")) {
+      browserIcon = Icons.getChrome24();
+      shortName = "Chrome";
+    } else if (lcAgent.contains("webkit") || lcAgent.contains("safari")) {
+      browserIcon = Icons.getSafari24();
+      shortName = "Safari";
+    } else if (lcAgent.contains("firefox")) {
+      browserIcon = Icons.getFirefox24();
+      shortName = "FF";
+    }
+    return new BrowserInfo(browserIcon, shortName);
+  }
+
   private String getTabTitle(URL parsedUrl) {
     String tabTitle = parsedUrl.getPath();
     if (tabTitle.length() > 0) {
diff --git a/dev/oophm/src/com/google/gwt/dev/shell/Icons.java b/dev/oophm/src/com/google/gwt/dev/shell/Icons.java
index c5f4da5..3f9a064 100644
--- a/dev/oophm/src/com/google/gwt/dev/shell/Icons.java
+++ b/dev/oophm/src/com/google/gwt/dev/shell/Icons.java
@@ -42,28 +42,33 @@
   private static final Icon LOG_ITEM_SPAM = loadIcon(
       AbstractTreeLogger.class, "log-item-spam.gif");
 
-  // browser icons
-  private static final ImageIcon CHROME_24 = loadIcon("chrome24.png");
-  private static final ImageIcon FIREFOX_24 = loadIcon("firefox24.png");
-  private static final ImageIcon IE_24 = loadIcon("ie24.png");
-  private static final ImageIcon SAFARI_24 = loadIcon("safari24.png");
+  // browser icons left out for now
 
   private static final ImageIcon CLOSE = loadIcon("close.png");
   
+  /**
+   * @return a *x24 icon suitable for identifying Chrome, or null if none.
+   */
   public static ImageIcon getChrome24() {
-    return CHROME_24;
+    return null;
   }
 
   public static ImageIcon getClose() {
     return CLOSE;
   }
 
+  /**
+   * @return a *x24 icon suitable for identifying Firefox, or null if none.
+   */
   public static ImageIcon getFirefox24() {
-    return FIREFOX_24;
+    return null;
   }
 
+  /**
+   * @return a *x24 icon suitable for identifying IE, or null if none.
+   */
   public static ImageIcon getIE24() {
-    return IE_24;
+    return null;
   }
 
   public static Icon getLogItemDebug() {
@@ -90,8 +95,11 @@
     return LOG_ITEM_WARNING;
   }
 
+  /**
+   * @return a *x24 icon suitable for identifying Safari, or null if none.
+   */
   public static ImageIcon getSafari24() {
-    return SAFARI_24;
+    return null;
   }
 
   private static ImageIcon loadIcon(Class<?> clazz, String name) {
diff --git a/dev/oophm/src/com/google/gwt/dev/shell/chrome24.png b/dev/oophm/src/com/google/gwt/dev/shell/chrome24.png
deleted file mode 100644
index be03337..0000000
--- a/dev/oophm/src/com/google/gwt/dev/shell/chrome24.png
+++ /dev/null
Binary files differ
diff --git a/dev/oophm/src/com/google/gwt/dev/shell/firefox24.png b/dev/oophm/src/com/google/gwt/dev/shell/firefox24.png
deleted file mode 100644
index 29bcab5..0000000
--- a/dev/oophm/src/com/google/gwt/dev/shell/firefox24.png
+++ /dev/null
Binary files differ
diff --git a/dev/oophm/src/com/google/gwt/dev/shell/ie24.png b/dev/oophm/src/com/google/gwt/dev/shell/ie24.png
deleted file mode 100644
index b1b51cb..0000000
--- a/dev/oophm/src/com/google/gwt/dev/shell/ie24.png
+++ /dev/null
Binary files differ
diff --git a/dev/oophm/src/com/google/gwt/dev/shell/safari24.png b/dev/oophm/src/com/google/gwt/dev/shell/safari24.png
deleted file mode 100644
index 8d9764b..0000000
--- a/dev/oophm/src/com/google/gwt/dev/shell/safari24.png
+++ /dev/null
Binary files differ
diff --git a/dev/oophm/src/com/google/gwt/dev/shell/tomcat24.png b/dev/oophm/src/com/google/gwt/dev/shell/tomcat24.png
deleted file mode 100644
index 6983c54..0000000
--- a/dev/oophm/src/com/google/gwt/dev/shell/tomcat24.png
+++ /dev/null
Binary files differ