From jflesch at freenetproject.org Sun Jul 1 21:28:00 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sun, 1 Jul 2007 21:28:00 +0000 (UTC) Subject: [Thaw-dev] r13867 - trunk/apps/Thaw/src/thaw/gui Message-ID: <20070701212800.1111147A08A@emu.freenetproject.org> Author: jflesch Date: 2007-07-01 21:27:59 +0000 (Sun, 01 Jul 2007) New Revision: 13867 Modified: trunk/apps/Thaw/src/thaw/gui/TransferProgressBar.java Log: Specify again when download progression is not reliable Modified: trunk/apps/Thaw/src/thaw/gui/TransferProgressBar.java =================================================================== --- trunk/apps/Thaw/src/thaw/gui/TransferProgressBar.java 2007-07-01 20:51:22 UTC (rev 13866) +++ trunk/apps/Thaw/src/thaw/gui/TransferProgressBar.java 2007-07-01 21:27:59 UTC (rev 13867) @@ -48,16 +48,22 @@ if(query.isFinished() && !query.isSuccessful()) setString(I18n.getMessage("thaw.common.failed")); - - if(query.isFinished() && query.isSuccessful()) + else if(query.isFinished() && query.isSuccessful()) setString(I18n.getMessage("thaw.common.finished")); + else if(!query.isFinished()) { + String txt= ""; - if(!query.isFinished()) { if (statusInProgressBar) - setString(query.getStatus() + + txt = (query.getStatus() + " [ "+Integer.toString(progress)+"% ]"); else - setString(Integer.toString(progress)+"%"); + txt = (Integer.toString(progress)+"%"); + + if (!query.isProgressionReliable()) + txt += " [*]"; + + setString(txt); } + } } From jflesch at freenetproject.org Sun Jul 1 21:42:36 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sun, 1 Jul 2007 21:42:36 +0000 (UTC) Subject: [Thaw-dev] r13868 - in trunk/apps/Thaw/src/thaw: core plugins Message-ID: <20070701214236.DB7274791C0@emu.freenetproject.org> Author: jflesch Date: 2007-07-01 21:42:36 +0000 (Sun, 01 Jul 2007) New Revision: 13868 Modified: trunk/apps/Thaw/src/thaw/core/Core.java trunk/apps/Thaw/src/thaw/core/MainWindow.java trunk/apps/Thaw/src/thaw/plugins/TrayIcon.java Log: Prevent a plugin from making the main window visible again while Thaw is stopping Modified: trunk/apps/Thaw/src/thaw/core/Core.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/Core.java 2007-07-01 21:27:59 UTC (rev 13867) +++ trunk/apps/Thaw/src/thaw/core/Core.java 2007-07-01 21:42:36 UTC (rev 13868) @@ -48,6 +48,8 @@ private static final Random RANDOM = new Yarrow(); + private boolean isStopping = false; + // MDNS stuffs private MDNSDiscovery discovery; @@ -55,6 +57,7 @@ * Creates a core, but do nothing else (no initialization). */ public Core() { + isStopping = false; Logger.info(this, "Thaw, version "+Main.VERSION, true); Logger.info(this, "2006(c) Freenet project", true); Logger.info(this, "Released under GPL license version 2 or later (see http://www.fsf.org/licensing/licenses/gpl.html)", true); @@ -527,6 +530,8 @@ * @see #exit() */ public void exit(boolean force) { + isStopping = true; + if(!force) { if(!canDisconnect()) { if(!askDeconnectionConfirmation()) @@ -708,4 +713,8 @@ return RANDOM; } + + public boolean isStopping() { + return isStopping; + } } Modified: trunk/apps/Thaw/src/thaw/core/MainWindow.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/MainWindow.java 2007-07-01 21:27:59 UTC (rev 13867) +++ trunk/apps/Thaw/src/thaw/core/MainWindow.java 2007-07-01 21:42:36 UTC (rev 13868) @@ -227,7 +227,8 @@ * Make the window visible or not. */ public void setVisible(final boolean v) { - mainWindow.setVisible(v); + if (!v || !core.isStopping()) + mainWindow.setVisible(v); } Modified: trunk/apps/Thaw/src/thaw/plugins/TrayIcon.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/TrayIcon.java 2007-07-01 21:27:59 UTC (rev 13867) +++ trunk/apps/Thaw/src/thaw/plugins/TrayIcon.java 2007-07-01 21:42:36 UTC (rev 13868) @@ -44,6 +44,7 @@ public final static int DIALOG_X = 300; public final static int DIALOG_Y = 500; + public TrayIcon() { } @@ -65,7 +66,7 @@ public boolean stop() { - core.getMainWindow().addWindowListener(this); + core.getMainWindow().removeWindowListener(this); icon.removeMouseListener(this); icon.setVisible(false); From jflesch at freenetproject.org Sun Jul 1 22:50:17 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sun, 1 Jul 2007 22:50:17 +0000 (UTC) Subject: [Thaw-dev] r13869 - in trunk/apps/Thaw/src/thaw: i18n plugins/index Message-ID: <20070701225017.339FA479F7B@emu.freenetproject.org> Author: jflesch Date: 2007-07-01 22:50:16 +0000 (Sun, 01 Jul 2007) New Revision: 13869 Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties trunk/apps/Thaw/src/thaw/i18n/thaw.properties trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java Log: In the index browser : add stats about the indexes (number of files, number of links) Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-01 21:42:36 UTC (rev 13868) +++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-01 22:50:16 UTC (rev 13869) @@ -362,6 +362,9 @@ thaw.plugin.index.warningNonNegative=Attention ! T?l?charger les commentaires sans avoir la derni?re version de l'index peut vous faire t?l?charger des spams ! +thaw.plugin.index.numberOfFiles=Nombre de fichiers : ? +thaw.plugin.index.numberOfLinks=Nombre de liens : ? + # Peer monitor thaw.plugin.peerMonitor.peerMonitor=Connexion Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-01 21:42:36 UTC (rev 13868) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-01 22:50:16 UTC (rev 13869) @@ -371,6 +371,9 @@ thaw.plugin.index.warningNonNegative=Warning ! Downloading comments without having the latest versions of the indexes may result in receiving spams ! +thaw.plugin.index.numberOfFiles=Number of files : ? +thaw.plugin.index.numberOfLinks=Number of links : ? + # Peer monitor thaw.plugin.peerMonitor.peerMonitor=Connection Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-01 21:42:36 UTC (rev 13868) +++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-01 22:50:16 UTC (rev 13869) @@ -362,6 +362,9 @@ thaw.plugin.index.warningNonNegative=Attention ! T\u00e9l\u00e9charger les commentaires sans avoir la derni\u00e8re version de l'index peut vous faire t\u00e9l\u00e9charger des spams ! +thaw.plugin.index.numberOfFiles=Nombre de fichiers : ? +thaw.plugin.index.numberOfLinks=Nombre de liens : ? + # Peer monitor thaw.plugin.peerMonitor.peerMonitor=Connexion Modified: trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java 2007-07-01 21:42:36 UTC (rev 13868) +++ trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java 2007-07-01 22:50:16 UTC (rev 13869) @@ -10,6 +10,8 @@ import java.util.Vector; import java.util.Iterator; +import java.sql.*; + import thaw.core.I18n; import thaw.core.Logger; import thaw.core.Config; @@ -27,19 +29,33 @@ * be used for the comments */ public class DetailPanel { + private IndexBrowserPanel indexBrowser; + private JPanel panel; private JButton viewCommentButton; private Vector buttonActions; + private JLabel nmbFilesLabel; + private JLabel nmbLinksLabel; + public DetailPanel(FCPQueueManager queueManager, IndexBrowserPanel indexBrowser) { + this.indexBrowser = indexBrowser; + + nmbFilesLabel = new JLabel(I18n.getMessage("thaw.plugin.index.numberOfFiles").replaceAll("\\?", "")); + nmbLinksLabel = new JLabel(I18n.getMessage("thaw.plugin.index.numberOfLinks").replaceAll("\\?", "")); + panel = new JPanel(new BorderLayout()); - panel.add(new JLabel(""), BorderLayout.CENTER); /* because we need something */ + JPanel stats = new JPanel(new GridLayout(1, 2)); + stats.add(nmbFilesLabel); + stats.add(nmbLinksLabel); - JPanel buttonPanel = new JPanel(new GridLayout(1, 2)); + panel.add(stats, BorderLayout.CENTER); + + JPanel buttonPanel = new JPanel(new GridLayout(1, 1)); buttonActions = new Vector(2); JButton button; @@ -64,7 +80,8 @@ - public void setIndexTarget(Index l) { + private void setIndexTarget(Index l) { + viewCommentButton.setText(I18n.getMessage("thaw.plugin.index.comment.comments").replaceAll("\\?", l == null ? "0" : Integer.toString(l.getNmbComments()))); @@ -75,5 +92,106 @@ } } + + private void setStats(int nmbFiles, int nmbLinks) { + nmbFilesLabel.setText(I18n.getMessage("thaw.plugin.index.numberOfFiles").replaceAll("\\?", + Integer.toString(nmbFiles))); + nmbLinksLabel.setText(I18n.getMessage("thaw.plugin.index.numberOfLinks").replaceAll("\\?", + Integer.toString(nmbLinks))); + } + + + /* called by IndexBrowserPanel.setList() */ + public void setTarget(FileAndLinkList node) { + if (node instanceof Index) + setIndexTarget((Index)node); + else + setIndexTarget(null); + + int nmbFilesInt = 0; + int nmbLinksInt = 0; + + if (node != null) { + nmbFilesInt = node.getFileList(null, true).size(); + nmbLinksInt = node.getLinkList(null, true).size(); + } + + setStats(nmbFilesInt, nmbLinksInt); + } + + + /* called by IndexTree.valueChanged() */ + public void setTarget(IndexTreeNode node) { + Hsqldb db = indexBrowser.getDb(); + PreparedStatement st; + ResultSet rs; + + int nmbFilesInt = 0; + int nmbLinksInt = 0; + + synchronized(db.dbLock) { + try { + if (node instanceof IndexFolder) { + if (node instanceof IndexRoot) { + st = db.getConnection().prepareStatement("SELECT count(id) from files"); + rs = st.executeQuery(); + rs.next(); + nmbFilesInt = rs.getInt(1); + + st = db.getConnection().prepareStatement("SELECT count(id) from links"); + rs = st.executeQuery(); + rs.next(); + nmbLinksInt = rs.getInt(1); + } else { + st = db.getConnection().prepareStatement("SELECT count(id) "+ + "FROM files WHERE files.indexParent IN "+ + "(SELECT indexParents.indexId "+ + " FROM indexParents "+ + " WHERE indexParents.folderId = ?)"); + + + st.setInt(1, node.getId()); + rs = st.executeQuery(); + rs.next(); + nmbFilesInt = rs.getInt(1); + + + st = db.getConnection().prepareStatement("SELECT count(id) "+ + "FROM links WHERE links.indexParent IN "+ + "(SELECT indexParents.indexId "+ + " FROM indexParents "+ + " WHERE indexParents.folderId = ?)"); + st.setInt(1, node.getId()); + rs = st.executeQuery(); + rs.next(); + nmbLinksInt = rs.getInt(1); + } + + + } else if (node instanceof Index) { + st = db.getConnection().prepareStatement("SELECT count(id) "+ + "FROM files WHERE files.indexParent = ?"); + st.setInt(1, node.getId()); + rs = st.executeQuery(); + rs.next(); + nmbFilesInt = rs.getInt(1); + + + st = db.getConnection().prepareStatement("SELECT count(id) "+ + "FROM links WHERE links.indexParent = ?"); + st.setInt(1, node.getId()); + rs = st.executeQuery(); + rs.next(); + nmbLinksInt = rs.getInt(1); + } + + } catch(SQLException e) { + Logger.error(this, "Exception while counting files/links : "+e.toString()); + } + } + + setStats(nmbFilesInt, nmbLinksInt); + } + } Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java 2007-07-01 21:42:36 UTC (rev 13868) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java 2007-07-01 22:50:16 UTC (rev 13869) @@ -169,11 +169,11 @@ protected void setList(final FileAndLinkList l) { tables.setList(l); + detailPanel.setTarget(l); + if (l instanceof Index) { - detailPanel.setIndexTarget((Index)l); commentTab.setIndex((Index)l); } else { - detailPanel.setIndexTarget(null); commentTab.setIndex(null); } } Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2007-07-01 21:42:36 UTC (rev 13868) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2007-07-01 22:50:16 UTC (rev 13869) @@ -400,6 +400,7 @@ selectedNode = (IndexTreeNode)(path.getLastPathComponent()); + indexBrowser.getDetailPanel().setTarget(selectedNode); // Update toolbar for (final Iterator it = toolbarActions.iterator(); From jflesch at freenetproject.org Sun Jul 1 23:12:56 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sun, 1 Jul 2007 23:12:56 +0000 (UTC) Subject: [Thaw-dev] r13870 - in trunk/apps/Thaw/src/thaw: core i18n Message-ID: <20070701231256.53484400855@emu.freenetproject.org> Author: jflesch Date: 2007-07-01 23:12:55 +0000 (Sun, 01 Jul 2007) New Revision: 13870 Modified: trunk/apps/Thaw/src/thaw/core/Core.java trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties trunk/apps/Thaw/src/thaw/i18n/thaw.properties trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties Log: Let the user select the directory used for temporary files Modified: trunk/apps/Thaw/src/thaw/core/Core.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/Core.java 2007-07-01 22:50:16 UTC (rev 13869) +++ trunk/apps/Thaw/src/thaw/core/Core.java 2007-07-01 23:12:55 UTC (rev 13870) @@ -178,6 +178,9 @@ config.setDefaultValues(); } + if (config.getValue("tmpDir") != null) + System.setProperty("java.io.tmpdir", config.getValue("tmpDir")); + return true; } Modified: trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java 2007-07-01 22:50:16 UTC (rev 13869) +++ trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java 2007-07-01 23:12:55 UTC (rev 13870) @@ -1,18 +1,25 @@ package thaw.core; import java.awt.GridLayout; +import java.awt.BorderLayout; import java.util.Observable; import java.util.Observer; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JButton; import javax.swing.JTextField; +import javax.swing.JTextField; +import thaw.gui.FileChooser; + /** * Creates and manages the panel containing all the things to configure related to Thaw and only Thaw. */ -public class ThawConfigPanel implements Observer { +public class ThawConfigPanel implements Observer, ActionListener { private Core core; private JPanel thawConfigPanel = null; @@ -20,7 +27,10 @@ private boolean advancedMode; + private JTextField tmpDirField; + private JButton tmpDirButton; + public ThawConfigPanel(final ConfigWindow configWindow, final Core core) { this.core = core; @@ -38,6 +48,23 @@ thawConfigPanel.add(advancedModeBox); thawConfigPanel.add(new JLabel(" ")); + tmpDirField = new JTextField(System.getProperty("java.io.tmpdir")); + tmpDirButton = new JButton(I18n.getMessage("thaw.common.browse")); + tmpDirButton.addActionListener(this); + + if (advancedMode) { + thawConfigPanel.add(new JLabel(I18n.getMessage("thaw.common.tempDir"))); + + JPanel tempDirPanel = new JPanel(new BorderLayout()); + + tempDirPanel.add(tmpDirField, + BorderLayout.CENTER); + tempDirPanel.add(tmpDirButton, + BorderLayout.EAST); + + thawConfigPanel.add(tempDirPanel); + } + configWindow.addObserver(this); } @@ -47,14 +74,31 @@ } + public void actionPerformed(ActionEvent e) { + FileChooser chooser = new FileChooser(System.getProperty("java.io.tmpdir")); + chooser.setTitle(I18n.getMessage("thaw.common.tempDir")); + chooser.setDirectoryOnly(true); + chooser.setDialogType(javax.swing.JFileChooser.OPEN_DIALOG); + + java.io.File file = chooser.askOneFile(); + tmpDirField.setText(file.getPath()); + } + + public void update(final Observable o, final Object arg) { if(arg == core.getConfigWindow().getOkButton()) { advancedMode = advancedModeBox.isSelected(); core.getConfig().setValue("advancedMode", Boolean.toString(advancedMode)); + + core.getConfig().setValue("tmpDir", tmpDirField.getText()); + System.setProperty("java.io.tmpdir", tmpDirField.getText()); + tmpDirField.setText(System.getProperty("java.io.tmpdir")); } if(arg == core.getConfigWindow().getCancelButton()) { advancedModeBox.setSelected(advancedMode); + + tmpDirField.setText(System.getProperty("java.io.tmpdir")); } } Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-01 22:50:16 UTC (rev 13869) +++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-01 23:12:55 UTC (rev 13870) @@ -83,7 +83,10 @@ thaw.common.apply=Appliquer +thaw.common.tempDir=R?pertoire pour les fichiers temporaires +thaw.common.browse=Parcourir... + ## Errors thaw.error.idAlreadyUsed=Impossible de se connecter. Notre identifiant est d?j? utilis? par un autre client connect? au noeud. Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-01 22:50:16 UTC (rev 13869) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-01 23:12:55 UTC (rev 13870) @@ -85,6 +85,9 @@ thaw.common.apply=Apply +thaw.common.tempDir=Directory for the temporary files +thaw.common.browse=Browse... + ## Errors thaw.error.idAlreadyUsed=Unable to connect. Our Id is already used by another client connected to the node. Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-01 22:50:16 UTC (rev 13869) +++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-01 23:12:55 UTC (rev 13870) @@ -83,7 +83,10 @@ thaw.common.apply=Appliquer +thaw.common.tempDir=R\u00e9pertoire pour les fichiers temporaires +thaw.common.browse=Parcourir... + ## Errors thaw.error.idAlreadyUsed=Impossible de se connecter. Notre identifiant est d\u00e9j\u00e0 utilis\u00e9 par un autre client connect\u00e9 au noeud. From jflesch at freenetproject.org Sun Jul 1 23:17:44 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sun, 1 Jul 2007 23:17:44 +0000 (UTC) Subject: [Thaw-dev] r13871 - trunk/apps/Thaw/src/thaw/core Message-ID: <20070701231744.00F0A3886E4@emu.freenetproject.org> Author: jflesch Date: 2007-07-01 23:17:43 +0000 (Sun, 01 Jul 2007) New Revision: 13871 Modified: trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java Log: Fix the visibility of the option to select the directory where temporary files are created Modified: trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java 2007-07-01 23:12:55 UTC (rev 13870) +++ trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java 2007-07-01 23:17:43 UTC (rev 13871) @@ -27,6 +27,7 @@ private boolean advancedMode; + private JLabel tmpDirLabel; private JTextField tmpDirField; private JButton tmpDirButton; @@ -52,18 +53,18 @@ tmpDirButton = new JButton(I18n.getMessage("thaw.common.browse")); tmpDirButton.addActionListener(this); - if (advancedMode) { - thawConfigPanel.add(new JLabel(I18n.getMessage("thaw.common.tempDir"))); + tmpDirLabel = new JLabel(I18n.getMessage("thaw.common.tempDir")); + thawConfigPanel.add(tmpDirLabel); - JPanel tempDirPanel = new JPanel(new BorderLayout()); + JPanel tempDirPanel = new JPanel(new BorderLayout()); - tempDirPanel.add(tmpDirField, - BorderLayout.CENTER); - tempDirPanel.add(tmpDirButton, - BorderLayout.EAST); + tempDirPanel.add(tmpDirField, + BorderLayout.CENTER); + tempDirPanel.add(tmpDirButton, + BorderLayout.EAST); + thawConfigPanel.add(tempDirPanel); - thawConfigPanel.add(tempDirPanel); - } + setAdvancedOptionsVisibility(advancedMode); configWindow.addObserver(this); } @@ -74,6 +75,12 @@ } + private void setAdvancedOptionsVisibility(boolean v) { + tmpDirField.setVisible(v); + tmpDirButton.setVisible(v); + tmpDirLabel.setVisible(v); + } + public void actionPerformed(ActionEvent e) { FileChooser chooser = new FileChooser(System.getProperty("java.io.tmpdir")); chooser.setTitle(I18n.getMessage("thaw.common.tempDir")); @@ -93,6 +100,8 @@ core.getConfig().setValue("tmpDir", tmpDirField.getText()); System.setProperty("java.io.tmpdir", tmpDirField.getText()); tmpDirField.setText(System.getProperty("java.io.tmpdir")); + + setAdvancedOptionsVisibility(advancedMode); } if(arg == core.getConfigWindow().getCancelButton()) { From jflesch at freenetproject.org Sun Jul 1 23:34:45 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sun, 1 Jul 2007 23:34:45 +0000 (UTC) Subject: [Thaw-dev] r13872 - in trunk/apps/Thaw/src/thaw: i18n plugins/index Message-ID: <20070701233446.006753886EA@emu.freenetproject.org> Author: jflesch Date: 2007-07-01 23:34:45 +0000 (Sun, 01 Jul 2007) New Revision: 13872 Removed: trunk/apps/Thaw/src/thaw/plugins/index/IndexProgressBar.java Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java Log: Remove the progress bar in the index browser panel (meaningless) Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-01 23:17:43 UTC (rev 13871) +++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-01 23:34:45 UTC (rev 13872) @@ -331,7 +331,7 @@ thaw.plugin.index.loadOnTheFly=Charger l'arbre d'indexes ? la vol?e (signifie moins de m?moire utilis?e, mais plus de temps CPU consomm?) -thaw.plugin.index.indexLoading=Chargement d'indexes +thaw.plugin.index.indexLoading=Chargement de l'index thaw.plugin.index.blackList=Liste noire d'indexes thaw.plugin.index.editBlackList=Editer la liste noire d'indexes Modified: trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java 2007-07-01 23:17:43 UTC (rev 13871) +++ trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java 2007-07-01 23:34:45 UTC (rev 13872) @@ -123,8 +123,6 @@ index.downloadFromFreenet(this, browserPanel.getIndexTree(), queueManager); browserPanel.getIndexTree().redraw(); - - browserPanel.getIndexProgressBar().addTransfer(1); } return ret; @@ -148,7 +146,6 @@ browserPanel.getTables().getLinkTable().refresh(); } browserPanel.getUnknownIndexList().addLinks((LinkList)o); - browserPanel.getIndexProgressBar().removeTransfer(1); } Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java 2007-07-01 23:17:43 UTC (rev 13871) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java 2007-07-01 23:34:45 UTC (rev 13872) @@ -20,7 +20,6 @@ private Tables tables; private DetailPanel detailPanel; private UnknownIndexList unknownList; - private IndexProgressBar indexProgressBar; private BlackList blackList; private CommentTab commentTab; @@ -73,11 +72,9 @@ indexTree.addTreeSelectionListener(this); - indexProgressBar = new IndexProgressBar(); globalPanel = new JPanel(new BorderLayout()); globalPanel.add(split, BorderLayout.CENTER); - globalPanel.add(indexProgressBar.getProgressBar(), BorderLayout.SOUTH); } @@ -131,9 +128,6 @@ return commentTab; } - public IndexProgressBar getIndexProgressBar() { - return indexProgressBar; - } public MainWindow getMainWindow() { return mainWindow; Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-07-01 23:17:43 UTC (rev 13871) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-07-01 23:34:45 UTC (rev 13872) @@ -785,9 +785,6 @@ public static class IndexDownloader extends BasicIndexAction implements Runnable, Observer { - public boolean allStarted; - public int toRemove; - public IndexDownloader(FCPQueueManager queueManager, IndexBrowserPanel indexBrowser, final AbstractButton actionSource) { super(queueManager, indexBrowser, actionSource); } @@ -797,21 +794,8 @@ } public void apply() { - int i; - - toRemove = 0; - allStarted = false; - - i = getTarget().downloadFromFreenet(this, getIndexBrowserPanel().getIndexTree(), getQueueManager()); - + getTarget().downloadFromFreenet(this, getIndexBrowserPanel().getIndexTree(), getQueueManager()); getIndexBrowserPanel().getIndexTree().redraw(getTarget()); - - if (i > 0) - getIndexBrowserPanel().getIndexProgressBar().addTransfer(i); - else - Logger.notice(this, "No download started ?!"); - - allStarted = true; } public void update(Observable o, Object param) { @@ -827,13 +811,6 @@ } getIndexBrowserPanel().getUnknownIndexList().addLinks((LinkList)o); - - toRemove++; - - if (allStarted) { - getIndexBrowserPanel().getIndexProgressBar().removeTransfer(toRemove); - toRemove = 0; - } } } @@ -851,9 +828,6 @@ public static class IndexUploader extends BasicIndexAction implements Runnable, Observer { - private boolean allStarted = false; - private int toRemove = 0; - public IndexUploader(FCPQueueManager queueManager, IndexBrowserPanel indexBrowser, final AbstractButton actionSource) { super(queueManager, indexBrowser, actionSource); } @@ -866,32 +840,13 @@ } public void apply() { - int i; + getTarget().insertOnFreenet(this, getIndexBrowserPanel(), getQueueManager()); - toRemove = 0; - allStarted = false; - - i = getTarget().insertOnFreenet(this, getIndexBrowserPanel(), getQueueManager()); - getIndexBrowserPanel().getIndexTree().redraw(getTarget()); - - if (i > 0) - getIndexBrowserPanel().getIndexProgressBar().addTransfer(i); - else - Logger.notice(this, "No insertion started ?!"); - - allStarted = true; } public void update(Observable o, Object param) { getIndexBrowserPanel().getIndexTree().redraw(((Index)o)); - - toRemove++; - - if (allStarted) { - getIndexBrowserPanel().getIndexProgressBar().removeTransfer(toRemove); - toRemove = 0; - } } } Deleted: trunk/apps/Thaw/src/thaw/plugins/index/IndexProgressBar.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexProgressBar.java 2007-07-01 23:17:43 UTC (rev 13871) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexProgressBar.java 2007-07-01 23:34:45 UTC (rev 13872) @@ -1,72 +0,0 @@ -package thaw.plugins.index; - -import javax.swing.JProgressBar; - -import thaw.core.I18n; -import thaw.core.Logger; - -public class IndexProgressBar { - - private JProgressBar progressBar; - - private int total; - private int current; - - private int nmbTransfers; - - public IndexProgressBar() { - progressBar = new JProgressBar(0, 100); - total = 0; - current = 0; - nmbTransfers = 0; - refreshBar(); - progressBar.setStringPainted(true); - } - - public void addTransfer(int nmb) { - Logger.info(this, "Adding "+Integer.toString(nmb)+" transfers"); - - total += nmb; - current += 0; - nmbTransfers += nmb; - - refreshBar(); - } - - - public void removeTransfer(int nmb) { - Logger.info(this, "Removing "+Integer.toString(nmb)+" transfers"); - - nmbTransfers -= nmb; - - if (nmbTransfers <= 0) { - total = 0; - current = 0; - } - else { - current++; - } - - refreshBar(); - } - - public void refreshBar() { - int pourcent; - - if (total == 0) { - progressBar.setValue(0); - progressBar.setString(""); - } else { - pourcent = (current * 100) / total; - progressBar.setValue(pourcent); - progressBar.setString(I18n.getMessage("thaw.plugin.index.indexLoading")+": " - + Integer.toString(pourcent) + " %"); - } - } - - public JProgressBar getProgressBar() { - return progressBar; - } -} - - From jflesch at freenetproject.org Sun Jul 1 23:40:51 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sun, 1 Jul 2007 23:40:51 +0000 (UTC) Subject: [Thaw-dev] r13873 - trunk/apps/Thaw/src/thaw/plugins/queueWatcher Message-ID: <20070701234051.6030C4793F3@emu.freenetproject.org> Author: jflesch Date: 2007-07-01 23:40:51 +0000 (Sun, 01 Jul 2007) New Revision: 13873 Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java Log: The option 'Remove finished transfers' won't remove the failed ones anymore Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java 2007-07-01 23:34:45 UTC (rev 13872) +++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java 2007-07-01 23:40:51 UTC (rev 13873) @@ -348,7 +348,7 @@ for(final Iterator it = qs.iterator(); it.hasNext(); ) { final FCPTransferQuery query = (FCPTransferQuery)it.next(); - if(query.isFinished() && + if(query.isFinished() && query.isSuccessful() && (!(query instanceof FCPClientGet) || (!query.isSuccessful() || ((FCPClientGet)query).isWritingSuccessful()))) { if(query.stop(core.getQueueManager())) { core.getQueueManager().remove(query); From jflesch at freenetproject.org Mon Jul 2 00:01:22 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Mon, 2 Jul 2007 00:01:22 +0000 (UTC) Subject: [Thaw-dev] r13874 - in trunk/apps/Thaw/src/thaw: core i18n Message-ID: <20070702000122.2F3B3479F00@emu.freenetproject.org> Author: jflesch Date: 2007-07-02 00:01:19 +0000 (Mon, 02 Jul 2007) New Revision: 13874 Modified: trunk/apps/Thaw/src/thaw/core/Core.java trunk/apps/Thaw/src/thaw/core/I18n.java trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties trunk/apps/Thaw/src/thaw/i18n/thaw.properties trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties Log: Let the user select the language to use Modified: trunk/apps/Thaw/src/thaw/core/Core.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/Core.java 2007-07-01 23:40:51 UTC (rev 13873) +++ trunk/apps/Thaw/src/thaw/core/Core.java 2007-07-02 00:01:19 UTC (rev 13874) @@ -181,6 +181,9 @@ if (config.getValue("tmpDir") != null) System.setProperty("java.io.tmpdir", config.getValue("tmpDir")); + if (config.getValue("lang") != null) + I18n.setLocale(new java.util.Locale(config.getValue("lang"))); + return true; } Modified: trunk/apps/Thaw/src/thaw/core/I18n.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/I18n.java 2007-07-01 23:40:51 UTC (rev 13873) +++ trunk/apps/Thaw/src/thaw/core/I18n.java 2007-07-02 00:01:19 UTC (rev 13874) @@ -34,6 +34,10 @@ * @version $Id: I18n.java 355 2006-03-24 15:04:11Z bombe $ */ public class I18n { + public final static Locale[] supportedLocales = { + new Locale("en"), + new Locale("fr") + }; private static Locale currentLocale; Modified: trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java 2007-07-01 23:40:51 UTC (rev 13873) +++ trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java 2007-07-02 00:01:19 UTC (rev 13874) @@ -13,7 +13,11 @@ import javax.swing.JButton; import javax.swing.JTextField; import javax.swing.JTextField; +import javax.swing.JComboBox; +import java.util.Vector; +import java.util.Locale; + import thaw.gui.FileChooser; /** @@ -31,6 +35,8 @@ private JTextField tmpDirField; private JButton tmpDirButton; + private JLabel langLabel; + private JComboBox langBox; public ThawConfigPanel(final ConfigWindow configWindow, final Core core) { this.core = core; @@ -41,6 +47,8 @@ advancedMode = Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue(); + /* advanced mode */ + thawConfigPanel = new JPanel(); thawConfigPanel.setLayout(new GridLayout(15, 1)); @@ -49,6 +57,9 @@ thawConfigPanel.add(advancedModeBox); thawConfigPanel.add(new JLabel(" ")); + + /* tmpdir */ + tmpDirField = new JTextField(System.getProperty("java.io.tmpdir")); tmpDirButton = new JButton(I18n.getMessage("thaw.common.browse")); tmpDirButton.addActionListener(this); @@ -64,6 +75,19 @@ BorderLayout.EAST); thawConfigPanel.add(tempDirPanel); + /* lang */ + langLabel = new JLabel(I18n.getMessage("thaw.common.language")); + langBox = new JComboBox(I18n.supportedLocales); + + setLang(); + + thawConfigPanel.add(new JLabel("")); + thawConfigPanel.add(langLabel); + thawConfigPanel.add(langBox); + + + /* misc */ + setAdvancedOptionsVisibility(advancedMode); configWindow.addObserver(this); @@ -74,11 +98,19 @@ return thawConfigPanel; } + private void setLang() { + for (int i = 0 ; i < I18n.supportedLocales.length; i++) { + if (I18n.supportedLocales[i].getLanguage().equals(I18n.getLocale().getLanguage())) + langBox.setSelectedItem(I18n.supportedLocales[i]); + } + } private void setAdvancedOptionsVisibility(boolean v) { tmpDirField.setVisible(v); tmpDirButton.setVisible(v); tmpDirLabel.setVisible(v); + langLabel.setVisible(v); + langBox.setVisible(v); } public void actionPerformed(ActionEvent e) { @@ -101,6 +133,9 @@ System.setProperty("java.io.tmpdir", tmpDirField.getText()); tmpDirField.setText(System.getProperty("java.io.tmpdir")); + core.getConfig().setValue("lang", + ((Locale)langBox.getSelectedItem()).getLanguage()); + setAdvancedOptionsVisibility(advancedMode); } @@ -108,6 +143,7 @@ advancedModeBox.setSelected(advancedMode); tmpDirField.setText(System.getProperty("java.io.tmpdir")); + setLang(); } } Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-01 23:40:51 UTC (rev 13873) +++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-02 00:01:19 UTC (rev 13874) @@ -86,7 +86,10 @@ thaw.common.tempDir=R?pertoire pour les fichiers temporaires thaw.common.browse=Parcourir... +thaw.common.language=Langue (n?cessite de red?marrer Thaw) : + + ## Errors thaw.error.idAlreadyUsed=Impossible de se connecter. Notre identifiant est d?j? utilis? par un autre client connect? au noeud. Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-01 23:40:51 UTC (rev 13873) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-02 00:01:19 UTC (rev 13874) @@ -88,6 +88,8 @@ thaw.common.tempDir=Directory for the temporary files thaw.common.browse=Browse... +thaw.common.language=Language (you must restart Thaw) : + ## Errors thaw.error.idAlreadyUsed=Unable to connect. Our Id is already used by another client connected to the node. Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-01 23:40:51 UTC (rev 13873) +++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-02 00:01:19 UTC (rev 13874) @@ -86,7 +86,10 @@ thaw.common.tempDir=R\u00e9pertoire pour les fichiers temporaires thaw.common.browse=Parcourir... +thaw.common.language=Langue (n\u00e9cessite de red\u00e9marrer Thaw) : + + ## Errors thaw.error.idAlreadyUsed=Impossible de se connecter. Notre identifiant est d\u00e9j\u00e0 utilis\u00e9 par un autre client connect\u00e9 au noeud. @@ -331,7 +334,7 @@ thaw.plugin.index.loadOnTheFly=Charger l'arbre d'indexes \u00e0 la vol\u00e9e (signifie moins de m\u00e9moire utilis\u00e9e, mais plus de temps CPU consomm\u00e9) -thaw.plugin.index.indexLoading=Chargement d'indexes +thaw.plugin.index.indexLoading=Chargement de l'index thaw.plugin.index.blackList=Liste noire d'indexes thaw.plugin.index.editBlackList=Editer la liste noire d'indexes From jflesch at freenetproject.org Mon Jul 2 01:45:38 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Mon, 2 Jul 2007 01:45:38 +0000 (UTC) Subject: [Thaw-dev] r13875 - trunk/apps/Thaw/src/thaw/plugins/index Message-ID: <20070702014538.925B2479933@emu.freenetproject.org> Author: jflesch Date: 2007-07-02 01:45:38 +0000 (Mon, 02 Jul 2007) New Revision: 13875 Modified: trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java Log: Fix index import Modified: trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java 2007-07-02 00:01:19 UTC (rev 13874) +++ trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java 2007-07-02 01:45:38 UTC (rev 13875) @@ -593,7 +593,8 @@ } if ("fullIndex".equals(rawName)) { - indexHandler.endDocument(); + if (indexHandler != null) + indexHandler.endDocument(); indexHandler = null; return; } From jflesch at freenetproject.org Mon Jul 2 01:54:35 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Mon, 2 Jul 2007 01:54:35 +0000 (UTC) Subject: [Thaw-dev] r13876 - trunk/apps/Thaw/src/thaw/plugins/index Message-ID: <20070702015435.6B15C390347@emu.freenetproject.org> Author: jflesch Date: 2007-07-02 01:54:35 +0000 (Mon, 02 Jul 2007) New Revision: 13876 Modified: trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java trunk/apps/Thaw/src/thaw/plugins/index/IndexRoot.java Log: Fix the function to delete ALL the indexes in the database Modified: trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java 2007-07-02 01:45:38 UTC (rev 13875) +++ trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java 2007-07-02 01:54:35 UTC (rev 13876) @@ -297,18 +297,19 @@ sendQuery(db, "DROP TABLE files"); sendQuery(db, "DROP TABLE links"); + sendQuery(db, "DROP TABLE indexBlackList"); + + sendQuery(db, "DROP TABLE indexCommentKeys"); + sendQuery(db, "DROP TABLE indexComments"); + sendQuery(db, "DROP TABLE indexCommentBlackList"); + sendQuery(db, "DROP TABLE indexes"); sendQuery(db, "DROP TABLE indexFolders"); sendQuery(db, "DROP TABLE indexParents"); sendQuery(db, "DROP TABLE folderParents"); - sendQuery(db, "DROP TABLE indexCommentKeys"); - sendQuery(db, "DROP TABLE indexComments"); - sendQuery(db, "DROP TABLE categories"); - - sendQuery(db, "DROP TABLE indexBlackList"); } Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexRoot.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexRoot.java 2007-07-02 01:45:38 UTC (rev 13875) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexRoot.java 2007-07-02 01:54:35 UTC (rev 13876) @@ -92,33 +92,9 @@ Logger.warning(this, "DELETING ALL THE INDEXES"); - try { - synchronized(getDb().dbLock) { - PreparedStatement st; + DatabaseManager.dropTables(indexBrowser.getDb()); + DatabaseManager.createTables(indexBrowser.getDb()); - st = getDb().getConnection().prepareStatement("DELETE FROM FILES"); - st.execute(); - - st = getDb().getConnection().prepareStatement("DELETE FROM LINKS"); - st.execute(); - - st = getDb().getConnection().prepareStatement("DELETE FROM INDEXES"); - st.execute(); - - st = getDb().getConnection().prepareStatement("DELETE FROM INDEXFOLDERS"); - st.execute(); - - st = getDb().getConnection().prepareStatement("DELETE FROM INDEXPARENTS"); - st.execute(); - - st = getDb().getConnection().prepareStatement("DELETE FROM FOLDERPARENTS"); - st.execute(); - } - } catch(SQLException e) { - Logger.error(this, "Woops, error while destroying the world : "+e.toString()); - return; - } - IndexManagementHelper.addIndex(queueManager, indexBrowser, null, thaw.plugins.IndexBrowser.DEFAULT_INDEX); From thaw at freenetproject.org Mon Jul 2 05:41:26 2007 From: thaw at freenetproject.org (thaw at freenetproject.org) Date: Mon, 2 Jul 2007 05:41:26 +0000 (UTC) Subject: [Thaw-dev] *****SPAM***** You're in luck - special savings inside. Message-ID: <20070702-43627.5257.qmail@static-host-24-149-194-193.patmedia.net> An embedded and charset-unspecified text was scrubbed... Name: not available Url: http://emu.freenetproject.org/pipermail/thaw/attachments/20070702/dc4e7327/attachment.txt -------------- next part -------------- An embedded message was scrubbed... From: Subject: You're in luck - special savings inside. Date: Mon, 2 Jul 2007 05:41:26 +0000 (UTC) Size: 8296 Url: http://emu.freenetproject.org/pipermail/thaw/attachments/20070702/dc4e7327/attachment.eml From jflesch at freenetproject.org Mon Jul 2 15:17:18 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Mon, 2 Jul 2007 15:17:18 +0000 (UTC) Subject: [Thaw-dev] r13877 - in trunk/apps/Thaw/src/thaw: i18n plugins Message-ID: <20070702151718.A2A2D479836@emu.freenetproject.org> Author: jflesch Date: 2007-07-02 15:17:18 +0000 (Mon, 02 Jul 2007) New Revision: 13877 Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties trunk/apps/Thaw/src/thaw/i18n/thaw.properties trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java trunk/apps/Thaw/src/thaw/plugins/ThemeSelector.java Log: Specify to the user that the sun's GTK look'n'feel is buggy Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-02 01:54:35 UTC (rev 13876) +++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-02 15:17:18 UTC (rev 13877) @@ -88,6 +88,7 @@ thaw.common.language=Langue (n?cessite de red?marrer Thaw) : +thaw.common.buggy=Buggu? ## Errors Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-02 01:54:35 UTC (rev 13876) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-02 15:17:18 UTC (rev 13877) @@ -90,6 +90,8 @@ thaw.common.language=Language (you must restart Thaw) : +thaw.common.buggy=Buggy + ## Errors thaw.error.idAlreadyUsed=Unable to connect. Our Id is already used by another client connected to the node. Modified: trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java 2007-07-02 01:54:35 UTC (rev 13876) +++ trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java 2007-07-02 15:17:18 UTC (rev 13877) @@ -19,7 +19,10 @@ public class IndexBrowser extends ToolbarModifier implements Plugin, ChangeListener { - public static final String DEFAULT_INDEX = "USK at p-uFAWUomLm37MCQLu3r67-B8e6yF1kS4q2v0liM1Vk,h0MWqM~lF0Bec-AIv445PLn06ams9-RFbnwO6Cm2Snc,AQACAAE/Thaw/2/Thaw.frdx"; + public static final String DEFAULT_INDEX = + "USK at p-uFAWUomLm37MCQLu3r67-B8e6yF1kS4q2v0liM1Vk,"+ + "h0MWqM~lF0Bec-AIv445PLn06ams9-RFbnwO6Cm2Snc,AQACAAE"+ + "/Thaw/2/Thaw.frdx"; private Core core; private Hsqldb hsqldb; Modified: trunk/apps/Thaw/src/thaw/plugins/ThemeSelector.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/ThemeSelector.java 2007-07-02 01:54:35 UTC (rev 13876) +++ trunk/apps/Thaw/src/thaw/plugins/ThemeSelector.java 2007-07-02 15:17:18 UTC (rev 13877) @@ -30,13 +30,22 @@ private JList themeList = null; private Vector themes = null; + public final static String[] buggyLnf = new String[] { + "com.sun.java.swing.plaf.gtk.GTKLookAndFeel" + }; + public ThemeSelector() { } - public static void addToVector(Vector v, Object o) { - if (v.indexOf(o) < 0) - v.add(o); + public static void addToVector(Vector v, String s) { + for (int i = 0 ; i < buggyLnf.length ; i++) { + if (buggyLnf[i].equals(s)) + s += " ("+I18n.getMessage("thaw.common.buggy")+")"; + } + + if (v.indexOf(s) < 0) + v.add(s); } public static Vector getPossibleThemes() { @@ -103,6 +112,11 @@ if (theme == null) theme = UIManager.getSystemLookAndFeelClassName(); + for (int i = 0 ; i < buggyLnf.length ; i++) { + if (buggyLnf[i].equals(theme)) + theme += " ("+I18n.getMessage("thaw.common.buggy")+")"; + } + themeList.setSelectedValue(theme, true); } @@ -122,8 +136,9 @@ if (arg == core.getConfigWindow().getOkButton()) { if (themeList.getSelectedValue() != null) { + String[] str = ((String)themeList.getSelectedValue()).split(" "); core.getConfig().setValue("lookAndFeel", - ((String)themeList.getSelectedValue())); + str[0]); resetSelection(); } @@ -155,7 +170,8 @@ public void valueChanged(ListSelectionEvent e) { if (e.getFirstIndex() >= 0 && themes.get(e.getFirstIndex()) != null) { - Thread th = new Thread(new ThemeSetter((String)themeList.getSelectedValue())); + String[] str = ((String)themeList.getSelectedValue()).split(" "); + Thread th = new Thread(new ThemeSetter(str[0])); th.start(); } } From jflesch at freenetproject.org Mon Jul 2 15:17:35 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Mon, 2 Jul 2007 15:17:35 +0000 (UTC) Subject: [Thaw-dev] r13878 - trunk/apps/Thaw/src/thaw/i18n Message-ID: <20070702151735.1C9F04798AE@emu.freenetproject.org> Author: jflesch Date: 2007-07-02 15:17:34 +0000 (Mon, 02 Jul 2007) New Revision: 13878 Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties Log: I forgot to regenerate the french translation Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-02 15:17:18 UTC (rev 13877) +++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-02 15:17:34 UTC (rev 13878) @@ -88,6 +88,7 @@ thaw.common.language=Langue (n\u00e9cessite de red\u00e9marrer Thaw) : +thaw.common.buggy=Buggu\u00e9 ## Errors From jflesch at freenetproject.org Mon Jul 2 18:16:03 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Mon, 2 Jul 2007 18:16:03 +0000 (UTC) Subject: [Thaw-dev] r13879 - in trunk/apps/Thaw/src/thaw: core i18n Message-ID: <20070702181603.22AC94796C6@emu.freenetproject.org> Author: jflesch Date: 2007-07-02 18:16:02 +0000 (Mon, 02 Jul 2007) New Revision: 13879 Modified: trunk/apps/Thaw/src/thaw/core/ConfigWindow.java trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties trunk/apps/Thaw/src/thaw/i18n/thaw.properties trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties Log: Add a dialog "Please wait" when the user change the configuration Modified: trunk/apps/Thaw/src/thaw/core/ConfigWindow.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 2007-07-02 15:17:34 UTC (rev 13878) +++ trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 2007-07-02 18:16:02 UTC (rev 13879) @@ -11,8 +11,11 @@ import javax.swing.JDialog; import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.swing.JLabel; +import java.awt.Dimension; +import java.awt.Toolkit; + import thaw.gui.TabbedPane; - import thaw.gui.IconBox; @@ -220,12 +223,34 @@ } public void run() { + JDialog dialog = new JDialog(core.getMainWindow().getMainFrame(), + I18n.getMessage("thaw.common.pleaseWait")); + dialog.getContentPane().setLayout(new GridLayout(1, 1)); + dialog.getContentPane().add(new JLabel(I18n.getMessage("thaw.common.pleaseWait"))); + + dialog.setUndecorated(true); + dialog.setResizable(false); + + dialog.setSize(150, 30); + + final Dimension screenSize = + Toolkit.getDefaultToolkit().getScreenSize(); + + final Dimension dialogSize = dialog.getSize(); + dialog.setLocation(dialogSize.width/2 - (dialogSize.width/2), + dialogSize.height/2 - (dialogSize.height/2)); + + dialog.setVisible(true); + /* should reinit the whole connection correctly */ core.getPluginManager().stopPlugins(); if (resetConnection && !core.initConnection()) { - new thaw.gui.WarningWindow(core, I18n.getMessage("thaw.warning.unableToConnectTo")+ " "+core.getConfig().getValue("nodeAddress")+":"+ core.getConfig().getValue("nodePort")); + new thaw.gui.WarningWindow(dialog, + I18n.getMessage("thaw.warning.unableToConnectTo")+ + " "+core.getConfig().getValue("nodeAddress")+ + ":"+ core.getConfig().getValue("nodePort")); } needConnectionReset = false; @@ -235,6 +260,8 @@ core.getPluginManager().loadPlugins(); core.getPluginManager().runPlugins(); + + dialog.setVisible(false); } } Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-02 15:17:34 UTC (rev 13878) +++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-02 18:16:02 UTC (rev 13879) @@ -88,8 +88,9 @@ thaw.common.language=Langue (n?cessite de red?marrer Thaw) : -thaw.common.buggy=Buggu? +thaw.common.buggy=Bugg? +thaw.common.pleaseWait=Veuillez patienter ... ## Errors thaw.error.idAlreadyUsed=Impossible de se connecter. Notre identifiant est d?j? utilis? par un autre client connect? au noeud. Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-02 15:17:34 UTC (rev 13878) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-02 18:16:02 UTC (rev 13879) @@ -92,6 +92,8 @@ thaw.common.buggy=Buggy +thaw.common.pleaseWait=Please wait ... + ## Errors thaw.error.idAlreadyUsed=Unable to connect. Our Id is already used by another client connected to the node. Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-02 15:17:34 UTC (rev 13878) +++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-02 18:16:02 UTC (rev 13879) @@ -88,8 +88,9 @@ thaw.common.language=Langue (n\u00e9cessite de red\u00e9marrer Thaw) : -thaw.common.buggy=Buggu\u00e9 +thaw.common.buggy=Bugg\u00e9 +thaw.common.pleaseWait=Veuillez patienter ... ## Errors thaw.error.idAlreadyUsed=Impossible de se connecter. Notre identifiant est d\u00e9j\u00e0 utilis\u00e9 par un autre client connect\u00e9 au noeud. From jflesch at freenetproject.org Tue Jul 3 11:50:25 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Tue, 3 Jul 2007 11:50:25 +0000 (UTC) Subject: [Thaw-dev] r13886 - in trunk/apps/Thaw: . src/thaw/core src/thaw/i18n src/thaw/plugins/index Message-ID: <20070703115025.8E0A747973D@emu.freenetproject.org> Author: jflesch Date: 2007-07-03 11:50:25 +0000 (Tue, 03 Jul 2007) New Revision: 13886 Modified: trunk/apps/Thaw/gpl.txt trunk/apps/Thaw/src/thaw/core/ConfigWindow.java trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties trunk/apps/Thaw/src/thaw/i18n/thaw.properties trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java trunk/apps/Thaw/src/thaw/plugins/index/Index.java trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java Log: Add the insertion date to the indexes and display this date in the interface Modified: trunk/apps/Thaw/gpl.txt =================================================================== --- trunk/apps/Thaw/gpl.txt 2007-07-03 11:32:40 UTC (rev 13885) +++ trunk/apps/Thaw/gpl.txt 2007-07-03 11:50:25 UTC (rev 13886) @@ -1,3 +1,9 @@ +The following license is only valid for the code provided in the java +package 'thaw'. For the other packages, see the corresponding +licenses. + +====================================================================== + GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Modified: trunk/apps/Thaw/src/thaw/core/ConfigWindow.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 2007-07-03 11:32:40 UTC (rev 13885) +++ trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 2007-07-03 11:50:25 UTC (rev 13886) @@ -234,18 +234,25 @@ dialog.setSize(150, 30); - final Dimension screenSize = + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - final Dimension dialogSize = dialog.getSize(); + Dimension dialogSize = dialog.getSize(); dialog.setLocation(dialogSize.width/2 - (dialogSize.width/2), dialogSize.height/2 - (dialogSize.height/2)); dialog.setVisible(true); - /* should reinit the whole connection correctly */ + dialog.setSize(150, 30); + + dialogSize = dialog.getSize(); + dialog.setLocation(dialogSize.width/2 - (dialogSize.width/2), + dialogSize.height/2 - (dialogSize.height/2)); + + core.getPluginManager().stopPlugins(); + /* should reinit the whole connection correctly */ if (resetConnection && !core.initConnection()) { new thaw.gui.WarningWindow(dialog, I18n.getMessage("thaw.warning.unableToConnectTo")+ Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-03 11:32:40 UTC (rev 13885) +++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-03 11:50:25 UTC (rev 13886) @@ -373,6 +373,8 @@ thaw.plugin.index.numberOfFiles=Nombre de fichiers : ? thaw.plugin.index.numberOfLinks=Nombre de liens : ? +thaw.plugin.index.insertionDate=Inser? le : ? + # Peer monitor thaw.plugin.peerMonitor.peerMonitor=Connexion Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-03 11:32:40 UTC (rev 13885) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-03 11:50:25 UTC (rev 13886) @@ -382,7 +382,9 @@ thaw.plugin.index.numberOfFiles=Number of files : ? thaw.plugin.index.numberOfLinks=Number of links : ? +thaw.plugin.index.insertionDate=Inserted : ? + # Peer monitor thaw.plugin.peerMonitor.peerMonitor=Connection Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-03 11:32:40 UTC (rev 13885) +++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-03 11:50:25 UTC (rev 13886) @@ -373,6 +373,8 @@ thaw.plugin.index.numberOfFiles=Nombre de fichiers : ? thaw.plugin.index.numberOfLinks=Nombre de liens : ? +thaw.plugin.index.insertionDate=Inser\u00e9 le : ? + # Peer monitor thaw.plugin.peerMonitor.peerMonitor=Connexion Modified: trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java 2007-07-03 11:32:40 UTC (rev 13885) +++ trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java 2007-07-03 11:50:25 UTC (rev 13886) @@ -93,7 +93,7 @@ ResultSet results; int ret; - st = c.prepareStatement("SELECT id, originalName, displayName, publicKey, privateKey, author, positionInTree, revision "+ + st = c.prepareStatement("SELECT id, originalName, displayName, publicKey, privateKey, author, positionInTree, revision, insertionDate "+ "FROM indexes ORDER by RAND() LIMIT 1"); results = st.executeQuery(); @@ -118,6 +118,7 @@ results.getInt("revision"), results.getString("privateKey"), results.getString("displayName"), + results.getDate("insertionDate"), false, false); index.downloadFromFreenet(this, browserPanel.getIndexTree(), queueManager); Modified: trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java 2007-07-03 11:32:40 UTC (rev 13885) +++ trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java 2007-07-03 11:50:25 UTC (rev 13886) @@ -91,7 +91,7 @@ if (config.getValue("indexDatabaseVersion") == null) { newDb = true; - config.setValue("indexDatabaseVersion", "6"); + config.setValue("indexDatabaseVersion", "7"); } else { /* CONVERTIONS */ @@ -134,6 +134,13 @@ config.setValue("indexDatabaseVersion", "6"); } + if ("6".equals(config.getValue("indexDatabaseVersion"))) { + if (splashScreen != null) + splashScreen.setStatus("Converting database ..."); + if (convertDatabase_6_to_7(db)) + config.setValue("indexDatabaseVersion", "7"); + } + /* ... */ } @@ -172,6 +179,7 @@ + "author VARCHAR(255) NULL, " + "positionInTree INTEGER NOT NULL, " + "revision INTEGER NOT NULL, " + + "insertionDate DATE DEFAULT NULL NULL, " + "newRev BOOLEAN DEFAULT FALSE NOT NULL, " + "newComment BOOLEAN DEFAULT FALSE NOT NULL, " + "parent INTEGER NULL, " /* direct parent */ @@ -966,4 +974,14 @@ return true; } + + + public static boolean convertDatabase_6_to_7(Hsqldb db) { + if (!sendQuery(db, "ALTER TABLE indexes ADD COLUMN insertionDate DATE DEFAULT NULL NULL")) { + Logger.error(new DatabaseManager(), "Error while converting the database (6 to 7) ! (adding column to index table)"); + return false; + } + + return true; + } } Modified: trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java 2007-07-03 11:32:40 UTC (rev 13885) +++ trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java 2007-07-03 11:50:25 UTC (rev 13886) @@ -12,6 +12,9 @@ import java.sql.*; +import java.text.DateFormat; + + import thaw.core.I18n; import thaw.core.Logger; import thaw.core.Config; @@ -39,19 +42,25 @@ private JLabel nmbFilesLabel; private JLabel nmbLinksLabel; + private JLabel insertionDateLabel; + private DateFormat dateFormat; + public DetailPanel(FCPQueueManager queueManager, IndexBrowserPanel indexBrowser) { + this.dateFormat = DateFormat.getDateInstance(); this.indexBrowser = indexBrowser; nmbFilesLabel = new JLabel(I18n.getMessage("thaw.plugin.index.numberOfFiles").replaceAll("\\?", "")); nmbLinksLabel = new JLabel(I18n.getMessage("thaw.plugin.index.numberOfLinks").replaceAll("\\?", "")); + insertionDateLabel = new JLabel(I18n.getMessage("thaw.plugin.index.insertionDate").replaceAll("\\?", "")); panel = new JPanel(new BorderLayout()); - JPanel stats = new JPanel(new GridLayout(1, 2)); + JPanel stats = new JPanel(new GridLayout(1, 3)); stats.add(nmbFilesLabel); stats.add(nmbLinksLabel); + stats.add(insertionDateLabel); panel.add(stats, BorderLayout.CENTER); @@ -101,12 +110,36 @@ } + private void setInsertionDate(Index index) { + if (index == null) { + insertionDateLabel.setText(I18n.getMessage("thaw.plugin.index.insertionDate").replaceAll("\\?", "")); + return; + } + + String dateStr = null; + + java.sql.Date dateSql = index.getDate(); + + if (dateSql != null) + dateStr = dateFormat.format(dateSql); + + if (dateStr != null) + insertionDateLabel.setText(I18n.getMessage("thaw.plugin.index.insertionDate").replaceAll("\\?", dateStr)); + else if (dateSql != null) { + Logger.warning(this, "There is a date in the db, but I'm unable to print it"); + } + } + + /* called by IndexBrowserPanel.setList() */ public void setTarget(FileAndLinkList node) { - if (node instanceof Index) + if (node instanceof Index) { setIndexTarget((Index)node); - else + setInsertionDate((Index)node); + } else { setIndexTarget(null); + setInsertionDate(null); + } int nmbFilesInt = 0; int nmbLinksInt = 0; @@ -165,9 +198,12 @@ rs = st.executeQuery(); rs.next(); nmbLinksInt = rs.getInt(1); + } + setInsertionDate(null); + } else if (node instanceof Index) { st = db.getConnection().prepareStatement("SELECT count(id) "+ "FROM files WHERE files.indexParent = ?"); @@ -183,6 +219,9 @@ rs = st.executeQuery(); rs.next(); nmbLinksInt = rs.getInt(1); + + setInsertionDate((Index)node); + } } catch(SQLException e) { Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-07-03 11:32:40 UTC (rev 13885) +++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-07-03 11:50:25 UTC (rev 13886) @@ -14,6 +14,7 @@ import java.util.Observable; import java.util.Observer; import java.util.Vector; +import java.util.Calendar; import javax.swing.JOptionPane; import javax.swing.tree.MutableTreeNode; @@ -90,8 +91,8 @@ private String displayName = null; private boolean hasChanged = false; private boolean newComment = false; + private java.sql.Date date = null; - /* loaded only if asked explictly */ private String realName = null; @@ -103,6 +104,7 @@ private Config config; + public final static String DATE_FORMAT = "yyyyMMdd"; /** * @deprecated Just don't use it ! @@ -122,6 +124,7 @@ */ public Index(Hsqldb db, Config config, int id, TreeNode parentNode, String publicKey, int rev, String privateKey, String displayName, + java.sql.Date insertionDate, boolean hasChanged, boolean newComment) { this(db, config, id); this.parentNode = parentNode; @@ -129,6 +132,7 @@ this.publicKey = publicKey; this.rev = rev; this.displayName = displayName; + this.date = insertionDate; this.hasChanged = hasChanged; this.newComment = newComment; } @@ -365,7 +369,7 @@ synchronized(db.dbLock) { try { PreparedStatement st = - db.getConnection().prepareStatement("SELECT publicKey, revision, privateKey, displayName, newRev, newComment FROM indexes WHERE id = ? LIMIT 1"); + db.getConnection().prepareStatement("SELECT publicKey, revision, privateKey, displayName, newRev, newComment, insertionDate FROM indexes WHERE id = ? LIMIT 1"); st.setInt(1, id); @@ -378,6 +382,7 @@ displayName = set.getString("displayName"); hasChanged = set.getBoolean("newRev"); newComment = set.getBoolean("newComment"); + date = set.getDate("insertionDate"); return true; } else { Logger.error(this, "Unable to find index "+Integer.toString(id)+" in the database ?!"); @@ -400,7 +405,16 @@ return publicKey; } + public java.sql.Date getDate() { + if (publicKey == null) { + Logger.debug(this, "getDate() => loadData()"); + loadData(); + } + return date; + } + + public boolean isObsolete() { return FreenetURIHelper.isObsolete(getPublicKey()); } @@ -876,6 +890,27 @@ if (((FCPClientPut)o).isFinished()) { if (indexTree != null) indexTree.removeUpdatingIndex(this); + + try { + synchronized(db.dbLock) { + /* TODO : Find a nicer way */ + + PreparedStatement st; + + Calendar cal= Calendar.getInstance(); + java.sql.Date dateSql = new java.sql.Date(cal.getTime().getTime() ); + + st = db.getConnection().prepareStatement("UPDATE indexes "+ + "SET insertionDate = ? "+ + "WHERE id = ?"); + st.setDate(1, dateSql); + st.setInt(2, id); + + st.execute(); + } + } catch(SQLException e) { + Logger.error(this, "Error while updating the insertion date : "+e.toString()); + } } } @@ -1110,7 +1145,20 @@ header.appendChild(privateKeyEl); } + /* insertion date */ + String dateStr; + java.text.SimpleDateFormat sdf = + new java.text.SimpleDateFormat(DATE_FORMAT); + Calendar c1 = Calendar.getInstance(); // today + dateStr = sdf.format(c1.getTime()); + + final Element date = xmlDoc.createElement("date"); + final Text dateText = xmlDoc.createTextNode(dateStr); + date.appendChild(dateText); + + header.appendChild(date); + /* TODO : Author */ return header; @@ -1314,10 +1362,13 @@ private boolean ownerTag = false; private boolean privateKeyTag = false; + private boolean dateTag = false; private boolean commentsTag = false; private boolean hasCommentTag = false; + private String dateStr = null; + private PreparedStatement insertFileSt = null; private PreparedStatement insertLinkSt = null; @@ -1351,6 +1402,11 @@ return; } + if ("date".equals(rawName)) { + dateTag = true; + return; + } + if ("index".equals(rawName)) { /* links */ int nextId; @@ -1491,6 +1547,37 @@ return; } + if ("date".equals(rawName)) { + dateTag = false; + return; + } + + if ("header".equals(rawName)) { + try { + synchronized(db.dbLock) { + java.sql.Date dateSql = null; + + if (dateStr != null) { + java.text.SimpleDateFormat sdf = + new java.text.SimpleDateFormat(DATE_FORMAT); + java.util.Date dateUtil = sdf.parse(dateStr, new java.text.ParsePosition(0)); + dateSql = new java.sql.Date(dateUtil.getTime()); + } + + PreparedStatement st = + db.getConnection().prepareStatement("UPDATE indexes "+ + "SET insertionDate = ? "+ + "WHERE id = ?"); + st.setDate(1, dateSql); + st.setInt(2, id); + + st.execute(); + } + } catch(SQLException e) { + Logger.error(this, "Error while updating index insertion date: "+e.toString()); + } + } + if ("comments".equals(rawName)) { commentsTag = false; return; @@ -1514,6 +1601,10 @@ return; } + if (dateTag) { + dateStr = txt; + } + if (privateKeyTag) { if (privateKey == null || privateKey.trim().equals(txt.trim())) { /** @@ -1525,12 +1616,24 @@ * the provided key doesn't match with the one we have, * we won't publish it anymore */ - Logger.notice(this, "A private key was provided, but didn't match with the one we have ; ignored."); + Logger.warning(this, "A private key was provided, but didn't match with the one we have ; ignored."); } - if (privateKey == null) - setPrivateKey(txt.trim()); + if (privateKey == null) { + String newPrivate = txt.trim(); + + /* check that nobody is trying to inject some FCP commands + * through the private key + */ + if (!newPrivate.startsWith("SSK@") + || newPrivate.indexOf('\n') >= 0) { + Logger.warning(this, "Invalid private key"); + return; + } + + setPrivateKey(newPrivate); + } return; } Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java 2007-07-03 11:32:40 UTC (rev 13885) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java 2007-07-03 11:50:25 UTC (rev 13886) @@ -89,8 +89,8 @@ n = new Index(db, config, set.getInt("id"), this, set.getString("publicKey"), set.getInt("revision"), set.getString("privateKey"), - set.getString("displayName"), set.getBoolean("newRev"), - set.getBoolean("newComment")); + set.getString("displayName"), set.getDate("insertionDate"), + set.getBoolean("newRev"), set.getBoolean("newComment")); int pos = set.getInt("positionInTree"); @@ -145,11 +145,11 @@ if (id >= 0) { - st = db.getConnection().prepareStatement("SELECT id, positionInTree, displayName, publicKey, privateKey, revision, newRev, newComment FROM indexes " + st = db.getConnection().prepareStatement("SELECT id, positionInTree, displayName, publicKey, privateKey, revision, newRev, newComment, insertionDate FROM indexes " + "WHERE parent = ? ORDER BY positionInTree"); st.setInt(1, id); } else { - st = db.getConnection().prepareStatement("SELECT id, positionInTree, displayName, publicKey, privateKey, revision, newRev, newComment FROM indexes " + st = db.getConnection().prepareStatement("SELECT id, positionInTree, displayName, publicKey, privateKey, revision, newRev, newComment, insertionDate FROM indexes " + "WHERE parent IS NULL ORDER BY positionInTree"); } Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-07-03 11:32:40 UTC (rev 13885) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-07-03 11:50:25 UTC (rev 13886) @@ -19,6 +19,7 @@ import java.util.Observable; import java.util.Observer; import java.util.Vector; +import java.util.Calendar; import javax.swing.AbstractButton; import javax.swing.JButton; @@ -231,7 +232,8 @@ Index index = new Index(db, getIndexBrowserPanel().getConfig(), id, (TreeNode)getTarget(), sskGenerator.getPublicKey(), 0, sskGenerator.getPrivateKey(), - name, false, false); + name, null, + false, false); ((MutableTreeNode)getTarget()).insert((index), 0); @@ -672,7 +674,7 @@ index = new Index(db, indexBrowser.getConfig(), id, parent, publicKey, revision, privateKey, - name, false, false); + name, null, false, false); } catch(SQLException e) { Logger.error(new IndexManagementHelper(), "Error while adding index: "+e.toString()); From jflesch at freenetproject.org Tue Jul 3 15:11:30 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Tue, 3 Jul 2007 15:11:30 +0000 (UTC) Subject: [Thaw-dev] r13900 - in trunk/apps/Thaw: images src/thaw/gui src/thaw/i18n src/thaw/plugins/index Message-ID: <20070703151130.D04234797C9@emu.freenetproject.org> Author: jflesch Date: 2007-07-03 15:11:30 +0000 (Tue, 03 Jul 2007) New Revision: 13900 Added: trunk/apps/Thaw/images/min-details.png Modified: trunk/apps/Thaw/src/thaw/gui/IconBox.java trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties trunk/apps/Thaw/src/thaw/i18n/thaw.properties trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java Log: Replace the stats under the file list by a button showing a dialog with these stats Added: trunk/apps/Thaw/images/min-details.png =================================================================== (Binary files differ) Property changes on: trunk/apps/Thaw/images/min-details.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/apps/Thaw/src/thaw/gui/IconBox.java =================================================================== --- trunk/apps/Thaw/src/thaw/gui/IconBox.java 2007-07-03 14:55:25 UTC (rev 13899) +++ trunk/apps/Thaw/src/thaw/gui/IconBox.java 2007-07-03 15:11:30 UTC (rev 13900) @@ -132,6 +132,7 @@ public static ImageIcon minOrange; public static ImageIcon minGreen; + public static ImageIcon minDetails; /** * Not really used @@ -247,6 +248,7 @@ IconBox.minRed = IconBox.loadIcon("min-red.png"); IconBox.minOrange = IconBox.loadIcon("min-orange.png"); IconBox.minGreen = IconBox.loadIcon("min-green.png"); + IconBox.minDetails = IconBox.loadIcon("min-details.png"); } } Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-03 14:55:25 UTC (rev 13899) +++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-03 15:11:30 UTC (rev 13900) @@ -370,10 +370,11 @@ thaw.plugin.index.warningNonNegative=Attention ! T?l?charger les commentaires sans avoir la derni?re version de l'index peut vous faire t?l?charger des spams ! -thaw.plugin.index.numberOfFiles=Nombre de fichiers : ? -thaw.plugin.index.numberOfLinks=Nombre de liens : ? +thaw.plugin.index.details=D?tails -thaw.plugin.index.insertionDate=Inser? le : ? +thaw.plugin.index.numberOfFiles=Nombre de fichiers : +thaw.plugin.index.numberOfLinks=Nombre de liens : +thaw.plugin.index.insertionDate=Inser? le : # Peer monitor Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-03 14:55:25 UTC (rev 13899) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-03 15:11:30 UTC (rev 13900) @@ -380,11 +380,13 @@ thaw.plugin.index.warningNonNegative=Warning ! Downloading comments without having the latest versions of the indexes may result in receiving spams ! -thaw.plugin.index.numberOfFiles=Number of files : ? -thaw.plugin.index.numberOfLinks=Number of links : ? -thaw.plugin.index.insertionDate=Inserted : ? +thaw.plugin.index.details=Details +thaw.plugin.index.numberOfFiles=Number of files : +thaw.plugin.index.numberOfLinks=Number of links : +thaw.plugin.index.insertionDate=Inserted : + # Peer monitor thaw.plugin.peerMonitor.peerMonitor=Connection Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-03 14:55:25 UTC (rev 13899) +++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-03 15:11:30 UTC (rev 13900) @@ -370,10 +370,11 @@ thaw.plugin.index.warningNonNegative=Attention ! T\u00e9l\u00e9charger les commentaires sans avoir la derni\u00e8re version de l'index peut vous faire t\u00e9l\u00e9charger des spams ! -thaw.plugin.index.numberOfFiles=Nombre de fichiers : ? -thaw.plugin.index.numberOfLinks=Nombre de liens : ? +thaw.plugin.index.details=D\u00e9tails -thaw.plugin.index.insertionDate=Inser\u00e9 le : ? +thaw.plugin.index.numberOfFiles=Nombre de fichiers : +thaw.plugin.index.numberOfLinks=Nombre de liens : +thaw.plugin.index.insertionDate=Inser\u00e9 le : # Peer monitor Modified: trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java 2007-07-03 14:55:25 UTC (rev 13899) +++ trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java 2007-07-03 15:11:30 UTC (rev 13900) @@ -37,6 +37,7 @@ private JPanel panel; private JButton viewCommentButton; + private JButton detailsButton; private Vector buttonActions; @@ -51,34 +52,24 @@ this.dateFormat = DateFormat.getDateInstance(); this.indexBrowser = indexBrowser; - nmbFilesLabel = new JLabel(I18n.getMessage("thaw.plugin.index.numberOfFiles").replaceAll("\\?", "")); - nmbLinksLabel = new JLabel(I18n.getMessage("thaw.plugin.index.numberOfLinks").replaceAll("\\?", "")); - insertionDateLabel = new JLabel(I18n.getMessage("thaw.plugin.index.insertionDate").replaceAll("\\?", "")); - panel = new JPanel(new BorderLayout()); - JPanel stats = new JPanel(new GridLayout(1, 3)); - stats.add(nmbFilesLabel); - stats.add(nmbLinksLabel); - stats.add(insertionDateLabel); + panel.add(new JLabel(""), BorderLayout.CENTER); - panel.add(stats, BorderLayout.CENTER); - JPanel buttonPanel = new JPanel(new GridLayout(1, 1)); buttonActions = new Vector(2); JButton button; + detailsButton = new JButton(I18n.getMessage("thaw.plugin.index.details"), + IconBox.minDetails); + buttonActions.add(new IndexManagementHelper.IndexDetailsViewer(indexBrowser, detailsButton)); + buttonPanel.add(detailsButton); + viewCommentButton = new JButton(I18n.getMessage("thaw.plugin.index.comment.comments").replaceAll("\\?", "0"), - IconBox.minReadComments); + IconBox.minReadComments); buttonActions.add(new IndexManagementHelper.IndexCommentViewer(indexBrowser, viewCommentButton)); buttonPanel.add(viewCommentButton); - //button = new JButton(I18n.getMessage("thaw.plugin.index.comment.add"), - // IconBox.minAddComment); - //buttonActions.add(new IndexManagementHelper.IndexCommentAdder(queueManager, indexBrowser, button)); - //buttonPanel.add(button); - - panel.add(buttonPanel, BorderLayout.EAST); } @@ -89,148 +80,31 @@ - private void setIndexTarget(Index l) { + public void setTarget(IndexTreeNode l) { - viewCommentButton.setText(I18n.getMessage("thaw.plugin.index.comment.comments").replaceAll("\\?", - l == null ? "0" : Integer.toString(l.getNmbComments()))); + if (l != null && l instanceof Index) + viewCommentButton.setText(I18n.getMessage("thaw.plugin.index.comment.comments").replaceAll("\\?", + Integer.toString(((Index)l).getNmbComments()))); + else + viewCommentButton.setText(I18n.getMessage("thaw.plugin.index.comment.comments").replaceAll("\\?", + "0")); for (Iterator it = buttonActions.iterator(); it.hasNext();) { IndexManagementHelper.IndexAction action = (IndexManagementHelper.IndexAction)it.next(); - action.setTarget((Index)l); + action.setTarget(l); } } - private void setStats(int nmbFiles, int nmbLinks) { - nmbFilesLabel.setText(I18n.getMessage("thaw.plugin.index.numberOfFiles").replaceAll("\\?", - Integer.toString(nmbFiles))); - nmbLinksLabel.setText(I18n.getMessage("thaw.plugin.index.numberOfLinks").replaceAll("\\?", - Integer.toString(nmbLinks))); - } - - - private void setInsertionDate(Index index) { - if (index == null) { - insertionDateLabel.setText(I18n.getMessage("thaw.plugin.index.insertionDate").replaceAll("\\?", "")); - return; - } - - String dateStr = null; - - java.sql.Date dateSql = index.getDate(); - - if (dateSql != null) - dateStr = dateFormat.format(dateSql); - - if (dateStr != null) - insertionDateLabel.setText(I18n.getMessage("thaw.plugin.index.insertionDate").replaceAll("\\?", dateStr)); - else if (dateSql != null) { - Logger.warning(this, "There is a date in the db, but I'm unable to print it"); - } - } - - /* called by IndexBrowserPanel.setList() */ public void setTarget(FileAndLinkList node) { if (node instanceof Index) { - setIndexTarget((Index)node); - setInsertionDate((Index)node); + setTarget((IndexTreeNode)node); } else { - setIndexTarget(null); - setInsertionDate(null); + setTarget((IndexTreeNode)null); } - - int nmbFilesInt = 0; - int nmbLinksInt = 0; - - if (node != null) { - nmbFilesInt = node.getFileList(null, true).size(); - nmbLinksInt = node.getLinkList(null, true).size(); - } - - setStats(nmbFilesInt, nmbLinksInt); } - - /* called by IndexTree.valueChanged() */ - public void setTarget(IndexTreeNode node) { - Hsqldb db = indexBrowser.getDb(); - PreparedStatement st; - ResultSet rs; - - int nmbFilesInt = 0; - int nmbLinksInt = 0; - - synchronized(db.dbLock) { - try { - if (node instanceof IndexFolder) { - if (node instanceof IndexRoot) { - st = db.getConnection().prepareStatement("SELECT count(id) from files"); - rs = st.executeQuery(); - rs.next(); - nmbFilesInt = rs.getInt(1); - - st = db.getConnection().prepareStatement("SELECT count(id) from links"); - rs = st.executeQuery(); - rs.next(); - nmbLinksInt = rs.getInt(1); - } else { - st = db.getConnection().prepareStatement("SELECT count(id) "+ - "FROM files WHERE files.indexParent IN "+ - "(SELECT indexParents.indexId "+ - " FROM indexParents "+ - " WHERE indexParents.folderId = ?)"); - - - st.setInt(1, node.getId()); - rs = st.executeQuery(); - rs.next(); - nmbFilesInt = rs.getInt(1); - - - st = db.getConnection().prepareStatement("SELECT count(id) "+ - "FROM links WHERE links.indexParent IN "+ - "(SELECT indexParents.indexId "+ - " FROM indexParents "+ - " WHERE indexParents.folderId = ?)"); - st.setInt(1, node.getId()); - rs = st.executeQuery(); - rs.next(); - nmbLinksInt = rs.getInt(1); - - } - - setInsertionDate(null); - - - } else if (node instanceof Index) { - st = db.getConnection().prepareStatement("SELECT count(id) "+ - "FROM files WHERE files.indexParent = ?"); - st.setInt(1, node.getId()); - rs = st.executeQuery(); - rs.next(); - nmbFilesInt = rs.getInt(1); - - - st = db.getConnection().prepareStatement("SELECT count(id) "+ - "FROM links WHERE links.indexParent = ?"); - st.setInt(1, node.getId()); - rs = st.executeQuery(); - rs.next(); - nmbLinksInt = rs.getInt(1); - - setInsertionDate((Index)node); - - } - - } catch(SQLException e) { - Logger.error(this, "Exception while counting files/links : "+e.toString()); - } - } - - setStats(nmbFilesInt, nmbLinksInt); - } - } Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-07-03 14:55:25 UTC (rev 13899) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-07-03 15:11:30 UTC (rev 13900) @@ -39,6 +39,8 @@ import javax.swing.tree.TreeNode; import javax.swing.JScrollPane; +import java.text.DateFormat; + import thaw.gui.IconBox; import thaw.core.Config; @@ -1658,7 +1660,8 @@ super.setTarget(node); if (getActionSource() != null) - getActionSource().setEnabled(node instanceof Index + getActionSource().setEnabled(node != null + && node instanceof Index && ((Index)node).canHaveComments()); } @@ -1666,4 +1669,155 @@ getIndexBrowserPanel().getCommentTab().showTab(); } } + + + public static class IndexDetailsViewer extends BasicIndexAction implements Runnable, ActionListener { + private DateFormat dateFormat; + + public IndexDetailsViewer(IndexBrowserPanel indexBrowser, final AbstractButton actionSource) { + super(null, indexBrowser, actionSource); + + dateFormat = DateFormat.getDateInstance(); + + if (actionSource != null) + actionSource.setEnabled(false); + } + + + public void setTarget(final IndexTreeNode node) { + super.setTarget(node); + + getActionSource().setEnabled(node != null); + } + + + private JDialog dialog; + private JButton closeButton; + + private void displayDialog(MainWindow mainWindow, + int nmbFiles, + int nmbLinks, + java.sql.Date dateSql) { + + String dateStr = null; + + if (dateSql != null) + dateStr = dateFormat.format(dateSql); + + if (dateStr == null && dateSql != null) + Logger.warning(this, "There is a date in the db, but I'm unable to print it"); + + if (dateStr == null) + dateStr = ""; + + + dialog = new JDialog(mainWindow.getMainFrame(), + I18n.getMessage("thaw.plugin.index.details")); + + dialog.getContentPane().setLayout(new BorderLayout(5, 5)); + + JPanel statPanel = new JPanel(new GridLayout(3, 2)); + + statPanel.add(new JLabel(I18n.getMessage("thaw.plugin.index.numberOfFiles"))); + statPanel.add(new JLabel(Integer.toString(nmbFiles), JLabel.RIGHT)); + + statPanel.add(new JLabel(I18n.getMessage("thaw.plugin.index.numberOfLinks"))); + statPanel.add(new JLabel(Integer.toString(nmbLinks), JLabel.RIGHT)); + + statPanel.add(new JLabel(I18n.getMessage("thaw.plugin.index.insertionDate"))); + statPanel.add(new JLabel(dateStr, JLabel.RIGHT)); + + dialog.getContentPane().add(statPanel, BorderLayout.CENTER); + + closeButton = new JButton(I18n.getMessage("thaw.common.ok")); + closeButton.addActionListener(this); + dialog.getContentPane().add(closeButton, BorderLayout.SOUTH); + + dialog.pack(); + + dialog.setVisible(true); + + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == closeButton) { + if (dialog != null) { + dialog.setVisible(false); + dialog = null; + } + } else { + super.actionPerformed(e); + } + } + + + public void apply() { + IndexTreeNode node = getTarget(); + + Hsqldb db = getIndexBrowserPanel().getDb(); + PreparedStatement st; + ResultSet rs; + + int nmbFilesInt = 0; + int nmbLinksInt = 0; + java.sql.Date insertionDate = null; + + synchronized(db.dbLock) { + try { + if (node instanceof IndexFolder) { + if (node instanceof IndexRoot) { + st = db.getConnection().prepareStatement("SELECT count(id) from files"); + rs = st.executeQuery(); + rs.next(); + nmbFilesInt = rs.getInt(1); + + st = db.getConnection().prepareStatement("SELECT count(id) from links"); + rs = st.executeQuery(); + rs.next(); + nmbLinksInt = rs.getInt(1); + } else { + st = db.getConnection().prepareStatement("SELECT count(id) "+ + "FROM files WHERE files.indexParent IN "+ + "(SELECT indexParents.indexId "+ + " FROM indexParents "+ + " WHERE indexParents.folderId = ?)"); + + st.setInt(1, node.getId()); + rs = st.executeQuery(); + rs.next(); + nmbFilesInt = rs.getInt(1); + + + st = db.getConnection().prepareStatement("SELECT count(id) "+ + "FROM links WHERE links.indexParent IN "+ + "(SELECT indexParents.indexId "+ + " FROM indexParents "+ + " WHERE indexParents.folderId = ?)"); + st.setInt(1, node.getId()); + rs = st.executeQuery(); + rs.next(); + nmbLinksInt = rs.getInt(1); + + } + + insertionDate = null; + + + } else if (node instanceof Index) { + nmbFilesInt = ((Index)node).getFileList(null, true).size(); + nmbLinksInt = ((Index)node).getLinkList(null, true).size(); + insertionDate = ((Index)node).getDate(); + + } + + } catch(SQLException e) { + Logger.error(this, "Exception while counting files/links : "+e.toString()); + return; + } + } + + displayDialog(getIndexBrowserPanel().getMainWindow(), + nmbFilesInt, nmbLinksInt, insertionDate); + } + } } From jflesch at freenetproject.org Tue Jul 3 15:24:49 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Tue, 3 Jul 2007 15:24:49 +0000 (UTC) Subject: [Thaw-dev] r13902 - in trunk/apps/Thaw/src/thaw: gui plugins plugins/index Message-ID: <20070703152449.371C14798E0@emu.freenetproject.org> Author: jflesch Date: 2007-07-03 15:24:49 +0000 (Tue, 03 Jul 2007) New Revision: 13902 Modified: trunk/apps/Thaw/src/thaw/gui/TabbedPane.java trunk/apps/Thaw/src/thaw/plugins/PeerMonitor.java trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java Log: Fix the warnings related to thaw.gui.TabbedPane Modified: trunk/apps/Thaw/src/thaw/gui/TabbedPane.java =================================================================== --- trunk/apps/Thaw/src/thaw/gui/TabbedPane.java 2007-07-03 15:22:46 UTC (rev 13901) +++ trunk/apps/Thaw/src/thaw/gui/TabbedPane.java 2007-07-03 15:24:49 UTC (rev 13902) @@ -43,12 +43,13 @@ if (x >= 0) tabNames.remove(x); else { - Logger.error(this, "remove(): Component not found ?"); - try { /* dirty way to have a trace back */ - throw new Exception("bleh"); - } catch(Exception e) { - e.printStackTrace(); - } + /* ConfigWindow is a little bit lazy : + * when you call ConfigWindow.addTabs(), + * it will first try to remove the tabs before readding them. + * This way, it's sure that there is not twice the tabs + */ + /* so this situation can be perfectly normal */ + Logger.debug(this, "remove(): Component not found ?"); } super.remove(panel); Modified: trunk/apps/Thaw/src/thaw/plugins/PeerMonitor.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/PeerMonitor.java 2007-07-03 15:22:46 UTC (rev 13901) +++ trunk/apps/Thaw/src/thaw/plugins/PeerMonitor.java 2007-07-03 15:24:49 UTC (rev 13902) @@ -121,7 +121,7 @@ public boolean stop() { - core.getMainWindow().removeTab(peerPanel.getTabPanel()); + hideTab(); core.getMainWindow().removeComponent(peerPanel.getPeerListPanel()); running = false; return false; @@ -139,18 +139,25 @@ } + private boolean tabVisible = false; + public void update(Observable o, Object param) { core.getMainWindow().addTab(I18n.getMessage("thaw.plugin.peerMonitor.peerMonitor"), thaw.gui.IconBox.peers, peerPanel.getTabPanel()); core.getMainWindow().setSelectedTab(peerPanel.getTabPanel()); + tabVisible = true; + peerPanel.showToolbarButtons(); } public void hideTab() { - peerPanel.hideToolbarButtons(); + if (tabVisible) { + peerPanel.hideToolbarButtons(); - core.getMainWindow().removeTab(peerPanel.getTabPanel()); + core.getMainWindow().removeTab(peerPanel.getTabPanel()); + tabVisible = false; + } } } Modified: trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java 2007-07-03 15:22:46 UTC (rev 13901) +++ trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java 2007-07-03 15:24:49 UTC (rev 13902) @@ -12,8 +12,8 @@ public class AutoRefresh implements Runnable, java.util.Observer { public final static boolean DEFAULT_ACTIVATED = true; - public final static int DEFAULT_INTERVAL = 300; - public final static int DEFAULT_INDEX_NUMBER = 20; + public final static int DEFAULT_INTERVAL = 150; + public final static int DEFAULT_INDEX_NUMBER = 10; private Hsqldb db; private IndexBrowserPanel browserPanel; Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-07-03 15:22:46 UTC (rev 13901) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-07-03 15:24:49 UTC (rev 13902) @@ -1708,7 +1708,7 @@ Logger.warning(this, "There is a date in the db, but I'm unable to print it"); if (dateStr == null) - dateStr = ""; + dateStr = I18n.getMessage("thaw.common.unknown");; dialog = new JDialog(mainWindow.getMainFrame(), From jflesch at freenetproject.org Fri Jul 6 16:33:04 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Fri, 6 Jul 2007 16:33:04 +0000 (UTC) Subject: [Thaw-dev] r13956 - in trunk/apps/Thaw/src/thaw: gui i18n plugins plugins/index plugins/transferLogs Message-ID: <20070706163304.0927747A241@emu.freenetproject.org> Author: jflesch Date: 2007-07-06 16:33:03 +0000 (Fri, 06 Jul 2007) New Revision: 13956 Added: trunk/apps/Thaw/src/thaw/plugins/transferLogs/ trunk/apps/Thaw/src/thaw/plugins/transferLogs/Transfer.java trunk/apps/Thaw/src/thaw/plugins/transferLogs/TransferManagementHelper.java trunk/apps/Thaw/src/thaw/plugins/transferLogs/TransferTable.java Modified: trunk/apps/Thaw/src/thaw/gui/Table.java trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties trunk/apps/Thaw/src/thaw/i18n/thaw.properties trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties trunk/apps/Thaw/src/thaw/plugins/TransferLogs.java trunk/apps/Thaw/src/thaw/plugins/TrayIcon.java trunk/apps/Thaw/src/thaw/plugins/index/FileManagementHelper.java trunk/apps/Thaw/src/thaw/plugins/index/Index.java trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java Log: Rewrite of the transferlogs plugin : better UI ; page per page display Modified: trunk/apps/Thaw/src/thaw/gui/Table.java =================================================================== --- trunk/apps/Thaw/src/thaw/gui/Table.java 2007-07-06 16:15:16 UTC (rev 13955) +++ trunk/apps/Thaw/src/thaw/gui/Table.java 2007-07-06 16:33:03 UTC (rev 13956) @@ -14,6 +14,7 @@ import javax.swing.JProgressBar; import javax.swing.JTextArea; import javax.swing.JLabel; +import javax.swing.JPanel; import java.awt.Color; import java.awt.Component; import javax.swing.ImageIcon; @@ -44,8 +45,6 @@ private boolean hasChanged = false; private Thread savingThread; - private int columnWithKeys = -1; - private boolean statusInProgressBars = true; public Table(Config config, String prefix) { @@ -104,16 +103,19 @@ setAsListener(); } + private DefaultRenderer renderer; + public void specifyColumnWithKeys(int c) { - columnWithKeys = c; + renderer.specifyColumnWithKeys(c); } public void showStatusInProgressBars(boolean v) { - statusInProgressBars = v; + renderer.showStatusInProgressBars(v); } public void setDefaultRenderer() { - setDefaultRenderer(getColumnClass(0), new DefaultRenderer()); + renderer = new DefaultRenderer(); + setDefaultRenderer(getColumnClass(0), renderer); } @@ -149,22 +151,33 @@ - protected class DefaultRenderer extends DefaultTableCellRenderer { + public static class DefaultRenderer extends DefaultTableCellRenderer { private final static long serialVersionUID = 20060821; + private boolean statusInProgressBars = true; + private int columnWithKeys = -1; + private Color softGray; + public DefaultRenderer() { softGray = new Color(240,240,240); } - public Component getTableCellRendererComponent(final JTable table, final Object value, + public void showStatusInProgressBars(boolean v) { + statusInProgressBars = v; + } + + public void specifyColumnWithKeys(int c) { + columnWithKeys = c; + } + + public Component getTableCellRendererComponent(final JTable table, Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) { if (value == null) - return super.getTableCellRendererComponent(table, "", - isSelected, hasFocus, row, column); + value = ""; if (value instanceof FCPTransferQuery) { final FCPTransferQuery query = (FCPTransferQuery)value; @@ -176,7 +189,9 @@ Component cell; if (value instanceof ImageIcon) { - cell = new JLabel(((ImageIcon)value)); + return new JLabel(((ImageIcon)value)); + } if (value instanceof JPanel) { + cell = (Component)value; } else if(value instanceof Long) { cell = super.getTableCellRendererComponent(table, @@ -189,8 +204,8 @@ area.setLineWrap(true); area.setWrapStyleWord(true); - if (getRowHeight(row) < area.getPreferredSize().getHeight()) - setRowHeight((int)area.getPreferredSize().getHeight()); + if (table.getRowHeight(row) < area.getPreferredSize().getHeight()) + table.setRowHeight((int)area.getPreferredSize().getHeight()); cell = area; Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-06 16:15:16 UTC (rev 13955) +++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-06 16:33:03 UTC (rev 13956) @@ -36,6 +36,10 @@ thaw.common.localPath=Chemin local thaw.common.priority=Priorit? + +# for page per page +thaw.common.page=Page + thaw.common.try=Essai thaw.common.key=Clef @@ -479,18 +483,21 @@ thaw.plugin.transferLogs.copyKey=Copier les clefs li?es aux entr?es s?lectionn?es thaw.plugin.transferLogs.date=Date +thaw.plugin.transferLogs.dates=Date(s) +thaw.plugin.transferLogs.dateStart=D?marr? le: +thaw.plugin.trasnferLogs.dateEnd=Fini le: thaw.plugin.transferLogs.message=Message thaw.plugin.transferLogs.key=Clef +thaw.plugin.transferLogs.file=Fichier +thaw.plugin.transferLogs.fileSize=Taille +thaw.plugin.transferLogs.isSuccess=R?ussi +thaw.plugin.transferLogs.averageSpeed=Vitesse moyenne thaw.plugin.transferLogs.isDup=Est-ce que la clef a d?j? ?t? vue ? -thaw.plugin.transferLogs.download.added=T?l?chargement ajout? -thaw.plugin.transferLogs.download.failed=T?l?chargement ?chou? -thaw.plugin.transferLogs.download.successful=T?l?chargement r?ussi +thaw.plugin.transferLogs.type=Type +thaw.plugin.transferLogs.type.download=T?l?chargement +thaw.plugin.transferLogs.type.insertion=Insertion -thaw.plugin.transferLogs.insertion.added=Insertion ajout?e -thaw.plugin.transferLogs.insertion.failed=Insertion ?chou?e -thaw.plugin.transferLogs.insertion.successful=Insertion r?ussie - thaw.plugin.transferLogs.finalStatus=Status final thaw.plugin.transferLogs.none=(aucune) Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-06 16:15:16 UTC (rev 13955) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-06 16:33:03 UTC (rev 13956) @@ -57,6 +57,9 @@ thaw.common.no=No thaw.common.priority=Priority +# for page per page +thaw.common.page=Page + thaw.common.clearFinished=Remove finished transfers # The following one *must* specify that this is about the transfer(s) only ! thaw.common.removeFromTheList=Cancel and remove selected transfers @@ -492,19 +495,21 @@ thaw.plugin.transferLogs.copyKey=Copy the keys related to the selected entries thaw.plugin.transferLogs.date=Date +thaw.plugin.transferLogs.dates=Date(s) +thaw.plugin.transferLogs.dateStart=Started: +thaw.plugin.transferLogs.dateEnd=Ended: thaw.plugin.transferLogs.message=Message thaw.plugin.transferLogs.key=Key +thaw.plugin.transferLogs.file=File +thaw.plugin.transferLogs.fileSize=File size +thaw.plugin.transferLogs.isSuccess=Successful +thaw.plugin.transferLogs.averageSpeed=Average speed thaw.plugin.transferLogs.isDup=has the key already been seen ? -thaw.plugin.transferLogs.download.added=Download added -thaw.plugin.transferLogs.download.failed=Download failed -thaw.plugin.transferLogs.download.successful=Download successful +thaw.plugin.transferLogs.type=Type +thaw.plugin.transferLogs.type.download=Download +thaw.plugin.transferLogs.type.insertion=Insertion -thaw.plugin.transferLogs.insertion.added=Insertion added -thaw.plugin.transferLogs.insertion.failed=Insertion failed -thaw.plugin.transferLogs.insertion.successful=Insertion successful - -thaw.plugin.transferLogs.finalStatus=Final status thaw.plugin.transferLogs.none=(none) thaw.plugin.transferLogs.importKeys=Import key list Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-06 16:15:16 UTC (rev 13955) +++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-06 16:33:03 UTC (rev 13956) @@ -36,6 +36,10 @@ thaw.common.localPath=Chemin local thaw.common.priority=Priorit\u00e9 + +# for page per page +thaw.common.page=Page + thaw.common.try=Essai thaw.common.key=Clef @@ -479,18 +483,21 @@ thaw.plugin.transferLogs.copyKey=Copier les clefs li\u00e9es aux entr\u00e9es s\u00e9lectionn\u00e9es thaw.plugin.transferLogs.date=Date +thaw.plugin.transferLogs.dates=Date(s) +thaw.plugin.transferLogs.dateStart=D\u00e9marr\u00e9 le: +thaw.plugin.trasnferLogs.dateEnd=Fini le: thaw.plugin.transferLogs.message=Message thaw.plugin.transferLogs.key=Clef +thaw.plugin.transferLogs.file=Fichier +thaw.plugin.transferLogs.fileSize=Taille +thaw.plugin.transferLogs.isSuccess=R\u00e9ussi +thaw.plugin.transferLogs.averageSpeed=Vitesse moyenne thaw.plugin.transferLogs.isDup=Est-ce que la clef a d\u00e9j\u00e0 \u00e9t\u00e9 vue ? -thaw.plugin.transferLogs.download.added=T\u00e9l\u00e9chargement ajout\u00e9 -thaw.plugin.transferLogs.download.failed=T\u00e9l\u00e9chargement \u00e9chou\u00e9 -thaw.plugin.transferLogs.download.successful=T\u00e9l\u00e9chargement r\u00e9ussi +thaw.plugin.transferLogs.type=Type +thaw.plugin.transferLogs.type.download=T\u00e9l\u00e9chargement +thaw.plugin.transferLogs.type.insertion=Insertion -thaw.plugin.transferLogs.insertion.added=Insertion ajout\u00e9e -thaw.plugin.transferLogs.insertion.failed=Insertion \u00e9chou\u00e9e -thaw.plugin.transferLogs.insertion.successful=Insertion r\u00e9ussie - thaw.plugin.transferLogs.finalStatus=Status final thaw.plugin.transferLogs.none=(aucune) Modified: trunk/apps/Thaw/src/thaw/plugins/TransferLogs.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/TransferLogs.java 2007-07-06 16:15:16 UTC (rev 13955) +++ trunk/apps/Thaw/src/thaw/plugins/TransferLogs.java 2007-07-06 16:33:03 UTC (rev 13956) @@ -45,13 +45,19 @@ import thaw.fcp.FCPTransferQuery; import thaw.fcp.FreenetURIHelper; +import thaw.plugins.transferLogs.*; -/** - * Quick and dirty plugin to log the transfers - */ + public class TransferLogs implements Plugin, ActionListener, Observer { - public final static String MAX_DISPLAYED = "1000"; + public final static byte TRANSFER_TYPE_NULL = 0; + public final static byte TRANSFER_TYPE_DOWNLOAD = 1; + public final static byte TRANSFER_TYPE_INSERTION = 2; + public final static String[] TRANSFER_TYPE_NAMES = { + I18n.getMessage("thaw.plugin.transferLogs.importedKey"), + I18n.getMessage("thaw.common.download"), + I18n.getMessage("thaw.common.insertion") + }; private Core core; private Hsqldb db; @@ -60,15 +66,12 @@ private JButton purgeLogs; - private JButton copyKey; private JButton importKeys; private JButton exportKeys; + private TransferTable table; - private Table table; - private EventListModel model; - public TransferLogs() { } @@ -102,19 +105,18 @@ JLabel topLabel = new JLabel(I18n.getMessage("thaw.plugin.transferLogs.transferLogs")); topLabel.setIcon(IconBox.file); - model = new EventListModel(); - model.reloadList(); - table = new Table(core.getConfig(), "transfer_log_table", - model); + table = new TransferTable(db, core.getConfig()); - purgeLogs = new JButton(I18n.getMessage("thaw.plugin.transferLogs.purgeLogs"), IconBox.minDelete); - copyKey = new JButton(I18n.getMessage("thaw.plugin.transferLogs.copyKey"), IconBox.minCopy ); - importKeys = new JButton(I18n.getMessage("thaw.plugin.transferLogs.importKeys"), IconBox.minImportAction); - exportKeys = new JButton(I18n.getMessage("thaw.plugin.transferLogs.exportKeys"), IconBox.minExportAction); + purgeLogs = new JButton(I18n.getMessage("thaw.plugin.transferLogs.purgeLogs"), + IconBox.minDelete); + importKeys = new JButton(I18n.getMessage("thaw.plugin.transferLogs.importKeys"), + IconBox.minImportAction); + exportKeys = new JButton(I18n.getMessage("thaw.plugin.transferLogs.exportKeys"), + IconBox.minExportAction); + purgeLogs.addActionListener(this); - copyKey.addActionListener(this); importKeys.addActionListener(this); exportKeys.addActionListener(this); @@ -123,17 +125,16 @@ buttonPanel.add(purgeLogs); buttonPanel.add(importKeys); buttonPanel.add(exportKeys); - buttonPanel.add(copyKey); JPanel southPanel = new JPanel(new BorderLayout()); southPanel.add(buttonPanel, BorderLayout.WEST); southPanel.add(new JLabel(""), BorderLayout.CENTER); tab.add(topLabel, BorderLayout.NORTH); - tab.add(new JScrollPane(table), BorderLayout.CENTER); + tab.add(table.getPanel(), BorderLayout.CENTER); tab.add(southPanel, BorderLayout.SOUTH); - setAsObserverEverywhere(true); + setAsObserverEverywhere(); core.getMainWindow().addTab(I18n.getMessage("thaw.plugin.transferLogs.transferLogsShort"), thaw.gui.IconBox.file, @@ -145,8 +146,12 @@ public boolean stop() { core.getMainWindow().removeTab(tab); - setAsObserverEverywhere(false); + core.getQueueManager().deleteObserver(this); + /* TODO : delete observers ! */ + /* Hm should we ? Just remove the observer on the queue should be enought ? */ + /* Others observers will just keep data sync ? */ + db.unregisterChild(this); return false; @@ -164,21 +169,44 @@ protected void createTables() { - /* - * this db structure is dirty, I know it, and at the moment, - * I don't care => I will fix it later - */ - sendQuery("CREATE CACHED TABLE transferEvents (" + sendQuery("CREATE CACHED TABLE transferLogs (" + "id INTEGER IDENTITY NOT NULL," - + "date TIMESTAMP NOT NULL," - + "msg VARCHAR(500) NOT NULL," + + "dateStart TIMESTAMP NOT NULL," + + "dateEnd TIMESTAMP NULL," + + "transferType TINYINT NOT NULL," + "key VARCHAR(500) NULL," + + "filename VARCHAR(128) NULL, " + + "size BIGINT NULL, " /* long */ + "isDup BOOLEAN NOT NULL, " + "isSuccess BOOLEAN NOT NULL, " + "PRIMARY KEY (id))"); } + protected boolean isDup(String key) { + return isDup(db, key); + } + public static boolean isDup(Hsqldb db, String key) { + try { + synchronized(db.dbLock) { + + PreparedStatement st; + + st = db.getConnection().prepareStatement("SELECT id FROM transferEvents "+ + "WHERE LOWER(key) LIKE ? AND isSuccess = TRUE"); + st.setString(1, FreenetURIHelper.getComparablePart(key)+"%"); + ResultSet set = st.executeQuery(); + return set.next(); + + } + } catch(SQLException e) { + Logger.error(new TransferLogs(), "Unable to know if a key is dup in the event because : "+e.toString()); + } + + return false; + } + + /** * Returns no error / Throws no exception. * @return false if an exception happened @@ -198,174 +226,30 @@ /** * Add the current plugin as an observer on all the running query - * @param really if set to false, will deleteObserver() instead of addObserver() */ - public void setAsObserverEverywhere(boolean really) { - if (really) - core.getQueueManager().addObserver(this); - else - core.getQueueManager().deleteObserver(this); - - + public void setAsObserverEverywhere() { Vector runningQueue = core.getQueueManager().getRunningQueue(); synchronized(runningQueue) { for (Iterator it = runningQueue.iterator(); it.hasNext();) { FCPTransferQuery query = (FCPTransferQuery)it.next(); - - if (really) { - if (query.isFinished() && !isDup(query.getFileKey())) - notifyEnd(query); - - if (query instanceof Observable) - ((Observable)query).addObserver(this); - } else { - if (query instanceof Observable) - ((Observable)query).deleteObserver(this); - } + notifyAddition(query); } - } - } - - protected boolean isDup(String key) { - try { - synchronized(db.dbLock) { - - PreparedStatement st; - - st = db.getConnection().prepareStatement("SELECT id FROM transferEvents "+ - "WHERE LOWER(key) LIKE ? AND isSuccess = TRUE"); - st.setString(1, FreenetURIHelper.getComparablePart(key)+"%"); - ResultSet set = st.executeQuery(); - return set.next(); - - } - } catch(SQLException e) { - Logger.error(this, "Unable to know if a key is dup in the event because : "+e.toString()); + core.getQueueManager().addObserver(this); } - - return false; } - protected void notifyAddition(FCPTransferQuery query) { - String str; - String key; - if (query.getQueryType() == 0) - return; - - if (query.getQueryType() == 1) { - str = I18n.getMessage("thaw.plugin.transferLogs.download.added") + " : " - + query.getFilename(); - key = query.getFileKey(); - } else { - if (query.getPath() == null) - return; - - str = I18n.getMessage("thaw.plugin.transferLogs.insertion.added") + " : " - + query.getPath(); - key = null; - } - - java.sql.Timestamp date = new java.sql.Timestamp((new java.util.Date()).getTime()); - - boolean isDup; - - if (key != null) - isDup = isDup(key); - else - isDup = false; - - try { - synchronized(db.dbLock) { - PreparedStatement st; - - - st = db.getConnection().prepareStatement("INSERT INTO transferEvents "+ - "(date, msg, key, isDup, isSuccess) "+ - " VALUES "+ - "(?, ?, ?, ?, FALSE)"); - st.setTimestamp(1, date); - st.setString(2, str); - st.setString(3, key); - st.setBoolean(4, isDup); - - st.execute(); - } - } catch(SQLException e) { - Logger.error(this, "Error while adding an event to the logs: "+e.toString()); - } - - model.reloadList(); + protected void notifyAddition(FCPTransferQuery query) { + new Transfer(db, query, table); + table.refresh(); } - protected void notifyEnd(FCPTransferQuery query) { - String str; - String key; - if (query.isFinished() && query instanceof Observable) - ((Observable)query).deleteObserver(this); - - if (query.getQueryType() == 0 || !query.isFinished()) - return; - - if (query.getQueryType() == 1) - str = "thaw.plugin.transferLogs.download."; - else - str = "thaw.plugin.transferLogs.insertion."; - - if (query.isSuccessful()) - str = I18n.getMessage(str+"successful"); - else - str = I18n.getMessage(str+"failed"); - - key = query.getFileKey(); - - str += " : "+query.getFilename(); - - str += "\n" + I18n.getMessage("thaw.plugin.transferLogs.finalStatus") + " : "+query.getStatus(); - - boolean isDup; - boolean isSuccess = query.isSuccessful(); - - if (key != null) - isDup = isDup(key); - else - isDup = false; - - java.sql.Timestamp date = new java.sql.Timestamp((new java.util.Date()).getTime()); - - - try { - synchronized(db.dbLock) { - PreparedStatement st; - - - st = db.getConnection().prepareStatement("INSERT INTO transferEvents "+ - "(date, msg, key, isDup, isSuccess) "+ - " VALUES "+ - "(?, ?, ?, ?, ?)"); - st.setTimestamp(1, date); - st.setString(2, str); - st.setString(3, key); - st.setBoolean(4, isDup); - st.setBoolean(5, isSuccess); - - st.execute(); - } - } catch(SQLException e) { - Logger.error(this, "Error while adding an event to the logs: "+e.toString()); - } - - - model.reloadList(); - } - - public void update(Observable o, Object param) { if (o instanceof FCPQueueManager) { @@ -378,167 +262,15 @@ if(core.getQueueManager().isInTheQueues(query) && query.isRunning()) { // then it's an addition - if (query instanceof Observable) - ((Observable)query).addObserver(this); - if (core.getQueueManager().isQueueCompletlyLoaded()) - notifyAddition(query); + notifyAddition(query); return; } } - - if (o instanceof FCPTransferQuery) { - FCPTransferQuery query = (FCPTransferQuery)o; - - if (query.isFinished()) { - notifyEnd(query); - return; - } - } } - private class Event { - private java.sql.Timestamp date; - private String msg; - private String key; - private boolean isDup; - public Event(java.sql.Timestamp date, String message, String key, boolean isDup) { - this.date = date; - this.msg = message; - this.key = key; - this.isDup = isDup; - } - - public java.sql.Timestamp getDate() { - return date; - } - - public String getMsg() { - return msg; - } - - public String getKey() { - return key; - } - - public boolean isDup() { - return isDup; - } - } - - private class EventListModel extends javax.swing.table.AbstractTableModel { - private static final long serialVersionUID = 1L; - - private DateFormat dateFormat; - - public String[] columnNames = - { - I18n.getMessage("thaw.plugin.transferLogs.date"), - I18n.getMessage("thaw.plugin.transferLogs.message"), - I18n.getMessage("thaw.plugin.transferLogs.key"), - I18n.getMessage("thaw.plugin.transferLogs.isDup") - }; - - - public Vector events = null; /* thaw.plugins.index.File Vector */ - - - public EventListModel() { - super(); - dateFormat = DateFormat.getDateTimeInstance(); - } - - public void reloadList() { - events = null; - - try { - synchronized(db.dbLock) { - PreparedStatement st; - - st = db.getConnection().prepareStatement("SELECT date, msg, key, isDup FROM "+ - "transferEvents ORDER BY date DESC LIMIT "+MAX_DISPLAYED); - - ResultSet set = st.executeQuery(); - - events = new Vector(); - - while(set.next()) { - events.add(new Event(set.getTimestamp("date"), - set.getString("msg"), - set.getString("key"), - set.getBoolean("isDup"))); - } - } - } catch(SQLException e) { - Logger.error(this, "Error while getting the list of events from the logs: "+e.toString()); - } - - refresh(); - } - - - protected void refresh() { - final TableModelEvent event = new TableModelEvent(this); - fireTableChanged(event); - } - - public int getRowCount() { - if (events == null) - return 0; - - return events.size(); - } - - public int getColumnCount() { - return columnNames.length; - } - - public String getColumnName(final int column) { - return columnNames[column]; - - } - - public Object getValueAt(final int row, final int column) { - if (events == null) - return null; - - if (column == 0) - return dateFormat.format(((Event)events.get(row)).getDate()); - - if (column == 1) - return ((Event)events.get(row)).getMsg(); - - if (column == 2) { - String key = ((Event)events.get(row)).getKey(); - return key != null ? key : I18n.getMessage("thaw.plugin.transferLogs.none"); - } - - if (column == 3) - return ((Event)events.get(row)).isDup() ? "X" : ""; - - return null; - } - - - public Vector getSelectedRows(Table table) { - int[] selectedRows = table.getSelectedRows(); - - if (selectedRows == null) - return null; - - Vector r = new Vector(); - - for (int i = 0 ; i < selectedRows.length ; i++) { - r.add(events.get(selectedRows[i])); - } - - return r; - } - } - - private File chooseFile(boolean save) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle(I18n.getMessage("thaw.plugin.transferLogs.chooseFile")); @@ -549,11 +281,16 @@ } + public static java.sql.Timestamp getNow() { + return new java.sql.Timestamp((new java.util.Date()).getTime()); + } + + private class KeyImporter implements Runnable { public KeyImporter() { } public void run() { - java.sql.Timestamp date = new java.sql.Timestamp((new java.util.Date()).getTime()); + java.sql.Timestamp date = getNow(); File file = chooseFile(false); @@ -569,6 +306,18 @@ String strLine; + PreparedStatement st = null; + + try { + st = db.getConnection().prepareStatement("INSERT INTO transferLogs "+ + "(dateStart, dateEnd, transferType,"+ + " key, filename, size, isDup, isSuccess) "+ + " VALUES "+ + "(?, ?, 0, ?, ?, NULL, ?, TRUE)"); + } catch(SQLException e) { + Logger.error(this, "Error while preparing to import keys : "+e.toString()); + } + while ((strLine = br.readLine()) != null) { String key = strLine.trim(); @@ -576,21 +325,14 @@ continue; boolean isDup = isDup(key); - String str = I18n.getMessage("thaw.plugin.transferLogs.importedKey") - + " : "+FreenetURIHelper.getFilenameFromKey(key); try { synchronized(db.dbLock) { - PreparedStatement st; - - st = db.getConnection().prepareStatement("INSERT INTO transferEvents "+ - "(date, msg, key, isDup, isSuccess) "+ - " VALUES "+ - "(?, ?, ?, ?, FALSE)"); st.setTimestamp(1, date); - st.setString(2, str); + st.setTimestamp(2, date); st.setString(3, key); - st.setBoolean(4, isDup); + st.setString(4, FreenetURIHelper.getFilenameFromKey(key)); + st.setBoolean(5, isDup); st.execute(); } @@ -607,7 +349,7 @@ Logger.error(this, "(2) Unable to import keys because: "+e.toString()); } - model.reloadList(); + table.refresh(); } } @@ -628,8 +370,9 @@ PreparedStatement st; st = db.getConnection().prepareStatement("SELECT DISTINCT key "+ - "FROM transferEvents "+ - "WHERE key is NOT NULL"); + "FROM transferLogs "+ + "WHERE key is NOT NULL"+ + " AND isSuccess = TRUE"); ResultSet set = st.executeQuery(); @@ -657,35 +400,15 @@ if (e.getSource() == purgeLogs) { sendQuery("DROP TABLE transferEvents"); + sendQuery("DROP TABLE transferLogs"); createTables(); - model.reloadList(); + table.refresh(); return; } - if (e.getSource() == copyKey) { - Vector v = model.getSelectedRows(table); - if (v == null) - return; - - String str = ""; - - for (Iterator it = v.iterator(); - it.hasNext();) { - String key = ((Event)it.next()).getKey(); - - if (key != null) - str += key + "\n"; - } - - GUIHelper.copyToClipboard(str); - - return; - } - - if (e.getSource() == importKeys) { Thread th = new Thread(new KeyImporter()); th.start(); Modified: trunk/apps/Thaw/src/thaw/plugins/TrayIcon.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/TrayIcon.java 2007-07-06 16:15:16 UTC (rev 13955) +++ trunk/apps/Thaw/src/thaw/plugins/TrayIcon.java 2007-07-06 16:33:03 UTC (rev 13956) @@ -41,7 +41,7 @@ private JDialog dialog; private JButton closeDialog; - public final static int DIALOG_X = 300; + public final static int DIALOG_X = 400; public final static int DIALOG_Y = 500; Modified: trunk/apps/Thaw/src/thaw/plugins/index/FileManagementHelper.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/FileManagementHelper.java 2007-07-06 16:15:16 UTC (rev 13955) +++ trunk/apps/Thaw/src/thaw/plugins/index/FileManagementHelper.java 2007-07-06 16:33:03 UTC (rev 13956) @@ -21,7 +21,7 @@ public class FileManagementHelper { /** - * Class implementing IndexAction will automatically do an addActionListener if necessary + * Class implementing FileAction will automatically do an addActionListener if necessary */ public interface FileAction extends ActionListener { Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-07-06 16:15:16 UTC (rev 13955) +++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-07-06 16:33:03 UTC (rev 13956) @@ -786,8 +786,6 @@ return 0; } - Logger.info(this, "Getting lastest version ..."); - String key; if (specificRev >= 0) { Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-07-06 16:15:16 UTC (rev 13955) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-07-06 16:33:03 UTC (rev 13956) @@ -1306,7 +1306,7 @@ JLabel header = null; JPanel buttonPanel = null; - frame = new JDialog(getIndexBrowserPanel().getMainWindow().getMainFrame(), I18n.getMessage("thaw.plugins.index.addKeys")); + frame = new JDialog(getIndexBrowserPanel().getMainWindow().getMainFrame(), I18n.getMessage("thaw.plugin.index.addKeys")); frame.setVisible(false); header = new JLabel(I18n.getMessage("thaw.plugin.fetch.keyList")); Added: trunk/apps/Thaw/src/thaw/plugins/transferLogs/Transfer.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/transferLogs/Transfer.java (rev 0) +++ trunk/apps/Thaw/src/thaw/plugins/transferLogs/Transfer.java 2007-07-06 16:33:03 UTC (rev 13956) @@ -0,0 +1,427 @@ +package thaw.plugins.transferLogs; + +import java.sql.*; + +import java.util.Observer; +import java.util.Observable; + + +import thaw.core.Logger; + +import thaw.fcp.FCPTransferQuery; +import thaw.fcp.FCPClientPut; +import thaw.fcp.FCPClientGet; +import thaw.fcp.FreenetURIHelper; + +import thaw.plugins.Hsqldb; +import thaw.plugins.TransferLogs; + + +public class Transfer implements Observer { + private Hsqldb db; + + private FCPTransferQuery query; + + private int id; + + private Timestamp dateStart; + private Timestamp dateEnd; + private byte transferType; + private String key; + private String filename; + private long size; + private boolean isDup; + private boolean isSuccess; + + private TransferTable table; + + + public Transfer(Hsqldb db, + FCPTransferQuery query, + TransferTable table) { + this.db = db; + this.query = query; + this.id = -1; + this.table = table; + + + if (!findOrInsertEntry(query)) + findOrInsertEntry(query); /* because we need the id of the entry */ + + if (!query.isFinished() + && query instanceof Observable) { + ((Observable)query).addObserver(this); + } + } + + + /** + * If found, return true, if inserted returns false. + * If found, but some informations in the bdd is not correct, it's updated. + */ + private boolean findOrInsertEntry(FCPTransferQuery query) { + boolean entryFound; + + entryFound = false; + + Logger.info(this, "Searching corresponding query in the logs ..."); + + synchronized(db.dbLock) { + try { + PreparedStatement st; + + String qKey = query.getFileKey(); + + if (qKey == null || !FreenetURIHelper.isAKey(qKey)) + qKey = null; + + /* by key first */ + + if (qKey != null) { + + st = db.getConnection().prepareStatement("SELECT id, dateStart, dateEnd, "+ + "transferType, "+ + "key, filename, size, isDup, isSuccess "+ + "FROM transferLogs "+ + "WHERE key LIKE ? AND dateEnd IS NULL "+ + "ORDER BY dateStart DESC "+ + "LIMIT 1"); + st.setString(1, FreenetURIHelper.getComparablePart(qKey)+"%"); + + ResultSet set = st.executeQuery(); + + if (set.next()) { + entryFound = true; + this.id = set.getInt("id"); + this.dateStart = set.getTimestamp("dateStart"); + this.dateEnd = set.getTimestamp("dateEnd"); + this.transferType = set.getByte("transferType"); + this.key = set.getString("key"); + this.filename = set.getString("filename"); + this.size = set.getLong("size"); + this.isDup = set.getBoolean("isDup"); + this.isSuccess = set.getBoolean("isSuccess"); + } + } + + + /* by filename else */ + + String filename = query.getFilename(); + + if (filename != null && entryFound == false) { + st = db.getConnection().prepareStatement("SELECT id, dateStart, dateEnd, "+ + "transferType, "+ + "key, filename, size, isDup, isSuccess "+ + "FROM transferLogs "+ + "WHERE filename = ? AND dateEnd IS NULL "+ + "ORDER BY dateStart DESC "+ + "LIMIT 1"); + st.setString(1, filename); + + ResultSet set = st.executeQuery(); + + if (set.next()) { + entryFound = true; + this.id = set.getInt("id"); + this.dateStart = set.getTimestamp("dateStart"); + this.dateEnd = set.getTimestamp("dateEnd"); + this.transferType = set.getByte("transferType"); + this.key = set.getString("key"); + this.filename = set.getString("filename"); + this.size = set.getLong("size"); + this.isDup = set.getBoolean("isDup"); + this.isSuccess = set.getBoolean("isSuccess"); + } + } + + + if (qKey == null && filename == null) { /* this query would be useless ?! */ + Logger.warning(this, "Query with filename & key == null ? can do nothing with that"); + return false; + } + + + if (entryFound) { /* we check if we must update the entry */ + boolean mustUpdateKey = false; + boolean mustUpdateDateEnd = false; + boolean mustUpdateSize = false; + + if (this.key == null && qKey != null) + mustUpdateKey = true; + + if (qKey == null && this.key != null) + qKey = this.key; + + if (qKey != null && this.key != null + && !qKey.equals(this.key)) /* the key has changed ? can it happen ? */ + mustUpdateKey = true; + + if (query.isFinished() && this.dateEnd == null) + mustUpdateDateEnd = true; + + if (query.getFileSize() >= 0 + && query.getFileSize() >= size) + mustUpdateSize = true; + + + if (mustUpdateKey) { + updateKey(qKey); + } + + + if (mustUpdateDateEnd) { + updateDateEnd(query.isSuccessful()); + } + + if (mustUpdateSize) { + updateSize(query.getFileSize()); + } + + } else { /* we insert a new one */ + /* except if this query has already ended, because it means we weren't + * used for this job, so we won't move :P */ + if (query.isFinished()) + return false; + + /* the main problem here is that when we insert a data + * hsqldb is not able to give us back the primary key generated + * so when this function will return false (no entry found => inserted), + * the constructor will call it again to find the primary key + */ + + Timestamp now = TransferLogs.getNow(); + + st = db.getConnection().prepareStatement("INSERT INTO transferLogs "+ + "(dateStart, dateEnd, transferType, "+ + " key, filename, size, isDup, isSuccess) "+ + "VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); + st.setTimestamp(1, now); + + if (query.isFinished()) + st.setTimestamp(2, now); + else + st.setNull(2, Types.TIMESTAMP); + + if (query instanceof FCPClientPut) + st.setByte(3, TransferLogs.TRANSFER_TYPE_INSERTION); + else + st.setByte(3, TransferLogs.TRANSFER_TYPE_DOWNLOAD); + + if (qKey != null) + st.setString(4, qKey); + else + st.setNull(4, Types.VARCHAR); + + st.setString(5, filename); + st.setLong(6, query.getFileSize()); + st.setBoolean(7, TransferLogs.isDup(db, query.getFileKey())); + st.setBoolean(8, query.isFinished() && query.isSuccessful()); + st.execute(); + } + + + } catch(SQLException e) { + Logger.error(this, + "Error while trying to find a specific "+ + "entry in the log: "+e.toString()); + } + } + + if (entryFound) + Logger.info(this, "Entry found"); + else + Logger.info(this, "Entry added"); + + return entryFound; + } + + + private void updateKey(String qKey) { + Logger.info(this, "Updating key in logs"); + try { + PreparedStatement st = db.getConnection().prepareStatement("UPDATE transferLogs SET "+ + "key = ? WHERE id = ?"); + st.setString(1, qKey); + st.setInt(2, this.id); + st.execute(); + } catch(SQLException e) { + Logger.error(this, "Unable to update key in transfer logs because : "+e.toString()); + } + } + + private void updateSize(long size) { + Logger.info(this, "Updating file size in logs"); + + try { + PreparedStatement st = db.getConnection().prepareStatement("UPDATE transferLogs SET "+ + "size = ? WHERE id = ?"); + st.setLong(1, size); + st.setInt(2, this.id); + st.execute(); + } catch(SQLException e) { + Logger.error(this, "Unable to update size in transfer logs because : "+e.toString()); + } + } + + + private void updateDateEnd(boolean success) { + Logger.info(this, "Updating end date in logs"); + + try { + PreparedStatement st = db.getConnection().prepareStatement("UPDATE transferLogs SET "+ + "dateEnd = ?, isSuccess = ? "+ + "WHERE id = ?"); + st.setTimestamp(1, TransferLogs.getNow()); + st.setBoolean(2, success); + st.setInt(3, this.id); + st.execute(); + } catch(SQLException e) { + Logger.error(this, "Unable to update dateEnd in transfer logs because : "+e.toString()); + } + } + + + public Transfer(Hsqldb db, + int id, + Timestamp dateStart, Timestamp dateEnd, + byte transferType, String key, String filename, long size, + boolean isDup, boolean isSuccess) { + this.db = db; + this.id = id; + this.dateStart = dateStart; + this.dateEnd = dateEnd; + this.transferType = transferType; + this.key = key; + this.filename = filename; + this.size = size; + this.isDup = isDup; + this.isSuccess = isSuccess; + } + + + public Timestamp getDateStart() { + return dateStart; + } + + public Timestamp getDateEnd() { + return dateEnd; + } + + public byte getTransferTypeByte() { + return transferType; + } + + public String getTransferTypeStr() { + return TransferLogs.TRANSFER_TYPE_NAMES[transferType]; + } + + public String getKey() { + return key; + } + + public String getFilename() { + return filename; + } + + public long getSize() { + return size; + } + + public boolean isDup() { + return isDup; + } + + public boolean isSuccess() { + retur