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