Release and build date methods changed
authoramwaterhouse <Andrew Waterhouse>
Mon, 11 Jul 2005 13:05:45 +0000 (13:05 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 11 Jul 2005 13:05:45 +0000 (13:05 +0000)
src/jalview/appletgui/AlignFrame.java
src/jalview/bin/Cache.java
src/jalview/gui/Desktop.java
src/jalview/gui/Jalview2XML.java
src/jalview/gui/SplashScreen.java

index 3ab3132..079a756 100755 (executable)
@@ -1132,7 +1132,7 @@ public class AlignFrame
         int y = 5, x = 7;\r
         g.setColor(Color.black);\r
         g.setFont(new Font("Helvetica", Font.BOLD, 14));\r
-        g.drawString("JalView - Release 2.0", 200, y += fh);\r
+        g.drawString("JalView - Release 2.01", 200, y += fh);\r
         g.setFont(new Font("Helvetica", Font.PLAIN, 12));\r
         g.drawString("Authors:  Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton.",\r
                      x, y += fh * 2);\r
index 57ae4ce..d4c7e5d 100755 (executable)
@@ -22,6 +22,8 @@ import java.io.*;
 \r
 import java.util.*;\r
 \r
+import java.net.*;\r
+\r
 \r
 /**\r
  * Stores and retrieves Jalview Application Properties\r
@@ -39,11 +41,6 @@ import java.util.*;
  */\r
 public class Cache\r
 {\r
-    /** Current release tag */\r
-    public static String VERSION = "AW Test";\r
-\r
-    /** Date Jalview was last packaged, else compilation date of Cache.class */\r
-    public static String BUILD_DATE = "";\r
 \r
     /** Jalview Properties */\r
     public static Properties applicationProperties;\r
@@ -54,59 +51,68 @@ public class Cache
     /** Called when Jalview is started */\r
     public static void loadProperties(String propsFile)\r
     {\r
-      propertiesFile = propsFile;\r
-      if (propsFile == null)\r
-      {\r
-        propertiesFile = System.getProperty("user.home") + "/.jalview_properties";\r
-      }\r
-\r
+        applicationProperties = new Properties();\r
 \r
-        // get last build time.\r
-        long date = 0;\r
+        propertiesFile = propsFile;\r
+        if (propsFile == null)\r
+        {\r
+          propertiesFile = System.getProperty("user.home") + "/.jalview_properties";\r
+        }\r
 \r
         try\r
         {\r
-            String localFile = Cache.class.getProtectionDomain().getCodeSource()\r
-                                          .getLocation().toString();\r
-            localFile = localFile.concat("!/");\r
-\r
-            String tmpString = "jar:";\r
-            String localJarFileString = tmpString.concat(localFile);\r
-            java.net.URL localJarFileURL = new java.net.URL(localJarFileString);\r
-            java.net.JarURLConnection localJarFile = (java.net.JarURLConnection) localJarFileURL.openConnection();\r
-            date = localJarFile.getLastModified();\r
+            FileInputStream fis = new FileInputStream(propertiesFile);\r
+            applicationProperties.load(fis);\r
+            fis.close();\r
         }\r
         catch (Exception ex)\r
         {\r
-            ex.printStackTrace();\r
+          System.out.println("Error reading properties file: "+ex);\r
         }\r
 \r
-        if (date == 0)\r
-        {\r
-            // this is called for unpackaged class files, ie not in a Jar file\r
-            // InstallAnywhere version will find build date this way\r
-            // not entirely accurate as it only tells you when Cache.class was last compiled\r
-            java.io.File f = new java.io.File(System.getProperty("user.dir") +\r
-                    "/jalview/bin/Cache.class");\r
-            date = f.lastModified();\r
-        }\r
+        // FIND THE VERSION NUMBER AND BUILD DATE FROM jalview.jar\r
+        // MUST FOLLOW READING OF LOCAL PROPERTIES FILE AS THE\r
+        // VERSION MAY HAVE CHANGED SINCE LAST USING JALVIEW\r
+         try\r
+         {\r
+             String buildDetails = "jar:"\r
+                 .concat(\r
+                 Cache.class.getProtectionDomain().getCodeSource().getLocation().toString()\r
+                 .concat("!/.build_properties")\r
+                 );\r
 \r
-        if (date != 0)\r
-        {\r
-            BUILD_DATE = new Date(date).toString();\r
-        }\r
-\r
-        applicationProperties = new Properties();\r
+             java.net.URL localJarFileURL = new java.net.URL(buildDetails);\r
 \r
-        try\r
-        {\r
-            FileInputStream in = new FileInputStream(propertiesFile);\r
-            applicationProperties = new Properties();\r
+            InputStream in = localJarFileURL.openStream();\r
             applicationProperties.load(in);\r
             in.close();\r
+         }\r
+         catch (Exception ex)\r
+         {\r
+           System.out.println("Error reading build details: "+ex);\r
         }\r
-        catch (Exception ex)\r
+\r
+        String jnlpVersion = System.getProperty("jalview.version");\r
+        String codeVersion = getProperty("VERSION");\r
+\r
+        // jnlpVersion will be null if we're using InstallAnywhere\r
+        if(jnlpVersion==null)\r
         {\r
+          try{\r
+            java.net.URL url = new java.net.URL("http://www.jalview.org/webstart/jalview.jnlp");\r
+            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));\r
+            String line = null;\r
+            while( (line = in.readLine()) !=null)\r
+            {\r
+              if(line.indexOf("jalview.version")==-1)\r
+                continue;\r
+\r
+              line = line.substring(line.indexOf("value=")+7);\r
+              line = line.substring(0, line.lastIndexOf("\""));\r
+              setProperty("jalview.version", line);\r
+            }\r
+          }catch(Exception ex)\r
+          {setProperty("jalview.version", codeVersion);}\r
         }\r
     }\r
 \r
index 6a6ba2f..d5182df 100755 (executable)
@@ -436,15 +436,32 @@ public class Desktop extends jalview.jbgui.GDesktop
      */\r
     public void aboutMenuItem_actionPerformed(ActionEvent e)\r
     {\r
-        JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
-            "JalView 2005 version " + jalview.bin.Cache.VERSION +\r
-            "; last updated: " + jalview.bin.Cache.BUILD_DATE +\r
-            "\nAuthors:  Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton." +\r
+      StringBuffer message = new StringBuffer("JalView 2005 version " +\r
+                                              jalview.bin.Cache.getProperty(\r
+          "VERSION") +\r
+                                              "; last updated: " +\r
+                                              jalview.bin.\r
+                                              Cache.getProperty("BUILD_DATE"));\r
+\r
+      if (!jalview.bin.Cache.getProperty("jalview.version").equals(\r
+          jalview.bin.Cache.getProperty("VERSION")))\r
+      {\r
+        message.append("\n\n!! Jalview version "\r
+                       + jalview.bin.Cache.getProperty("jalview.version")\r
+                       + " is available for download from http://www.jalview.org !!\n");\r
+\r
+      }\r
+\r
+      message.append( "\nAuthors:  Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton." +\r
             "\nCurrent development managed by Andrew Waterhouse; Barton Group, University of Dundee." +\r
             "\nFor all issues relating to Jalview, email help@jalview.org" +\r
             "\n\nIf  you use JalView, please cite:" +\r
             "\n\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"" +\r
-            "\nBioinformatics,  2004 12;426-7.", "About Jalview",\r
+            "\nBioinformatics,  2004 12;426-7.");\r
+\r
+        JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
+\r
+           message.toString(), "About Jalview",\r
             JOptionPane.INFORMATION_MESSAGE);\r
     }\r
 \r
index ee96baa..44ff2ad 100755 (executable)
@@ -158,7 +158,7 @@ public class Jalview2XML
         object.setVamsasModel(new VamsasModel());\r
 \r
         object.setCreationDate(new java.util.Date(timeStamp));\r
-        object.setVersion(jalview.bin.Cache.VERSION);\r
+        object.setVersion(jalview.bin.Cache.getProperty("VERSION"));\r
 \r
         jalview.datamodel.AlignmentI jal = af.viewport.alignment;\r
 \r
index aff93d7..515b2a6 100755 (executable)
@@ -123,18 +123,35 @@ public class SplashScreen extends JPanel implements Runnable
             g.drawImage(image, 5, yoffset + 12, this);\r
         }\r
 \r
-        g.drawString("JalView 2005 ", 50, yoffset);\r
+        int y = yoffset;\r
+\r
+        g.drawString("JalView 2005 ", 50, y);\r
         g.setFont(new Font("Verdana", Font.BOLD, fontSize + 2));\r
-        g.drawString("Version " + jalview.bin.Cache.VERSION +\r
-            "; Last updated: " + jalview.bin.Cache.BUILD_DATE, 180, yoffset);\r
+        g.drawString("Version " + jalview.bin.Cache.getProperty("VERSION") +\r
+                     "; Last updated: " + jalview.bin.Cache.getProperty("BUILD_DATE"),\r
+                     180, y);\r
+\r
+        if (!jalview.bin.Cache.getProperty("jalview.version").equals(\r
+            jalview.bin.Cache.getProperty("VERSION")))\r
+        {\r
+          // If the jnlp version and the code version differ, warn the user\r
+          g.setColor(Color.red);\r
+          g.drawString("!! Jalview version " +\r
+                       jalview.bin.Cache.getProperty("jalview.version")\r
+                       + " is available for download from http://www.jalview.org !!",\r
+                       50, y += fontSize + 10);\r
+          y += 5;\r
+          g.setColor(Color.black);\r
+        }\r
+\r
         g.setFont(new Font("Verdana", Font.BOLD, fontSize));\r
         g.drawString("Authors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton.",\r
-            50, yoffset + 20);\r
+            50, y+=fontSize+4);\r
         g.drawString("Current development managed by Andrew Waterhouse; Barton Group, University of Dundee.",\r
-            50, yoffset + 24 + fontSize);\r
+            50,  y+=fontSize+4);\r
         g.drawString("If  you use JalView, please cite: Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004),",\r
-            50, yoffset + 28 + (fontSize * 2));\r
+            50, y+=fontSize+4);\r
         g.drawString("\"The Jalview Java Alignment Editor\" Bioinformatics,  2004 12;426-7.",\r
-            50, yoffset + 32 + (fontSize * 3));\r
+            50, y+=fontSize+4);\r
     }\r
 }\r