Author: jflesch
Date: 2007-08-07 21:18:47 +0000 (Tue, 07 Aug 2007)
New Revision: 14520

Modified:
   trunk/apps/Thaw/images/blueBunny.png
   trunk/apps/Thaw/src/thaw/core/Main.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/DatabaseManager.java
   trunk/apps/Thaw/src/thaw/plugins/index/Index.java
   trunk/apps/Thaw/src/thaw/plugins/index/IndexConfigDialog.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java
Log:
Fix a bug at the initial startup : The jar path was URLEncoded

Modified: trunk/apps/Thaw/images/blueBunny.png
===================================================================
(Binary files differ)

Modified: trunk/apps/Thaw/src/thaw/core/Main.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Main.java     2007-08-07 17:57:33 UTC (rev 
14519)
+++ trunk/apps/Thaw/src/thaw/core/Main.java     2007-08-07 21:18:47 UTC (rev 
14520)
@@ -153,8 +153,9 @@
                try {
                        String realHome = this.getClass().getProtectionDomain().
                                getCodeSource().getLocation().toString();
-                       String home = realHome.substring(5);

+                       String home = 
java.net.URLDecoder.decode(realHome.substring(5), "UTF-8");
+
                        Logger.info(this, "Extracting : "+realHome+" ; "+src+" 
; "+dst);

                        ZipFile jar = new ZipFile(home);

Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-08-07 
17:57:33 UTC (rev 14519)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-08-07 
21:18:47 UTC (rev 14520)
@@ -396,6 +396,11 @@

 thaw.plugin.index.newRev=Index 'X' mis ? jour ? la r?vision 'Y'

+thaw.plugin.index.category=Tri automatique dans:
+thaw.plugin.index.changeCategory=Changer
+thaw.plugin.index.categoryUnspecified=[Non-sp?cifi?]
+
+
 # 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-07 17:57:33 UTC 
(rev 14519)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-08-07 21:18:47 UTC 
(rev 14520)
@@ -406,7 +406,11 @@

 thaw.plugin.index.newRev=Index 'X' updated to the revision 'Y'

+thaw.plugin.index.category=Automatic sorting in:
+thaw.plugin.index.changeCategory=Change
+thaw.plugin.index.categoryUnspecified=[Unspecified]

+
 # 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-07 17:57:33 UTC 
(rev 14519)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-08-07 21:18:47 UTC 
(rev 14520)
@@ -396,6 +396,10 @@

 thaw.plugin.index.newRev=Index 'X' mis \u00e0 jour \u00e0 la r\u00e9vision 'Y'

+thaw.plugin.index.category=Tri automatique dans:
+thaw.plugin.index.changeCategory=Changer
+
+
 # Peer monitor

 thaw.plugin.peerMonitor.peerMonitor=Connexion

Modified: trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java 2007-08-07 
17:57:33 UTC (rev 14519)
+++ trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java 2007-08-07 
21:18:47 UTC (rev 14520)
@@ -59,7 +59,7 @@
  *  |-- indexFolders (id, name, positionInTree)
  *  | |-- [...]
  *  |
- *  |-- indexes (id, realName, displayName, publicKey, [privateKey], 
positionInTree, ...)
+ *  |-- indexes (id, realName, displayName, publicKey, [privateKey], ...)
  *    |-- links (id, indexName, indexPublicKey)
  *    |-- files (id, filename, publicKey, mime, size)
  *      |-- metadatas (id, name, value)
@@ -91,7 +91,7 @@

                if (config.getValue("indexDatabaseVersion") == null) {
                        newDb = true;
-                       config.setValue("indexDatabaseVersion", "8");
+                       config.setValue("indexDatabaseVersion", "9");
                } else {

                        /* CONVERTIONS */
@@ -148,6 +148,13 @@
                                        config.setValue("indexDatabaseVersion", 
"8");
                        }

+                       if 
("8".equals(config.getValue("indexDatabaseVersion"))) {
+                               if (splashScreen != null)
+                                       splashScreen.setStatus("Converting 
database ...");
+                               if (convertDatabase_8_to_9(db))
+                                       config.setValue("indexDatabaseVersion", 
"9");
+                       }
+
                        /* ... */
                }

@@ -165,6 +172,9 @@
                //sendQuery(db,
                //        "SET IGNORECASE TRUE");

+               /* category syntax:
+                *  "folder[/subfolder[/subsubfolder]]"
+                */
                sendQuery(db,
                          "CREATE CACHED TABLE categories ("
                          + "id INTEGER IDENTITY NOT NULL,"
@@ -192,6 +202,7 @@
                          + "positionInTree INTEGER NOT NULL, "
                          + "revision INTEGER NOT NULL, "
                          + "insertionDate DATE DEFAULT NULL NULL, "
+                         + "categoryId INTEGER DEFAULT NULL NULL, "
                          + "newRev BOOLEAN DEFAULT FALSE NOT NULL, "
                          + "newComment BOOLEAN DEFAULT FALSE NOT NULL, "
                          + "parent INTEGER NULL, " /* direct parent */
@@ -993,7 +1004,7 @@
                if (!sendQuery(db, "DELETE FROM indexComments")
                    || !sendQuery(db, "ALTER TABLE indexComments DROP r")
                    || !sendQuery(db, "ALTER TABLE indexComments DROP s")
-                   || !sendQuery(db, "ALTER TABLE indexComments ADD sig 
VARCHAR(400) NOT NULL")) {
+                   || !sendQuery(db, "ALTER TABLE indexComments ADD COLUMN sig 
VARCHAR(400) NOT NULL")) {

                        Logger.error(new DatabaseManager(), "Error while 
converting the database (7 to 8) !");
                        return false;
@@ -1001,4 +1012,17 @@

                return true;
        }
+
+
+       public static boolean convertDatabase_8_to_9(Hsqldb db) {
+               if (!sendQuery(db, "ALTER TABLE indexes ADD COLUMN categoryId 
INTEGER DEFAULT NULL NULL")
+                   || !sendQuery(db, "ALTER TABLE indexes ADD FOREIGN KEY 
(categoryId) REFERENCES categories (id)")) {
+
+                       Logger.error(new DatabaseManager(), "Error while 
converting the database (8 to 9) !");
+                       return false;
+               }
+
+               return true;
+
+       }
 }

Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java   2007-08-07 17:57:33 UTC 
(rev 14519)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java   2007-08-07 21:18:47 UTC 
(rev 14520)
@@ -78,6 +78,7 @@
        private int lastCommentRev = 0;
        private int nmbFailedCommentFetching = 0;

+
        private Config config;

        /**
@@ -1814,4 +1815,78 @@
        public String getClientVersion() {
                return ("Thaw "+Main.VERSION);
        }
+
+
+       public String getCategory() {
+               try {
+                       synchronized(db.dbLock) {
+                               PreparedStatement st;
+                               st = 
db.getConnection().prepareStatement("SELECT categories.name AS name "+
+                                                                        "FROM 
categories INNER JOIN indexes "+
+                                                                        " ON 
categories.id = indexes.categoryId "+
+                                                                        "WHERE 
indexes.id = ? LIMIT 1");
+                               st.setInt(1, id);
+
+                               ResultSet set = st.executeQuery();
+
+                               if (!set.next())
+                                       return null;
+
+                               return set.getString("name").toLowerCase();
+                       }
+               } catch(SQLException e) {
+                       Logger.error(this,
+                                    "Unable to get the category of the index 
because : "+
+                                    e.toString());
+               }
+
+               return null;
+       }
+
+
+       /**
+        * create it if it doesn't exist
+        */
+       public void setCategory(String category) {
+               try {
+                       synchronized(db.dbLock) {
+                               PreparedStatement st;
+                               ResultSet set;
+
+                               int catId = 0;
+
+                               while (catId == 0) {
+                                       /* localisation */
+                                       st = 
db.getConnection().prepareStatement("SELECT id FROM categories "+
+                                                                               
 "WHERE name = ? LIMIT 1");
+                                       st.setString(1, category.toLowerCase());
+
+                                       set = st.executeQuery();
+
+                                       if (set.next())
+                                               catId = set.getInt("id");
+                                       else {
+                                               /* insertion */
+                                               st = 
db.getConnection().prepareStatement("INSERT INTO categories "+
+                                                                               
         "(name) VALUES (?)");
+                                               st.setString(1, 
category.toLowerCase());
+                                               st.execute();
+                                       }
+                               }
+
+
+                               /* set the categoryId of the index */
+
+                               st = 
db.getConnection().prepareStatement("UPDATE indexes SET categoryId = ? "+
+                                                                        "WHERE 
id = ?");
+                               st.setInt(1, catId);
+                               st.setInt(2, id);
+                               st.execute();
+
+                       }
+
+               } catch(SQLException e) {
+                       Logger.error(this, "Can't set the category because : 
"+e.toString());
+               }
+       }
 }

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexConfigDialog.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexConfigDialog.java       
2007-08-07 17:57:33 UTC (rev 14519)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexConfigDialog.java       
2007-08-07 21:18:47 UTC (rev 14520)
@@ -22,13 +22,18 @@
 import thaw.fcp.FreenetURIHelper;
 import thaw.core.I18n;
 import thaw.core.Logger;
+import thaw.plugins.Hsqldb;


 public class IndexConfigDialog implements ActionListener, MouseListener {
+       public final static int SIZE_X = 700;
+       public final static int SIZE_Y = 170;
+
        private JDialog frame;

        private IndexBrowserPanel indexBrowser;
        private FCPQueueManager queueManager;
+       private Hsqldb db;
        private Index index;


@@ -43,6 +48,8 @@
        private JCheckBox  publishPrivateKeyBox = null;
        private JCheckBox  allowCommentsBox     = null;

+       private JButton    changeCategory;
+
        private JPopupMenu popupMenuA;
        private JPopupMenu popupMenuB;

@@ -65,7 +72,8 @@
                                 Index index) {
                this.indexBrowser = indexBrowser;
                this.queueManager = queueManager;
-               this.index = index;
+               this.index        = index;
+               this.db           = indexBrowser.getDb();
        }


@@ -145,9 +153,21 @@


                resetCommentsButton = new 
JButton(I18n.getMessage("thaw.plugin.index.comment.reset"));
+               resetCommentsButton.setEnabled(index != null && 
index.getPrivateKey() != null);
                resetCommentsButton.addActionListener(this);

+               String cat = (index == null ? null : index.getCategory());

+               if (cat == null)
+                       cat = 
I18n.getMessage("thaw.plugin.index.categoryUnspecified");
+
+               JLabel categoryLabel = new 
JLabel(I18n.getMessage("thaw.plugin.index.category")
+                                                 +" "+cat);
+               changeCategory = new 
JButton(I18n.getMessage("thaw.plugin.index.changeCategory"));
+               changeCategory.setEnabled(index != null && 
index.getPrivateKey() != null);
+               changeCategory.addActionListener(this);
+
+
                /* public & private keys */

                final JPanel labelPanel = new JPanel();
@@ -184,7 +204,7 @@


                final JPanel indexSettingsPanel = new JPanel();
-               indexSettingsPanel.setLayout(new GridLayout(3, 1));
+               indexSettingsPanel.setLayout(new GridLayout(4, 1));

                final JPanel mainButtonPanel = new JPanel();
                mainButtonPanel.setLayout(new GridLayout(1, 2));
@@ -200,13 +220,16 @@

                JPanel commentPanel = new JPanel(new BorderLayout());
                commentPanel.add(allowCommentsBox, BorderLayout.CENTER);
+               commentPanel.add(resetCommentsButton, BorderLayout.EAST);

-               if (index != null && index.getPrivateKey() != null)
-                       commentPanel.add(resetCommentsButton, 
BorderLayout.EAST);
+               JPanel categoryPanel = new JPanel(new BorderLayout());
+               categoryPanel.add(categoryLabel, BorderLayout.CENTER);
+               categoryPanel.add(changeCategory, BorderLayout.EAST);

-
                indexSettingsPanel.add(publishPrivateKeyBox);
                indexSettingsPanel.add(commentPanel);
+               indexSettingsPanel.add(categoryPanel);
+
                indexSettingsPanel.add(mainButtonPanel);

                frame.getContentPane().add(indexSettingsPanel, 
BorderLayout.SOUTH);
@@ -217,7 +240,7 @@

                /* let's rock'n'rool :p */

-               frame.setSize(700, 140);
+               frame.setSize(SIZE_X, SIZE_Y);
                frame.setVisible(true);

                try {
@@ -259,25 +282,30 @@
        }


-       public synchronized void actionPerformed(final ActionEvent e) {
+       public void actionPerformed(final ActionEvent e) {
                if (e.getSource() == okButton) {
                        formState = 1;
                        synchronized(this) {
                                notifyAll();
                        }
                        return;
-               }

-               if (e.getSource() == cancelButton) {
+               } else if (e.getSource() == cancelButton) {
+
                        formState = 2;
                        synchronized(this) {
                                notifyAll();
                        }
                        return;
-               }

-               if (e.getSource() == resetCommentsButton) {
+               } else if (e.getSource() == resetCommentsButton) {
+
                        index.regenerateCommentKeys(queueManager);
+
+               } else if (e.getSource() == changeCategory) {
+
+                       /* TODO */
+
                }
        }


Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java   
2007-08-07 17:57:33 UTC (rev 14519)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java   
2007-08-07 21:18:47 UTC (rev 14520)
@@ -567,7 +567,7 @@

                /* if the last date was in the future */
                if (getMidnight(originalDate).getTime() > today.getTime()) {
-                       /* TODO : Take in consideration that we could have
+                       /* TODO : Take into consideration that we could have
                         *        MIN_DAYS_IN_THE_FUTURE > 1
                         */
                        /* we stop */


Reply via email to