← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 552: replaced encoded spaces in directory name with space characters

 

------------------------------------------------------------
revno: 552
committer: Bob Jolliffe <bobj@bobj-laptop>
branch nick: trunk
timestamp: Tue 2009-09-01 21:41:26 +0100
message:
  replaced encoded spaces in directory name with space characters
modified:
  lite-package/src/main/java/org/hisp/dhis/TrayApp.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.
=== modified file 'lite-package/src/main/java/org/hisp/dhis/TrayApp.java'
--- lite-package/src/main/java/org/hisp/dhis/TrayApp.java	2009-08-25 11:37:39 +0000
+++ lite-package/src/main/java/org/hisp/dhis/TrayApp.java	2009-09-01 20:41:26 +0000
@@ -231,7 +231,6 @@
     throws Exception
   {
     log.info("Environment variable DHIS2_HOME: "+System.getenv("DHIS2_HOME"));
-    log.info("System property user.dir: "+System.getProperty("user.dir"));
     if(!SystemTray.isSupported()) {
       String message = "SystemTray not supported on this platform";
       JOptionPane.showMessageDialog((JFrame)null, message);
@@ -242,7 +241,16 @@
     new TrayApp();
   }
 
-  public static String getInstallDir() {
+
+    /**
+     *  The <code>getInstallDir</code> method is a hack to determine the current
+     *  directory the dhis2 lite package is installed in.  It does this by finding
+     *  the file URL of a resource within the executable jar and extracting the 
+     *  installation path from that. 
+     *
+     * @return a <code>String</code> value representing the installation directory
+     */
+    public static String getInstallDir() {
         // find a resource
         String resourceString = TrayApp.class.getResource("/icons/").toString();
         // we expect to see something of the form:
@@ -253,8 +261,10 @@
         }
         // find the last "/" just before the "!"
         int endIndex = resourceString.lastIndexOf("/", resourceString.lastIndexOf("!"));
-        // make a URI of type file
-        return "file://" + resourceString.substring(9, endIndex);
-      }
-
+        String result = resourceString.substring(9, endIndex); 
+        // replace encoded spaces
+        result = result.replaceAll("%20"," ");
+        return result;
+    }
+    
 }