Author: jflesch
Date: 2007-08-08 18:27:27 +0000 (Wed, 08 Aug 2007)
New Revision: 14531

Modified:
   trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
   trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
   trunk/apps/Thaw/src/thaw/i18n/thaw.properties
   trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
   trunk/apps/Thaw/src/thaw/plugins/index/Index.java
   trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
Log:
Always highlight an index when it's downloaded for the first time

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java      2007-08-08 18:20:48 UTC 
(rev 14530)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java      2007-08-08 18:27:27 UTC 
(rev 14531)
@@ -1071,6 +1071,10 @@
                return publicKey;
        }

+       public int getRevision() {
+               return rev;
+       }
+
        /**
         * Do nothing.
         */

Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-08-08 
18:20:48 UTC (rev 14530)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-08-08 
18:27:27 UTC (rev 14531)
@@ -401,10 +401,11 @@
 thaw.plugin.index.categoryUnspecified=[Non-sp?cifi?]

 thaw.plugin.index.category=Categorie
-
 thaw.plugin.index.categories=Categories (S?parateur: '/')
+thaw.plugin.index.noCategory=Vous n'avez sp?cifi? aucune cat?gorie pour 
l'index '?'.\n?tes-vous s?r de vouloir l'ins?rer tel quel ?


+
 # Peer monitor

 thaw.plugin.peerMonitor.peerMonitor=Connexion

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-08-08 18:20:48 UTC 
(rev 14530)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-08-08 18:27:27 UTC 
(rev 14531)
@@ -414,8 +414,11 @@

 thaw.plugin.index.category=Category
 thaw.plugin.index.categories=Categories (Separator: '/')
+thaw.plugin.index.noCategory=You didn't specify a category for the index 
'?'.\nAre you sure that you want to insert it as it ?


+
+
 # Peer monitor

 thaw.plugin.peerMonitor.peerMonitor=Connection

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-08-08 18:20:48 UTC 
(rev 14530)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-08-08 18:27:27 UTC 
(rev 14531)
@@ -401,10 +401,11 @@
 thaw.plugin.index.categoryUnspecified=[Non-sp\u00e9cifi\u00e9]

 thaw.plugin.index.category=Categorie
-
 thaw.plugin.index.categories=Categories (S\u00e9parateur: '/')
+thaw.plugin.index.noCategory=Vous n'avez sp\u00e9cifi\u00e9 aucune 
cat\u00e9gorie pour l'index '?'.\n\u00cates-vous s\u00fbr de vouloir 
l'ins\u00e9rer tel quel ?


+
 # Peer monitor

 thaw.plugin.peerMonitor.peerMonitor=Connexion

Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java   2007-08-08 18:20:48 UTC 
(rev 14530)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java   2007-08-08 18:27:27 UTC 
(rev 14531)
@@ -81,6 +81,9 @@

        private Config config;

+       private boolean isNew;
+
+
        /**
         * @deprecated Just don't use it !
         */
@@ -113,6 +116,11 @@
        }


+       public void setIsNewFlag() {
+               isNew = true;
+       }
+
+
        /**
         * Won't apply in the database !
         */
@@ -645,6 +653,27 @@
                                        Logger.error(this, "Error while 
checking the link number before insertion : "+e.toString());
                                }
                        }
+
+
+
+                       if (getCategory() == null) {
+                               int ret =
+                                       
JOptionPane.showOptionDialog(indexBrowser.getMainWindow().getMainFrame(),
+                                                                    
I18n.getMessage("thaw.plugin.index.noCategory").replaceAll("\\?", 
toString(false)),
+                                                                    
I18n.getMessage("thaw.warning.title"),
+                                                                    
JOptionPane.YES_NO_OPTION,
+                                                                    
JOptionPane.WARNING_MESSAGE,
+                                                                    null,
+                                                                    null,
+                                                                    null);
+
+                               if (ret == JOptionPane.CLOSED_OPTION
+                                   || ret == JOptionPane.NO_OPTION) {
+                                       return 0;
+                               }
+                       }
+
+
                }


@@ -880,11 +909,13 @@
                                        setPublicKey(key, newRev);
                                }

-                               if (oldRev < newRev) {
+                               if (oldRev < newRev || isNew) {
                                        setHasChangedFlag(true);
                                        useTrayIconToNotifyNewRev();
                                }

+                               isNew = false;
+
                                String path = get.getPath();

                                if (path != null) {
@@ -920,32 +951,37 @@
                }

                if (o instanceof FCPClientPut) {
+                       FCPClientPut put = ((FCPClientPut)o);
+
                        /* TODO : check if it's successful, else merge if it's 
due to a collision */
-                       if (((FCPClientPut)o).isFinished()) {
-                               ((FCPClientPut)o).deleteObserver(this);
+                       if (put.isFinished()) {
+                               put.deleteObserver(this);

                                if (indexTree != null)
                                        indexTree.removeUpdatingIndex(this);

-                               try {
-                                       synchronized(db.dbLock) {
-                                               /* TODO : Find a nicer way */
+                               if (put.isSuccessful()) {
+                                       try {
+                                               synchronized(db.dbLock) {
+                                                       PreparedStatement st;

-                                               PreparedStatement st;
+                                                       Calendar cal= 
Calendar.getInstance();
+                                                       java.sql.Date dateSql = 
new java.sql.Date(cal.getTime().getTime() );

-                                               Calendar cal= 
Calendar.getInstance();
-                                               java.sql.Date dateSql = new 
java.sql.Date(cal.getTime().getTime() );
+                                                       st = 
db.getConnection().prepareStatement("UPDATE indexes "+
+                                                                               
                 "SET insertionDate = ? "+
+                                                                               
                 "WHERE id = ?");
+                                                       st.setDate(1, dateSql);
+                                                       st.setInt(2, id);

-                                               st = 
db.getConnection().prepareStatement("UPDATE indexes "+
-                                                                               
         "SET insertionDate = ? "+
-                                                                               
         "WHERE id = ?");
-                                               st.setDate(1, dateSql);
-                                               st.setInt(2, id);
-
-                                               st.execute();
+                                                       st.execute();
+                                               }
+                                       } catch(SQLException e) {
+                                               Logger.error(this, "Error while 
updating the insertion date : "+e.toString());
                                        }
-                               } catch(SQLException e) {
-                                       Logger.error(this, "Error while 
updating the insertion date : "+e.toString());
+                               } else {
+                                       if (put.getRevision() == rev)
+                                               setPublicKey(publicKey, rev-1);
                                }
                        }
                }

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java   
2007-08-08 18:20:48 UTC (rev 14530)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java   
2007-08-08 18:27:27 UTC (rev 14531)
@@ -457,14 +457,17 @@

                }

+               index.setIsNewFlag();
+
                ((MutableTreeNode)parent).insert((index), 0);

                indexBrowser.getIndexTree().refresh(parent);

                indexBrowser.getUnknownIndexList().removeLink(index);

-               if (load)
+               if (load) {
                        download(queueManager, indexBrowser, index);
+               }

                return index;
        }


Reply via email to