Changeset 4812


Ignore:
Timestamp:
02/17/09 12:04:17 (11 years ago)
Author:
melissa
Message:

Added ImageJ plugin that will download the latest trunk, daily or stable build.
This plugin is automatically called if upgrade checking is enabled and a new stable version is detected; it can also be called manually using Plugins>LOCI>Upgrade LOCI Plugins. Closes #327, see #263.

Location:
trunk/components/loci-plugins/src
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/loci-plugins/src/loci/plugins/Importer.java

    r4810 r4812  
    8787      IJ.showStatus("Checking for new version..."); 
    8888      if (Util.newVersionAvailable()) { 
    89         IJ.showMessage("A new stable version of the Bio-Formats plugin is " + 
    90           "available.\nYou can download the latest version from " + 
    91           "http://loci.wisc.edu/ome/formats-download.html"); 
     89        boolean doUpgrade = IJ.showMessageWithCancel("", 
     90          "A new stable version of Bio-Formats is available.\n" + 
     91          "Click 'OK' to upgrade."); 
     92        if (doUpgrade) { 
     93          Updater.install(Updater.STABLE_BUILD); 
     94        } 
    9295      } 
    9396    } 
  • trunk/components/loci-plugins/src/loci/plugins/Util.java

    r4796 r4812  
    6666 
    6767  public static final String VERSION = "4.0.0"; 
     68 
     69  public static final String REGISTRY = "http://upgrade.openmicroscopy.org.uk"; 
     70 
     71  public static final String[] REGISTRY_PROPERTIES = new String[] { 
     72    "version", "os.name", "os.version", "os.arch", 
     73    "java.runtime.version", "java.vm.vendor" 
     74  }; 
    6875 
    6976  // -- Constructor -- 
     
    606613    // connect to the registry 
    607614 
    608     StringBuffer query = 
    609       new StringBuffer("http://upgrade.openmicroscopy.org.uk/"); 
    610     String[] properties = new String[] {"version", "os.name", "os.version", 
    611       "os.arch", "java.runtime.version", "java.vm.vendor"}; 
    612     for (int i=0; i<properties.length; i++) { 
     615    StringBuffer query = new StringBuffer(REGISTRY); 
     616    for (int i=0; i<REGISTRY_PROPERTIES.length; i++) { 
    613617      if (i == 0) query.append("?"); 
    614618      else query.append(";"); 
    615       query.append(properties[i]); 
     619      query.append(REGISTRY_PROPERTIES[i]); 
    616620      query.append("="); 
    617621      if (i == 0) query.append(VERSION); 
    618622      else { 
    619623        try { 
    620           query.append( 
    621             URLEncoder.encode(System.getProperty(properties[i]), "UTF-8")); 
     624          query.append(URLEncoder.encode( 
     625            System.getProperty(REGISTRY_PROPERTIES[i]), "UTF-8")); 
    622626        } 
    623627        catch (UnsupportedEncodingException e) { } 
     
    642646      in.close(); 
    643647 
    644       // TODO : registry does not yet return the latest version number 
    645       //return !latestVersion.toString().equals(VERSION); 
    646       return false; 
    647     } 
    648     catch (IOException e) { 
    649       return false; 
    650     } 
     648      // check to see if version reported by registry is greater than 
     649      // the current version - version number should be in "x.x.x" format 
     650 
     651      String[] version = latestVersion.toString().split("\\."); 
     652      String[] thisVersion = VERSION.split("\\."); 
     653      for (int i=0; i<thisVersion.length; i++) { 
     654        int subVersion = Integer.parseInt(thisVersion[i]); 
     655        try { 
     656          int registrySubVersion = Integer.parseInt(version[i]); 
     657          if (registrySubVersion > subVersion) return true; 
     658          if (registrySubVersion < subVersion) return false; 
     659        } 
     660        catch (NumberFormatException e) { 
     661          return false; 
     662        } 
     663      } 
     664    } 
     665    catch (IOException e) { } 
     666    return false; 
    651667  } 
    652668 
  • trunk/components/loci-plugins/src/plugins.config

    r4743 r4812  
    4141Plugins>LOCI, "LOCI Plugins Shortcut Window", loci.plugins.ShortcutPanel("") 
    4242 
     43Plugins>LOCI, "-" 
     44Plugins>LOCI, "Update LOCI Plugins", loci.plugins.Updater("") 
     45 
    4346Help>About Plugins, "LOCI Plugins...", loci.plugins.About("") 
Note: See TracChangeset for help on using the changeset viewer.