From jflesch at freenetproject.org Wed Nov 1 17:51:26 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Wed, 1 Nov 2006 17:51:26 +0000 (UTC) Subject: [Thaw-dev] r10777 - in trunk/apps/Thaw/src/thaw: core plugins plugins/queueWatcher Message-ID: <20061101175126.4198A9CA09@emu.freenetproject.org> Author: jflesch Date: 2006-11-01 17:51:20 +0000 (Wed, 01 Nov 2006) New Revision: 10777 Added: trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java Modified: trunk/apps/Thaw/src/thaw/core/MainWindow.java trunk/apps/Thaw/src/thaw/core/PluginManager.java trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java Log: Remove 2 tabs and add 2 buttons in the Toolbar Modified: trunk/apps/Thaw/src/thaw/core/MainWindow.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/MainWindow.java 2006-11-01 17:13:09 UTC (rev 10776) +++ trunk/apps/Thaw/src/thaw/core/MainWindow.java 2006-11-01 17:51:20 UTC (rev 10777) @@ -17,7 +17,10 @@ import javax.swing.Icon; import java.awt.Font; +import java.util.Vector; +import java.util.Iterator; + /** * MainWindow. This class create the main window. * @@ -69,6 +72,7 @@ private Core core = null; /* core is called back when exit() */ + private Object lastToolBarModifier = null; /** * Creates a new MainWindow instance, and so a new Swing window. @@ -122,8 +126,6 @@ this.menuBar.add(this.helpMenu); // TOOLBAR - this.toolBar = new JToolBar(I18n.getMessage("thaw.toolbar.title")); - this.connectButton = new JButton(IconBox.connectAction); this.connectButton.setToolTipText(I18n.getMessage("thaw.toolbar.button.connect")); this.disconnectButton = new JButton(IconBox.disconnectAction); @@ -135,21 +137,12 @@ this.quitButton = new JButton(IconBox.quitAction); this.quitButton.setToolTipText(I18n.getMessage("thaw.toolbar.button.quit")); - this.connectButton.addActionListener(this); this.disconnectButton.addActionListener(this); this.settingsButton.addActionListener(this); this.quitButton.addActionListener(this); - this.toolBar.add(this.connectButton); - this.toolBar.add(this.disconnectButton); - this.toolBar.addSeparator(); - this.toolBar.add(this.settingsButton); - this.toolBar.addSeparator(); - this.toolBar.add(this.quitButton); - this.updateToolBar(); - // TABBED PANE this.tabbedPane = new JTabbedPane(); @@ -164,7 +157,8 @@ this.mainWindow.getContentPane().setLayout(new BorderLayout()); this.mainWindow.setJMenuBar(this.menuBar); - this.mainWindow.getContentPane().add(this.toolBar, BorderLayout.NORTH); + + /* Toolbar adding: */ changeButtonsInTheToolbar(this, null); this.mainWindow.getContentPane().add(this.tabbedPane, BorderLayout.CENTER); this.mainWindow.getContentPane().add(this.statusBar, BorderLayout.SOUTH); @@ -199,6 +193,54 @@ } /** + * @param modifier Correspond to the caller object: it's a security to avoid that a modifier wipe out the buttons from another one + */ + public void changeButtonsInTheToolbar(Object modifier, Vector newButtons) { + JToolBar newToolBar; + + Logger.debug(this, "Called by "+modifier.getClass().getName()); + + if (lastToolBarModifier == null || newButtons != null || lastToolBarModifier == modifier) { + lastToolBarModifier = modifier; + } else { + /* Only the modifer who added the buttons can remove them */ + return; + } + + newToolBar = new JToolBar(I18n.getMessage("thaw.toolbar.title")); + + newToolBar.add(this.connectButton); + newToolBar.add(this.disconnectButton); + newToolBar.addSeparator(); + newToolBar.add(this.settingsButton); + newToolBar.addSeparator(); + + if (newButtons != null) { + newToolBar.addSeparator(); + for (Iterator it = newButtons.iterator(); + it.hasNext();) { + JButton button = (JButton)it.next(); + if (button != null) + newToolBar.add(button); + else + newToolBar.addSeparator(); + } + newToolBar.addSeparator(); + newToolBar.addSeparator(); + } + + newToolBar.add(this.quitButton); + newToolBar.setFloatable(false); + + if (this.toolBar != null) + this.mainWindow.getContentPane().remove(this.toolBar); + this.toolBar = newToolBar; + this.mainWindow.getContentPane().add(this.toolBar, BorderLayout.NORTH); + this.updateToolBar(); + } + + + /** * Used to add a tab in the main window. * In the future, even if the interface, this function should remain available. */ Modified: trunk/apps/Thaw/src/thaw/core/PluginManager.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/PluginManager.java 2006-11-01 17:13:09 UTC (rev 10776) +++ trunk/apps/Thaw/src/thaw/core/PluginManager.java 2006-11-01 17:51:20 UTC (rev 10777) @@ -9,8 +9,8 @@ */ public class PluginManager { private final static String[] defaultPlugins = {"thaw.plugins.QueueWatcher", + "thaw.plugins.FetchPlugin", "thaw.plugins.InsertPlugin", - "thaw.plugins.FetchPlugin", "thaw.plugins.StatusBar", "thaw.plugins.IndexBrowser", "thaw.plugins.IndexEditor"}; Modified: trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2006-11-01 17:13:09 UTC (rev 10776) +++ trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2006-11-01 17:51:20 UTC (rev 10777) @@ -1,16 +1,27 @@ package thaw.plugins; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + +import javax.swing.JFrame; +import javax.swing.JButton; +import javax.swing.WindowConstants; + import thaw.core.*; import thaw.plugins.fetchPlugin.*; import thaw.fcp.*; -public class FetchPlugin implements thaw.core.Plugin { +public class FetchPlugin implements thaw.core.Plugin, ActionListener { private Core core; private FetchPanel fetchPanel = null; - + private JFrame fetchFrame = null; + private JButton buttonInToolBar = null; + + private QueueWatcher queueWatcher; + public FetchPlugin() { } @@ -18,15 +29,44 @@ public boolean run(Core core) { this.core = core; - + Logger.info(this, "Starting plugin \"FetchPlugin\" ..."); this.fetchPanel = new FetchPanel(core, this); - core.getMainWindow().addTab(I18n.getMessage("thaw.common.download"), - IconBox.minDownloads, - this.fetchPanel.getPanel()); + //core.getMainWindow().addTab(I18n.getMessage("thaw.common.download"), + // IconBox.minDownloads, + // this.fetchPanel.getPanel()); + + // Prepare the frame + + fetchFrame = new JFrame(I18n.getMessage("thaw.common.download")); + fetchFrame.setVisible(false); + fetchFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); + fetchFrame.setContentPane(fetchPanel.getPanel()); + fetchFrame.setSize(650, 500); + + // Add the button to the toolbar when the QueueWatch tab is selected + buttonInToolBar = new JButton(IconBox.downloads); + buttonInToolBar.setToolTipText(I18n.getMessage("thaw.common.download")); + buttonInToolBar.addActionListener(this); + + + if(core.getPluginManager().getPlugin("thaw.plugins.QueueWatcher") == null) { + Logger.info(this, "Loading QueueWatcher plugin"); + + if(!core.getPluginManager().loadPlugin("thaw.plugins.QueueWatcher") + || !core.getPluginManager().runPlugin("thaw.plugins.QueueWatcher")) { + Logger.error(this, "Unable to load thaw.plugins.QueueWatcher !"); + return false; + } + } + + queueWatcher = (QueueWatcher)core.getPluginManager().getPlugin("thaw.plugins.QueueWatcher"); + + queueWatcher.addButtonToTheToolbar(buttonInToolBar); + return true; } @@ -34,8 +74,11 @@ public boolean stop() { Logger.info(this, "Stopping plugin \"FetchPlugin\" ..."); - this.core.getMainWindow().removeTab(this.fetchPanel.getPanel()); + //this.core.getMainWindow().removeTab(this.fetchPanel.getPanel()); + if (queueWatcher != null) + queueWatcher.removeButtonFromTheToolbar(buttonInToolBar); + return true; } @@ -43,6 +86,10 @@ return I18n.getMessage("thaw.common.download"); } + public void actionPerformed(ActionEvent e) { + if (e.getSource() == buttonInToolBar) + fetchFrame.setVisible(true); + } public void fetchFiles(String[] keys, int priority, int persistence, boolean globalQueue, @@ -63,6 +110,7 @@ destination)); } + fetchFrame.setVisible(false); } } Modified: trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java 2006-11-01 17:13:09 UTC (rev 10776) +++ trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java 2006-11-01 17:51:20 UTC (rev 10777) @@ -35,7 +35,7 @@ } - public void lockWriting() { + public synchronized void lockWriting() { while(writeLock > 0) { try { Thread.sleep(100); Modified: trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java 2006-11-01 17:13:09 UTC (rev 10776) +++ trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java 2006-11-01 17:51:20 UTC (rev 10777) @@ -3,16 +3,29 @@ import javax.swing.JScrollPane; import java.io.File; +import javax.swing.JFrame; +import javax.swing.JButton; +import javax.swing.WindowConstants; + +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + import thaw.core.*; import thaw.plugins.insertPlugin.*; import thaw.fcp.*; -public class InsertPlugin implements thaw.core.Plugin { +public class InsertPlugin implements thaw.core.Plugin, ActionListener { private Core core; private InsertPanel insertPanel; private JScrollPane scrollPane; + private JFrame insertionFrame; + private JButton buttonInToolBar; + + private QueueWatcher queueWatcher; + + public InsertPlugin() { } @@ -28,10 +41,40 @@ this.scrollPane = new JScrollPane(this.insertPanel.getPanel()); - core.getMainWindow().addTab(I18n.getMessage("thaw.common.insertion"), - IconBox.minInsertions, - this.scrollPane); + //core.getMainWindow().addTab(I18n.getMessage("thaw.common.insertion"), + // IconBox.minInsertions, + // this.scrollPane); + insertionFrame = new JFrame(I18n.getMessage("thaw.common.insertion")); + insertionFrame.setVisible(false); + insertionFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); + insertionFrame.setContentPane(scrollPane); + + if (core.getConfig().getValue("advancedMode") == null + || Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue()) { + insertionFrame.setSize(750, 450); + } else { + insertionFrame.setSize(350, 200); + } + + buttonInToolBar = new JButton(IconBox.insertions); + buttonInToolBar.setToolTipText(I18n.getMessage("thaw.common.insertion")); + buttonInToolBar.addActionListener(this); + + if(core.getPluginManager().getPlugin("thaw.plugins.QueueWatcher") == null) { + Logger.info(this, "Loading QueueWatcher plugin"); + + if(!core.getPluginManager().loadPlugin("thaw.plugins.QueueWatcher") + || !core.getPluginManager().runPlugin("thaw.plugins.QueueWatcher")) { + Logger.error(this, "Unable to load thaw.plugins.QueueWatcher !"); + return false; + } + } + + queueWatcher = (QueueWatcher)core.getPluginManager().getPlugin("thaw.plugins.QueueWatcher"); + + queueWatcher.addButtonToTheToolbar(buttonInToolBar); + return true; } @@ -39,8 +82,11 @@ public boolean stop() { Logger.info(this, "Stopping plugin \"InsertPlugin\" ..."); - this.core.getMainWindow().removeTab(this.scrollPane); + //this.core.getMainWindow().removeTab(this.scrollPane); + if (queueWatcher != null) + queueWatcher.removeButtonFromTheToolbar(buttonInToolBar); + return true; } @@ -50,6 +96,12 @@ } + public void actionPerformed(ActionEvent e) { + if (e.getSource() == buttonInToolBar) + insertionFrame.setVisible(true); + } + + /** * Note: public key is found from private one. * @param fileList File list, separated by ';' @@ -98,6 +150,8 @@ } + insertionFrame.setVisible(false); + return true; } Modified: trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-11-01 17:13:09 UTC (rev 10776) +++ trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-11-01 17:51:20 UTC (rev 10777) @@ -7,13 +7,16 @@ import java.util.Iterator; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.ChangeEvent; + import thaw.core.*; import thaw.plugins.queueWatcher.*; import thaw.fcp.*; -public class QueueWatcher implements thaw.core.Plugin, PropertyChangeListener { +public class QueueWatcher extends ToolbarModifier implements thaw.core.Plugin, PropertyChangeListener, ChangeListener { private Core core; //private JPanel mainPanel; @@ -83,23 +86,17 @@ this.panelAdded = this.panel; } + setMainWindow(core.getMainWindow()); + core.getMainWindow().addTab(I18n.getMessage("thaw.common.status"), IconBox.minQueue, this.panelAdded); + core.getMainWindow().getTabbedPane().addChangeListener(this); - //if(core.getConnectionManager() != null && core.getConnectionManager().isConnected()) { - // core.getConnectionManager().addObserver(this); - //} + this.dnd = new DragAndDropManager(core, this.queuePanels); - //if(core.getQueueManager() != null) - // core.getQueueManager().addObserver(this); - //else { - // Logger.warning(this, "Unable to connect to QueueManager. Is the connection established ?"); - // return false; - //} + stateChanged(null); - this.dnd = new DragAndDropManager(core, this.queuePanels); - return true; } @@ -137,6 +134,9 @@ } + /** + * Called when the split bar position changes. + */ public void propertyChange(PropertyChangeEvent evt) { if("dividerLocation".equals( evt.getPropertyName() )) { @@ -162,4 +162,24 @@ } + /** + * Called when the JTabbedPane changed (ie change in the selected tab, etc) + * @param e can be null. + */ + public void stateChanged(ChangeEvent e) { + int tabId; + + tabId = core.getMainWindow().getTabbedPane().indexOfTab(I18n.getMessage("thaw.common.status")); + + if (tabId < 0) { + Logger.warning(this, "Unable to find back the tab !"); + return; + } + + if (core.getMainWindow().getTabbedPane().getSelectedIndex() == tabId) { + displayButtonsInTheToolbar(); + } else { + hideButtonsInTheToolbar(); + } + } } Added: trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java 2006-11-01 17:13:09 UTC (rev 10776) +++ trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java 2006-11-01 17:51:20 UTC (rev 10777) @@ -0,0 +1,63 @@ +package thaw.plugins; + +import java.util.Vector; +import javax.swing.JButton; + +import thaw.core.Logger; +import thaw.core.MainWindow; + +/** + * Not a plugin ! Just an helper for the plugins ! + */ +public class ToolbarModifier { + private MainWindow mainWindow = null; + + private Vector buttons; /* JButtons */ + + private boolean areDisplayed = false; + + public ToolbarModifier() { + buttons = new Vector(); + areDisplayed = false; + } + + public ToolbarModifier(MainWindow toolbarTarget) { + this(); + setMainWindow(toolbarTarget); + } + + + public void setMainWindow(MainWindow target) { + this.mainWindow = target; + } + + public void addButtonToTheToolbar(JButton button) { + buttons.add(button); + + if (areDisplayed) + displayButtonsInTheToolbar(); + } + + public void removeButtonFromTheToolbar(JButton button) { + buttons.remove(button); + + if (areDisplayed) + displayButtonsInTheToolbar(); + } + + public void displayButtonsInTheToolbar() { + if (mainWindow != null) { + mainWindow.changeButtonsInTheToolbar(this, buttons); + areDisplayed = true; + } else + Logger.error(this, "MainWindow not SET !"); + } + + public void hideButtonsInTheToolbar() { + if (mainWindow != null) { + mainWindow.changeButtonsInTheToolbar(this, null); + areDisplayed = false; + } else + Logger.error(this, "MainWindow not SET !"); + } +} Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java 2006-11-01 17:13:09 UTC (rev 10776) +++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java 2006-11-01 17:51:20 UTC (rev 10777) @@ -264,6 +264,10 @@ this.resetPriorityRadioButtons(); } else { FCPTransferQuery query = this.tableModel.getQuery(this.selectedRows[0]); + + if (query == null) + return; + this.priorityRadioButton[query.getFCPPriority()].setSelected(true); } } From jflesch at freenetproject.org Wed Nov 1 18:38:29 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Wed, 1 Nov 2006 18:38:29 +0000 (UTC) Subject: [Thaw-dev] r10784 - trunk/apps/Thaw/src/thaw/core Message-ID: <20061101183829.C41709CA70@emu.freenetproject.org> Author: jflesch Date: 2006-11-01 18:38:13 +0000 (Wed, 01 Nov 2006) New Revision: 10784 Modified: trunk/apps/Thaw/src/thaw/core/MainWindow.java Log: Fix separators in toolbar Modified: trunk/apps/Thaw/src/thaw/core/MainWindow.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/MainWindow.java 2006-11-01 18:18:59 UTC (rev 10783) +++ trunk/apps/Thaw/src/thaw/core/MainWindow.java 2006-11-01 18:38:13 UTC (rev 10784) @@ -216,7 +216,6 @@ newToolBar.addSeparator(); if (newButtons != null) { - newToolBar.addSeparator(); for (Iterator it = newButtons.iterator(); it.hasNext();) { JButton button = (JButton)it.next(); @@ -226,7 +225,6 @@ newToolBar.addSeparator(); } newToolBar.addSeparator(); - newToolBar.addSeparator(); } newToolBar.add(this.quitButton); From jflesch at freenetproject.org Wed Nov 1 19:24:35 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Wed, 1 Nov 2006 19:24:35 +0000 (UTC) Subject: [Thaw-dev] r10785 - trunk/apps/Thaw/src/thaw/core Message-ID: <20061101192435.5EE5B9CA46@emu.freenetproject.org> Author: jflesch Date: 2006-11-01 19:24:32 +0000 (Wed, 01 Nov 2006) New Revision: 10785 Modified: trunk/apps/Thaw/src/thaw/core/IconBox.java Log: Improve IconBox loading mechanism Modified: trunk/apps/Thaw/src/thaw/core/IconBox.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/IconBox.java 2006-11-01 18:38:13 UTC (rev 10784) +++ trunk/apps/Thaw/src/thaw/core/IconBox.java 2006-11-01 19:24:32 UTC (rev 10785) @@ -1,6 +1,7 @@ package thaw.core; import javax.swing.ImageIcon; +import java.net.URL; /** * This class is simply an helper to find and load quickly some common icons. @@ -65,98 +66,66 @@ } - /** - * no warranty - */ - public static void loadIcons() { - try { + protected static ImageIcon loadIcon(String fileName) { + ImageIcon imageIcon; + URL url; + Class daClass; + ClassLoader classLoader; - blueBunny = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("blueBunny.png")); + daClass = (new IconBox()).getClass(); + if (daClass == null) { + Logger.error(new IconBox(), "Icon '"+fileName+"' not found ! (Class)"); + return null; + } - connectAction = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("go-jump.png")); - minConnectAction = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("min-go-jump.png")); + classLoader = daClass.getClassLoader(); + if (classLoader == null) { + Logger.error(new IconBox(), "Icon '"+fileName+"' not found ! (Class)"); + return null; + } - disconnectAction = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("process-stop.png")); + url = classLoader.getResource(fileName); - queue = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("system-search.png")); - minQueue = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("min-system-search.png")); + if (url == null) { + Logger.error(new IconBox(), "Icon '"+fileName+"' not found ! (Class)"); + return null; + } + return new ImageIcon(url); + } - insertions = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("go-next.png")); - minInsertions = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("min-go-next.png")); - - - minIndex = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("index.png")); - - indexNew = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("index-new.png")); - - indexReuse = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("index-existing.png")); - - - downloads = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("go-first.png")); - minDownloads = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("min-go-first.png")); - - clearAction = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("edit-clear.png")); - - settings = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("preferences-system.png")); - minSettings = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("min-preferences-system.png")); - - - indexEditor = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("edit-find-replace.png")); - minIndexEditor = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("min-edit-find-replace.png")); - - - indexBrowser = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("edit-find.png")); - 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")); - makeALinkAction = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("application-internet.png")); - - - reconnectAction = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("view-refresh.png")); - minReconnectAction = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("min-view-refresh.png")); - - refreshAction = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("view-refresh.png")); - - quitAction = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("system-log-out.png")); - minQuitAction = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("min-system-log-out.png")); - - search = - new ImageIcon((new IconBox()).getClass().getClassLoader().getResource("system-search.png")); - } catch(Exception e) { - Logger.notice(new IconBox(), "Exception while loading icons: "+e); - } + public static void loadIcons() { + blueBunny = loadIcon("blueBunny.png"); + connectAction = loadIcon("go-jump.png"); + minConnectAction = loadIcon("min-go-jump.png"); + disconnectAction = loadIcon("process-stop.png"); + queue = loadIcon("system-search.png"); + minQueue = loadIcon("min-system-search.png"); + insertions = loadIcon("go-next.png"); + minInsertions = loadIcon("min-go-next.png"); + minIndex = loadIcon("index.png"); + indexNew = loadIcon("index-new.png"); + indexReuse = loadIcon("index-existing.png"); + downloads = loadIcon("go-first.png"); + minDownloads = loadIcon("min-go-first.png"); + clearAction = loadIcon("edit-clear.png"); + settings = loadIcon("preferences-system.png"); + minSettings = loadIcon("min-preferences-system.png"); + indexEditor = loadIcon("edit-find-replace.png"); + minIndexEditor = loadIcon("min-edit-find-replace.png"); + indexBrowser = loadIcon("edit-find.png"); + minIndexBrowser = loadIcon("min-edit-find.png"); + addToIndexAction = loadIcon("folder.png"); + insertAndAddToIndexAction = loadIcon("folder-new.png"); + makeALinkAction = loadIcon("application-internet.png"); + reconnectAction = loadIcon("view-refresh.png"); + minReconnectAction = loadIcon("min-view-refresh.png"); + refreshAction = loadIcon("view-refresh.png"); + quitAction = loadIcon("system-log-out.png"); + minQuitAction = loadIcon("min-system-log-out.png"); + search = loadIcon("system-search.png"); } } From jflesch at freenetproject.org Wed Nov 1 20:35:09 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Wed, 1 Nov 2006 20:35:09 +0000 (UTC) Subject: [Thaw-dev] r10788 - in trunk/apps/Thaw/src/thaw: core plugins plugins/index plugins/queueWatcher Message-ID: <20061101203509.491749CAA6@emu.freenetproject.org> Author: jflesch Date: 2006-11-01 20:35:02 +0000 (Wed, 01 Nov 2006) New Revision: 10788 Modified: trunk/apps/Thaw/src/thaw/core/Logger.java trunk/apps/Thaw/src/thaw/core/MainWindow.java trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java trunk/apps/Thaw/src/thaw/plugins/index/Index.java trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java Log: Fix possible freeze when updating indexes with a jvm 1.4 Modified: trunk/apps/Thaw/src/thaw/core/Logger.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/Logger.java 2006-11-01 20:16:48 UTC (rev 10787) +++ trunk/apps/Thaw/src/thaw/core/Logger.java 2006-11-01 20:35:02 UTC (rev 10788) @@ -20,7 +20,7 @@ * * 2 or more is recommanded. */ - public final static int LOG_LEVEL = 3; + public final static int LOG_LEVEL = 2; private static Vector logListeners = null; Modified: trunk/apps/Thaw/src/thaw/core/MainWindow.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/MainWindow.java 2006-11-01 20:16:48 UTC (rev 10787) +++ trunk/apps/Thaw/src/thaw/core/MainWindow.java 2006-11-01 20:35:02 UTC (rev 10788) @@ -237,7 +237,11 @@ this.updateToolBar(); } + public void resetLastKnowToolBarModifier() { + lastToolBarModifier = null; + } + /** * Used to add a tab in the main window. * In the future, even if the interface, this function should remain available. Modified: trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-11-01 20:16:48 UTC (rev 10787) +++ trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-11-01 20:35:02 UTC (rev 10788) @@ -172,7 +172,7 @@ tabId = core.getMainWindow().getTabbedPane().indexOfTab(I18n.getMessage("thaw.common.status")); if (tabId < 0) { - Logger.warning(this, "Unable to find back the tab !"); + Logger.warning(this, "Unable to find the tab !"); return; } Modified: trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java 2006-11-01 20:16:48 UTC (rev 10787) +++ trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java 2006-11-01 20:35:02 UTC (rev 10788) @@ -29,6 +29,7 @@ public void setMainWindow(MainWindow target) { this.mainWindow = target; + this.mainWindow.resetLastKnowToolBarModifier(); } public void addButtonToTheToolbar(JButton button) { @@ -47,6 +48,10 @@ public void displayButtonsInTheToolbar() { if (mainWindow != null) { + if (buttons.size() == 0) { + Logger.notice(this, "No button to display ?"); + } + mainWindow.changeButtonsInTheToolbar(this, buttons); areDisplayed = true; } else Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-11-01 20:16:48 UTC (rev 10787) +++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-11-01 20:35:02 UTC (rev 10788) @@ -334,14 +334,6 @@ clientGet.addObserver(this); - /* - * These requests are usually quite fast, and don't consume a lot - * of bandwith / CPU. So we can skip the queue and start immediatly - * (and like this, they won't appear in the queue) - */ - //this.queueManager.addQueryToThePendingQueue(clientGet); - clientGet.start(queueManager); - Thread downloadAndParse = new Thread(new DownloadAndParse(clientGet, rewriteKey)); downloadAndParse.start(); @@ -363,6 +355,13 @@ } public void run() { + /* + * These requests are usually quite fast, and don't consume a lot + * of bandwith / CPU. So we can skip the queue and start immediatly + * (and like this, they won't appear in the queue) + */ + //this.queueManager.addQueryToThePendingQueue(clientGet); + clientGet.start(queueManager); loadXML(clientGet.getInputStream()); save(); } Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2006-11-01 20:16:48 UTC (rev 10787) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2006-11-01 20:35:02 UTC (rev 10788) @@ -329,6 +329,25 @@ return null; } + + public void startUpdateFromThisNode(IndexTreeNode node) { + Thread th = new Thread(new Updater(node)); + th.start(); + } + + private class Updater implements Runnable { + IndexTreeNode node; + + public Updater(IndexTreeNode node) { + this.node = node; + } + + public void run() { + node.update(); + } + } + + public void actionPerformed(ActionEvent e) { if(this.selectedNode == null) this.selectedNode = this.root; @@ -445,15 +464,15 @@ if(e.getSource() == this.updateIndex || e.getSource() == this.updateIndexCategory) { - this.selectedNode.update(); + startUpdateFromThisNode(this.selectedNode); } if (e.getSource() == this.reloadFromFreenet) { - this.selectedNode.updateFromFreenet(-1); + startUpdateFromThisNode(this.selectedNode); } if (e.getSource() == this.refreshAll) { - this.root.update(); + startUpdateFromThisNode(this.selectedNode); } if(e.getSource() == this.copyPublicKey Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java 2006-11-01 20:16:48 UTC (rev 10787) +++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java 2006-11-01 20:35:02 UTC (rev 10788) @@ -315,7 +315,7 @@ } } - Logger.warning(this, "update(): Unknow change ?!"); + Logger.notice(this, "update(): unknow change"); this.reloadQueue(); } From jflesch at freenetproject.org Wed Nov 1 23:48:32 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Wed, 1 Nov 2006 23:48:32 +0000 (UTC) Subject: [Thaw-dev] r10792 - in trunk/apps/Thaw/src/thaw: i18n plugins plugins/index plugins/queueWatcher Message-ID: <20061101234832.89D0720AFF2@emu.freenetproject.org> Author: jflesch Date: 2006-11-01 23:48:15 +0000 (Wed, 01 Nov 2006) New Revision: 10792 Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java trunk/apps/Thaw/src/thaw/plugins/index/Index.java trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java Log: Add two item to the contextual menus in the QueueWatcher Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2006-11-01 22:38:27 UTC (rev 10791) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2006-11-01 23:48:15 UTC (rev 10792) @@ -12,8 +12,10 @@ thaw.common.insertion=Insertion thaw.common.download=Download +thaw.common.addDownloads=Download files thaw.common.insertions=Insertions thaw.common.downloads=Downloads +thaw.common.addInsertions=Insert files thaw.common.uploading=Uploading Modified: trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2006-11-01 22:38:27 UTC (rev 10791) +++ trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2006-11-01 23:48:15 UTC (rev 10792) @@ -7,6 +7,8 @@ import javax.swing.JButton; import javax.swing.WindowConstants; +import javax.swing.JMenuItem; + import thaw.core.*; import thaw.plugins.fetchPlugin.*; @@ -19,6 +21,7 @@ private JFrame fetchFrame = null; private JButton buttonInToolBar = null; + private JMenuItem menuItem = null; private QueueWatcher queueWatcher; @@ -52,6 +55,8 @@ buttonInToolBar.setToolTipText(I18n.getMessage("thaw.common.download")); buttonInToolBar.addActionListener(this); + menuItem = new JMenuItem(I18n.getMessage("thaw.common.addDownloads")); + menuItem.addActionListener(this); if(core.getPluginManager().getPlugin("thaw.plugins.QueueWatcher") == null) { Logger.info(this, "Loading QueueWatcher plugin"); @@ -67,6 +72,9 @@ queueWatcher.addButtonToTheToolbar(buttonInToolBar); + /* WARNING: This menu item can't be remove cleanly ... :/ */ + queueWatcher.addMenuItemToTheDownloadTable(menuItem); + return true; } @@ -87,8 +95,7 @@ } public void actionPerformed(ActionEvent e) { - if (e.getSource() == buttonInToolBar) - fetchFrame.setVisible(true); + fetchFrame.setVisible(true); } public void fetchFiles(String[] keys, int priority, Modified: trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java 2006-11-01 22:38:27 UTC (rev 10791) +++ trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java 2006-11-01 23:48:15 UTC (rev 10792) @@ -10,6 +10,8 @@ import java.awt.event.ActionListener; import java.awt.event.ActionEvent; +import javax.swing.JMenuItem; + import thaw.core.*; import thaw.plugins.insertPlugin.*; import thaw.fcp.*; @@ -23,6 +25,8 @@ private JFrame insertionFrame; private JButton buttonInToolBar; + private JMenuItem menuItem; + private QueueWatcher queueWatcher; @@ -61,6 +65,9 @@ buttonInToolBar.setToolTipText(I18n.getMessage("thaw.common.insertion")); buttonInToolBar.addActionListener(this); + menuItem = new JMenuItem(I18n.getMessage("thaw.common.addInsertions")); + menuItem.addActionListener(this); + if(core.getPluginManager().getPlugin("thaw.plugins.QueueWatcher") == null) { Logger.info(this, "Loading QueueWatcher plugin"); @@ -75,6 +82,9 @@ queueWatcher.addButtonToTheToolbar(buttonInToolBar); + /* WARNING: This menu item can't be remove cleanly ... :/ */ + queueWatcher.addMenuItemToTheInsertionTable(menuItem); + return true; } @@ -97,8 +107,7 @@ public void actionPerformed(ActionEvent e) { - if (e.getSource() == buttonInToolBar) - insertionFrame.setVisible(true); + insertionFrame.setVisible(true); } Modified: trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-11-01 22:38:27 UTC (rev 10791) +++ trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-11-01 23:48:15 UTC (rev 10792) @@ -112,6 +112,14 @@ } + public void addMenuItemToTheDownloadTable(javax.swing.JMenuItem item) { + queuePanels[0].addMenuItem(item); + } + + public void addMenuItemToTheInsertionTable(javax.swing.JMenuItem item) { + queuePanels[1].addMenuItem(item); + } + public String getNameForUser() { return I18n.getMessage("thaw.common.status"); } Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-11-01 22:38:27 UTC (rev 10791) +++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-11-01 23:48:15 UTC (rev 10792) @@ -437,7 +437,7 @@ st.execute(); this.linkList = new Vector(); } catch(SQLException e) { - Logger.warning(this, "Unable to purge da list ! Exception: "+e.toString()); + Logger.error(this, "Unable to purge da list ! Exception: "+e.toString()); } } @@ -449,7 +449,7 @@ st.execute(); this.fileList = new Vector(); } catch(SQLException e) { - Logger.warning(this, "Unable to purge da list ! Exception: "+e.toString()); + Logger.error(this, "Unable to purge da list ! Exception: "+e.toString()); } } @@ -644,7 +644,7 @@ } catch(java.sql.SQLException e) { - Logger.warning(this, "Unable to get the file list for index: '"+this.toString()+"' because: "+e.toString()); + Logger.error(this, "Unable to get the file list for index: '"+this.toString()+"' because: "+e.toString()); } this.setChanged(); @@ -854,7 +854,7 @@ } catch(java.sql.SQLException e) { - Logger.warning(this, "Unable to get the link list for index: '"+this.toString()+"' because: "+e.toString()); + Logger.error(this, "Unable to get the link list for index: '"+this.toString()+"' because: "+e.toString()); } } @@ -1099,6 +1099,7 @@ thaw.plugins.index.File file = new thaw.plugins.index.File(this.db, e, this); this.addFile(file); + } } Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java 2006-11-01 22:38:27 UTC (rev 10791) +++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java 2006-11-01 23:48:15 UTC (rev 10792) @@ -176,7 +176,11 @@ } } + public void addMenuItem(JMenuItem item) { + rightClickMenu.insert(item, 0); + } + private class ProgressRenderer extends DefaultTableCellRenderer { private final static long serialVersionUID = 20060709; From jflesch at freenetproject.org Thu Nov 2 00:01:15 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 2 Nov 2006 00:01:15 +0000 (UTC) Subject: [Thaw-dev] r10793 - trunk/apps/Thaw/src/thaw/plugins/index Message-ID: <20061102000115.2BF139CA1C@emu.freenetproject.org> Author: jflesch Date: 2006-11-02 00:00:58 +0000 (Thu, 02 Nov 2006) New Revision: 10793 Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java Log: Fix horrible freeze when an index update takes too much time Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-11-01 23:48:15 UTC (rev 10792) +++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-11-02 00:00:58 UTC (rev 10793) @@ -1002,7 +1002,7 @@ return files; } - public synchronized void loadXML(java.io.InputStream input) { + public void loadXML(java.io.InputStream input) { DocumentBuilderFactory xmlFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder xmlBuilder; @@ -1070,7 +1070,7 @@ } } - public void loadLinks(Element rootEl) { + public synchronized void loadLinks(Element rootEl) { this.purgeLinkList(); Element links = (Element)rootEl.getElementsByTagName("indexes").item(0); @@ -1087,7 +1087,7 @@ } - public void loadFileList(Element rootEl) { + public synchronized void loadFileList(Element rootEl) { this.purgeFileList(); Element filesEl = (Element)rootEl.getElementsByTagName("files").item(0); From jflesch at freenetproject.org Thu Nov 2 07:17:53 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 2 Nov 2006 07:17:53 +0000 (UTC) Subject: [Thaw-dev] r10794 - trunk/apps/Thaw/src/thaw/plugins/index Message-ID: <20061102071753.A25A59CA6C@emu.freenetproject.org> Author: jflesch Date: 2006-11-02 07:17:51 +0000 (Thu, 02 Nov 2006) New Revision: 10794 Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java Log: Re-fix possible freeze Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-11-02 00:00:58 UTC (rev 10793) +++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-11-02 07:17:51 UTC (rev 10794) @@ -1070,7 +1070,7 @@ } } - public synchronized void loadLinks(Element rootEl) { + public void loadLinks(Element rootEl) { this.purgeLinkList(); Element links = (Element)rootEl.getElementsByTagName("indexes").item(0); @@ -1087,7 +1087,7 @@ } - public synchronized void loadFileList(Element rootEl) { + public void loadFileList(Element rootEl) { this.purgeFileList(); Element filesEl = (Element)rootEl.getElementsByTagName("files").item(0); From jflesch at freenetproject.org Thu Nov 2 22:03:34 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 2 Nov 2006 22:03:34 +0000 (UTC) Subject: [Thaw-dev] r10798 - in trunk/apps/Thaw/src/thaw: core plugins/index Message-ID: <20061102220334.B19DB20AFAC@emu.freenetproject.org> Author: jflesch Date: 2006-11-02 22:02:57 +0000 (Thu, 02 Nov 2006) New Revision: 10798 Modified: trunk/apps/Thaw/src/thaw/core/Logger.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/LinkTable.java Log: Fix index refreshing Modified: trunk/apps/Thaw/src/thaw/core/Logger.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/Logger.java 2006-11-02 18:50:28 UTC (rev 10797) +++ trunk/apps/Thaw/src/thaw/core/Logger.java 2006-11-02 22:02:57 UTC (rev 10798) @@ -20,7 +20,7 @@ * * 2 or more is recommanded. */ - public final static int LOG_LEVEL = 2; + public final static int LOG_LEVEL = 3; private static Vector logListeners = null; Modified: trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java 2006-11-02 18:50:28 UTC (rev 10797) +++ trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java 2006-11-02 22:02:57 UTC (rev 10798) @@ -339,14 +339,6 @@ this.files = this.fileList.getFileList(); } - if(this.files != null) { - for(Iterator it = this.files.iterator(); - it.hasNext(); ) { - thaw.plugins.index.File file = (thaw.plugins.index.File)it.next(); - } - - } - this.refresh(); } @@ -366,6 +358,9 @@ } public Object getValueAt(int row, int column) { + if (row >= this.files.size()) + return null; + thaw.plugins.index.File file = (thaw.plugins.index.File)this.files.get(row); if(column == 0) Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-11-02 18:50:28 UTC (rev 10797) +++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-11-02 22:02:57 UTC (rev 10798) @@ -364,6 +364,9 @@ clientGet.start(queueManager); loadXML(clientGet.getInputStream()); save(); + + setChanged(); + notifyObservers(); } } @@ -430,6 +433,7 @@ public void purgeLinkList() { + unloadLinks(); try { Connection c = this.db.getConnection(); PreparedStatement st = c.prepareStatement("DELETE FROM links WHERE indexParent = ?"); @@ -442,6 +446,7 @@ } public void purgeFileList() { + unloadFiles(); try { Connection c = this.db.getConnection(); PreparedStatement st = c.prepareStatement("DELETE FROM files WHERE indexParent = ?"); @@ -611,10 +616,6 @@ ////// FILE LIST //////// public void loadFiles(String columnToSort, boolean asc) { - if(this.fileList != null) { - Logger.notice(this, "Files already loaded, won't reload them"); - return; - } this.fileList = new Vector(); @@ -695,17 +696,6 @@ public void unloadFiles() { - /* - for(Iterator it = fileList.iterator(); - it.hasNext(); ) { - thaw.plugins.index.File file = (thaw.plugins.index.File)it.next(); - if(file.getTransfer() != null && !file.getTransfer().isFinished()) { - Logger.info(this, "Transfer still runinng. No unloading"); - return; - } - } - */ - if (this.fileList != null) { for (Iterator it = this.fileList.iterator(); it.hasNext();) @@ -780,8 +770,9 @@ link.insert(); this.addLinkToList(link); - this.setChanged(); - this.notifyObservers(link); + + setChanged(); + notifyObservers(link); } else Logger.notice(this, "Link already in the database for this index"); @@ -818,11 +809,6 @@ public void loadLinks(String columnToSort, boolean asc) { - if(this.linkList != null) { - Logger.notice(this, "Links aleady loaded, won't reload ..."); - return; - } - this.linkList = new Vector(); try { @@ -857,6 +843,9 @@ Logger.error(this, "Unable to get the link list for index: '"+this.toString()+"' because: "+e.toString()); } + setChanged(); + notifyObservers(); + } /* Returns a copy ! */ @@ -1085,6 +1074,8 @@ } } + setChanged(); + notifyObservers(); } public void loadFileList(Element rootEl) { Modified: trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java 2006-11-02 18:50:28 UTC (rev 10797) +++ trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java 2006-11-02 22:02:57 UTC (rev 10798) @@ -218,14 +218,6 @@ this.links = this.linkList.getLinkList(); } - if(this.links != null) { - for(Iterator it = this.links.iterator(); - it.hasNext(); ) { - thaw.plugins.index.Link link = (thaw.plugins.index.Link)it.next(); - //link.addObserver(this); - } - } - this.refresh(); } From jflesch at freenetproject.org Sat Nov 4 18:00:40 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sat, 4 Nov 2006 18:00:40 +0000 (UTC) Subject: [Thaw-dev] r10816 - in trunk/apps/Thaw/src/thaw: fcp plugins/index Message-ID: <20061104180040.DB7719CA53@emu.freenetproject.org> Author: jflesch Date: 2006-11-04 18:00:36 +0000 (Sat, 04 Nov 2006) New Revision: 10816 Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java trunk/apps/Thaw/src/thaw/plugins/index/Index.java Log: Use a temporary file when fetching an Index, to avoid issues with PipedStream + XML parser Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2006-11-04 16:10:00 UTC (rev 10815) +++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2006-11-04 18:00:36 UTC (rev 10816) @@ -2,8 +2,6 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.util.Observer; @@ -31,6 +29,7 @@ private int persistence = 0; private boolean globalQueue = false; private String destinationDir = null; + private String finalPath = null; private int attempt = -1; private String status; @@ -49,9 +48,7 @@ private boolean alreadySaved = false; - private PipedOutputStream pipedOutputStream = new PipedOutputStream(); - /** * See setParameters(). */ @@ -75,7 +72,7 @@ /** * Used to resume query from persistent queue of the node. * Think of adding this FCPClientGet as a queryManager observer. - * @param destinationDir if null, then you are expected to use the streams (see getInputStream()) + * @param destinationDir if null, then a temporary file will be create (path determined only when the file is availabed ; this file will be deleted on jvm exit) */ public FCPClientGet(String id, String key, int priority, int persistence, boolean globalQueue, @@ -114,7 +111,7 @@ /** * Only for initial queries : To resume queries, use FCPClientGet(FCPQueueManager, Hashmap). - * @param destinationDir if null, you're expected to use the streams + * @param destinationDir if null => temporary file * @param persistence 0 = Forever ; 1 = Until node reboot ; 2 = Until the app disconnect */ public FCPClientGet(String key, int priority, @@ -597,23 +594,28 @@ if (file != null) { newFile = new File(file); + } else { + try { + Logger.info(this, "Using temporary file"); + newFile = File.createTempFile("thaw_", ".tmp"); + finalPath = newFile.getPath(); + newFile.deleteOnExit(); + } catch(java.io.IOException e) { + Logger.error(this, "Error while creating temporary file: "+e.toString()); + } } if(reallyWrite) { Logger.info(this, "Getting file from node ... "); - if (newFile != null) { - try { - outputStream = new FileOutputStream(newFile); - } catch(java.io.IOException e) { - Logger.error(this, "Unable to write file on disk ... disk space / perms ? : "+e.toString()); - this.status = "Write error"; - return false; - } - } else { - Logger.info(this, "Use PipedOutputStream"); - outputStream = pipedOutputStream; + try { + outputStream = new FileOutputStream(newFile); + } catch(java.io.IOException e) { + Logger.error(this, "Unable to write file on disk ... disk space / perms ? : "+e.toString()); + this.status = "Write error"; + return false; } + } else { Logger.info(this, "File is supposed already written. Not rewriting."); } @@ -690,17 +692,7 @@ } - public InputStream getInputStream() { - try { - return new PipedInputStream(pipedOutputStream); - } catch(java.io.IOException e) { - Logger.error(this, "Error while instanciating PipedInputStream: "+e.toString()); - return null; - } - } - - public boolean removeRequest() { FCPMessage stopMessage = new FCPMessage(); @@ -840,6 +832,9 @@ } public String getPath() { + if (finalPath != null) + return finalPath; + if(this.destinationDir != null) return this.destinationDir + File.separator + this.filename; Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-11-04 16:10:00 UTC (rev 10815) +++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-11-04 18:00:36 UTC (rev 10816) @@ -22,12 +22,10 @@ import org.w3c.dom.NodeList; import java.io.OutputStream; -import java.io.PipedOutputStream; import java.io.InputStream; -import java.io.PipedInputStream; import java.io.FileOutputStream; +import java.io.FileInputStream; - import thaw.fcp.*; import thaw.plugins.Hsqldb; import thaw.core.*; @@ -64,6 +62,7 @@ private boolean rewriteKey = true; + private boolean xmlParserReady = false; private FCPClientPut publicKeyRecalculation = null; @@ -281,7 +280,7 @@ this.revision++; - clientPut = new FCPClientPut(this.targetFile, 2, this.revision, this.toString(), this.privateKey, 2, false, 0); + clientPut = new FCPClientPut(this.targetFile, 2, this.revision, this.toString(), this.privateKey, 2, true, 0); this.transfer = clientPut; clientPut.addObserver(this); @@ -334,8 +333,13 @@ clientGet.addObserver(this); - Thread downloadAndParse = new Thread(new DownloadAndParse(clientGet, rewriteKey)); - downloadAndParse.start(); + /* + * These requests are usually quite fast, and don't consume a lot + * of bandwith / CPU. So we can skip the queue and start immediatly + * (and like this, they won't appear in the queue) + */ + //this.queueManager.addQueryToThePendingQueue(clientGet); + clientGet.start(queueManager); this.setChanged(); this.notifyObservers(); @@ -346,31 +350,6 @@ } - private class DownloadAndParse implements Runnable { - FCPClientGet clientGet; - boolean rewriteKey; - - public DownloadAndParse(FCPClientGet clientGet, boolean rewriteKey) { - this.clientGet = clientGet; - } - - public void run() { - /* - * These requests are usually quite fast, and don't consume a lot - * of bandwith / CPU. So we can skip the queue and start immediatly - * (and like this, they won't appear in the queue) - */ - //this.queueManager.addQueryToThePendingQueue(clientGet); - clientGet.start(queueManager); - loadXML(clientGet.getInputStream()); - save(); - - setChanged(); - notifyObservers(); - } - } - - protected void setTransfer(FCPTransferQuery query) { this.transfer = query; @@ -574,6 +553,14 @@ // this.queueManager.remove(this.transfer); this.queueManager.remove(this.transfer); + if (transfer.getPath() == null) { + Logger.error(this, "No path ?!"); + return; + } + + loadXML(transfer.getPath()); + (new java.io.File(transfer.getPath())).delete(); + this.transfer = null; this.setChanged(); @@ -991,7 +978,15 @@ return files; } - public void loadXML(java.io.InputStream input) { + public void loadXML(String filePath) { + try { + loadXML(new FileInputStream(filePath)); + } catch(java.io.FileNotFoundException e) { + Logger.error(this, "Unable to load XML: FileNotFoundException ('"+filePath+"') ! : "+e.toString()); + } + } + + public synchronized void loadXML(java.io.InputStream input) { DocumentBuilderFactory xmlFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder xmlBuilder; @@ -1005,7 +1000,10 @@ Document xmlDoc; try { + Logger.info(this, "XML parser ready"); + xmlParserReady = true; xmlDoc = xmlBuilder.parse(input); + Logger.info(this, "Index parsed"); } catch(org.xml.sax.SAXException e) { Logger.error(this, "Unable to load index because: "+e.toString()); return; From jflesch at freenetproject.org Sat Nov 4 18:17:15 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sat, 4 Nov 2006 18:17:15 +0000 (UTC) Subject: [Thaw-dev] r10817 - in trunk/apps/Thaw/src/thaw: core plugins/index Message-ID: <20061104181715.D5D4A9CA12@emu.freenetproject.org> Author: jflesch Date: 2006-11-04 18:17:12 +0000 (Sat, 04 Nov 2006) New Revision: 10817 Modified: trunk/apps/Thaw/src/thaw/core/Main.java trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java Log: Fix 'reload from freenet copy' option Modified: trunk/apps/Thaw/src/thaw/core/Main.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/Main.java 2006-11-04 18:00:36 UTC (rev 10816) +++ trunk/apps/Thaw/src/thaw/core/Main.java 2006-11-04 18:17:12 UTC (rev 10817) @@ -13,7 +13,7 @@ public class Main { public final static String VERSION="0.6 WIP r at custom@"; - //public final static String VERSION="0.5.9 Beta"; + //public final static String VERSION="0.5.9b Beta"; /** * Look & feel use by GUI front end Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2006-11-04 18:00:36 UTC (rev 10816) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2006-11-04 18:17:12 UTC (rev 10817) @@ -468,7 +468,8 @@ } if (e.getSource() == this.reloadFromFreenet) { - startUpdateFromThisNode(this.selectedNode); + //startUpdateFromThisNode(this.selectedNode); + selectedNode.updateFromFreenet(-1); } if (e.getSource() == this.refreshAll) { From jflesch at freenetproject.org Sat Nov 4 22:37:52 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sat, 4 Nov 2006 22:37:52 +0000 (UTC) Subject: [Thaw-dev] r10818 - in trunk/apps/Thaw: images src/thaw/core src/thaw/i18n src/thaw/plugins src/thaw/plugins/index Message-ID: <20061104223752.C473F9CA4D@emu.freenetproject.org> Author: jflesch Date: 2006-11-04 22:37:44 +0000 (Sat, 04 Nov 2006) New Revision: 10818 Added: trunk/apps/Thaw/images/key.png Modified: trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java trunk/apps/Thaw/src/thaw/core/IconBox.java trunk/apps/Thaw/src/thaw/core/Main.java trunk/apps/Thaw/src/thaw/i18n/thaw.properties 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/IndexEditorPanel.java trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java Log: Add a button to add specific key to an index Added: trunk/apps/Thaw/images/key.png =================================================================== (Binary files differ) Property changes on: trunk/apps/Thaw/images/key.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java 2006-11-04 18:17:12 UTC (rev 10817) +++ trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java 2006-11-04 22:37:44 UTC (rev 10818) @@ -22,6 +22,14 @@ Logger.warning(new FreenetURIHelper(), "UnsupportedEncodingException (UTF-8): "+e.toString()); } + if (uri.indexOf("CHK@") < 0 + && uri.indexOf("USK@") < 0 + && uri.indexOf("KSK@") < 0 + && uri.indexOf("SSK@") < 0) { + Logger.notice(new FreenetURIHelper(), "Not a valid key: "+uri); + return null; + } + return uri; } Modified: trunk/apps/Thaw/src/thaw/core/IconBox.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/IconBox.java 2006-11-04 18:17:12 UTC (rev 10817) +++ trunk/apps/Thaw/src/thaw/core/IconBox.java 2006-11-04 22:37:44 UTC (rev 10818) @@ -59,6 +59,9 @@ public static ImageIcon search; + public static ImageIcon key; + + /** * Not really used */ @@ -126,6 +129,7 @@ quitAction = loadIcon("system-log-out.png"); minQuitAction = loadIcon("min-system-log-out.png"); search = loadIcon("system-search.png"); + key = loadIcon("key.png"); } } Modified: trunk/apps/Thaw/src/thaw/core/Main.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/Main.java 2006-11-04 18:17:12 UTC (rev 10817) +++ trunk/apps/Thaw/src/thaw/core/Main.java 2006-11-04 22:37:44 UTC (rev 10818) @@ -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.9b Beta"; + //public final static String VERSION="0.6 WIP r at custom@"; + public final static String VERSION="0.5.9b Beta"; /** * Look & feel use by GUI front end Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2006-11-04 18:17:12 UTC (rev 10817) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2006-11-04 22:37:44 UTC (rev 10818) @@ -132,7 +132,7 @@ thaw.plugin.priority.p5=Very low thaw.plugin.priority.p6=Will never finish -thaw.plugin.fetch.keyList=Key list (one key per line) +thaw.plugin.fetch.keyList=Key list (one key per line) #?Also used in IndexEditorPanel thaw.plugin.fetch.loadKeyListFromFile=Load keys from file ... thaw.plugin.fetch.destinationDirectory=Destination directory thaw.plugin.fetch.chooseDestination=Choose destination ... @@ -245,3 +245,5 @@ thaw.plugin.index.selectIndex=Select an index or specify the key thaw.plugin.index.gotoIndex=Go to the corresponding index + +thaw.plugin.index.addKeys=Add specific key(s) Modified: trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2006-11-04 18:17:12 UTC (rev 10817) +++ trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2006-11-04 22:37:44 UTC (rev 10818) @@ -110,11 +110,12 @@ String key = FreenetURIHelper.cleanURI(subKey[0]); - this.core.getQueueManager().addQueryToThePendingQueue(new FCPClientGet(key, - priority, - persistence, - globalQueue, -1, - destination)); + if (key != null) + this.core.getQueueManager().addQueryToThePendingQueue(new FCPClientGet(key, + priority, + persistence, + globalQueue, -1, + destination)); } fetchFrame.setVisible(false); Modified: trunk/apps/Thaw/src/thaw/plugins/index/File.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/File.java 2006-11-04 18:17:12 UTC (rev 10817) +++ trunk/apps/Thaw/src/thaw/plugins/index/File.java 2006-11-04 22:37:44 UTC (rev 10818) @@ -37,6 +37,16 @@ private FCPQueueManager queueManager = null; + + public File(Hsqldb db, String publicKey, Index parent) { + this.db = db; + this.id = -1; + this.publicKey = publicKey; + deduceFilenameFromKey(); + + this.size = 0; + } + /** * @param path Local path * @param transfer Corresponding tranfer (can be null). @@ -402,6 +412,7 @@ if(this.transfer.isFinished() && this.transfer instanceof FCPClientGet) { ((FCPClientGet)this.transfer).deleteObserver(this); + this.size = (new java.io.File(transfer.getPath())).length(); } if(this.transfer.isFinished() && this.transfer.isSuccessful()) { Modified: trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java 2006-11-04 18:17:12 UTC (rev 10817) +++ trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java 2006-11-04 22:37:44 UTC (rev 10818) @@ -366,8 +366,12 @@ if(column == 0) return file.getFilename(); - if(column == 1) - return new Long(file.getSize()); + if(column == 1) { + if (file.getSize() > 0) + return new Long(file.getSize()); + else + return I18n.getMessage("thaw.common.unknown"); + } if(column == 2 && FileTable.this.modifiables) return file.getLocalPath(); Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexEditorPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexEditorPanel.java 2006-11-04 18:17:12 UTC (rev 10817) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexEditorPanel.java 2006-11-04 22:37:44 UTC (rev 10818) @@ -10,7 +10,14 @@ import javax.swing.JFileChooser; +import javax.swing.JOptionPane; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JTextArea; + import java.awt.BorderLayout; +import java.awt.GridLayout; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; @@ -38,6 +45,7 @@ private JToolBar toolBar; private JButton addButton; private JButton insertAndAddButton; + private JButton addKeyButton; private JButton linkButton; private FileList fileList = null; /* Index or SearchResult object */ @@ -61,19 +69,23 @@ this.addButton.setToolTipText(I18n.getMessage("thaw.plugin.index.addFilesWithoutInserting")); this.insertAndAddButton = new JButton(IconBox.insertAndAddToIndexAction); this.insertAndAddButton.setToolTipText(I18n.getMessage("thaw.plugin.index.addFilesWithInserting")); + this.addKeyButton = new JButton(IconBox.key); + this.addKeyButton.setToolTipText(I18n.getMessage("thaw.plugin.index.addKeys")); this.linkButton = new JButton(IconBox.makeALinkAction); this.linkButton.setToolTipText(I18n.getMessage("thaw.plugin.index.addLink")); this.addButton.addActionListener(this); this.insertAndAddButton.addActionListener(this); this.linkButton.addActionListener(this); + this.addKeyButton.addActionListener(this); this.buttonsEnabled(false); - this.toolBar.add(this.insertAndAddButton); - this.toolBar.add(this.addButton); + this.toolBar.add(insertAndAddButton); + this.toolBar.add(addButton); + this.toolBar.add(addKeyButton); this.toolBar.addSeparator(); - this.toolBar.add(this.linkButton); + this.toolBar.add(linkButton); this.tables = new Tables(true, db, queueManager, this.indexTree, config); this.fileDetails = new FileDetailsEditor(true); @@ -113,6 +125,7 @@ this.addButton.setEnabled(a); this.insertAndAddButton.setEnabled(a); this.linkButton.setEnabled(a); + this.addKeyButton.setEnabled(a); } protected void setList(FileAndLinkList l) { @@ -169,6 +182,14 @@ linkMakerThread.start(); } + if (e.getSource() == this.addKeyButton) { + if (fileList instanceof Index) { + Thread keyAdder = new Thread(new KeyAdder((Index)fileList)); + keyAdder.start(); + } else + Logger.warning(this, "Not in an index ?!"); + } + if(e.getSource() == this.addButton || e.getSource() == this.insertAndAddButton) { FileChooser fileChooser = new FileChooser(); @@ -220,8 +241,66 @@ } } + private class KeyAdder implements Runnable, ActionListener { + JFrame frame = null; + JLabel header = null; + JTextArea textArea = null; + JPanel buttonPanel = null; + JButton cancelButton = null; + JButton okButton = null; - public class LinkMaker implements Runnable { + Index parent; + + public KeyAdder(Index parent) { + this.parent = parent; + } + + public void run() { + frame = new JFrame(I18n.getMessage("thaw.plugins.insert.addKeys")); + frame.setVisible(false); + + header = new JLabel(I18n.getMessage("thaw.plugin.fetch.keyList")); + textArea = new JTextArea(); + buttonPanel = new JPanel(); + cancelButton = new JButton(I18n.getMessage("thaw.common.cancel")); + okButton = new JButton(I18n.getMessage("thaw.common.ok")); + + cancelButton.addActionListener(this); + okButton.addActionListener(this); + + frame.getContentPane().setLayout(new BorderLayout()); + frame.getContentPane().add(header, BorderLayout.NORTH); + frame.getContentPane().add(textArea, BorderLayout.CENTER); + + buttonPanel.setLayout(new GridLayout(1, 2)); + buttonPanel.add(okButton); + buttonPanel.add(cancelButton); + + frame.getContentPane().add(buttonPanel, BorderLayout.SOUTH); + + frame.setSize(500, 300); + + frame.setVisible(true); + } + + public void actionPerformed(ActionEvent e) { + frame.setVisible(false); + + String[] keys = textArea.getText().split("\n"); + + for (int i = 0 ; i < keys.length ; i++) { + String key = FreenetURIHelper.cleanURI(keys[i]); + + if (key != null) { + thaw.plugins.index.File file = new thaw.plugins.index.File(db, key, parent); + parent.addFile(file); + } + } + + } + } + + private class LinkMaker implements Runnable { public LinkMaker() { } public void run() { Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2006-11-04 18:17:12 UTC (rev 10817) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2006-11-04 22:37:44 UTC (rev 10818) @@ -361,11 +361,11 @@ if(!this.modifiables) { publicKey = this.askAName(I18n.getMessage("thaw.plugin.index.indexKey"), "USK@"); + publicKey = FreenetURIHelper.cleanURI(publicKey); + if (publicKey == null) return; - publicKey = FreenetURIHelper.cleanURI(publicKey); - name = Index.getNameFromKey(publicKey); } else { From jflesch at freenetproject.org Sat Nov 4 22:56:03 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sat, 4 Nov 2006 22:56:03 +0000 (UTC) Subject: [Thaw-dev] r10819 - trunk/apps/Thaw/src/thaw/i18n Message-ID: <20061104225603.6A7FA9CA75@emu.freenetproject.org> Author: jflesch Date: 2006-11-04 22:55:59 +0000 (Sat, 04 Nov 2006) New Revision: 10819 Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties Log: Fix my spelling (french translation) Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2006-11-04 22:37:44 UTC (rev 10818) +++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2006-11-04 22:55:59 UTC (rev 10819) @@ -49,7 +49,7 @@ thaw.common.no=Non thaw.common.priority=Priorit? -thaw.common.clearFinished=Enlever de la liste tout les transferts finis +thaw.common.clearFinished=Enlever de la liste les transferts finis thaw.common.removeFromTheList=Enlever de la liste les transferts s?lectionn?s thaw.common.cancel=Annuler thaw.common.delay=D?lai From jflesch at freenetproject.org Sun Nov 5 02:28:26 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sun, 5 Nov 2006 02:28:26 +0000 (UTC) Subject: [Thaw-dev] r10820 - trunk/apps/Thaw/images Message-ID: <20061105022826.64E939CA46@emu.freenetproject.org> Author: jflesch Date: 2006-11-05 02:28:23 +0000 (Sun, 05 Nov 2006) New Revision: 10820 Modified: trunk/apps/Thaw/images/key.png Log: Change key icon color Modified: trunk/apps/Thaw/images/key.png =================================================================== (Binary files differ) From jflesch at freenetproject.org Sun Nov 5 20:15:48 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sun, 5 Nov 2006 20:15:48 +0000 (UTC) Subject: [Thaw-dev] r10829 - trunk/apps/Thaw/src/thaw/plugins/index Message-ID: <20061105201548.932309CA26@emu.freenetproject.org> Author: jflesch Date: 2006-11-05 20:15:37 +0000 (Sun, 05 Nov 2006) New Revision: 10829 Modified: trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java Log: Do searchs on file names instead of file keys Modified: trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java 2006-11-05 19:37:17 UTC (rev 10828) +++ trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java 2006-11-05 20:15:37 UTC (rev 10829) @@ -34,7 +34,7 @@ this.db = hsqldb; } - protected PreparedStatement makeSearchQuery(String fields, String table, Vector indexIds, String[] searchPatterns, + protected PreparedStatement makeSearchQuery(String fields, String searchField, String table, Vector indexIds, String[] searchPatterns, String columnToSort, boolean asc) throws SQLException { String query = ""; PreparedStatement st; @@ -56,7 +56,7 @@ query = query + "(TRUE"; for (int i = 0 ; i < searchPatterns.length; i++) { - query = query + " AND LOWER(publicKey) LIKE ?"; + query = query + " AND LOWER("+searchField+") LIKE ?"; } query = query +")"; @@ -98,7 +98,7 @@ this.fileList = new Vector(); try { - PreparedStatement st = this.makeSearchQuery("id, filename, publicKey, localPath, mime, size, category, indexParent", + PreparedStatement st = this.makeSearchQuery("id, filename, publicKey, localPath, mime, size, category, indexParent", "filename", "files", this.indexIds, this.search, columnToSort, asc); if (st.execute()) { ResultSet results = st.getResultSet(); @@ -111,7 +111,7 @@ } } } catch(SQLException e) { - Logger.warning(this, "Exception while searching: "+e.toString()); + Logger.error(this, "Exception while searching: "+e.toString()); } this.setChanged(); @@ -126,7 +126,7 @@ this.linkList = new Vector(); try { - PreparedStatement st = this.makeSearchQuery("id, publicKey, mark, comment, indexTarget, indexParent", + PreparedStatement st = this.makeSearchQuery("id, publicKey, mark, comment, indexTarget, indexParent", "publicKey", "links", this.indexIds, this.search, columnToSort, asc); if (st.execute()) { ResultSet results = st.getResultSet(); @@ -137,7 +137,7 @@ } } } catch(SQLException e) { - Logger.warning(this, "Exception while searching: "+e.toString()); + Logger.error(this, "Exception while searching: "+e.toString()); } this.setChanged(); From jflesch at freenetproject.org Sun Nov 5 20:30:47 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sun, 5 Nov 2006 20:30:47 +0000 (UTC) Subject: [Thaw-dev] r10830 - trunk/apps/Thaw/src/thaw/plugins/index Message-ID: <20061105203047.D9DA49CA33@emu.freenetproject.org> Author: jflesch Date: 2006-11-05 20:30:44 +0000 (Sun, 05 Nov 2006) New Revision: 10830 Modified: 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/Tables.java Log: Change default link list size Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java 2006-11-05 20:15:37 UTC (rev 10829) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java 2006-11-05 20:30:44 UTC (rev 10830) @@ -54,9 +54,10 @@ } public void restoreState() { - if (this.config.getValue("indexBrowserPanelSplitPosition") != null) - this.split.setDividerLocation(Integer.parseInt(this.config.getValue("indexBrowserPanelSplitPosition"))); - this.tables.restoreState(); + if (config.getValue("indexBrowserPanelSplitPosition") != null) + split.setDividerLocation(Integer.parseInt(this.config.getValue("indexBrowserPanelSplitPosition"))); + + tables.restoreState(); } public JSplitPane getPanel() { Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexEditorPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexEditorPanel.java 2006-11-05 20:15:37 UTC (rev 10829) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexEditorPanel.java 2006-11-05 20:30:44 UTC (rev 10830) @@ -106,9 +106,10 @@ } public void restoreState() { - if (this.config.getValue("indexEditorPanelSplitPosition") != null) - this.split.setDividerLocation(Integer.parseInt(this.config.getValue("indexEditorPanelSplitPosition"))); - this.tables.restoreState(); + if (config.getValue("indexEditorPanelSplitPosition") != null) + split.setDividerLocation(Integer.parseInt(this.config.getValue("indexEditorPanelSplitPosition"))); + + tables.restoreState(); } public JSplitPane getPanel() { Modified: trunk/apps/Thaw/src/thaw/plugins/index/Tables.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Tables.java 2006-11-05 20:15:37 UTC (rev 10829) +++ trunk/apps/Thaw/src/thaw/plugins/index/Tables.java 2006-11-05 20:30:44 UTC (rev 10830) @@ -46,8 +46,10 @@ } public void restoreState() { - if (this.config.getValue("indexFileLinkSplit") != null) - this.split.setDividerLocation(Integer.parseInt(this.config.getValue("indexFileLinkSplit"))); + if (config.getValue("indexFileLinkSplit") != null) + split.setDividerLocation(Integer.parseInt(this.config.getValue("indexFileLinkSplit"))); + else + split.setDividerLocation(100); } public void saveState() { From nextgens at freenetproject.org Sun Nov 19 18:19:20 2006 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Sun, 19 Nov 2006 18:19:20 +0000 (UTC) Subject: [Thaw-dev] r11013 - trunk/apps/Thaw/src/thaw/i18n Message-ID: <20061119181920.9E74C20B0C2@emu.freenetproject.org> Author: nextgens Date: 2006-11-19 18:19:19 +0000 (Sun, 19 Nov 2006) New Revision: 11013 Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties Log: Thaw: improve the wording as suggested on frost Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2006-11-19 18:14:53 UTC (rev 11012) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2006-11-19 18:19:19 UTC (rev 11013) @@ -51,8 +51,8 @@ thaw.common.no=No thaw.common.priority=Priority -thaw.common.clearFinished=Remove from the list all the finished transfers -thaw.common.removeFromTheList=Remove from the list selected transfers +thaw.common.clearFinished=Remove all the finished transfers from the list +thaw.common.removeFromTheList=Remove all the selected transfers from the list thaw.common.cancel=Cancel thaw.common.delay=Delay thaw.common.copyKeysToClipboard=Copy keys to clipboard From jflesch at freenetproject.org Wed Nov 29 22:51:50 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Wed, 29 Nov 2006 22:51:50 +0000 (UTC) Subject: [Thaw-dev] r11123 - in trunk/apps/Thaw/src/thaw/plugins: . index Message-ID: <20061129225150.424B89CAEB@emu.freenetproject.org> Author: jflesch Date: 2006-11-29 22:51:47 +0000 (Wed, 29 Nov 2006) New Revision: 11123 Modified: trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java Log: Add some ugly icons in the toolbar (will be changed) Modified: trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java 2006-11-29 22:19:49 UTC (rev 11122) +++ trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java 2006-11-29 22:51:47 UTC (rev 11123) @@ -1,10 +1,14 @@ package thaw.plugins; +import javax.swing.JButton; +import javax.swing.event.ChangeListener; +import javax.swing.event.ChangeEvent; + import thaw.core.*; import thaw.plugins.index.*; -public class IndexBrowser implements Plugin { +public class IndexBrowser extends ToolbarModifier implements Plugin, ChangeListener { private Core core; private Hsqldb hsqldb; @@ -27,20 +31,47 @@ } } - this.hsqldb = (Hsqldb)core.getPluginManager().getPlugin("thaw.plugins.Hsqldb"); + hsqldb = (Hsqldb)core.getPluginManager().getPlugin("thaw.plugins.Hsqldb"); - this.hsqldb.registerChild(this); + hsqldb.registerChild(this); - TableCreator.createTables(this.hsqldb); + TableCreator.createTables(hsqldb); - this.browserPanel = new IndexBrowserPanel(this.hsqldb, core.getQueueManager(), core.getConfig()); + browserPanel = new IndexBrowserPanel(hsqldb, core.getQueueManager(), core.getConfig()); + setMainWindow(core.getMainWindow()); + core.getMainWindow().getTabbedPane().addChangeListener(this); + core.getMainWindow().addTab(I18n.getMessage("thaw.plugin.index.indexes"), IconBox.minIndexBrowser, - this.browserPanel.getPanel()); + browserPanel.getPanel()); - this.browserPanel.restoreState(); + browserPanel.restoreState(); + JButton button; + IndexManagementHelper.IndexAction action; + + button = new JButton(IconBox.refreshAction); + button.setToolTipText(I18n.getMessage("thaw.plugin.index.downloadIndexes")); + action = new IndexManagementHelper.IndexDownloader(button); + action.setTarget(browserPanel.getIndexTree().getRoot()); /* TODO : Listen to tree to only refresh the selected node */ + addButtonToTheToolbar(button); + + button = new JButton(IconBox.indexReuse); + button.setToolTipText(I18n.getMessage("thaw.plugin.index.addAlreadyExistingIndex")); + action = new IndexManagementHelper.IndexReuser(hsqldb, core.getQueueManager(), browserPanel.getIndexTree(), button); + action.setTarget(browserPanel.getIndexTree().getRoot()); + addButtonToTheToolbar(button); + + button = new JButton(IconBox.indexNew); + button.setToolTipText(I18n.getMessage("thaw.plugin.index.createIndex")); + action = new IndexManagementHelper.IndexCreator(hsqldb, core.getQueueManager(), browserPanel.getIndexTree(), button); + action.setTarget(browserPanel.getIndexTree().getRoot()); + addButtonToTheToolbar(button); + + + stateChanged(null); + return true; } @@ -60,4 +91,25 @@ } + /** + * Called when the JTabbedPane changed (ie change in the selected tab, etc) + * @param e can be null. + */ + public void stateChanged(ChangeEvent e) { + int tabId; + + tabId = core.getMainWindow().getTabbedPane().indexOfTab(I18n.getMessage("thaw.plugin.index.indexes")); + + if (tabId < 0) { + Logger.warning(this, "Unable to find the tab !"); + return; + } + + if (core.getMainWindow().getTabbedPane().getSelectedIndex() == tabId) { + displayButtonsInTheToolbar(); + } else { + hideButtonsInTheToolbar(); + } + } + } Modified: trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-11-29 22:19:49 UTC (rev 11122) +++ trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-11-29 22:51:47 UTC (rev 11123) @@ -87,11 +87,10 @@ } setMainWindow(core.getMainWindow()); - + core.getMainWindow().getTabbedPane().addChangeListener(this); core.getMainWindow().addTab(I18n.getMessage("thaw.common.status"), IconBox.minQueue, this.panelAdded); - core.getMainWindow().getTabbedPane().addChangeListener(this); this.dnd = new DragAndDropManager(core, this.queuePanels); Modified: trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java 2006-11-29 22:19:49 UTC (rev 11122) +++ trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java 2006-11-29 22:51:47 UTC (rev 11123) @@ -60,8 +60,10 @@ public void hideButtonsInTheToolbar() { if (mainWindow != null) { - mainWindow.changeButtonsInTheToolbar(this, null); - areDisplayed = false; + if (areDisplayed) { + mainWindow.changeButtonsInTheToolbar(this, null); + areDisplayed = false; + } } else Logger.error(this, "MainWindow not SET !"); } Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java 2006-11-29 22:19:49 UTC (rev 11122) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java 2006-11-29 22:51:47 UTC (rev 11123) @@ -58,6 +58,14 @@ tables.restoreState(); } + public Tables getTables() { + return tables; + } + + public IndexTree getIndexTree() { + return indexTree; + } + public JSplitPane getPanel() { return this.split; } From jflesch at freenetproject.org Thu Nov 30 07:08:04 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 30 Nov 2006 07:08:04 +0000 (UTC) Subject: [Thaw-dev] r11133 - trunk/apps/Thaw/src/thaw/plugins/index Message-ID: <20061130070804.7BDFC9CAA6@emu.freenetproject.org> Author: jflesch Date: 2006-11-30 07:08:01 +0000 (Thu, 30 Nov 2006) New Revision: 11133 Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java Log: Fix index adding Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2006-11-30 02:36:03 UTC (rev 11132) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2006-11-30 07:08:01 UTC (rev 11133) @@ -261,6 +261,12 @@ else keys[1] = null; + if (keys[0].equals("USK@")) + return null; + + if (keys[1].equals("SSK@")) + keys[1] = null; + return keys; } @@ -307,6 +313,9 @@ publicKey = FreenetURIHelper.cleanURI(publicKey); privateKey = FreenetURIHelper.cleanURI(privateKey); + if (publicKey == null) + return; + String name = Index.getNameFromKey(publicKey); IndexCategory parent; From jflesch at freenetproject.org Thu Nov 30 07:11:40 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 30 Nov 2006 07:11:40 +0000 (UTC) Subject: [Thaw-dev] r11134 - trunk/apps/Thaw/src/thaw/i18n Message-ID: <20061130071140.2A3E69CAA6@emu.freenetproject.org> Author: jflesch Date: 2006-11-30 07:11:28 +0000 (Thu, 30 Nov 2006) New Revision: 11134 Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties Log: Fix text for JLabel just before the search field Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2006-11-30 07:08:01 UTC (rev 11133) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2006-11-30 07:11:28 UTC (rev 11134) @@ -233,7 +233,7 @@ thaw.plugin.index.indexKey=Index key: thaw.plugin.index.indexPrivateKey=Index private key: -thaw.plugin.index.search.label=Search: +thaw.plugin.index.search.label=Search in the selected folder or index: thaw.plugin.index.search.apply=Search thaw.plugin.index.addFilesWithInserting=Insert file(s) on Freenet and add them to this index Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2006-11-30 07:08:01 UTC (rev 11133) +++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2006-11-30 07:11:28 UTC (rev 11134) @@ -214,7 +214,7 @@ thaw.plugin.index.indexKey=Cl? de l'index: -thaw.plugin.index.search.label=Rechercher dans ce r?pertoire / index +thaw.plugin.index.search.label=Rechercher dans le r?pertoire ou l'index selectionn?: thaw.plugin.index.search.apply=Rechercher thaw.plugin.index.addFilesWithInserting=Ins?rer des fichier(s) sur Freenet et les ajouter ? cet index From jflesch at freenetproject.org Thu Nov 30 20:01:28 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 30 Nov 2006 20:01:28 +0000 (UTC) Subject: [Thaw-dev] r11145 - in trunk/apps/Thaw/src/thaw: core plugins Message-ID: <20061130200128.6BC5A9CAF2@emu.freenetproject.org> Author: jflesch Date: 2006-11-30 20:01:25 +0000 (Thu, 30 Nov 2006) New Revision: 11145 Modified: trunk/apps/Thaw/src/thaw/core/MainWindow.java trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java Log: Use a JSplitPane to split downloads / uploads in the transfer queue tab Modified: trunk/apps/Thaw/src/thaw/core/MainWindow.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/MainWindow.java 2006-11-30 19:46:12 UTC (rev 11144) +++ trunk/apps/Thaw/src/thaw/core/MainWindow.java 2006-11-30 20:01:25 UTC (rev 11145) @@ -49,6 +49,9 @@ public class MainWindow implements java.awt.event.ActionListener, java.awt.event.WindowListener, java.util.Observer { + public final static int DEFAULT_SIZE_X = 790; + public final static int DEFAULT_SIZE_Y = 550; + private JFrame mainWindow = null; private JMenuBar menuBar = null; @@ -162,7 +165,7 @@ this.mainWindow.getContentPane().add(this.tabbedPane, BorderLayout.CENTER); this.mainWindow.getContentPane().add(this.statusBar, BorderLayout.SOUTH); - this.mainWindow.setSize(790, 550); + this.mainWindow.setSize(DEFAULT_SIZE_X, DEFAULT_SIZE_Y); this.mainWindow.addWindowListener(this); Modified: trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-11-30 19:46:12 UTC (rev 11144) +++ trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-11-30 20:01:25 UTC (rev 11145) @@ -26,7 +26,7 @@ private DetailPanel detailPanel; private DragAndDropManager dnd; - private JPanel panel; + private JSplitPane split; private final static int DIVIDER_LOCATION = 310; private long lastChange = 0; @@ -48,52 +48,54 @@ this.detailPanel = new DetailPanel(core); - this.queuePanels[0] = new QueuePanel(core, this.detailPanel, false); /* download */ - this.queuePanels[1] = new QueuePanel(core, this.detailPanel, true); /* upload */ + queuePanels[0] = new QueuePanel(core, detailPanel, false); /* download */ + queuePanels[1] = new QueuePanel(core, detailPanel, true); /* upload */ - this.panel = new JPanel(); + split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, + queuePanels[0].getPanel(), + queuePanels[1].getPanel()); - GridLayout layout = new GridLayout(2, 1, 10, 10); - this.panel.setLayout(layout); - if(this.queuePanels[0].getPanel() != null) - this.panel.add(this.queuePanels[0].getPanel()); - - if(this.queuePanels[1].getPanel() != null) - this.panel.add(this.queuePanels[1].getPanel()); - this.advancedMode = Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue(); - if(this.advancedMode) { - this.mainPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.detailPanel.getPanel(), this.panel); + if(advancedMode) { + mainPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, detailPanel.getPanel(), split); if(core.getConfig().getValue("detailPanelFolded") == null || ((new Boolean(core.getConfig().getValue("detailPanelFolded"))).booleanValue()) == true) { - this.folded = true; - this.detailPanel.getPanel().setVisible(false); - this.mainPanel.setDividerLocation(1); + folded = true; + detailPanel.getPanel().setVisible(false); + mainPanel.setDividerLocation(1); } else { - this.folded = false; - this.detailPanel.getPanel().setVisible(true); - this.mainPanel.setDividerLocation(DIVIDER_LOCATION); + folded = false; + detailPanel.getPanel().setVisible(true); + mainPanel.setDividerLocation(DIVIDER_LOCATION); } - this.mainPanel.addPropertyChangeListener(this); - this.mainPanel.setOneTouchExpandable(true); + mainPanel.addPropertyChangeListener(this); + mainPanel.setOneTouchExpandable(true); - this.panelAdded = this.mainPanel; + panelAdded = mainPanel; } else { - this.panelAdded = this.panel; + panelAdded = split; } setMainWindow(core.getMainWindow()); core.getMainWindow().getTabbedPane().addChangeListener(this); core.getMainWindow().addTab(I18n.getMessage("thaw.common.status"), IconBox.minQueue, - this.panelAdded); + panelAdded); - this.dnd = new DragAndDropManager(core, this.queuePanels); + if (core.getConfig().getValue("queuePanelSplitLocation") == null) { + split.setDividerLocation((MainWindow.DEFAULT_SIZE_Y - 150)/2); /* approximation */ + } else { + split.setDividerLocation(Integer.parseInt(core.getConfig().getValue("queuePanelSplitLocation"))); + } + split.setResizeWeight(0.5); + + dnd = new DragAndDropManager(core, queuePanels); + stateChanged(null); return true; @@ -103,8 +105,10 @@ public boolean stop() { Logger.info(this, "Stopping plugin \"QueueWatcher\" ..."); + core.getConfig().setValue("queuePanelSplitLocation", + Integer.toString(split.getDividerLocation())); + this.core.getConfig().setValue("detailPanelFolded", ((new Boolean(this.folded)).toString())); - this.core.getMainWindow().removeTab(this.panelAdded); return true; From jflesch at freenetproject.org Thu Nov 30 20:42:14 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 30 Nov 2006 20:42:14 +0000 (UTC) Subject: [Thaw-dev] r11147 - trunk/apps/Thaw/src/thaw/plugins Message-ID: <20061130204214.580A99BCE4@emu.freenetproject.org> Author: jflesch Date: 2006-11-30 20:42:12 +0000 (Thu, 30 Nov 2006) New Revision: 11147 Modified: trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java Log: Fix splitpane behavior Modified: trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-11-30 20:34:40 UTC (rev 11146) +++ trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-11-30 20:42:12 UTC (rev 11147) @@ -80,16 +80,21 @@ panelAdded = split; } + split.setSize(MainWindow.DEFAULT_SIZE_X - 150, MainWindow.DEFAULT_SIZE_Y - 150); + split.setResizeWeight(0.5); + setMainWindow(core.getMainWindow()); core.getMainWindow().getTabbedPane().addChangeListener(this); core.getMainWindow().addTab(I18n.getMessage("thaw.common.status"), IconBox.minQueue, panelAdded); + split.setResizeWeight(0.5); + if (core.getConfig().getValue("queuePanelSplitLocation") == null) { - split.setDividerLocation((MainWindow.DEFAULT_SIZE_Y - 150)/2); /* approximation */ + split.setDividerLocation(((double)0.5)); } else { - split.setDividerLocation(Integer.parseInt(core.getConfig().getValue("queuePanelSplitLocation"))); + split.setDividerLocation(Double.parseDouble(core.getConfig().getValue("queuePanelSplitLocation"))); } split.setResizeWeight(0.5); @@ -105,8 +110,12 @@ public boolean stop() { Logger.info(this, "Stopping plugin \"QueueWatcher\" ..."); + double splitLocation; + + splitLocation = ((double)split.getDividerLocation() - ((double)split.getMinimumDividerLocation())) / (((double)split.getMaximumDividerLocation()) - ((double)split.getMinimumDividerLocation())); + core.getConfig().setValue("queuePanelSplitLocation", - Integer.toString(split.getDividerLocation())); + Double.toString(splitLocation)); this.core.getConfig().setValue("detailPanelFolded", ((new Boolean(this.folded)).toString())); this.core.getMainWindow().removeTab(this.panelAdded); From jflesch at freenetproject.org Thu Nov 30 21:13:04 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 30 Nov 2006 21:13:04 +0000 (UTC) Subject: [Thaw-dev] r11149 - in trunk/apps/Thaw/src/thaw/plugins: . index Message-ID: <20061130211304.2BC319BD09@emu.freenetproject.org> Author: jflesch Date: 2006-11-30 21:13:01 +0000 (Thu, 30 Nov 2006) New Revision: 11149 Modified: trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java trunk/apps/Thaw/src/thaw/plugins/index/Index.java trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java Log: Bug https://bugs.freenetproject.org/view.php?id=914 should be fixed Modified: trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-11-30 20:53:09 UTC (rev 11148) +++ trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-11-30 21:13:01 UTC (rev 11149) @@ -80,7 +80,7 @@ panelAdded = split; } - split.setSize(MainWindow.DEFAULT_SIZE_X - 150, MainWindow.DEFAULT_SIZE_Y - 150); + split.setSize(MainWindow.DEFAULT_SIZE_X - 150, MainWindow.DEFAULT_SIZE_Y - 150); /* needed to avoid size = 0at the begining */ split.setResizeWeight(0.5); setMainWindow(core.getMainWindow()); Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-11-30 20:53:09 UTC (rev 11148) +++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-11-30 21:13:01 UTC (rev 11149) @@ -65,6 +65,7 @@ private FCPClientPut publicKeyRecalculation = null; + private boolean updateWhenKeyAreAvailable = false; /** * The bigest constructor of the world ... @@ -133,12 +134,12 @@ } public void generateKeys() { - this.publicKey = "N/A"; - this.privateKey = "N/A"; + publicKey = null; + privateKey = null; - this.sskGenerator = new FCPGenerateSSK(); - this.sskGenerator.addObserver(this); - this.sskGenerator.start(queueManager); + sskGenerator = new FCPGenerateSSK(); + sskGenerator.addObserver(this); + sskGenerator.start(queueManager); } public boolean create() { @@ -247,6 +248,15 @@ public void update() { + if (publicKey != null && privateKey == null) /* non modifiable */ + return; + + if (publicKey == null && privateKey == null) { + generateKeys(); + updateWhenKeyAreAvailable = true; + return; + } + String tmpdir = System.getProperty("java.io.tmpdir"); if (tmpdir == null) @@ -348,7 +358,7 @@ } public boolean isUpdating() { - return (this.transfer != null && (!this.transfer.isFinished())); + return (sskGenerator != null || (transfer != null && (!transfer.isFinished()))); } @@ -512,13 +522,18 @@ public void update(java.util.Observable o, Object p) { if(o == this.sskGenerator) { - this.sskGenerator.deleteObserver(this); - this.publicKey = this.sskGenerator.getPublicKey(); - this.privateKey = this.sskGenerator.getPrivateKey(); + sskGenerator.deleteObserver(this); + publicKey = sskGenerator.getPublicKey(); + privateKey = sskGenerator.getPrivateKey(); + sskGenerator = null; - Logger.debug(this, "Index public key: " +this.publicKey); - Logger.debug(this, "Index private key: "+this.privateKey); + Logger.debug(this, "Index public key: " +publicKey); + Logger.debug(this, "Index private key: "+privateKey); + if (updateWhenKeyAreAvailable) { + updateWhenKeyAreAvailable = false; + update(); + } } if(o == this.transfer) { Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2006-11-30 20:53:09 UTC (rev 11148) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2006-11-30 21:13:01 UTC (rev 11149) @@ -205,15 +205,15 @@ indexMenu.add(item); indexAndFileActions.add(new IndexManagementHelper.IndexDeleter(this, item)); + item = new JMenuItem(I18n.getMessage("thaw.plugin.index.copyPrivateKey")); + indexMenu.add(item); + indexAndFileActions.add(new IndexManagementHelper.PrivateKeyCopier(item)); + item = new JMenuItem(I18n.getMessage("thaw.plugin.index.copyKey")); indexMenu.add(item); indexAndFileActions.add(new IndexManagementHelper.PublicKeyCopier(item)); - item = new JMenuItem(I18n.getMessage("thaw.plugin.index.copyPrivateKey")); - indexMenu.add(item); - indexAndFileActions.add(new IndexManagementHelper.PrivateKeyCopier(item)); - // File menu item = new JMenuItem(I18n.getMessage("thaw.plugin.index.addFilesWithInserting")); From jflesch at freenetproject.org Thu Nov 30 21:35:11 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 30 Nov 2006 21:35:11 +0000 (UTC) Subject: [Thaw-dev] r11151 - in trunk/apps/Thaw/src/thaw/plugins: . index Message-ID: <20061130213511.1539E20B239@emu.freenetproject.org> Author: jflesch Date: 2006-11-30 21:35:09 +0000 (Thu, 30 Nov 2006) New Revision: 11151 Modified: trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java Log: By default, index "Thaw" is now added to the tree Modified: trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java 2006-11-30 21:30:17 UTC (rev 11150) +++ trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java 2006-11-30 21:35:09 UTC (rev 11151) @@ -9,6 +9,8 @@ import thaw.plugins.index.*; public class IndexBrowser extends ToolbarModifier implements Plugin, ChangeListener { + public static final String DEFAULT_INDEX = "USK at BXd4EqMSOR589aHNHOY-e2QjI9NHwPlJurKxcvo1hBg,HkrDarIUF79uc9fjGu0S3mbp7Qf8YeMHynKf2GQO3r0,AQABAAE/Thaw/2/Thaw.xml"; + private Core core; private Hsqldb hsqldb; @@ -35,8 +37,16 @@ hsqldb.registerChild(this); - TableCreator.createTables(hsqldb); + boolean newDb; + newDb = false; + + if (core.getConfig().getValue("indexDatabaseVersion") == null) { + TableCreator.createTables(hsqldb); + newDb = true; + core.getConfig().setValue("indexDatabaseVersion", "1"); + } + browserPanel = new IndexBrowserPanel(hsqldb, core.getQueueManager(), core.getConfig()); setMainWindow(core.getMainWindow()); @@ -69,6 +79,10 @@ action.setTarget(browserPanel.getIndexTree().getRoot()); addButtonToTheToolbar(button); + if (newDb) { + IndexManagementHelper.addIndex(hsqldb, core.getQueueManager(), browserPanel.getIndexTree(), + browserPanel.getIndexTree().getRoot(), DEFAULT_INDEX); + } stateChanged(null); Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java 2006-11-30 21:30:17 UTC (rev 11150) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java 2006-11-30 21:35:09 UTC (rev 11151) @@ -234,6 +234,16 @@ return this.id; } + public int getChildNumber() { + if (children == null) + children = loadChildren(); + + if (children == null) + return 0; + + return children.size(); + } + public Vector loadChildren() { Vector children = new Vector(); From jflesch at freenetproject.org Thu Nov 30 22:01:21 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 30 Nov 2006 22:01:21 +0000 (UTC) Subject: [Thaw-dev] r11154 - trunk/apps/Thaw/src/thaw/plugins Message-ID: <20061130220121.80C419CA9F@emu.freenetproject.org> Author: jflesch Date: 2006-11-30 22:01:19 +0000 (Thu, 30 Nov 2006) New Revision: 11154 Modified: trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java Log: Ensure once again that database is written to disk when exit Modified: trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java 2006-11-30 21:59:19 UTC (rev 11153) +++ trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java 2006-11-30 22:01:19 UTC (rev 11154) @@ -54,7 +54,7 @@ Logger.info(this, "Connecting to the database ..."); if(this.core.getConfig().getValue("hsqldb.url") == null) - this.core.getConfig().setValue("hsqldb.url", "jdbc:hsqldb:file:thaw.db"); + this.core.getConfig().setValue("hsqldb.url", "jdbc:hsqldb:file:thaw.db;shutdown=true"); try { this.connect(); From jflesch at freenetproject.org Thu Nov 30 22:42:46 2006 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 30 Nov 2006 22:42:46 +0000 (UTC) Subject: [Thaw-dev] r11156 - in trunk/apps/Thaw/src/thaw/plugins: . queueWatcher Message-ID: <20061130224246.735AE9BCE4@emu.freenetproject.org> Author: jflesch Date: 2006-11-30 22:42:43 +0000 (Thu, 30 Nov 2006) New Revision: 11156 Modified: trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java Log: Replace the two JLabel in the 'state' tab by two buttons Modified: trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2006-11-30 22:24:58 UTC (rev 11155) +++ trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2006-11-30 22:42:43 UTC (rev 11156) @@ -71,9 +71,8 @@ queueWatcher = (QueueWatcher)core.getPluginManager().getPlugin("thaw.plugins.QueueWatcher"); queueWatcher.addButtonToTheToolbar(buttonInToolBar); - - /* WARNING: This menu item can't be remove cleanly ... :/ */ queueWatcher.addMenuItemToTheDownloadTable(menuItem); + queueWatcher.addButtonListener(QueueWatcher.DOWNLOAD_PANEL, this); return true; } Modified: trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java 2006-11-30 22:24:58 UTC (rev 11155) +++ trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java 2006-11-30 22:42:43 UTC (rev 11156) @@ -81,9 +81,8 @@ queueWatcher = (QueueWatcher)core.getPluginManager().getPlugin("thaw.plugins.QueueWatcher"); queueWatcher.addButtonToTheToolbar(buttonInToolBar); - - /* WARNING: This menu item can't be remove cleanly ... :/ */ queueWatcher.addMenuItemToTheInsertionTable(menuItem); + queueWatcher.addButtonListener(QueueWatcher.INSERTION_PANEL, this); return true; } Modified: trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-11-30 22:24:58 UTC (rev 11155) +++ trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-11-30 22:42:43 UTC (rev 11156) @@ -3,12 +3,14 @@ import javax.swing.JPanel; import javax.swing.JSplitPane; import java.awt.GridLayout; +import java.awt.event.ActionListener; import java.util.Vector; import java.util.Iterator; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.ChangeEvent; +import javax.swing.JButton; import thaw.core.*; @@ -22,7 +24,10 @@ //private JPanel mainPanel; private JSplitPane mainPanel; + public final static int DOWNLOAD_PANEL = 0; + public final static int INSERTION_PANEL = 1; private QueuePanel[] queuePanels = new QueuePanel[2]; + private DetailPanel detailPanel; private DragAndDropManager dnd; @@ -48,8 +53,8 @@ this.detailPanel = new DetailPanel(core); - queuePanels[0] = new QueuePanel(core, detailPanel, false); /* download */ - queuePanels[1] = new QueuePanel(core, detailPanel, true); /* upload */ + queuePanels[DOWNLOAD_PANEL] = new QueuePanel(core, detailPanel, false); /* download */ + queuePanels[INSERTION_PANEL] = new QueuePanel(core, detailPanel, true); /* upload */ split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queuePanels[0].getPanel(), @@ -106,7 +111,14 @@ return true; } + /** + * @param panel see DOWNLOAD_PANEL and INSERTION_PANEL + */ + public void addButtonListener(int panel, ActionListener listener) { + queuePanels[panel].getButton().addActionListener(listener); + } + public boolean stop() { Logger.info(this, "Stopping plugin \"QueueWatcher\" ..."); Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java 2006-11-30 22:24:58 UTC (rev 11155) +++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java 2006-11-30 22:42:43 UTC (rev 11156) @@ -3,11 +3,13 @@ import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.JLabel; +import javax.swing.JButton; import javax.swing.JScrollPane; import javax.swing.JProgressBar; import javax.swing.JFileChooser; import javax.swing.SwingConstants; +import java.awt.Dimension; import java.awt.BorderLayout; import java.awt.Component; import java.util.Vector; @@ -43,7 +45,7 @@ public class QueuePanel implements MouseListener, ActionListener, KeyListener { private Core core; - private JLabel label; + private JButton button; private JTable table = null; private JScrollPane scrollPane = null; @@ -92,19 +94,26 @@ header.setReorderingAllowed(true); if(isForInsertionQueue) { - this.label = new JLabel(I18n.getMessage("thaw.common.insertions")); - this.label.setIcon(IconBox.insertions); + button = new JButton(I18n.getMessage("thaw.common.insertions")); + button.setIcon(IconBox.insertions); } else { - this.label = new JLabel(I18n.getMessage("thaw.common.downloads")); - this.label.setIcon(IconBox.downloads); + button = new JButton(I18n.getMessage("thaw.common.downloads")); + button.setIcon(IconBox.downloads); } - this.label.setVerticalAlignment(SwingConstants.CENTER); + button.setVerticalAlignment(SwingConstants.CENTER); + button.setHorizontalAlignment(SwingConstants.LEFT); + button.setPreferredSize(new Dimension(190, 40)); + JPanel buttonPanel = new JPanel(new BorderLayout()); + buttonPanel.add(button, BorderLayout.EAST); + buttonPanel.add(new JLabel(""), BorderLayout.CENTER); + this.panel = new JPanel(); this.panel.setLayout(new BorderLayout()); - this.panel.add(this.label, BorderLayout.NORTH); + this.panel.add(buttonPanel, BorderLayout.NORTH); + this.scrollPane = new JScrollPane(this.table); this.panel.add(this.scrollPane, BorderLayout.CENTER); @@ -180,7 +189,11 @@ rightClickMenu.insert(item, 0); } + public JButton getButton() { + return button; + } + private class ProgressRenderer extends DefaultTableCellRenderer { private final static long serialVersionUID = 20060709;