Author: jflesch
Date: 2006-09-29 13:33:39 +0000 (Fri, 29 Sep 2006)
New Revision: 10564

Added:
   trunk/apps/Thaw/images/application-internet.png
   trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java
Modified:
   trunk/apps/Thaw/src/thaw/core/FileChooser.java
   trunk/apps/Thaw/src/thaw/core/IconBox.java
   trunk/apps/Thaw/src/thaw/core/Logger.java
   trunk/apps/Thaw/src/thaw/core/Main.java
   trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
   trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java
   trunk/apps/Thaw/src/thaw/i18n/thaw.properties
   trunk/apps/Thaw/src/thaw/plugins/index/File.java
   trunk/apps/Thaw/src/thaw/plugins/index/FileList.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/IndexEditorPanel.java
   trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
   trunk/apps/Thaw/src/thaw/plugins/index/Link.java
   trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java
Log:
Add TargetFilename field to ClientPut requests and fix again CHK keys when 
inserting

Added: trunk/apps/Thaw/images/application-internet.png
===================================================================
(Binary files differ)


Property changes on: trunk/apps/Thaw/images/application-internet.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/apps/Thaw/src/thaw/core/FileChooser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/FileChooser.java      2006-09-29 13:22:42 UTC 
(rev 10563)
+++ trunk/apps/Thaw/src/thaw/core/FileChooser.java      2006-09-29 13:33:39 UTC 
(rev 10564)
@@ -28,7 +28,7 @@
                if(v)
                        
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                else
-                       
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
+                       
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); /* 
Directories -> Recursivity */
        }

        /**
@@ -68,7 +68,14 @@

                return fileChooser.getSelectedFile();
        }
+

+       protected File[] expandRecursivly(File[] selectedFiles)
+       {
+               /* TODO */
+               return selectedFiles;
+       }
+       
        /**
         * @return null if nothing choosed.
         */
@@ -77,10 +84,8 @@

                if(!showDialog())
                        return null;
-
-               
-
-               return fileChooser.getSelectedFiles();
+       
+               return expandRecursivly(fileChooser.getSelectedFiles());
        }

 }

Modified: trunk/apps/Thaw/src/thaw/core/IconBox.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/IconBox.java  2006-09-29 13:22:42 UTC (rev 
10563)
+++ trunk/apps/Thaw/src/thaw/core/IconBox.java  2006-09-29 13:33:39 UTC (rev 
10564)
@@ -36,6 +36,8 @@

        public static ImageIcon insertAndAddToIndexAction;

+       public static ImageIcon makeALinkAction;
+
        public static ImageIcon minIndex;

        public static ImageIcon clearAction;
@@ -121,6 +123,9 @@
                                new ImageIcon((new 
IconBox()).getClass().getClassLoader().getResource("folder.png"));
                        insertAndAddToIndexAction =
                                new ImageIcon((new 
IconBox()).getClass().getClassLoader().getResource("folder-new.png"));
+                       makeALinkAction =
+                               new ImageIcon((new 
IconBox()).getClass().getClassLoader().getResource("application-internet.png"));
+                       

                        reconnectAction =
                                new ImageIcon((new 
IconBox()).getClass().getClassLoader().getResource("view-refresh.png"));

Modified: trunk/apps/Thaw/src/thaw/core/Logger.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Logger.java   2006-09-29 13:22:42 UTC (rev 
10563)
+++ trunk/apps/Thaw/src/thaw/core/Logger.java   2006-09-29 13:33:39 UTC (rev 
10564)
@@ -94,10 +94,10 @@
         * As it. Similar to verbose()
         */
        public static void asIt(Object o, String msg) {
-               if(LOG_LEVEL >= 5) {
+               //if(LOG_LEVEL >= 5) {
                        System.out.println(msg);
                        notifyLogListeners(msg);
-               }
+                       //}
        }



Modified: trunk/apps/Thaw/src/thaw/core/Main.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Main.java     2006-09-29 13:22:42 UTC (rev 
10563)
+++ trunk/apps/Thaw/src/thaw/core/Main.java     2006-09-29 13:33:39 UTC (rev 
10564)
@@ -12,8 +12,8 @@
  */
 public class Main {

-       //public final static String VERSION="0.6 WIP r at custom@";
-       public final static String VERSION="0.5 Beta";
+       public final static String VERSION="0.6 WIP r at custom@";
+       //public final static String VERSION="0.5 Beta";

        /**
         * Look & feel use by GUI front end

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java      2006-09-29 13:22:42 UTC 
(rev 10563)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java      2006-09-29 13:33:39 UTC 
(rev 10564)
@@ -377,6 +377,8 @@
                default: Logger.notice(this, "Unknow persistence !?"); break;
                }

+               msg.setValue("TargetFilename", localFile.getName());
+
                msg.setValue("UploadFrom", "direct");

                msg.setAmountOfDataWaiting(localFile.length());
@@ -561,15 +563,6 @@

                                status = "Inserting";

-                               if(keyType == 0)
-                                       publicKey = publicKey + "/" +name;
-
-                               /*
-                               if(keyType > 0)
-                                       publicKey = publicKey + "/" + name + 
"-" + Integer.toString(rev);
-                               */
-                               
-
                                setChanged();
                                notifyObservers();
                                return;

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java     2006-09-29 13:22:42 UTC 
(rev 10563)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java     2006-09-29 13:33:39 UTC 
(rev 10564)
@@ -18,7 +18,7 @@
  * Call observer when connected / disconnected.<br/>
  * WARNING: This FCP implement don't guarantee that messages are sent in the 
same order than initally put
  *          if the lock on writting is not set !<br/>
- * TODO: Add functions socketToFile(long size, File file) / fileToSocket(File 
file)
+ * TODO: Add functions socketToStream(long size, OutputStream file) / 
streamToSocket(InputStream file)
  */
 public class FCPConnection extends Observable {
        /** If == true, then will print on stdout
@@ -428,9 +428,9 @@
                                return result;

                        } catch (java.io.IOException e) {
-                               if(isConnected()) {
+                               if(isConnected())
                                        Logger.error(this, "IOException while 
reading but still connected, wtf? : "+e.toString());
-                               } else
+                               else
                                        Logger.notice(this, "IOException. 
Disconnected.");

                                disconnect();

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2006-09-29 13:22:42 UTC 
(rev 10563)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2006-09-29 13:33:39 UTC 
(rev 10564)
@@ -64,6 +64,8 @@
 thaw.common.done=Done
 thaw.common.ok=Ok

+thaw.common.search=Search
+
 ## Errors
 thaw.error.idAlreadyUsed=Unable to connect. Our Id is already used by another 
client connected to the node.

@@ -185,6 +187,8 @@

 # In internal, thaw use the word "category" instead of "folders"

+thaw.plugin.index.index=Index
+
 thaw.plugin.index.category=Category

 thaw.plugin.index.editor=Your shared files
@@ -198,10 +202,10 @@
 thaw.plugin.index.addCategory=Add a folder
 thaw.plugin.index.rename=Rename
 thaw.plugin.index.delete=Delete
-thaw.plugin.index.insertIndex=Insert / update this index
-thaw.plugin.index.insertIndexes=Insert / update these indexes
-thaw.plugin.index.downloadIndex=Download / update this index
-thaw.plugin.index.downloadIndexes=Download / update these indexes
+thaw.plugin.index.insertIndex=[Re]insert this index
+thaw.plugin.index.insertIndexes=[Re]insert these indexes
+thaw.plugin.index.downloadIndex=[Re]download this index
+thaw.plugin.index.downloadIndexes=[Re]download these indexes
 thaw.plugin.index.copyKey=Copy index key(s) to clipboard
 thaw.plugin.index.recalculateKeys=Recalculate keys

@@ -211,9 +215,9 @@
 thaw.plugin.index.newCategory=New folder
 thaw.plugin.index.newIndex=New index

-thaw.plugin.index.indexKey=Index key ?
+thaw.plugin.index.indexKey=Index key:

-thaw.plugin.index.search.label=Search in this folder / index
+thaw.plugin.index.search.label=Search:
 thaw.plugin.index.search.apply=Search

 thaw.plugin.index.addFilesWithInserting=Insert file(s) on Freenet and add them 
to this index
@@ -221,3 +225,8 @@
 thaw.plugin.index.addLink=Add a link to another index

 thaw.plugin.index.insert=Insert
+
+thaw.plugin.index.fileList=File list
+thaw.plugin.index.linkList=Link list
+
+thaw.plugin.index.selectIndex=Select an index or specify the key

Modified: trunk/apps/Thaw/src/thaw/plugins/index/File.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/File.java    2006-09-29 13:22:42 UTC 
(rev 10563)
+++ trunk/apps/Thaw/src/thaw/plugins/index/File.java    2006-09-29 13:33:39 UTC 
(rev 10564)
@@ -206,8 +206,6 @@
                        else
                                st.setNull(6, Types.VARCHAR);

-                       Logger.info(this, "PARENT : "+parent.getId());
-
                        st.setInt(7, parent.getId());

                        st.execute();

Modified: trunk/apps/Thaw/src/thaw/plugins/index/FileList.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/FileList.java        2006-09-29 
13:22:42 UTC (rev 10563)
+++ trunk/apps/Thaw/src/thaw/plugins/index/FileList.java        2006-09-29 
13:33:39 UTC (rev 10564)
@@ -3,11 +3,11 @@
 import java.util.Vector;

 /**
- * List files, but also links.
+ * List files
  */
 public interface FileList {

-       public void loadLists(String fileColumnToSort, boolean asc);
+       public void loadFiles(String fileColumnToSort, boolean asc);

        /**
         * Must returns a copy of the vector it's using !
@@ -18,12 +18,7 @@
        public thaw.plugins.index.File getFile(int index);

        /**
-        * Must returns a copy of the vector it's using !
-        */
-       public Vector getLinkList();
-
-       /**
         * Can update the database.
         */
-       public void unloadLists();
+       public void unloadFiles();
 }

Modified: trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java       2006-09-29 
13:22:42 UTC (rev 10563)
+++ trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java       2006-09-29 
13:33:39 UTC (rev 10564)
@@ -25,6 +25,7 @@
 import javax.swing.JMenu;
 import javax.swing.JFileChooser;
 import javax.swing.JProgressBar;
+import javax.swing.JLabel;

 import java.awt.Toolkit;
 import java.awt.datatransfer.Clipboard;
@@ -41,12 +42,12 @@
 import thaw.fcp.*;

 public class FileTable implements MouseListener, KeyListener, ActionListener {
+
+       private JPanel panel;

        private JTable table;
        private FileListModel fileListModel;

-       private JPanel panel;
-
        private FileList fileList = null;

        private boolean modifiables;
@@ -66,13 +67,10 @@

        public FileTable(boolean modifiables, FCPQueueManager queueManager) {
                this.queueManager = queueManager;
-               panel = new JPanel();
-               panel.setLayout(new BorderLayout(10, 10));

                this.modifiables = modifiables;
-
+       

-               
                rightClickMenu = new JPopupMenu();

                if(modifiables) {
@@ -102,21 +100,27 @@

                table.addMouseListener(this);

+               panel = new JPanel();
+               panel.setLayout(new BorderLayout());
+               
+               panel.add(new 
JLabel(I18n.getMessage("thaw.plugin.index.fileList")), BorderLayout.NORTH);
+               panel.add(new JScrollPane(table));
+
        }


-       public JScrollPane getPanel() {
-               return new JScrollPane(table);
+       public JPanel getPanel() {
+               return panel;
        }


        public void setFileList(FileList fileList) {
                if(this.fileList != null) {
-                       this.fileList.unloadLists();
+                       this.fileList.unloadFiles();
                }

                if(fileList != null) {
-                       fileList.loadLists(null, true);
+                       fileList.loadFiles(null, true);
                }

                this.fileList = fileList;
@@ -180,7 +184,10 @@
                for(int i = 0 ; i < selectedRows.length ; i++) {

                        if(e.getSource() == removeFiles) {
-                               
index.removeFile((thaw.plugins.index.File)files.get(selectedRows[i]));
+                               thaw.plugins.index.File file = 
(thaw.plugins.index.File)files.get(selectedRows[i]);
+                               if (file.getTransfer() != null)
+                                       file.getTransfer().stop(queueManager);
+                               index.removeFile(file);
                        }

                        if(e.getSource() == insertFiles) {
@@ -353,13 +360,6 @@
                public void refresh(TableModelEvent e) {

                        fireTableChanged(e);
-                       /*
-                       TableModelListener[] listeners = 
getTableModelListeners();
-
-                       for(int i = 0 ; i < listeners.length ; i++) {
-                               listeners[i].tableChanged(e);
-                       }
-                       */
                }

                public void update(java.util.Observable o, Object param) {
@@ -413,10 +413,12 @@
                                        
bar.setString(I18n.getMessage("thaw.common.ok"));

                                if(!query.isFinished()) {
-                                       if(query instanceof FCPClientGet)
+                                       /*if(query instanceof FCPClientGet)
                                                
bar.setString(I18n.getMessage("thaw.common.downloading"));
                                        else
                                                
bar.setString(I18n.getMessage("thaw.common.uploading"));
+                                       */
+                                       bar.setString(query.getStatus());
                                }

                                return bar;

Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java   2006-09-29 13:22:42 UTC 
(rev 10563)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java   2006-09-29 13:33:39 UTC 
(rev 10564)
@@ -177,7 +177,7 @@

        public void delete() {
                try {
-                       loadLists(null, false);
+                       loadFiles(null, false);

                        for(Iterator fileIt = fileList.iterator();
                            fileIt.hasNext(); ) {
@@ -361,7 +361,7 @@

        ////// FILE LIST ////////

-       public void loadLists(String columnToSort, boolean asc) {
+       public void loadFiles(String columnToSort, boolean asc) {
                if(fileList != null)
                        return;

@@ -414,11 +414,8 @@
                return (thaw.plugins.index.File)fileList.get(index);
        }

-       public Vector getLinkList() {
-               return null;
-       }

-       public void unloadLists() {
+       public void unloadFiles() {
                for(Iterator it = fileList.iterator();
                    it.hasNext(); ) {
                        thaw.plugins.index.File file = 
(thaw.plugins.index.File)it.next();
@@ -567,7 +564,7 @@
                Element files = xmlDoc.createElement("files");

                if(fileList == null) {
-                       loadLists(null, true);
+                       loadFiles(null, true);
                }

                for(Iterator it = getFileList().iterator();

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java       
2006-09-29 13:22:42 UTC (rev 10563)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java       
2006-09-29 13:33:39 UTC (rev 10564)
@@ -28,11 +28,9 @@
        private JSplitPane split;

        private JPanel listAndDetails;
-       private FileTable fileTable;
+       private Tables tables;
        private FileDetailsEditor fileDetails;

-       private FileList fileList = null;
-       
        private Hsqldb db;
        private FCPQueueManager queueManager;

@@ -41,15 +39,15 @@
                this.db = db;
                this.queueManager = queueManager;

-               indexTree = new 
IndexTree(I18n.getMessage("thaw.plugin.index.indexes"), false, queueManager, 
db);
+               indexTree = new 
IndexTree(I18n.getMessage("thaw.plugin.index.indexes"), false, false, 
queueManager, db);

                listAndDetails = new JPanel();
                listAndDetails.setLayout(new BorderLayout(10, 10));

-               fileTable = new FileTable(false, queueManager);
+               tables = new Tables(false, queueManager);
                fileDetails = new FileDetailsEditor(false);

-               listAndDetails.add(fileTable.getPanel(), BorderLayout.CENTER);
+               listAndDetails.add(tables.getPanel(), BorderLayout.CENTER);
                listAndDetails.add(fileDetails.getPanel(), BorderLayout.SOUTH);

                split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
@@ -67,11 +65,11 @@
        public void save() {
                indexTree.save();
        }
-
-       public void setFileList(FileList l) {
-               this.fileList = l;
-               fileTable.setFileList(l);               
+       
+       protected void setFileList(FileList l) {
+               tables.getFileTable().setFileList(l);           
        }
+       

        public void valueChanged(javax.swing.event.TreeSelectionEvent e) {
                javax.swing.tree.TreePath path = e.getPath();

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexEditorPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexEditorPanel.java        
2006-09-29 13:22:42 UTC (rev 10563)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexEditorPanel.java        
2006-09-29 13:33:39 UTC (rev 10564)
@@ -28,12 +28,13 @@
        private JSplitPane split;

        private JPanel listAndDetails;
-       private FileTable fileTable;
+       private Tables tables;
        private FileDetailsEditor fileDetails;

        private JToolBar toolBar;
        private JButton addButton;
        private JButton insertAndAddButton;
+       private JButton linkButton;

        private FileList fileList = null;

@@ -45,12 +46,12 @@
                this.db = db;
                this.queueManager = queueManager;

-               indexTree = new 
IndexTree(I18n.getMessage("thaw.plugin.index.yourIndexes"), true, queueManager, 
db);
+               indexTree = new 
IndexTree(I18n.getMessage("thaw.plugin.index.yourIndexes"), true, false, 
queueManager, db);

                listAndDetails = new JPanel();
-               listAndDetails.setLayout(new BorderLayout(10, 10));
+               listAndDetails.setLayout(new BorderLayout(0, 0));

-               fileTable = new FileTable(true, queueManager);
+               tables = new Tables(true, queueManager);
                fileDetails = new FileDetailsEditor(true);

                toolBar = new JToolBar();
@@ -60,17 +61,22 @@
                
addButton.setToolTipText(I18n.getMessage("thaw.plugin.index.addFilesWithoutInserting"));
                insertAndAddButton = new 
JButton(IconBox.insertAndAddToIndexAction);
                
insertAndAddButton.setToolTipText(I18n.getMessage("thaw.plugin.index.addFilesWithInserting"));
+               linkButton = new JButton(IconBox.makeALinkAction);
+               
linkButton.setToolTipText(I18n.getMessage("thaw.plugin.index.addLink"));

                addButton.addActionListener(this);
                insertAndAddButton.addActionListener(this);
+               linkButton.addActionListener(this);

                buttonsEnabled(false);

                toolBar.add(addButton);
                toolBar.add(insertAndAddButton);
+               toolBar.addSeparator();
+               toolBar.add(linkButton);

                listAndDetails.add(toolBar, BorderLayout.NORTH);
-               listAndDetails.add(fileTable.getPanel(), BorderLayout.CENTER);
+               listAndDetails.add(tables.getPanel(), BorderLayout.CENTER);
                listAndDetails.add(fileDetails.getPanel(), BorderLayout.SOUTH);

                split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
@@ -92,13 +98,14 @@
        public void buttonsEnabled(boolean a) {
                addButton.setEnabled(a);
                insertAndAddButton.setEnabled(a);
+               linkButton.setEnabled(a);
        }

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

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

        public void valueChanged(javax.swing.event.TreeSelectionEvent e) {
@@ -128,6 +135,11 @@


        public void actionPerformed(ActionEvent e) {
+               if (e.getSource() == linkButton) {
+                       Thread linkMakerThread = new Thread(new LinkMaker());
+                       linkMakerThread.start();
+               }
+
                if(e.getSource() == addButton
                   || e.getSource() == insertAndAddButton) {
                        FileChooser fileChooser = new FileChooser();
@@ -176,6 +188,18 @@
        }


+       public class LinkMaker implements Runnable {
+               public LinkMaker() {
+
+               }
+
+               public void run() {
+                       IndexSelecter indexSelecter = new IndexSelecter();
+                       String indexKey = indexSelecter.askForAnIndexURI(db);
+                       
+               }
+       }
+
        public void update(java.util.Observable o, Object param) {
                if(o instanceof FCPClientPut) {
                        FCPClientPut clientPut = (FCPClientPut)o;

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java       2006-09-29 
13:22:42 UTC (rev 10563)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java       2006-09-29 
13:33:39 UTC (rev 10564)
@@ -46,11 +46,12 @@
 /**
  * Manages the index tree and its menu (right-click).
  */
-public class IndexTree implements MouseListener, ActionListener, 
java.util.Observer {
+public class IndexTree extends java.util.Observable implements MouseListener, 
ActionListener, java.util.Observer {

        private JPanel panel;

-       private JDragTree tree;
+       //private JDragTree tree;
+       private JTree tree;
        private IndexCategory root;

        private JPopupMenu indexCategoryMenu;
@@ -68,6 +69,7 @@
        private JMenuItem copyKey;

        private boolean modifiables;
+       private boolean selectionOnly;

        private IndexTreeNode selectedNode;

@@ -81,15 +83,18 @@
         * @param modifiables If set to true, then only indexes having private 
keys will
         *                    be displayed else only indexes not having private 
keys will
         *                    be displayed.
+        * @param queueManager Not used if selectionOnly is set to true
         */
-       public IndexTree(String name,
+       public IndexTree(String rootName,
                         boolean modifiables,
+                        boolean selectionOnly,
                         FCPQueueManager queueManager,
                         Hsqldb db) {
                this.queueManager = queueManager;

                this.db = db;
                this.modifiables = modifiables;
+               this.selectionOnly = selectionOnly;

                panel = new JPanel();
                panel.setLayout(new BorderLayout(10, 10));
@@ -145,15 +150,21 @@
                deleteIndex.addActionListener(this);


-               root = new IndexCategory(db, queueManager, -1, null, name, 
modifiables);
+               root = new IndexCategory(db, queueManager, -1, null, rootName, 
modifiables);
                root.loadChildren();

                root.addObserver(this);

                treeModel = new DefaultTreeModel(root);
-               tree = new JDragTree(treeModel);
-               tree.addMouseListener(this);

+               if (!selectionOnly) {
+                       tree = new JDragTree(treeModel);
+                       tree.addMouseListener(this);
+               } else {
+                       tree = new JTree(treeModel);
+                       tree.addMouseListener(this);
+               }
+
                IndexTreeRenderer treeRenderer = new IndexTreeRenderer();
                treeRenderer.setLeafIcon(IconBox.minIndex);

@@ -177,16 +188,21 @@
        }


-       public void mouseClicked(MouseEvent e) { }
+       public void mouseClicked(MouseEvent e) {
+               notifySelection(e);
+       }
+
        public void mouseEntered(MouseEvent e) { }
        public void mouseExited(MouseEvent e) { }

        public void mousePressed(MouseEvent e) {
-               showPopupMenu(e);
+               if (!selectionOnly)
+                       showPopupMenu(e);
        }

        public void mouseReleased(MouseEvent e) {
-               showPopupMenu(e);
+               if (!selectionOnly)
+                       showPopupMenu(e);
        }

        protected void showPopupMenu(MouseEvent e) {
@@ -209,6 +225,18 @@
                }
        }

+       public void notifySelection(MouseEvent e) {
+               TreePath path = tree.getPathForLocation(e.getX(), e.getY());
+                       
+               if(path == null)
+                       return;
+
+               selectedNode = 
(IndexTreeNode)((DefaultMutableTreeNode)path.getLastPathComponent()).getUserObject();
+
+               setChanged();
+               notifyObservers(selectedNode);
+       }
+
        public void actionPerformed(ActionEvent e) {
                if(selectedNode == null)
                        return;

Modified: trunk/apps/Thaw/src/thaw/plugins/index/Link.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Link.java    2006-09-29 13:22:42 UTC 
(rev 10563)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Link.java    2006-09-29 13:33:39 UTC 
(rev 10564)
@@ -5,13 +5,25 @@
 import thaw.fcp.*;
 import thaw.plugins.Hsqldb;

-public class Link {
+public class Link extends java.util.Observable {

+       String indexName = null;
+       String key = null;
+
        public Link() {

        }

-       
+       public Link(String indexName, String key) {
+               this.indexName = indexName;
+               this.key = key;
+       }

+       public String getIndexName() {
+               return indexName;
+       }

+       public String getKey() {
+               return key;
+       }
 }

Added: trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java       2006-09-29 
13:22:42 UTC (rev 10563)
+++ trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java       2006-09-29 
13:33:39 UTC (rev 10564)
@@ -0,0 +1,228 @@
+package thaw.plugins.index;
+
+import javax.swing.JPanel;
+import javax.swing.JTable;
+import javax.swing.JScrollPane;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+
+import javax.swing.event.TableModelListener;
+import javax.swing.event.TableModelEvent;
+
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.KeyEvent;
+
+import javax.swing.table.DefaultTableCellRenderer;
+import java.awt.Component;
+
+import javax.swing.JPopupMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JMenu;
+import javax.swing.JFileChooser;
+import javax.swing.JProgressBar;
+import javax.swing.JLabel;
+
+import java.awt.Toolkit;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.ClipboardOwner;
+import java.awt.datatransfer.StringSelection;
+
+import java.util.Vector;
+import java.util.Iterator;
+
+import java.util.Observable;
+import java.util.Observer;
+
+import thaw.core.*;
+import thaw.fcp.*;
+
+public class LinkTable implements MouseListener, KeyListener, ActionListener {
+
+       private JPanel panel;
+       private JTable table;
+
+       private LinkListModel linkListModel;
+       private LinkList      linkList;
+
+       private FCPQueueManager queueManager;
+       private boolean modifiables;
+
+       private int[] selectedRows;
+
+       public LinkTable (boolean modifiables, FCPQueueManager queueManager) {
+               this.modifiables = modifiables;
+               this.queueManager = queueManager;
+
+               linkListModel = new LinkListModel();
+               table = new JTable(linkListModel);
+               table.setShowGrid(true);
+
+               panel = new JPanel();
+               panel.setLayout(new BorderLayout());
+               
+               panel.add(new 
JLabel(I18n.getMessage("thaw.plugin.index.linkList")), BorderLayout.NORTH);
+               panel.add(new JScrollPane(table));
+               
+       }
+
+       public JPanel getPanel() {
+               return panel;
+       }
+
+       public void setLinkList(LinkList linkList) {
+               if(this.linkList != null) {
+                       this.linkList.unloadLinks();
+               }
+               
+               if(linkList != null) {
+                       linkList.loadLinks(null, true);
+               }
+
+               this.linkList = linkList;
+
+               linkListModel.reloadLinkList(linkList);
+       }
+
+       public void mouseClicked(MouseEvent e) {
+
+       }
+
+       public void mouseEntered(MouseEvent e) { }
+
+       public void mouseExited(MouseEvent e) { }
+
+       public void mousePressed(MouseEvent e) { }
+
+       public void mouseReleased(MouseEvent e) { }
+
+       public void keyPressed(KeyEvent e) { }
+
+       public void keyReleased(KeyEvent e) { }
+
+       public void keyTyped(KeyEvent e) { }
+
+       public void actionPerformed(ActionEvent e) {
+
+       }
+
+
+
+       public class LinkListModel extends javax.swing.table.AbstractTableModel 
implements java.util.Observer {
+               public Vector columnNames;
+
+               public Vector links = null; /* thaw.plugins.index.Link Vector */
+
+               public LinkList linkList;
+
+               public LinkListModel() {
+                       super();
+
+                       columnNames = new Vector();
+
+                       
columnNames.add(I18n.getMessage("thaw.plugin.index.index"));
+                       columnNames.add(I18n.getMessage("thaw.common.key"));
+               }
+
+               public void reloadLinkList(LinkList newLinkList) {
+                       if (linkList != null && (linkList instanceof 
Observable)) {
+                               ((Observable)linkList).deleteObserver(this);
+                       }
+
+                       if (newLinkList != null && (newLinkList instanceof 
Observable)) {
+                               ((Observable)newLinkList).deleteObserver(this);
+                       }
+
+                       linkList = newLinkList;
+
+
+                       if(links != null) {
+                               for(Iterator it = links.iterator();
+                                   it.hasNext(); ) {
+                                       thaw.plugins.index.Link link = 
(thaw.plugins.index.Link)it.next();
+                                       link.deleteObserver(this);
+                               }
+                       }
+
+                       links = null;
+                       
+                       if(linkList != null) {
+                               links = linkList.getLinkList();
+                       }
+
+                       if(links != null) {
+                               for(Iterator it = links.iterator();
+                                   it.hasNext(); ) {
+                                       thaw.plugins.index.Link link = 
(thaw.plugins.index.Link)it.next();
+                                       link.addObserver(this);
+                               }
+                       }
+
+               }
+
+               public int getRowCount() {
+                       if (links == null)
+                               return 0;
+
+                       return links.size();
+               }
+               
+
+               public int getColumnCount() {
+                       return columnNames.size();
+               }
+
+               public String getColumnName(int column) {
+                       return (String)columnNames.get(column);
+               }
+
+               public Object getValueAt(int row, int column) {
+                       thaw.plugins.index.Link link = 
(thaw.plugins.index.Link)links.get(row);
+
+                       switch(column) {
+                       case(0): return link.getIndexName();
+                       case(1): return link.getKey();
+                       default: return null;
+                       }
+               }
+
+               public void refresh() {
+                       if(linkList != null) {                          
+                               links = linkList.getLinkList();
+                       }
+
+                       TableModelEvent event = new TableModelEvent(this);
+                       refresh(event);
+               }
+
+                       public void refresh(int row) {
+                       TableModelEvent event = new TableModelEvent(this, row);
+                       refresh(event);
+               }
+
+               public void refresh(TableModelEvent e) {
+
+                       fireTableChanged(e);
+               }
+
+               public void update(java.util.Observable o, Object param) {
+                       if(param instanceof thaw.plugins.index.Link) {
+
+                               /* TODO : It can be a remove ... to check ... */
+
+                               thaw.plugins.index.Link link = 
(thaw.plugins.index.Link)param;
+                               
+                               link.deleteObserver(this);
+                               link.addObserver(this);
+                       }
+
+                       refresh(); /* TODO : Do it more nicely ... :) */
+               }
+       }
+
+}
+

Modified: trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java    2006-09-29 
13:22:42 UTC (rev 10563)
+++ trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java    2006-09-29 
13:33:39 UTC (rev 10564)
@@ -4,13 +4,14 @@


 public class SearchResult implements FileList {
+
        private Vector fileList = null;

        public SearchResult() {

        }

-       public void loadLists(String fileColumnToSort, boolean asc) {
+       public void loadFiles(String columnToSort, boolean asc) {
                fileList = new Vector();
        }

@@ -22,11 +23,7 @@
                return null;
        }

-       public Vector getLinkList() {
-               return null;
-       }
-
-       public void unloadLists() {
+       public void unloadFiles() {
                fileList = null;
        }       



Reply via email to