Author: jflesch
Date: 2007-12-16 16:46:19 +0000 (Sun, 16 Dec 2007)
New Revision: 16600

Added:
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/KnownBoardListProvider.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/BoardAttachment.java
Modified:
   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/MiniFrost.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/SpecialBoardFactory.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardAttachment.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoardFactory.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/BoardFactory.java
Log:
Allow to add a new board from a known board list

Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-12-16 
15:55:55 UTC (rev 16599)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-12-16 
16:46:19 UTC (rev 16600)
@@ -683,6 +683,8 @@
 thaw.plugin.miniFrost.views.gmail=Vue 1
 thaw.plugin.miniFrost.views.outlook=Vue 2

+thaw.plugin.miniFrost.knownBoard=Board connue
+thaw.plugin.miniFrost.knownBoard.select=Veuillez s?lectionner une board:

 ## Index web grapher
 thaw.plugin.indexWebGrapher=Une tentative de repr?sentation de la toile des 
indexes

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-12-16 15:55:55 UTC 
(rev 16599)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-12-16 16:46:19 UTC 
(rev 16600)
@@ -691,6 +691,8 @@
 thaw.plugin.miniFrost.views.gmail=View 1
 thaw.plugin.miniFrost.views.outlook=View 2

+thaw.plugin.miniFrost.knownBoard=Known board
+thaw.plugin.miniFrost.knownBoard.select=Please select a board:

 ## index web grapher


Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-12-16 15:55:55 UTC 
(rev 16599)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-12-16 16:46:19 UTC 
(rev 16600)
@@ -683,6 +683,8 @@
 thaw.plugin.miniFrost.views.gmail=Vue 1
 thaw.plugin.miniFrost.views.outlook=Vue 2

+thaw.plugin.miniFrost.knownBoard=Board connue
+thaw.plugin.miniFrost.knownBoard.select=Veuillez s\u00e9lectionner une board:

 ## Index web grapher
 thaw.plugin.indexWebGrapher=Une tentative de repr\u00e9sentation de la toile 
des indexes

Modified: trunk/apps/Thaw/src/thaw/plugins/MiniFrost.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/MiniFrost.java     2007-12-16 15:55:55 UTC 
(rev 16599)
+++ trunk/apps/Thaw/src/thaw/plugins/MiniFrost.java     2007-12-16 16:46:19 UTC 
(rev 16600)
@@ -28,6 +28,7 @@

        public final static BoardFactory[] factories =
                new BoardFactory[] {
+                       new thaw.plugins.miniFrost.KnownBoardListProvider(),
                        new thaw.plugins.miniFrost.frostKSK.KSKBoardFactory(),
                        new thaw.plugins.miniFrost.frostKSK.SSKBoardFactory(),
                        new thaw.plugins.miniFrost.SpecialBoardFactory()

Added: trunk/apps/Thaw/src/thaw/plugins/miniFrost/KnownBoardListProvider.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/KnownBoardListProvider.java      
                        (rev 0)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/KnownBoardListProvider.java      
2007-12-16 16:46:19 UTC (rev 16600)
@@ -0,0 +1,88 @@
+package thaw.plugins.miniFrost;
+
+import java.util.Collections;
+import java.util.Vector;
+
+import javax.swing.JOptionPane;
+
+import thaw.core.Core;
+import thaw.core.MainWindow;
+import thaw.core.I18n;
+import thaw.plugins.Hsqldb;
+import thaw.plugins.MiniFrost;
+import thaw.plugins.miniFrost.interfaces.BoardAttachment;
+import thaw.plugins.miniFrost.interfaces.BoardFactory;
+
+public class KnownBoardListProvider implements BoardFactory {
+       private Hsqldb db;
+       private Core core;
+       private MiniFrost miniFrost;
+       
+       public KnownBoardListProvider() {
+               
+       }
+
+       public boolean init(Hsqldb db, Core core, MiniFrost miniFrost) {
+               this.db = db;
+               this.core = core;
+               this.miniFrost = miniFrost;
+
+               return true;
+       }
+       
+       public boolean cleanUp(int archiveAfter, int deleteAfter) {
+
+               return true;
+       }
+
+       public void createBoard(MainWindow mainWindow) {
+               Vector boardList = new Vector();
+               BoardFactory[] factories = miniFrost.getFactories();
+               
+               for (int i = 0; i < factories.length ; i++) {
+                       boardList.addAll(factories[i].getAllKnownBoards());
+               }
+               
+               Collections.sort(boardList);
+               
+               Object[] boardListAr = boardList.toArray();
+               
+               BoardAttachment selection = 
(BoardAttachment)JOptionPane.showInputDialog(mainWindow.getMainFrame(),
+                             
I18n.getMessage("thaw.plugin.miniFrost.knownBoard.select"),
+                             
I18n.getMessage("thaw.plugin.miniFrost.knownBoard.select"),
+                             JOptionPane.QUESTION_MESSAGE,
+                             null, /* icon */
+                             boardListAr,
+                             boardListAr[0]);
+               
+               if (selection == null)
+                       return;
+               
+               selection.addBoard(db, core.getQueueManager());
+               
+               miniFrost.getPanel().getBoardTree().refresh();
+       }
+
+       public Vector getAllKnownBoards() {
+               return new Vector();
+       }
+
+       public Vector getAllMessages(String[] keywords, int orderBy, boolean 
desc,
+                       boolean archived, boolean read, boolean unsigned, int 
minTrustLevel) {
+
+               return new Vector();
+       }
+
+       public Vector getBoards() {
+
+               return new Vector();
+       }
+
+       public Vector getSentMessages() {
+               return new Vector();
+       }
+
+       public String toString() {
+               return 
"["+I18n.getMessage("thaw.plugin.miniFrost.knownBoard")+"]";
+       }
+}

Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/SpecialBoardFactory.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/SpecialBoardFactory.java 
2007-12-16 15:55:55 UTC (rev 16599)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/SpecialBoardFactory.java 
2007-12-16 16:46:19 UTC (rev 16600)
@@ -68,6 +68,9 @@
                Logger.warning(this, "NI !");
        }

+       public Vector getAllKnownBoards() {
+               return new Vector();
+       }

        /**
         * For example 'frost boards' ; Use I18n ...

Modified: 
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardAttachment.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardAttachment.java 
2007-12-16 15:55:55 UTC (rev 16599)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardAttachment.java 
2007-12-16 16:46:19 UTC (rev 16600)
@@ -9,10 +9,10 @@
 import thaw.core.Logger;
 import thaw.fcp.FCPQueueManager;
 import thaw.plugins.miniFrost.interfaces.Board;
+import thaw.plugins.miniFrost.interfaces.BoardAttachment;

-
 public class KSKBoardAttachment
-       extends KSKAttachment {
+       extends KSKAttachment implements BoardAttachment {

        private String boardName;
        private String publicKey;
@@ -36,11 +36,20 @@
                        privateKey = ((SSKBoard)board).getPrivateKey();
                }
        }
+       
+       public KSKBoardAttachment(KSKBoardFactory factory,
+                       String boardName,
+                       String publicKey,
+                       String privateKey,
+                       String description) {
+               this(boardName, publicKey, privateKey, description);
+               this.boardFactory = factory;
+       }

        public KSKBoardAttachment(String boardName,
-                                 String publicKey,
-                                 String privateKey,
-                                 String description) {
+                                                       String publicKey,
+                                                       String privateKey,
+                                                       String description) {
                this.boardName = boardName;

                if (publicKey != null && publicKey.endsWith("/"))
@@ -188,15 +197,19 @@

        public void apply(Hsqldb db, FCPQueueManager queueManager, String 
action) {
                if (action.equals(I18n.getMessage("thaw.common.add"))) {
-                       if (publicKey != null) {
-                               boardFactory.createBoard(boardName, publicKey, 
privateKey);
-                               
boardFactory.getPlugin().getPanel().notifyChange();
+                       addBoard(db, queueManager);
+               }
+       }
+       
+       public void addBoard(Hsqldb db, FCPQueueManager queueManager) {
+               if (publicKey != null) {
+                       boardFactory.createBoard(boardName, publicKey, 
privateKey);
+                       boardFactory.getPlugin().getPanel().notifyChange();

-                               return;
-                       }
-                       boardFactory.createBoard(boardName);
-                       boardFactory.getPlugin().getPanel().notifyChange();
+                       return;
                }
+               boardFactory.createBoard(boardName);
+               boardFactory.getPlugin().getPanel().notifyChange();
        }


@@ -334,4 +347,8 @@
        public boolean isReady() {
                return true;
        }
+       
+       public int compareTo(Object o) {
+               return toString().compareTo(o.toString());
+       }
 }

Modified: 
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java    
2007-12-16 15:55:55 UTC (rev 16599)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java    
2007-12-16 16:46:19 UTC (rev 16600)
@@ -574,7 +574,32 @@
                }
        }

+       public Vector getAllKnownBoards() {
+               Vector v = new Vector();

+               try {
+                       synchronized(db.dbLock) {
+                               PreparedStatement st;
+                               
+                               st = 
db.getConnection().prepareStatement("select distinct name, publickey, 
privatekey from frostKSKAttachmentBoards");
+                               
+                               ResultSet set = st.executeQuery();
+                               
+                               while(set.next()) {
+                                       v.add(new KSKBoardAttachment(this,
+                                                                               
                set.getString("name"),
+                                                                               
                set.getString("publicKey"),
+                                                                               
                set.getString("privateKey"),
+                                                                               
                null));
+                               }
+                       }
+               } catch(SQLException e) {
+                       Logger.error(this, "Can't get the list of know boards 
because: "+e.toString());
+               }
+
+               return v;
+       }
+
        public String toString() {
                return I18n.getMessage("thaw.plugin.miniFrost.FrostKSK");
        }

Modified: 
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoardFactory.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoardFactory.java    
2007-12-16 15:55:55 UTC (rev 16599)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoardFactory.java    
2007-12-16 16:46:19 UTC (rev 16600)
@@ -228,6 +228,11 @@
                        }
                }
        }
+       
+       public Vector getAllKnownBoards() {
+               /* KSKBoardFactory already answered for us */
+               return new Vector();
+       }

        public String toString() {
                return I18n.getMessage("thaw.plugin.miniFrost.FrostSSK");

Added: 
trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/BoardAttachment.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/BoardAttachment.java  
                        (rev 0)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/BoardAttachment.java  
2007-12-16 16:46:19 UTC (rev 16600)
@@ -0,0 +1,13 @@
+package thaw.plugins.miniFrost.interfaces;
+
+import thaw.fcp.FCPQueueManager;
+import thaw.plugins.Hsqldb;
+
+public interface BoardAttachment extends Attachment, java.lang.Comparable {
+
+       /**
+        * Add the specified board to the board list (board list will be 
refreshed after)
+        */
+       public void addBoard(Hsqldb db, FCPQueueManager queueManager);
+       
+}

Modified: 
trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/BoardFactory.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/BoardFactory.java     
2007-12-16 15:55:55 UTC (rev 16599)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/BoardFactory.java     
2007-12-16 16:46:19 UTC (rev 16600)
@@ -36,6 +36,11 @@
        public Vector getSentMessages();

        /**
+        * @return a list of BoardAttachment
+        */
+       public Vector getAllKnownBoards();
+
+       /**
         * display the dialog asking for a name, etc.
         * the tree will be reloaded after that
         */


Reply via email to