From: <bma...@us...> - 2017-01-02 14:44:00
|
Revision: 9497 http://sourceforge.net/p/fudaa/svn/9497 Author: bmarchan Date: 2017-01-02 14:43:57 +0000 (Mon, 02 Jan 2017) Log Message: ----------- Fudaa-LSPIV : Detection de mises ?\195?\160 jour Modified Paths: -------------- trunk/soft/fudaa-lspiv/src/main/java/org/fudaa/fudaa/piv/PivImplementation.java Added Paths: ----------- trunk/soft/fudaa-lspiv/src/main/java/org/fudaa/fudaa/piv/PivUpdatePanel.java Modified: trunk/soft/fudaa-lspiv/src/main/java/org/fudaa/fudaa/piv/PivImplementation.java =================================================================== --- trunk/soft/fudaa-lspiv/src/main/java/org/fudaa/fudaa/piv/PivImplementation.java 2017-01-02 14:42:28 UTC (rev 9496) +++ trunk/soft/fudaa-lspiv/src/main/java/org/fudaa/fudaa/piv/PivImplementation.java 2017-01-02 14:43:57 UTC (rev 9497) @@ -16,6 +16,9 @@ import java.beans.PropertyVetoException; import java.io.File; import java.io.IOException; +import java.io.InputStreamReader; +import java.io.LineNumberReader; +import java.net.URL; import java.util.Iterator; import java.util.List; import java.util.Observable; @@ -78,6 +81,7 @@ import com.memoire.bu.BuRegistry; import com.memoire.bu.BuResource; import com.memoire.bu.BuUserPreferencesPanel; +import com.memoire.fu.FuLib; import com.memoire.fu.FuLog; /** @@ -92,9 +96,9 @@ protected static BuInformationsSoftware isPIV_ = new BuInformationsSoftware(); static { isPIV_.name = "LSPIV"; - isPIV_.version = "1.5.0"; + isPIV_.version = "1.5.1"; isPIV_.date = "2016-12-20"; - isPIV_.rights = PivResource.getS("Tous droits r\xE9serv\xE9s")+". CEREMA (c)1999-2016"; + isPIV_.rights = PivResource.getS("Tous droits r\xE9serv\xE9s")+". CEREMA (c)1999-2017"; isPIV_.license = "GPL2"; isPIV_.languages = "en,fr"; isPIV_.authors=new String[]{"B.Marchand (mar...@de...)"}; @@ -102,6 +106,7 @@ isPIV_.http="http://forge.irstea.fr/projects/fudaa-lspiv"; isPIV_.man="guide_Fudaa-lspiv_"+BuPreferences.BU.getStringProperty("locale.language", System.getProperty("piv.lang", "fr"))+".pdf"; isPIV_.citation=PivResource.getS("Ichiro Fujita (Prof.), Universit\xE9 de Kob\xE9"); + isPIV_.update=System.getProperty("piv.update", "http://www.deltacad.fr/downloads"); isPIV_.logo = PivResource.PIV.getIcon("iconepiv.gif"); isPIV_.banner = PivResource.PIV.getIcon("banniere.jpg"); @@ -269,6 +274,10 @@ create(); } else if ("AIDE_INDEX".equals(action)) { showHelp(); + } else if ("MAJ".equals(action)) { + if (!checkForUpdate(false)) { + message(PivResource.getS("Information"),PivResource.getS("La version de Fudaa-LSPIV est \xE0 jour"),false); + } } else if (action.startsWith("REOUVRIR")) { FuLog.trace(action.substring(9,action.length()-1)); @@ -706,6 +715,8 @@ setEnabledForAction("IMPORTER", true); setEnabledForAction("EXPORTER", true); + setEnabledForAction("MAJ", true); + BuMenuRecentFiles mr= (BuMenuRecentFiles)mb.getMenu("REOUVRIR"); if (mr != null) { mr.setPreferences(PivPreferences.PIV); @@ -939,6 +950,42 @@ PivResource.getS("La biblioth\xE8que JAI Image I/O n'est probablement pas install\xE9e.\nElle doit l'\xEAtre dans le r\xE9pertoire des extensions Java.\n\nL'application ne fonctionnera pas correctement.")); } } + + /** + * Controle l'existence d'une mise a jour sur l'URL de mise a jour et affiche un dialogue pour t\xE9l\xE9charger si c'est le cas. + * @param _showHideButton True : Le bouton "Ne plus afficher" est affich\xE9 dans le dialogue. + * @return True : Une mise a jour existe. + */ + public boolean checkForUpdate(boolean _showHideButton) { + try { + URL urlFlag=new URL(isPIV_.update+"/fudaa-lspiv-lastversion.txt"); + if (FuLib.existsURL(urlFlag)) { + LineNumberReader is=null; + try { + is=new LineNumberReader(new InputStreamReader(urlFlag.openStream())); + String lastversion; + while ((lastversion=is.readLine()) != null && lastversion.trim().startsWith("#")) { + } + + if (lastversion.compareTo(isPIV_.version)>0) { + URL urlJar = new URL(isPIV_.update+"/fudaa-lspiv-"+lastversion+"-setup.jar"); + new PivUpdatePanel(lastversion, urlJar, _showHideButton).afficheModale(this.getFrame(),PivResource.getS("Mise \xE0 jour disponible")); + return true; + } + } + finally { + if (is!=null) { + is.close(); + } + } + } + } + catch (IOException e) { + e.printStackTrace(); + } + + return false; + } /** * D\xE9marre l'application. @@ -949,6 +996,10 @@ super.addFrameListLeft(); controlJAILibrary(); + + if (PivPreferences.PIV.getBooleanProperty(FudaaStartupExitPreferencesPanel.PREF_CHECK_NEW_VERSION, true)) { + checkForUpdate(true); + } } } Added: trunk/soft/fudaa-lspiv/src/main/java/org/fudaa/fudaa/piv/PivUpdatePanel.java =================================================================== --- trunk/soft/fudaa-lspiv/src/main/java/org/fudaa/fudaa/piv/PivUpdatePanel.java (rev 0) +++ trunk/soft/fudaa-lspiv/src/main/java/org/fudaa/fudaa/piv/PivUpdatePanel.java 2017-01-02 14:43:57 UTC (rev 9497) @@ -0,0 +1,82 @@ +/* + * @creation 8 sept. 06 + * @modification $Date: 2009-06-03 15:10:45 +0200 (mer., 03 juin 2009) $ + * @license GNU General Public License 2 + * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail de...@fu... + */ +package org.fudaa.fudaa.piv; + +import java.awt.Cursor; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.net.URL; + +import javax.swing.BorderFactory; +import javax.swing.JCheckBox; +import javax.swing.JLabel; + +import org.fudaa.ctulu.gui.CtuluDialogPanel; +import org.fudaa.fudaa.commun.FudaaBrowserControl; +import org.fudaa.fudaa.commun.impl.FudaaStartupExitPreferencesPanel; +import org.jdesktop.swingx.VerticalLayout; + + +/** + * Un panneau pour l'affichage de la version a telecharger. + * @author Bertrand Marchand (mar...@de...) + * @version $Id: PivFlowInfoPanel.java 9491 2016-12-20 14:46:54Z bmarchan $ + */ +public class PivUpdatePanel extends CtuluDialogPanel { + + private JCheckBox cbHidden_; + + public PivUpdatePanel(String _version, final URL _url, boolean _showHideButton) { + setLayout(new VerticalLayout(10)); + setBorder(BorderFactory.createEmptyBorder(5, 5, 15, 5)); + + final JLabel lbLink=new JLabel(PivResource.getS("<html><a href=\"{0}\">T\xE9l\xE9chargez la version {1} de Fudaa-LSPIV</a></html>", _url.toString(), _version)); + lbLink.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent me) { + lbLink.setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + + public void mouseExited(MouseEvent me) { + lbLink.setCursor(Cursor.getDefaultCursor()); + } + + public void mouseClicked(MouseEvent me) { + try { + FudaaBrowserControl.displayURL(_url); + } + catch (Exception e) { + System.out.println(e); + } + } + }); + + + add(new JLabel(PivResource.getS("<html>Une mise \xE0 jour de Fudaa-LSPIV est disponible.<br>Cliquez sur le lien ci-dessous pour la t\xE9l\xE9charger.</html>"))); + add(lbLink); + + if (_showHideButton) { + cbHidden_=new JCheckBox(PivResource.getS("Ne plus afficher ce dialogue")); + add(cbHidden_); + } + } + + @Override + public boolean isDataValid() { + return true; + } + + @Override + public void apply() { + super.apply(); + + if (cbHidden_ != null) + PivPreferences.PIV.putBooleanProperty(FudaaStartupExitPreferencesPanel.PREF_CHECK_NEW_VERSION, !cbHidden_.isSelected()); + } + + +} \ No newline at end of file Property changes on: trunk/soft/fudaa-lspiv/src/main/java/org/fudaa/fudaa/piv/PivUpdatePanel.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |