Revision: 8504
          
http://languagetool.svn.sourceforge.net/languagetool/?rev=8504&view=rev
Author:   dnaber
Date:     2012-12-04 19:52:27 +0000 (Tue, 04 Dec 2012)
Log Message:
-----------
stand-alone GUI: the tray icon will show a small "S" symbol when the server is 
running

Modified Paths:
--------------
    trunk/JLanguageTool/CHANGES.txt
    trunk/JLanguageTool/src/main/java/org/languagetool/gui/Main.java
    
trunk/JLanguageTool/src/main/resources/org/languagetool/MessagesBundle.properties
    
trunk/JLanguageTool/src/main/resources/org/languagetool/MessagesBundle_en.properties

Added Paths:
-----------
    
trunk/JLanguageTool/src/main/resources/org/languagetool/resource/TrayIconSmallWithServer.png
    
trunk/JLanguageTool/src/main/resources/org/languagetool/resource/TrayIconWithServer.png

Modified: trunk/JLanguageTool/CHANGES.txt
===================================================================
--- trunk/JLanguageTool/CHANGES.txt     2012-12-04 18:05:45 UTC (rev 8503)
+++ trunk/JLanguageTool/CHANGES.txt     2012-12-04 19:52:27 UTC (rev 8504)
@@ -62,6 +62,8 @@
  -stand-alone GUI: the tray icon menu (reachable with the right mouse button 
on the tray
   icon) now has a checkbox to enable the embedded HTTP server
 
+ -stand-alone GUI: the tray icon will show a small "S" symbol when the server 
is running
+
  -stand-alone GUI: Fixed bug "Tray icon too big sometimes" (Sourceforge 
#3573078)
 
 

Modified: trunk/JLanguageTool/src/main/java/org/languagetool/gui/Main.java
===================================================================
--- trunk/JLanguageTool/src/main/java/org/languagetool/gui/Main.java    
2012-12-04 18:05:45 UTC (rev 8503)
+++ trunk/JLanguageTool/src/main/java/org/languagetool/gui/Main.java    
2012-12-04 19:52:27 UTC (rev 8504)
@@ -54,9 +54,12 @@
   static final String HTML_FONT_END = "</font>";
   static final String HTML_GREY_FONT_START = "<font face='Arial,Helvetica' 
color='#666666'>";
 
-  private static final String SYSTEM_TRAY_ICON_NAME = "/TrayIcon.png";
-  private static final String SYSTEM_TRAY_SMALL_ICON_NAME = 
"/TrayIconSmall.png";
-  private static final String SYSTEM_TRAY_TOOLTIP = "LanguageTool";
+  private static final String TRAY_ICON = "/TrayIcon.png";
+  private static final String TRAY_SERVER_ICON = "/TrayIconWithServer.png";
+  private static final String TRAY_SMALL_ICON = "/TrayIconSmall.png";
+  private static final String TRAY_SMALL_SERVER_ICON = 
"/TrayIconSmallWithServer.png";
+  private static final String TRAY_TOOLTIP = "LanguageTool";
+
   private static final String CONFIG_FILE = ".languagetool.cfg";
   private static final int WINDOW_WIDTH = 600;
   private static final int WINDOW_HEIGHT = 550;
@@ -79,6 +82,7 @@
 
   private final Map<Language, ConfigurationDialog> configDialogs = new 
HashMap<Language, ConfigurationDialog>();
 
+  private TrayIcon trayIcon;
   private boolean closeHidesToTray;
   private boolean isInTray;
   private boolean isAlreadyChecking;
@@ -164,7 +168,7 @@
 
     frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
     frame.addWindowListener(new CloseListener());
-    final URL iconUrl = 
JLanguageTool.getDataBroker().getFromResourceDirAsUrl(SYSTEM_TRAY_ICON_NAME);
+    final URL iconUrl = 
JLanguageTool.getDataBroker().getFromResourceDirAsUrl(TRAY_ICON);
     frame.setIconImage(new ImageIcon(iconUrl).getImage());
     frame.setJMenuBar(new MainMenuBar(this, messages));
 
@@ -289,12 +293,14 @@
   void hideToTray() {
     if (!isInTray) {
       final SystemTray tray = SystemTray.getSystemTray();
-      final String iconPath = tray.getTrayIconSize().height > 16 ? 
SYSTEM_TRAY_ICON_NAME : SYSTEM_TRAY_SMALL_ICON_NAME;
-      final Image img = 
Toolkit.getDefaultToolkit().getImage(JLanguageTool.getDataBroker().getFromResourceDirAsUrl(iconPath));
+      final String iconPath = tray.getTrayIconSize().height > 16 ? TRAY_ICON : 
TRAY_SMALL_ICON;
+      final URL iconUrl = 
JLanguageTool.getDataBroker().getFromResourceDirAsUrl(iconPath);
+      final Image img = Toolkit.getDefaultToolkit().getImage(iconUrl);
       final PopupMenu popup = makePopupMenu();
       try {
-        final TrayIcon trayIcon = new TrayIcon(img, SYSTEM_TRAY_TOOLTIP, 
popup);
+        trayIcon = new TrayIcon(img, TRAY_TOOLTIP, popup);
         trayIcon.addMouseListener(new TrayActionListener());
+        setTrayIcon();
         tray.add(trayIcon);
       } catch (AWTException e1) {
         // thrown if there's no system tray
@@ -340,6 +346,25 @@
     System.exit(0);
   }
 
+  private void setTrayIcon() {
+    if (trayIcon != null) {
+      final SystemTray tray = SystemTray.getSystemTray();
+      final boolean httpServerRunning = httpServer != null && 
httpServer.isRunning();
+      final boolean smallTray = tray.getTrayIconSize().height <= 16;
+      final String iconPath;
+      if (httpServerRunning) {
+        trayIcon.setToolTip(messages.getString("tray_tooltip_server_running"));
+        iconPath = smallTray ? TRAY_SMALL_SERVER_ICON : TRAY_SERVER_ICON;
+      } else {
+        trayIcon.setToolTip(TRAY_TOOLTIP);
+        iconPath = smallTray ? TRAY_SMALL_ICON : TRAY_ICON;
+      }
+      final URL iconUrl = 
JLanguageTool.getDataBroker().getFromResourceDirAsUrl(iconPath);
+      final Image img = Toolkit.getDefaultToolkit().getImage(iconUrl);
+      trayIcon.setImage(img);
+    }
+  }
+
   private void showGUI() {
     frame.setVisible(true);
   }
@@ -391,6 +416,7 @@
          httpServer.run();
         if (enableHttpServerItem != null) {
           enableHttpServerItem.setState(httpServer.isRunning());
+          setTrayIcon();
         }
       } catch (PortBindingException e) {
         JOptionPane.showMessageDialog(null, e.getMessage(), "Error", 
JOptionPane.ERROR_MESSAGE);
@@ -404,6 +430,7 @@
       httpServer.stop();
       if (enableHttpServerItem != null) {
         enableHttpServerItem.setState(httpServer.isRunning());
+        setTrayIcon();
       }
       httpServer = null;
     }

Modified: 
trunk/JLanguageTool/src/main/resources/org/languagetool/MessagesBundle.properties
===================================================================
--- 
trunk/JLanguageTool/src/main/resources/org/languagetool/MessagesBundle.properties
   2012-12-04 18:05:45 UTC (rev 8503)
+++ 
trunk/JLanguageTool/src/main/resources/org/languagetool/MessagesBundle.properties
   2012-12-04 19:52:27 UTC (rev 8504)
@@ -270,3 +270,5 @@
 https_server_start_failed_unknown_reason = LanguageTool HTTPS server could not 
be started on host "{0}", port {1}
 
 tray_menu_enable_server = Run HTTP server
+
+tray_tooltip_server_running = LanguageTool (HTTP server running)

Modified: 
trunk/JLanguageTool/src/main/resources/org/languagetool/MessagesBundle_en.properties
===================================================================
--- 
trunk/JLanguageTool/src/main/resources/org/languagetool/MessagesBundle_en.properties
        2012-12-04 18:05:45 UTC (rev 8503)
+++ 
trunk/JLanguageTool/src/main/resources/org/languagetool/MessagesBundle_en.properties
        2012-12-04 19:52:27 UTC (rev 8504)
@@ -270,3 +270,5 @@
 https_server_start_failed_unknown_reason = LanguageTool HTTPS server could not 
be started on host "{0}", port {1}
 
 tray_menu_enable_server = Run HTTP server
+
+tray_tooltip_server_running = LanguageTool (HTTP server running)

Added: 
trunk/JLanguageTool/src/main/resources/org/languagetool/resource/TrayIconSmallWithServer.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/JLanguageTool/src/main/resources/org/languagetool/resource/TrayIconSmallWithServer.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: 
trunk/JLanguageTool/src/main/resources/org/languagetool/resource/TrayIconWithServer.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/JLanguageTool/src/main/resources/org/languagetool/resource/TrayIconWithServer.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Languagetool-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-commits

Reply via email to