1 32 33 package it.businesslogic.ireport.plugin.checkupdate; 34 35 import it.businesslogic.ireport.util.I18n; 36 import java.net.URLConnection ; 37 38 42 public class UpgradeSearch implements Runnable { 43 44 private CheckUpdateDialog win = null; 45 public void run() { 46 try { 47 49 java.net.URL url = new java.net.URL ("http://ireport.sf.net/lastversion.php"); 50 byte[] webBuffer = new byte[100]; 51 URLConnection uConn = url.openConnection(); 52 java.io.InputStream is = uConn.getInputStream(); 54 int readed = is.read(webBuffer); 55 String version = new String (webBuffer,0,readed); 56 if (version.toLowerCase().startsWith("ireport")) { 57 if (version.compareTo(it.businesslogic.ireport.gui.MainFrame.constTitle) > 0) { 58 59 final String fversion = version; 60 javax.swing.SwingUtilities.invokeLater(new Runnable () { 61 public void run() { 62 javax.swing.JOptionPane.showMessageDialog(it.businesslogic.ireport.gui.MainFrame.getMainInstance(), 63 I18n.getFormattedString("messages.upgradeSearch.newVersion", 64 "{0} is available on http://ireport.sf.net!", new Object []{fversion}) ); 65 }}); 66 } 67 } 68 } catch (Throwable ex) { 69 ex.printStackTrace(); 70 } 71 72 if (win != null) win.setVisible(false); 73 } 74 75 public CheckUpdateDialog getWin() { 76 return win; 77 } 78 79 public void setWin(CheckUpdateDialog win) { 80 this.win = win; 81 } 82 } 83 84 | Popular Tags |