Author: jflesch Date: 2006-08-15 21:58:20 +0000 (Tue, 15 Aug 2006) New Revision: 10101
Added: trunk/apps/Thaw/images/folder-new.png trunk/apps/Thaw/images/folder.png trunk/apps/Thaw/src/thaw/gui/ Modified: trunk/apps/Thaw/readme.txt trunk/apps/Thaw/src/thaw/core/IconBox.java trunk/apps/Thaw/src/thaw/core/PluginManager.java trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java trunk/apps/Thaw/src/thaw/fcp/FCPQuery.java trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java trunk/apps/Thaw/src/thaw/i18n/thaw.properties trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java trunk/apps/Thaw/src/thaw/plugins/SqlConsole.java trunk/apps/Thaw/src/thaw/plugins/index/TableCreator.java trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java Log: Optimize file list display Added: trunk/apps/Thaw/images/folder-new.png =================================================================== (Binary files differ) Property changes on: trunk/apps/Thaw/images/folder-new.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/apps/Thaw/images/folder.png =================================================================== (Binary files differ) Property changes on: trunk/apps/Thaw/images/folder.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/apps/Thaw/readme.txt =================================================================== --- trunk/apps/Thaw/readme.txt 2006-08-15 21:12:13 UTC (rev 10100) +++ trunk/apps/Thaw/readme.txt 2006-08-15 21:58:20 UTC (rev 10101) @@ -1,7 +1,7 @@ COPYRIGHT ========= -Thaw copyright is held by the Freenet project ( http://www.freenetproject.org/ ). +Thaw copyright is held by Freenet Project Incorporated. Thaw is distributed under the GPLv2 license. You can find it in a file called "gpl.txt" and joined with every copy of Thaw. Modified: trunk/apps/Thaw/src/thaw/core/IconBox.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/IconBox.java 2006-08-15 21:12:13 UTC (rev 10100) +++ trunk/apps/Thaw/src/thaw/core/IconBox.java 2006-08-15 21:58:20 UTC (rev 10101) @@ -32,6 +32,10 @@ public static ImageIcon indexBrowser; public static ImageIcon minIndexBrowser; + public static ImageIcon addToIndexAction; + + public static ImageIcon insertAndAddToIndexAction; + public static ImageIcon settings; public static ImageIcon minSettings; @@ -103,6 +107,11 @@ minIndexBrowser = new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("min-edit-find.png")); + addToIndexAction = + new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("folder.png")); + insertAndAddToIndexAction = + new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("folder-new.png")); + reconnectAction = new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("view-refresh.png")); minReconnectAction = Modified: trunk/apps/Thaw/src/thaw/core/PluginManager.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/PluginManager.java 2006-08-15 21:12:13 UTC (rev 10100) +++ trunk/apps/Thaw/src/thaw/core/PluginManager.java 2006-08-15 21:58:20 UTC (rev 10101) @@ -126,7 +126,8 @@ try { plugin.stop(); } catch(Exception e) { - Logger.error(this, "Unable to run the plugin '"+plugin.getClass().getName()+"'"); + Logger.error(this, "Unable to stop the plugin '"+plugin.getClass().getName()+"', because: "+e.toString()); + e.printStackTrace(); } Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2006-08-15 21:12:13 UTC (rev 10100) +++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2006-08-15 21:58:20 UTC (rev 10101) @@ -11,7 +11,7 @@ /** * notify() only when progress has really changes. - * TODO: Put the fetchLock on FCPConnection. Not here. + * TODO: Use streams instead of writing directly the file. */ public class FCPClientGet extends Observable implements Observer, FCPTransferQuery { private final static int MAX_RETRIES = -1; Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2006-08-15 21:12:13 UTC (rev 10100) +++ trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2006-08-15 21:58:20 UTC (rev 10101) @@ -12,6 +12,7 @@ /** * Allow to insert a simple file. + * TODO: Use streams instead of reading directly the file. */ public class FCPClientPut extends Observable implements FCPTransferQuery, Observer { private FCPQueueManager queueManager = null; Modified: trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java 2006-08-15 21:12:13 UTC (rev 10100) +++ trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java 2006-08-15 21:58:20 UTC (rev 10101) @@ -248,6 +248,9 @@ if(out != null && socket != null && socket.isConnected()) { try { lastWrite = System.currentTimeMillis(); + + System.out.println(new String(data)); + out.write(data); } catch(java.io.IOException e) { Logger.warning(this, "Unable to write() on the socket ?! : "+ e.toString()); Modified: trunk/apps/Thaw/src/thaw/fcp/FCPQuery.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPQuery.java 2006-08-15 21:12:13 UTC (rev 10100) +++ trunk/apps/Thaw/src/thaw/fcp/FCPQuery.java 2006-08-15 21:58:20 UTC (rev 10101) @@ -1,5 +1,8 @@ package thaw.fcp; +/** + * + */ public interface FCPQuery { /** Modified: trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java 2006-08-15 21:12:13 UTC (rev 10100) +++ trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java 2006-08-15 21:58:20 UTC (rev 10101) @@ -249,7 +249,22 @@ return false; } + /** + * Compare only the refs. + */ + public boolean isInTheQueues(FCPTransferQuery query) { + if(runningQueries.contains(query)) + return true; + for(int i = 0 ; i < pendingQueries.length ; i++) { + if(pendingQueries[i].contains(query)) + return true; + } + + return false; + } + + /** * Compare using the key. */ Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2006-08-15 21:12:13 UTC (rev 10100) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2006-08-15 21:58:20 UTC (rev 10101) @@ -173,5 +173,30 @@ thaw.plugin.hsqldb.console=Sql console ## Index management + +# In internal, thaw use the word "category" instead of "folders" + thaw.plugin.index.editor=Your shared files +thaw.plugin.index.addIndex=Add a file index +thaw.plugin.index.createIndex=Create a file index +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.downloadIndex=Download / update this index +thaw.plugin.index.copyKey=Copy index key(s) to clipboard +thaw.plugin.index.categoryName=Folder Name ? +thaw.plugin.index.indexName=Index name ? + +thaw.plugin.index.newCategory=New folder +thaw.plugin.index.newIndex=New index + +thaw.plugin.index.indexKey=Index key ? + +thaw.plugin.index.search.label=Search in this folder / index +thaw.plugin.index.search.apply=Search + +thaw.plugin.index.addFilesWithInserting=Insert file(s) on Freenet and add them to this index +thaw.plugin.index.addFilesWithoutInserting=Add file(s) to this index +thaw.plugin.index.addLink=Add a link to another index Modified: trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java 2006-08-15 21:12:13 UTC (rev 10100) +++ trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java 2006-08-15 21:58:20 UTC (rev 10101) @@ -73,6 +73,8 @@ try { connection.commit(); + executeQuery("SHUTDOWN"); + connection.close(); } catch(java.sql.SQLException e) { Logger.error(this, "SQLException while closing connection !"); @@ -92,7 +94,6 @@ public ResultSet executeQuery(String query) throws java.sql.SQLException { - ResultSet results; Statement stmt = connection.createStatement(); @@ -102,14 +103,4 @@ return results; } - - public boolean execute(String query) throws java.sql.SQLException { - boolean result; - - Statement stmt = connection.createStatement(); - - result = stmt.execute(query); - - return result; - } } Modified: trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-08-15 21:12:13 UTC (rev 10100) +++ trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-08-15 21:58:20 UTC (rev 10101) @@ -19,7 +19,7 @@ import thaw.fcp.*; -public class QueueWatcher implements thaw.core.Plugin, Observer, PropertyChangeListener { +public class QueueWatcher implements thaw.core.Plugin, PropertyChangeListener { private Core core; //private JPanel mainPanel; @@ -51,8 +51,8 @@ detailPanel = new DetailPanel(core); - queuePanels[0] = new QueuePanel(core, detailPanel, false); /* download */ - queuePanels[1] = new QueuePanel(core, detailPanel, true); /* upload */ + queuePanels[0] = new QueuePanel(core, detailPanel, core.getQueueManager(), false); /* download */ + queuePanels[1] = new QueuePanel(core, detailPanel, core.getQueueManager(), true); /* upload */ panel = new JPanel(); @@ -90,19 +90,19 @@ } core.getMainWindow().addTab(I18n.getMessage("thaw.common.status"), - IconBox.minQueue, + IconBox.minQueue, panelAdded); //if(core.getConnectionManager() != null && core.getConnectionManager().isConnected()) { // core.getConnectionManager().addObserver(this); //} - if(core.getQueueManager() != null) - core.getQueueManager().addObserver(this); - else { - Logger.warning(this, "Unable to connect to QueueManager. Is the connection established ?"); - return false; - } + //if(core.getQueueManager() != null) + // core.getQueueManager().addObserver(this); + //else { + // Logger.warning(this, "Unable to connect to QueueManager. Is the connection established ?"); + // return false; + //} dnd = new DragAndDropManager(core, queuePanels); @@ -145,6 +145,7 @@ } + /* public void update(Observable o, Object arg) { if(o == core.getConnectionManager()) { queuePanels[0].resetTable(); @@ -174,6 +175,7 @@ } } + */ public void propertyChange(PropertyChangeEvent evt) { Modified: trunk/apps/Thaw/src/thaw/plugins/SqlConsole.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/SqlConsole.java 2006-08-15 21:12:13 UTC (rev 10100) +++ trunk/apps/Thaw/src/thaw/plugins/SqlConsole.java 2006-08-15 21:58:20 UTC (rev 10101) @@ -154,11 +154,18 @@ return; } + java.sql.Statement st = hsqldb.getConnection().createStatement(); + ResultSet result; - if(!cmd.toLowerCase().equals("drop_tables")) - result = hsqldb.executeQuery(cmd); - else { + if(!cmd.toLowerCase().equals("drop_tables")) { + if(st.execute(cmd)) + result = st.getResultSet(); + else { + addToConsole("Ok\n"); + return; + } + } else { TableCreator.dropTables(hsqldb); addToConsole("Ok\n"); return; @@ -170,13 +177,8 @@ return; } - try { - if(result.getFetchSize() == 0) { - addToConsole("(done)\n"); - return; - } - } catch(java.sql.SQLException e) { - addToConsole("(SE)\n"); + if(result.getFetchSize() == 0) { + addToConsole("(done)\n"); return; } Modified: trunk/apps/Thaw/src/thaw/plugins/index/TableCreator.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/TableCreator.java 2006-08-15 21:12:13 UTC (rev 10100) +++ trunk/apps/Thaw/src/thaw/plugins/index/TableCreator.java 2006-08-15 21:58:20 UTC (rev 10101) @@ -76,9 +76,9 @@ sendQuery(db, "CREATE CACHED TABLE files (" + "id INTEGER IDENTITY NOT NULL," - + "publicKey VARCHAR(350)," // key ~= 100 + filename == 255 max - + "mime VARCHAR(50)," - + "size BIGINT," + + "publicKey VARCHAR(350) NOT NULL," // key ~= 100 + filename == 255 max => 350 + + "mime VARCHAR(50) NULL," + + "size BIGINT NULL," + "catParent INTEGER NULL," + "indexParent INTEGER NULL," + "PRIMARY KEY (id)," @@ -88,13 +88,18 @@ sendQuery(db, "CREATE CACHED TABLE links (" + "id INTEGER IDENTITY NOT NULL," - + "indexName VARCHAR(255)," - + "publicKey VARCHAR(350)," // key ~= 100 + filename == 255 max + + "indexName VARCHAR(255) NOT NULL," + + "publicKey VARCHAR(350) NOT NULL," // key ~= 100 + filename == 255 max + + "mark INTEGER NOT NULL," + + "comment VARCHAR(512) NOT NULL," + "catParent INTEGER NULL," + "indexParent INTEGER NULL," + + "indexTarget INTEGER NULL," + "PRIMARY KEY (id)," + "FOREIGN KEY (catParent) REFERENCES fileCategories (id)," - + "FOREIGN KEY (indexParent) REFERENCES indexes (id))"); + + "FOREIGN KEY (indexParent) REFERENCES indexes (id)," + + "FOREIGN KEY (indexTarget) REFERENCES indexes (id))"); + sendQuery(db, "CREATE CACHED TABLE metadataNames (" Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java 2006-08-15 21:12:13 UTC (rev 10100) +++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java 2006-08-15 21:58:20 UTC (rev 10101) @@ -72,13 +72,13 @@ private boolean insertionQueue = false; - public QueuePanel(Core core, DetailPanel detailPanel, boolean isForInsertionQueue) { + public QueuePanel(Core core, DetailPanel detailPanel, FCPQueueManager queueManager, boolean isForInsertionQueue) { insertionQueue = isForInsertionQueue; this.core = core; this.detailPanel = detailPanel; - tableModel = new QueueTableModel(isForInsertionQueue); + tableModel = new QueueTableModel(isForInsertionQueue, queueManager); table = new JTable(tableModel); @@ -389,7 +389,6 @@ if(query.stop(core.getQueueManager())) { core.getQueueManager().remove(query); - tableModel.removeQuery(query); } } Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java 2006-08-15 21:12:13 UTC (rev 10100) +++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java 2006-08-15 21:58:20 UTC (rev 10101) @@ -34,11 +34,13 @@ private boolean isSortedAsc = false; private int sortedColumn = -1; + private FCPQueueManager queueManager; - public QueueTableModel(boolean isForInsertions) { + public QueueTableModel(boolean isForInsertions, FCPQueueManager queueManager) { super(); + this.queueManager = queueManager; this.isForInsertions = isForInsertions; columnNames.add(I18n.getMessage("thaw.common.file")); @@ -51,7 +53,13 @@ columnNames.add(I18n.getMessage("thaw.common.progress")); resetTable(); - + + if(queueManager != null) { + reloadQueue(); + queueManager.addObserver(this); + } else { + Logger.warning(this, "Unable to connect to QueueManager. Is the connection established ?"); + } } @@ -146,6 +154,9 @@ return false; } + /** + * Don't call notifyObservers ! + */ public synchronized void resetTable() { if(queries != null) { @@ -158,9 +169,35 @@ queries = new Vector(); - notifyObservers(); } + public synchronized void reloadQueue() { + resetTable(); + + addQueries(queueManager.getRunningQueue()); + + Vector[] pendings = queueManager.getPendingQueues(); + + for(int i = 0;i < pendings.length ; i++) + addQueries(pendings[i]); + + } + + public synchronized void addQueries(Vector queries) { + for(Iterator it = queries.iterator(); + it.hasNext();) { + + FCPTransferQuery query = (FCPTransferQuery)it.next(); + + if(query.getQueryType() == 1 && !isForInsertions) + addQuery(query); + + if(query.getQueryType() == 2 && isForInsertions) + addQuery(query); + + } + } + public synchronized void addQuery(FCPTransferQuery query) { ((Observable)query).addObserver(this); @@ -168,17 +205,24 @@ sortTable(); - notifyObservers(); + int changedRow = queries.indexOf(query); + + notifyObservers(new TableModelEvent(this, changedRow, changedRow, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT)); } public synchronized void removeQuery(FCPTransferQuery query) { ((Observable)query).deleteObserver(this); + int changedRow = queries.indexOf(query); + queries.remove(query); sortTable(); - notifyObservers(); + if(changedRow >= 0) + notifyObservers(new TableModelEvent(this, changedRow, changedRow, TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE)); + else + notifyObservers(); } @@ -206,18 +250,62 @@ } public void notifyObservers() { + TableModelEvent event = new TableModelEvent(this); + + notifyObservers(event); + } + + public void notifyObservers(int changedRow) { + TableModelEvent event = new TableModelEvent(this, changedRow); + + notifyObservers(event); + } + + public void notifyObservers(TableModelEvent event) { TableModelListener[] listeners = getTableModelListeners(); - /* TODO : Sort queries by progression */ - for(int i = 0 ; i < listeners.length ; i++) { - listeners[i].tableChanged(new TableModelEvent(this)); + listeners[i].tableChanged(event); } } - public void update(Observable o, Object arg) { + public synchronized void update(Observable o, Object arg) { + int i; + sortTable(); - notifyObservers(); + + if( (i = queries.indexOf(o)) >= 0) { + notifyObservers(i); + return; + } + + if(arg == null) { + reloadQueue(); + return; + } + + FCPTransferQuery query = (FCPTransferQuery)arg; + + if(query.getQueryType() == 1 && isForInsertions) + return; + + if(query.getQueryType() == 2 && !isForInsertions) + return; + + if(queueManager.isInTheQueues(query)) { // then it's an adding + addQuery(query); + return; + } + + if(queries.contains(query)) { + Logger.notice(this, "REMOVE"); + + removeQuery(query); + return; + } + + Logger.warning(this, "update(): Unknow change ?!"); + reloadQueue(); }
