Revision: 6089 Author: j...@google.com Date: Fri Sep 4 12:23:59 2009 Log: Remove icons, add short text names for browser tabs in Swing UI.
Patch by: jat Review by: jgw (desk) http://code.google.com/p/google-web-toolkit/source/detail?r=6089 Deleted: /trunk/dev/core/src/com/google/gwt/dev/shell/jetty/icon24.png /trunk/dev/oophm/src/com/google/gwt/dev/shell/chrome24.png /trunk/dev/oophm/src/com/google/gwt/dev/shell/firefox24.png /trunk/dev/oophm/src/com/google/gwt/dev/shell/ie24.png /trunk/dev/oophm/src/com/google/gwt/dev/shell/safari24.png /trunk/dev/oophm/src/com/google/gwt/dev/shell/tomcat24.png Modified: /trunk/dev/core/src/com/google/gwt/dev/shell/jetty/JettyLauncher.java /trunk/dev/oophm/overlay/com/google/gwt/dev/GWTShell.java /trunk/dev/oophm/src/com/google/gwt/dev/ModuleTabPanel.java /trunk/dev/oophm/src/com/google/gwt/dev/shell/Icons.java ======================================= --- /trunk/dev/core/src/com/google/gwt/dev/shell/jetty/icon24.png Tue Mar 17 22:05:42 2009 +++ /dev/null Binary file, no diff available. ======================================= --- /trunk/dev/oophm/src/com/google/gwt/dev/shell/chrome24.png Sat Aug 22 16:01:38 2009 +++ /dev/null Binary file, no diff available. ======================================= --- /trunk/dev/oophm/src/com/google/gwt/dev/shell/firefox24.png Tue Nov 25 16:21:22 2008 +++ /dev/null Binary file, no diff available. ======================================= --- /trunk/dev/oophm/src/com/google/gwt/dev/shell/ie24.png Tue Nov 25 16:21:22 2008 +++ /dev/null Binary file, no diff available. ======================================= --- /trunk/dev/oophm/src/com/google/gwt/dev/shell/safari24.png Tue Nov 25 16:21:22 2008 +++ /dev/null Binary file, no diff available. ======================================= --- /trunk/dev/oophm/src/com/google/gwt/dev/shell/tomcat24.png Tue Nov 25 16:21:22 2008 +++ /dev/null Binary file, no diff available. ======================================= --- /trunk/dev/core/src/com/google/gwt/dev/shell/jetty/JettyLauncher.java Tue May 19 08:35:33 2009 +++ /trunk/dev/core/src/com/google/gwt/dev/shell/jetty/JettyLauncher.java Fri Sep 4 12:23:59 2009 @@ -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 ======================================= --- /trunk/dev/oophm/overlay/com/google/gwt/dev/GWTShell.java Sat Aug 22 16:01:38 2009 +++ /trunk/dev/oophm/overlay/com/google/gwt/dev/GWTShell.java Fri Sep 4 12:23:59 2009 @@ -267,7 +267,7 @@ @Override protected ImageIcon getWebServerIcon() { - return loadImageIcon("tomcat24.png"); + return null; } @Override ======================================= --- /trunk/dev/oophm/src/com/google/gwt/dev/ModuleTabPanel.java Mon Aug 24 10:11:55 2009 +++ /trunk/dev/oophm/src/com/google/gwt/dev/ModuleTabPanel.java Fri Sep 4 12:23:59 2009 @@ -226,10 +226,44 @@ } /** - * 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 { - + 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; + } + } + + /** + * Renderer used to show entries in the module dropdown box. + */ + private static class SessionModuleRenderer extends BasicComboBoxRenderer { + @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { @@ -237,23 +271,23 @@ // cast it back to a label super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof Session) { - Session session = (Session) value; - if (!session.hasActiveModules()) { + if (value instanceof SessionModule) { + SessionModule sessionModule = (SessionModule) value; + if (sessionModule.getModulePanel().isDisconnected()) { setForeground(DISCONNECTED_DROPDOWN_COLOR); setFont(getFont().deriveFont(Font.ITALIC)); } - // TODO(jat): set font to bold/etc if new modules were added + // TODO(jat): set font to bold/etc if the window has new messages } return this; } } /** - * Renderer used to show entries in the module dropdown box. + * Renderer used to show entries in the session dropdown box. */ - private static class SessionModuleRenderer extends BasicComboBoxRenderer { - + private static class SessionRenderer extends BasicComboBoxRenderer { + @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { @@ -261,13 +295,13 @@ // cast it back to a label super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof SessionModule) { - SessionModule sessionModule = (SessionModule) value; - if (sessionModule.getModulePanel().isDisconnected()) { + 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 the window has new messages + // TODO(jat): set font to bold/etc if new modules were added } return this; } @@ -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. * @@ -458,6 +478,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(); ======================================= --- /trunk/dev/oophm/src/com/google/gwt/dev/shell/Icons.java Mon Aug 24 10:11:55 2009 +++ /trunk/dev/oophm/src/com/google/gwt/dev/shell/Icons.java Fri Sep 4 12:23:59 2009 @@ -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) { --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---