Author: jflesch
Date: 2006-10-15 21:56:19 +0000 (Sun, 15 Oct 2006)
New Revision: 10664

Modified:
   trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
   trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java
   trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java
   trunk/apps/Thaw/src/thaw/plugins/index/File.java
   trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java
   trunk/apps/Thaw/src/thaw/plugins/index/Index.java
   trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
   trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java
   trunk/apps/Thaw/src/thaw/plugins/index/IndexEditorPanel.java
   trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
   trunk/apps/Thaw/src/thaw/plugins/index/IndexTreeNode.java
   trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java
   trunk/apps/Thaw/src/thaw/plugins/index/SearchBar.java
   trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java
   trunk/apps/Thaw/src/thaw/plugins/index/TableCreator.java
   trunk/apps/Thaw/src/thaw/plugins/index/Tables.java
Log:
Thaw now implements a search mechanism

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2006-10-15 17:21:03 UTC 
(rev 10663)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2006-10-15 21:56:19 UTC 
(rev 10664)
@@ -14,7 +14,7 @@
  * TODO: Use streams instead of writing directly the file.
  */
 public class FCPClientGet extends Observable implements Observer, 
FCPTransferQuery {
-       private final static int MAX_RETRIES = -1;
+       private int maxRetries = -1;
        private final static int PACKET_SIZE = 1024;
        private final static int BLOCK_SIZE = 32768;

@@ -73,9 +73,10 @@
        public FCPClientGet(String id, String key, int priority,
                            int persistence, boolean globalQueue,
                            String destinationDir, String status, int progress,
+                           int maxRetries,
                            FCPQueueManager queueManager) {

-               this(key, priority, persistence, globalQueue, destinationDir);
+               this(key, priority, persistence, globalQueue, maxRetries, 
destinationDir);

                progressReliable = false;

@@ -111,6 +112,7 @@
         */
        public FCPClientGet(String key, int priority,
                            int persistence, boolean globalQueue,
+                           int maxRetries,
                            String destinationDir) {    


@@ -120,6 +122,7 @@
                progressReliable = false;
                fromTheNodeProgress = 0;

+               this.maxRetries = maxRetries;
                this.key = key;
                this.priority = priority;
                this.persistence = persistence;
@@ -164,7 +167,7 @@
                queryMessage.setValue("URI", getFileKey());
                queryMessage.setValue("Identifier", identifier);
                queryMessage.setValue("Verbosity", "1");
-               queryMessage.setValue("MaxRetries", 
Integer.toString(MAX_RETRIES));
+               queryMessage.setValue("MaxRetries", 
Integer.toString(maxRetries));
                queryMessage.setValue("PriorityClass", 
Integer.toString(priority));

                if(destinationDir != null)
@@ -318,7 +321,7 @@

                        int code = Integer.parseInt(message.getValue("Code"));

-                       if(MAX_RETRIES == -1 || attempt >= MAX_RETRIES || code 
== 25) {
+                       if(maxRetries == -1 || attempt >= maxRetries || code == 
25) {
                            status = "Failed 
("+message.getValue("CodeDescription")+")";
                            progress = 100;
                            running = false;
@@ -837,7 +840,7 @@
        }

        public int getMaxAttempt() {
-               return MAX_RETRIES;
+               return maxRetries;
        }

        public boolean isSuccessful() {
@@ -870,12 +873,13 @@
                result.put("FileSize", Long.toString(fileSize));
                result.put("Running", Boolean.toString(running));
                result.put("Successful", Boolean.toString(successful));
+               result.put("MaxRetries", Integer.toString(maxRetries));

                return result;
        }

        public boolean setParameters(HashMap parameters) {
-               
+
                key            = (String)parameters.get("URI");

                Logger.debug(this, "Resuming key : "+key);
@@ -895,6 +899,7 @@
                fileSize       = 
Long.parseLong((String)parameters.get("FileSize"));
                running        = 
Boolean.valueOf((String)parameters.get("Running")).booleanValue();
                successful     = 
Boolean.valueOf((String)parameters.get("Successful")).booleanValue();
+               maxRetries     = 
Integer.parseInt((String)parameters.get("MaxRetries"));

                if(persistence == 2 && !isFinished()) {
                        progress = 0;

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java    2006-10-15 17:21:03 UTC 
(rev 10663)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java    2006-10-15 21:56:19 UTC 
(rev 10664)
@@ -72,7 +72,7 @@
                                                                  
msg.getValue("URI"), // key
                                                                  priority, 
persistence, global,
                                                                  
destinationDir, "Fetching", 0,
-                                                                 queueManager);
+                                                                 -1, 
queueManager);


                        if(queueManager.addQueryToTheRunningQueue(clientGet, 
false))

Modified: trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java   2006-10-15 17:21:03 UTC 
(rev 10663)
+++ trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java   2006-10-15 21:56:19 UTC 
(rev 10664)
@@ -68,7 +68,7 @@
                        core.getQueueManager().addQueryToThePendingQueue(new 
FCPClientGet(key,
                                                                                
          priority,
                                                                                
          persistence,
-                                                                               
          globalQueue,
+                                                                               
          globalQueue, -1,
                                                                                
          destination));
                }


Modified: trunk/apps/Thaw/src/thaw/plugins/index/File.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/File.java    2006-10-15 17:21:03 UTC 
(rev 10663)
+++ trunk/apps/Thaw/src/thaw/plugins/index/File.java    2006-10-15 21:56:19 UTC 
(rev 10664)
@@ -63,7 +63,7 @@
                publicKey = resultSet.getString("publicKey");
                localPath = resultSet.getString("localPath");
                size = resultSet.getLong("size");
-               category = resultSet.getString("category");
+               //category = resultSet.getString("category");

                deduceFilenameFromKey();

@@ -162,6 +162,11 @@
        }

        public void insert() {
+               if (parent == null) {
+                       Logger.notice(this, "insert(): No parent !");
+                       return;
+               }
+
                try {
                        PreparedStatement st;

@@ -216,6 +221,7 @@
        }

        public void delete() {
+
                try {
                        PreparedStatement st;

@@ -230,6 +236,11 @@
        }

        public void update() {
+               if (parent == null) {
+                       Logger.notice(this, "update(): No parent !");
+                       return;
+               }
+
                try {
                        PreparedStatement st;


Modified: trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java       2006-10-15 
17:21:03 UTC (rev 10663)
+++ trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java       2006-10-15 
21:56:19 UTC (rev 10664)
@@ -204,7 +204,7 @@
                        if(e.getSource() == downloadFiles) {
                                thaw.plugins.index.File file = 
index.getFile(selectedRows[i]);

-                               FCPClientGet clientGet = new 
FCPClientGet(file.getPublicKey(), 4, 0, true,
+                               FCPClientGet clientGet = new 
FCPClientGet(file.getPublicKey(), 4, 0, true, -1,
                                                                          
destination.getPath());

                                
queueManager.addQueryToThePendingQueue(clientGet);
@@ -292,7 +292,6 @@
                                for(Iterator it = files.iterator();
                                    it.hasNext(); ) {
                                        thaw.plugins.index.File file = 
(thaw.plugins.index.File)it.next();
-                                       file.addObserver(this);
                                }

                        }       
@@ -362,16 +361,18 @@
                }

                public void update(java.util.Observable o, Object param) {
-                       if(param instanceof thaw.plugins.index.File) {
+                       /*if(param instanceof thaw.plugins.index.File
+                          && o instanceof thaw.plugins.index.Index) {

-                               /* TODO : It can be a remove ... to check ... */
-
                                thaw.plugins.index.File file = 
(thaw.plugins.index.File)param;

                                file.deleteObserver(this);
-                               file.addObserver(this);
-                       }

+                               if (((Index)o).isInIndex(file))
+                                       file.addObserver(this);
+                               
+                                       }*/
+
                        refresh(); /* TODO : Do it more nicely ... :) */
                }
        }

Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java   2006-10-15 17:21:03 UTC 
(rev 10663)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java   2006-10-15 21:56:19 UTC 
(rev 10664)
@@ -96,7 +96,7 @@
                this.revision = revision;

                this.author = author;
-
+               
                treeNode.setUserObject(this);
        }

@@ -189,6 +189,7 @@
                } catch(SQLException e) {
                        Logger.error(this, "Unable to rename the index 
'"+this.displayName+"' in '"+name+"', because: "+e.toString());
                }
+
        }

        public void delete() {
@@ -273,7 +274,7 @@

                        Logger.info(this, "Key asked: "+key);

-                       clientGet = new FCPClientGet(key, 4, 2, false, 
System.getProperty("java.io.tmpdir"));
+                       clientGet = new FCPClientGet(key, 4, 2, false, 1, 
System.getProperty("java.io.tmpdir"));
                        transfer = clientGet;
                        clientGet.addObserver(this);

@@ -373,6 +374,7 @@

                        Logger.debug(this, "Index public key: "+publicKey);
                        Logger.debug(this, "Index private key: "+privateKey);
+
                }

                if(o == transfer) {
@@ -424,6 +426,12 @@
                        }

                }
+
+               if (o instanceof thaw.plugins.index.File
+                   || o instanceof Link) {
+                       setChanged();
+                       notifyObservers(o);
+               }
        }


@@ -456,7 +464,7 @@

                                while(results.next()) {
                                        thaw.plugins.index.File file = new 
thaw.plugins.index.File(db, results, this);
-                                       fileList.add(file);
+                                       addFileToList(file);
                                }
                        }

@@ -464,6 +472,9 @@
                } catch(java.sql.SQLException e) {
                        Logger.warning(this, "Unable to get the file list for 
index: '"+toString()+"' because: "+e.toString());
                }
+
+               setChanged();
+               notifyObservers();
        }

        /**
@@ -495,22 +506,44 @@
                        }
                }

+               if (fileList != null) {
+                       for (Iterator it  = fileList.iterator();
+                            it.hasNext();)
+                               {
+                                       thaw.plugins.index.File file = 
(thaw.plugins.index.File)it.next();
+                                       file.deleteObserver(this);
+                               }
+               }
+
                fileList = null;
        }


+       /**
+        * Note for myself: For external use only ! (file will be inserted in 
the database etc)
+        */
        public void addFile(thaw.plugins.index.File file) {
                file.setParent(this);
                file.insert();

-               if(fileList != null) {
-                       fileList.add(file);
+               addFileToList(file);

-                       setChanged();
-                       notifyObservers(file);
-               }
+               setChanged();
+               notifyObservers(file);
        }

+
+       /**
+        * Won't notify
+        */
+       protected void addFileToList(thaw.plugins.index.File file) {
+               if (fileList == null)
+                       loadFiles(null, true);
+               file.addObserver(this);
+               fileList.add(file);
+       }
+
+
        public void removeFile(thaw.plugins.index.File file) {
                file.delete();

@@ -545,6 +578,7 @@
                        setChanged();
                        notifyObservers(link);
                }
+
        }

        public void removeLink(Link link) {
@@ -555,6 +589,7 @@
                        setChanged();
                        notifyObservers(link);
                }
+
        }

        /**
@@ -851,10 +886,13 @@
                        if(list.item(i).getNodeType() == Node.ELEMENT_NODE) {
                                Element e = (Element)list.item(i);

-                               thaw.plugins.index.File file = new 
thaw.plugins.index.File(db, e, this);
-                               addFile(file);
+                               thaw.plugins.index.File file = new 
thaw.plugins.index.File(db, e, this);        
+                               addFileToList(file);
                        }
                }
+
+               setChanged();
+               notifyObservers();
        }


@@ -871,4 +909,18 @@
                return name;
        }

+       
+       public Vector getIndexIds() {
+               Vector ids = new Vector();
+               ids.add(new Integer(getId()));
+               return ids;
+       }
+
+
+       public boolean isInIndex(thaw.plugins.index.File file) {
+               if (fileList == null)
+                       loadFiles(null, true);
+               return fileList.contains(file);
+       }
+
 }

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java       
2006-10-15 17:21:03 UTC (rev 10663)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java       
2006-10-15 21:56:19 UTC (rev 10664)
@@ -68,16 +68,15 @@


        protected void setList(FileAndLinkList l) {
-               setFileList(l);
-               setLinkList(l);
+               tables.setList(l);
        }
-       
+
        protected void setFileList(FileList l) {
-               tables.getFileTable().setFileList(l);           
+               tables.setFileList(l);
        }

        protected void setLinkList(LinkList l) {
-               tables.getLinkTable().setLinkList(l);
+               tables.setLinkList(l);
        }



Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java   2006-10-15 
17:21:03 UTC (rev 10663)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java   2006-10-15 
21:56:19 UTC (rev 10664)
@@ -370,6 +370,19 @@
                return name;
        }

+       public Vector getIndexIds()
+       {
+               Vector result = new Vector();
+               
+               for(Iterator it = children.iterator();
+                   it.hasNext();) {
+                       IndexTreeNode node = 
(IndexTreeNode)((DefaultMutableTreeNode)it.next()).getUserObject();
+                       result.addAll(node.getIndexIds());
+               }
+               
+               return result;
+       }
+
        public boolean isLeaf() {
                return false;
        }

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexEditorPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexEditorPanel.java        
2006-10-15 17:21:03 UTC (rev 10663)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexEditorPanel.java        
2006-10-15 21:56:19 UTC (rev 10664)
@@ -112,14 +112,14 @@
        protected void setLinkList(LinkList l) {
                buttonsEnabled(l != null && l instanceof Index);
                this.linkList = l;
-               tables.getLinkTable().setLinkList(l);
+               tables.setLinkList(l);
        }

        protected void setFileList(FileList l) {
                buttonsEnabled(l != null && l instanceof Index);

                this.fileList = l;
-               tables.getFileTable().setFileList(l);           
+               tables.setFileList(l);          
        }

        public void valueChanged(javax.swing.event.TreeSelectionEvent e) {

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java       2006-10-15 
17:21:03 UTC (rev 10663)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java       2006-10-15 
21:56:19 UTC (rev 10664)
@@ -241,6 +241,23 @@
                notifyObservers(selectedNode);
        }

+       public IndexTreeNode getSelectedNode() {
+               Object obj = tree.getLastSelectedPathComponent();
+
+               if (obj == null)
+                       return null;
+
+               if (obj instanceof IndexTreeNode)
+                       return (IndexTreeNode)obj;
+
+               if (obj instanceof DefaultMutableTreeNode)
+                       return 
((IndexTreeNode)(((DefaultMutableTreeNode)obj).getUserObject()));
+
+               Logger.notice(this, "getSelectedNode(): Unknow kind of node 
?!");
+
+               return null;
+       }
+
        public void actionPerformed(ActionEvent e) {
                if(selectedNode == null)
                        return;

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTreeNode.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexTreeNode.java   2006-10-15 
17:21:03 UTC (rev 10663)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTreeNode.java   2006-10-15 
21:56:19 UTC (rev 10664)
@@ -1,5 +1,7 @@
 package thaw.plugins.index;

+import java.util.Vector;
+
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.MutableTreeNode;

@@ -47,5 +49,8 @@
         */
        public String getKey();

+
+       public Vector getIndexIds();
+
        public void addObserver(java.util.Observer o);
 }

Modified: trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java       2006-10-15 
17:21:03 UTC (rev 10663)
+++ trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java       2006-10-15 
21:56:19 UTC (rev 10664)
@@ -229,7 +229,7 @@
                                for(Iterator it = links.iterator();
                                    it.hasNext(); ) {
                                        thaw.plugins.index.Link link = 
(thaw.plugins.index.Link)it.next();
-                                       link.addObserver(this);
+                                       //link.addObserver(this);
                                }
                        }

@@ -288,8 +288,8 @@

                                thaw.plugins.index.Link link = 
(thaw.plugins.index.Link)param;

-                               link.deleteObserver(this);
-                               link.addObserver(this);
+                               //link.deleteObserver(this);
+                               //link.addObserver(this);
                        }

                        refresh(); /* TODO : Do it more nicely ... :) */

Modified: trunk/apps/Thaw/src/thaw/plugins/index/SearchBar.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/SearchBar.java       2006-10-15 
17:21:03 UTC (rev 10663)
+++ trunk/apps/Thaw/src/thaw/plugins/index/SearchBar.java       2006-10-15 
21:56:19 UTC (rev 10664)
@@ -7,15 +7,29 @@

 import java.awt.BorderLayout;

+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
 import thaw.core.I18n;

-public class SearchBar {
+import thaw.plugins.Hsqldb;
+
+public class SearchBar implements ActionListener {
        private JPanel panel;

        private JTextField userText;
        private JButton validationButton;

-       public SearchBar(FileTable fileTable, LinkTable linkTable) {
+       private Hsqldb db;
+       private IndexTree tree;
+
+       private Tables tables;
+
+       public SearchBar(Hsqldb db, IndexTree indexTree, Tables tables) {
+               this.db = db;
+               this.tree = indexTree;
+               this.tables = tables;
+
                panel = new JPanel();
                panel.setLayout(new BorderLayout(10, 10));

@@ -25,10 +39,24 @@
                panel.add(new 
JLabel(I18n.getMessage("thaw.plugin.index.search.label")), BorderLayout.WEST);
                panel.add(userText, BorderLayout.CENTER);
                panel.add(validationButton, BorderLayout.EAST);
+
+               userText.addActionListener(this);
+               validationButton.addActionListener(this);
        }

        public JPanel getPanel() {
                return panel;
        }

+       public void actionPerformed(ActionEvent e) {
+               if (userText.getText() == null)
+                       return;
+
+               if (tree.getSelectedNode() == null)
+                       return;
+
+               SearchResult sr = new SearchResult(db, userText.getText(), 
tree.getSelectedNode());
+               tables.setList(sr);
+       }
+
 }

Modified: trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java    2006-10-15 
17:21:03 UTC (rev 10663)
+++ trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java    2006-10-15 
21:56:19 UTC (rev 10664)
@@ -1,30 +1,160 @@
 package thaw.plugins.index;

 import java.util.Vector;
+import java.util.Iterator;

+import java.util.Observable;
+import java.util.Observer;

-public class SearchResult implements FileList {
+import java.sql.*;

+import thaw.plugins.Hsqldb;
+
+import thaw.core.Logger;
+
+public class SearchResult extends Observable implements FileAndLinkList {
+
        private Vector fileList = null;
+       private Vector linkList = null;

-       public SearchResult() {
+       private String[] search      = null;
+       private Vector indexIds = null;

+       private Hsqldb db;
+
+       public SearchResult(Hsqldb hsqldb, String search, IndexTreeNode node) {
+               this.search = search.split(" ");
+               this.indexIds = node.getIndexIds();
+               this.db = hsqldb;
        }

+       protected PreparedStatement makeSearchQuery(String fields, String 
table, Vector indexIds, String[] searchPatterns,
+                                        String columnToSort, boolean asc) 
throws SQLException {
+               String query = "";
+               PreparedStatement st;
+
+               query = "SELECT "+fields+" FROM "+table+" WHERE (FALSE";
+
+               for (Iterator it = indexIds.iterator();
+                    it.hasNext();) {
+                       it.next();
+                       query = query + " OR indexParent = ?";
+               }
+
+               query = query + ") AND (TRUE";
+
+               for (int i = 0 ; i < searchPatterns.length; i++) {
+                       query = query + " AND LOWER(publicKey) LIKE ?";
+               }
+
+               query = query +")";
+
+               if(columnToSort != null) {
+                       query = query + "ORDER BY " + columnToSort;
+                       
+                       if(!asc)
+                               query = query + " DESC";
+               }
+
+               Connection c = db.getConnection();
+               st = c.prepareStatement(query);
+
+               int i;
+
+               i = 1;
+
+               for (Iterator it = indexIds.iterator();
+                    it.hasNext(); i++) {
+                       st.setInt(i, (Integer)it.next());
+               }
+
+               for (int j = 0 ; j < searchPatterns.length; j++) {
+                       st.setString(i+j, 
"%"+(searchPatterns[j]).toLowerCase()+"%");
+               }
+
+               return st;
+       }
+
        public void loadFiles(String columnToSort, boolean asc) {
+               if (fileList != null) {
+                       Logger.notice(this, "Files already loaded, won't reload 
them");
+                       return;
+               }
+
                fileList = new Vector();
+
+               try {
+                       PreparedStatement st = makeSearchQuery("id, publicKey, 
localPath, mime, size, category, indexParent",
+                                                              "files", 
indexIds, search, columnToSort, asc);
+                       if (st.execute()) {
+                               ResultSet results = st.getResultSet();
+
+                               while(results.next()) {
+                                       thaw.plugins.index.File file = new 
thaw.plugins.index.File(db, results, null);
+                                       fileList.add(file);
+                               }
+                       }
+               } catch(SQLException e) {
+                       Logger.warning(this, "Exception while searching: 
"+e.toString());
+               }
+
+               setChanged();
+               notifyObservers();
        }

+       public void loadLinks(String columnToSort, boolean asc) {
+               if (linkList != null) {
+                       Logger.notice(this, "Links already loaded, won't reload 
them");
+                       return;
+               }
+               linkList = new Vector();
+
+               try {
+                       PreparedStatement st = makeSearchQuery("id, publicKey, 
mark, comment, indexTarget, indexParent",
+                                                              "links", 
indexIds, search, columnToSort, asc);
+                       if (st.execute()) {
+                               ResultSet results = st.getResultSet();
+
+                               while(results.next()) {
+                                       Link link = new Link(db, results, null);
+                                       linkList.add(link);
+                               }
+                       }
+               } catch(SQLException e) {
+                       Logger.warning(this, "Exception while searching: 
"+e.toString());
+               }
+
+               setChanged();
+               notifyObservers();
+       }
+
+
        public Vector getFileList() {
                return fileList;
        }

+       public Vector getLinkList() {
+               return linkList;
+       }
+
+
+
        public thaw.plugins.index.File getFile(int index) {
                return null;
        }

+       public Link getLink(int index) {
+               return null;
+       }
+
+
+
        public void unloadFiles() {
                fileList = null;
-       }       
+       }

+       public void unloadLinks() {
+               fileList = null;
+       }
+
 }

Modified: trunk/apps/Thaw/src/thaw/plugins/index/TableCreator.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/TableCreator.java    2006-10-15 
17:21:03 UTC (rev 10663)
+++ trunk/apps/Thaw/src/thaw/plugins/index/TableCreator.java    2006-10-15 
21:56:19 UTC (rev 10664)
@@ -41,6 +41,8 @@
         * Can be safely called, even if the tables already exist.
         */
        public static void createTables(Hsqldb db) {
+               //sendQuery(db,
+               //        "SET IGNORECASE TRUE");
                sendQuery(db, 
                          "CREATE CACHED TABLE indexCategories ("
                          + "id INTEGER IDENTITY NOT NULL,"

Modified: trunk/apps/Thaw/src/thaw/plugins/index/Tables.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Tables.java  2006-10-15 17:21:03 UTC 
(rev 10663)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Tables.java  2006-10-15 21:56:19 UTC 
(rev 10664)
@@ -25,7 +25,7 @@
                fileTable = new FileTable(modifiables, queueManager);
                linkTable = new LinkTable(modifiables, db, queueManager, tree);

-               searchBar = new SearchBar(fileTable, linkTable);
+               searchBar = new SearchBar(db, tree, this);

                panel.add(searchBar.getPanel(), BorderLayout.NORTH);
                panel.add(new JSplitPane(JSplitPane.VERTICAL_SPLIT,
@@ -34,14 +34,28 @@
        }


-       public FileTable getFileTable() {
+       protected FileTable getFileTable() {
                return fileTable;
        }

-       public LinkTable getLinkTable() {
+       protected LinkTable getLinkTable() {
                return linkTable;
        }

+       public void setLinkList(LinkList linkList) {
+               getLinkTable().setLinkList(linkList);
+       }
+
+       public void setFileList(FileList fileList) {
+               getFileTable().setFileList(fileList);
+       }
+
+       public void setList(FileAndLinkList l) {
+               setFileList(l);
+               setLinkList(l);
+       }
+
+
        public JPanel getPanel() {
                return panel;
        }


Reply via email to