From jflesch at freenetproject.org Mon Sep 3 20:20:11 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Mon, 3 Sep 2007 20:20:11 +0000 (UTC) Subject: [Thaw-dev] r14943 - in trunk/apps/Thaw/src/thaw/plugins: index miniFrost miniFrost/frostKSK Message-ID: <20070903202011.BE770479F2E@freenetproject.org> Author: jflesch Date: 2007-09-03 20:20:11 +0000 (Mon, 03 Sep 2007) New Revision: 14943 Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoardFactory.java Log: Don't force the download of the latest version of an index if comments are not activated Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-09-03 06:21:21 UTC (rev 14942) +++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-09-03 20:20:11 UTC (rev 14943) @@ -954,7 +954,8 @@ parser.loadXML(path); - if (!fetchingNegRev && mustFetchNegRev) { + if (!fetchingNegRev && mustFetchNegRev + && getCommentPublicKey() != null) { final java.io.File fl = new java.io.File(path); fl.delete(); Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-09-03 06:21:21 UTC (rev 14942) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-09-03 20:20:11 UTC (rev 14943) @@ -400,8 +400,10 @@ if (Index.isAlreadyKnown(indexBrowser.getDb(), publicKey, true) >= 0) { String name = FreenetURIHelper.getFilenameFromKey(publicKey); - if (name != null) + if (name != null) { + name = name.replaceAll(".frdx", ""); Logger.warning(new IndexManagementHelper(), "Index '"+name+"' already added"); + } return null; } Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java 2007-09-03 06:21:21 UTC (rev 14942) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java 2007-09-03 20:20:11 UTC (rev 14943) @@ -330,7 +330,7 @@ insidePanel = iPanel; panel.revalidate(); - + revalidate(); panel.repaint(); putScrollBarAtBottom(); @@ -342,26 +342,44 @@ } + private class ScrollBarSetter implements Runnable { + public ScrollBarSetter() { } + + public void run() { + try { + /* dirty way to have the expected result */ + Thread.sleep(100); + } catch(InterruptedException e) { + + } + + scrollPane.getVerticalScrollBar().setUnitIncrement(15); + + int max = scrollPane.getVerticalScrollBar().getMaximum(); + int extent = scrollPane.getVerticalScrollBar().getVisibleAmount(); + int min = scrollPane.getVerticalScrollBar().getMinimum(); + int value = scrollPane.getVerticalScrollBar().getValue(); + + Logger.debug(this, "ScrollBar: " + +"min : "+Integer.toString(min) + +" ; max : "+Integer.toString(max) + +" ; extent : "+Integer.toString(extent) + +" ; value : "+Integer.toString(value)); + + scrollPane.getVerticalScrollBar().setValue(max); + } + } + + private void putScrollBarAtBottom() { int max = scrollPane.getVerticalScrollBar().getMaximum(); scrollPane.getVerticalScrollBar().setValue(max); Runnable doScroll = new Runnable() { public void run() { - scrollPane.getVerticalScrollBar().setUnitIncrement(15); - int max = scrollPane.getVerticalScrollBar().getMaximum(); - int extent = scrollPane.getVerticalScrollBar().getVisibleAmount(); - int min = scrollPane.getVerticalScrollBar().getMinimum(); - int value = scrollPane.getVerticalScrollBar().getValue(); - - Logger.debug(this, "ScrollBar: " - +"min : "+Integer.toString(min) - +" ; max : "+Integer.toString(max) - +" ; extent : "+Integer.toString(extent) - +" ; value : "+Integer.toString(value)); - - scrollPane.getVerticalScrollBar().setValue(max); + Thread th = new Thread(new ScrollBarSetter()); + th.start(); } }; @@ -575,15 +593,15 @@ public void actionPerformed(ActionEvent e) { - if (e.getSource() == chkActions[2] - || e.getSource() == indexActions[2]) { /* copy this key */ + if (e.getSource() == chkActions[3] + || e.getSource() == indexActions[3]) { /* copy this key */ thaw.gui.GUIHelper.copyToClipboard(key); - } else if (e.getSource() == chkActions[3] - || e.getSource() == indexActions[3]) { /* copy all keys */ + } else if (e.getSource() == chkActions[4] + || e.getSource() == indexActions[4]) { /* copy all keys */ - Vector v = ( (e.getSource() == indexActions[3]) ? + Vector v = ( (e.getSource() == indexActions[4]) ? messagePanel.getIndexKeys() : messagePanel.getCHKKeys() ); Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java 2007-09-03 06:21:21 UTC (rev 14942) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java 2007-09-03 20:20:11 UTC (rev 14943) @@ -59,19 +59,27 @@ public boolean init(Hsqldb db, Core core, MiniFrost plugin) { + return init(db, core, plugin, "frostKSKDatabaseVersion"); + } + + public boolean init(Hsqldb db, Core core, MiniFrost plugin, String configOption) { this.db = db; this.core = core; this.plugin = plugin; - boolean firstStart = (core.getConfig().getValue("frostKSKDatabaseVersion") == null); + boolean firstStart = (core.getConfig().getValue(configOption) == null); convertExistingTables(); createTables(); - if (firstStart) + if (firstStart) { addDefaultBoards(); + if (core.getConfig().getValue(configOption) == null) + core.getConfig().setValue(configOption, "true"); + } + boardsHashMap = new HashMap(); return true; @@ -222,9 +230,6 @@ protected void createTables() { - if (core.getConfig().getValue("frostKSKDatabaseVersion") == null) - core.getConfig().setValue("frostKSKDatabaseVersion", "3"); - sendQuery("CREATE CACHED TABLE frostKSKBoards (" + "id INTEGER IDENTITY NOT NULL, " + "name VARCHAR(128) NOT NULL, " @@ -274,6 +279,9 @@ + "description VARCHAR(512) NULL, " + "messageId INTEGER NOT NULL, " + "FOREIGN KEY (messageId) REFERENCES frostKSKMessages (id))"); + + if (core.getConfig().getValue("frostKSKDatabaseVersion") == null) + core.getConfig().setValue("frostKSKDatabaseVersion", "3"); } Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoardFactory.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoardFactory.java 2007-09-03 06:21:21 UTC (rev 14942) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoardFactory.java 2007-09-03 20:20:11 UTC (rev 14943) @@ -58,7 +58,7 @@ this.db = db; this.core = core; this.boards = new HashMap(); - return super.init(db, core, plugin); + return super.init(db, core, plugin, "frostSSKInitialized"); } protected void addDefaultBoards() { From jflesch at freenetproject.org Mon Sep 3 22:23:10 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Mon, 3 Sep 2007 22:23:10 +0000 (UTC) Subject: [Thaw-dev] r14944 - in trunk/apps/Thaw: images src/thaw/core src/thaw/gui src/thaw/i18n src/thaw/plugins src/thaw/plugins/miniFrost Message-ID: <20070903222310.0E52B47AAA0@freenetproject.org> Author: jflesch Date: 2007-09-03 22:23:09 +0000 (Mon, 03 Sep 2007) New Revision: 14944 Added: trunk/apps/Thaw/images/miniFrost-view-gmail.png trunk/apps/Thaw/images/miniFrost-view-outlook.png Modified: trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 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/MiniFrost.java trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostConfigTab.java trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostPanel.java Log: Make it possible to use a more 'classical' view in minifrost Added: trunk/apps/Thaw/images/miniFrost-view-gmail.png =================================================================== (Binary files differ) Property changes on: trunk/apps/Thaw/images/miniFrost-view-gmail.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/apps/Thaw/images/miniFrost-view-outlook.png =================================================================== (Binary files differ) Property changes on: trunk/apps/Thaw/images/miniFrost-view-outlook.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/apps/Thaw/src/thaw/core/ConfigWindow.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 2007-09-03 20:20:11 UTC (rev 14943) +++ trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 2007-09-03 22:23:09 UTC (rev 14944) @@ -111,12 +111,15 @@ * Make [dis]appear the config window. */ public void setVisible(final boolean v) { - if(v == true) { + if (v) { setChanged(); this.notifyObservers(null); } configWin.setVisible(v); + + if (v) + configWin.repaint(); } public boolean addTab(final String name, final java.awt.Component panel) { @@ -231,33 +234,37 @@ } public void run() { - JDialog dialog = new JDialog(core.getMainWindow().getMainFrame(), - " "+I18n.getMessage("thaw.common.pleaseWait")); + JDialog dialog = null; - dialog.getContentPane().setLayout(new GridLayout(1, 1)); - dialog.getContentPane().add(new JLabel(I18n.getMessage("thaw.common.pleaseWait"), - JLabel.CENTER)); + if (resetConnection) { + dialog = new JDialog(core.getMainWindow().getMainFrame(), + " "+I18n.getMessage("thaw.common.pleaseWait")); - dialog.setUndecorated(true); - dialog.setResizable(false); + dialog.getContentPane().setLayout(new GridLayout(1, 1)); + dialog.getContentPane().add(new JLabel(I18n.getMessage("thaw.common.pleaseWait"), + JLabel.CENTER)); - dialog.setSize(150, 30); + dialog.setUndecorated(true); + dialog.setResizable(false); - Dimension screenSize = - Toolkit.getDefaultToolkit().getScreenSize(); + dialog.setSize(150, 30); - Dimension dialogSize = dialog.getSize(); - dialog.setLocation(screenSize.width/2 - (dialogSize.width/2), - screenSize.height/2 - (dialogSize.height/2)); + Dimension screenSize = + Toolkit.getDefaultToolkit().getScreenSize(); - dialog.setVisible(true); + Dimension dialogSize = dialog.getSize(); + dialog.setLocation(screenSize.width/2 - (dialogSize.width/2), + screenSize.height/2 - (dialogSize.height/2)); - dialog.setSize(150, 30); + dialog.setVisible(true); - dialogSize = dialog.getSize(); - dialog.setLocation(screenSize.width/2 - (dialogSize.width/2), - screenSize.height/2 - (dialogSize.height/2)); + dialog.setSize(150, 30); + dialogSize = dialog.getSize(); + dialog.setLocation(screenSize.width/2 - (dialogSize.width/2), + screenSize.height/2 - (dialogSize.height/2)); + } + /* Imply a whole reset => all the plugins will be reloaded */ if (resetConnection) { @@ -267,10 +274,16 @@ /* should reinit the whole connection correctly */ if (resetConnection && !core.initConnection()) { - new thaw.gui.WarningWindow(dialog, - I18n.getMessage("thaw.warning.unableToConnectTo")+ - " "+core.getConfig().getValue("nodeAddress")+ - ":"+ core.getConfig().getValue("nodePort")); + if (dialog == null) + new thaw.gui.WarningWindow(core.getMainWindow().getMainFrame(), + I18n.getMessage("thaw.warning.unableToConnectTo")+ + " "+core.getConfig().getValue("nodeAddress")+ + ":"+ core.getConfig().getValue("nodePort")); + else + new thaw.gui.WarningWindow(dialog, + I18n.getMessage("thaw.warning.unableToConnectTo")+ + " "+core.getConfig().getValue("nodeAddress")+ + ":"+ core.getConfig().getValue("nodePort")); } needConnectionReset = false; @@ -284,7 +297,8 @@ core.getConfig().applyChanges(); } - dialog.setVisible(false); + if (resetConnection) + dialog.setVisible(false); } } Modified: trunk/apps/Thaw/src/thaw/gui/IconBox.java =================================================================== --- trunk/apps/Thaw/src/thaw/gui/IconBox.java 2007-09-03 20:20:11 UTC (rev 14943) +++ trunk/apps/Thaw/src/thaw/gui/IconBox.java 2007-09-03 22:23:09 UTC (rev 14944) @@ -173,7 +173,10 @@ public static ImageIcon web; + public static ImageIcon miniFrostGmailView; + public static ImageIcon miniFrostOutlookView; + /** * Not really used */ @@ -316,6 +319,8 @@ IconBox.mail = IconBox.loadIcon("images/mail.png"); IconBox.minMail = IconBox.loadIcon("images/min-mail.png"); IconBox.web = IconBox.loadIcon("images/web.png"); + IconBox.miniFrostGmailView = IconBox.loadIcon("images/miniFrost-view-gmail.png"); + IconBox.miniFrostOutlookView = IconBox.loadIcon("images/miniFrost-view-outlook.png"); } } Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-09-03 20:20:11 UTC (rev 14943) +++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-09-03 22:23:09 UTC (rev 14944) @@ -663,7 +663,11 @@ thaw.plugin.miniFrost.copyThisKey=Copier cette clef dans le presse-papier thaw.plugin.miniFrost.copyAllKeys=Copier toutes les clefs dans le presse-papier +thaw.plugin.miniFrost.views=Vue: +thaw.plugin.miniFrost.views.gmail=Vue 1 +thaw.plugin.miniFrost.views.outlook=Vue 2 + ## Index web grapher thaw.plugin.indexWebGrapher=Une tentative de repr?sentation de la toile des indexes thaw.plugin.indexWebGrapher.shortName=Toile d'indexes Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-09-03 20:20:11 UTC (rev 14943) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-09-03 22:23:09 UTC (rev 14944) @@ -676,7 +676,11 @@ thaw.plugin.miniFrost.copyThisKey=Copy this key to the clipboard thaw.plugin.miniFrost.copyAllKeys=Copy all the keys to the clipboard +thaw.plugin.miniFrost.views=View: +thaw.plugin.miniFrost.views.gmail=View 1 +thaw.plugin.miniFrost.views.outlook=View 2 + ## index web grapher thaw.plugin.indexWebGrapher=An attempt to draw a graph of the index web Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-09-03 20:20:11 UTC (rev 14943) +++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-09-03 22:23:09 UTC (rev 14944) @@ -663,7 +663,11 @@ thaw.plugin.miniFrost.copyThisKey=Copier cette clef dans le presse-papier thaw.plugin.miniFrost.copyAllKeys=Copier toutes les clefs dans le presse-papier +thaw.plugin.miniFrost.views=Vue: +thaw.plugin.miniFrost.views.gmail=Vue 1 +thaw.plugin.miniFrost.views.outlook=Vue 2 + ## Index web grapher thaw.plugin.indexWebGrapher=Une tentative de repr\u00e9sentation de la toile des indexes thaw.plugin.indexWebGrapher.shortName=Toile d'indexes Modified: trunk/apps/Thaw/src/thaw/plugins/MiniFrost.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/MiniFrost.java 2007-09-03 20:20:11 UTC (rev 14943) +++ trunk/apps/Thaw/src/thaw/plugins/MiniFrost.java 2007-09-03 22:23:09 UTC (rev 14944) @@ -44,6 +44,7 @@ core.getConfig().addListener("miniFrostAutoRefreshMaxBoards", this); core.getConfig().addListener("miniFrostArchiveAfter", this); core.getConfig().addListener("miniFrostDeleteAfter", this); + core.getConfig().addListener("miniFrostView", this); if (!loadDeps() || !initFactories() Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java 2007-09-03 20:20:11 UTC (rev 14943) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java 2007-09-03 22:23:09 UTC (rev 14944) @@ -110,13 +110,17 @@ back = new JButton("", IconBox.minLeft); back.setToolTipText(I18n.getMessage("thaw.plugin.miniFrost.goBack")); back.addActionListener(this); - buttonPanel.add(back); + if (mainPanel.isInGmailView()) + buttonPanel.add(back); + nextUnread = new JButton("", IconBox.minNextUnread); nextUnread.setToolTipText(I18n.getMessage("thaw.plugin.miniFrost.nextUnread")); nextUnread.addActionListener(this); - buttonPanel.add(nextUnread); + if (mainPanel.isInGmailView()) + buttonPanel.add(nextUnread); + reply = new JButton("", IconBox.minMsgReply); reply.setToolTipText(I18n.getMessage("thaw.plugin.miniFrost.reply")); reply.addActionListener(this); @@ -407,6 +411,9 @@ } public void actionPerformed(ActionEvent e) { + if (msg == null) + return; + if (e.getSource() == back) { mainPanel.displayMessageTable(); Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java 2007-09-03 20:20:11 UTC (rev 14943) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java 2007-09-03 22:23:09 UTC (rev 14944) @@ -128,6 +128,8 @@ private JComboBox actions; + private JScrollPane tableScrollPane; + private String[] keywords; private int orderBy; private boolean desc; @@ -211,8 +213,10 @@ setBoard(null); + tableScrollPane = new JScrollPane(table); + panel.add(northPanel, BorderLayout.NORTH); - panel.add(new JScrollPane(table), BorderLayout.CENTER); + panel.add(tableScrollPane, BorderLayout.CENTER); /** some filters **/ @@ -1022,6 +1026,15 @@ table.setRowSelectionInterval(line, line); table.setColumnSelectionInterval(0, COLUMNS.length-1); model.refresh(line); + + int max = tableScrollPane.getVerticalScrollBar().getMaximum(); + int min = tableScrollPane.getVerticalScrollBar().getMinimum(); + int value = (((max-min) * (line-5)) / model.getRowCount()) + min; + + if (value < min) + value = min; + + tableScrollPane.getVerticalScrollBar().setValue(value); } } @@ -1044,7 +1057,8 @@ if (line >= 0) { Logger.info(this, "Line: "+Integer.toString(line)); - + model.setSelectedAll(false); + model.switchSelection(line, true); javax.swing.SwingUtilities.invokeLater(new LineSelecter(line)); } @@ -1167,6 +1181,8 @@ Message msg = model.getMsg(row); if (msg != null) { + model.setSelectedAll(false); + model.switchSelection(row, true); mainPanel.getMessagePanel().setMessage(msg); mainPanel.displayMessage(); } Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostConfigTab.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostConfigTab.java 2007-09-03 20:20:11 UTC (rev 14943) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostConfigTab.java 2007-09-03 22:23:09 UTC (rev 14944) @@ -4,6 +4,8 @@ import javax.swing.JLabel; import javax.swing.JComboBox; import javax.swing.JButton; +import javax.swing.JRadioButton; +import javax.swing.ButtonGroup; import java.util.Observer; import java.util.Observable; @@ -29,7 +31,7 @@ private ConfigWindow configWindow; private RegexpBlacklist regexpBlacklist; - private JPanel panel; + private JPanel globalPanel; public final static int MIN_BOARDS = 0; public final static int MAX_BOARDS = 30; @@ -45,7 +47,10 @@ private JButton regexpButton; + private JRadioButton gmailView; + private JRadioButton outlookView; + public MiniFrostConfigTab(Config config, ConfigWindow configWindow, RegexpBlacklist regexpBlacklist) { @@ -53,8 +58,10 @@ this.configWindow = configWindow; this.regexpBlacklist = regexpBlacklist; - panel = new JPanel(new GridLayout(16, 1)); + globalPanel = new JPanel(new BorderLayout(10, 10)); + JPanel panel = new JPanel(new GridLayout(10, 1)); + maxBoards = new JComboBox(); for (int i = MIN_BOARDS ; i <= MAX_BOARDS ; i++) @@ -68,8 +75,6 @@ deleteAfter.addItem( Integer.toString(i)+ " "+I18n.getMessage("thaw.plugin.miniFrost.days")); } - selectValue(); - panel.add(new JLabel(I18n.getMessage("thaw.plugin.miniFrost.maxBoardsRefreshed"))); panel.add(maxBoards); @@ -87,6 +92,48 @@ panel.add(new JLabel("")); panel.add(regexpPanel); + + + globalPanel.add(panel, BorderLayout.CENTER); + + JPanel southPanel = new JPanel(new BorderLayout()); + + southPanel.add(new JLabel(I18n.getMessage("thaw.plugin.miniFrost.views")), + BorderLayout.NORTH); + + ButtonGroup buttonGroup = new ButtonGroup(); + + JPanel viewPanel = new JPanel(new GridLayout(1, 2)); + + JPanel gmailPanel = new JPanel(new BorderLayout(3, 3)); + JPanel outlookPanel = new JPanel(new BorderLayout(3, 3)); + + gmailView = new JRadioButton(I18n.getMessage("thaw.plugin.miniFrost.views.gmail")); + outlookView = new JRadioButton(I18n.getMessage("thaw.plugin.miniFrost.views.outlook")); + + gmailPanel.add(gmailView, BorderLayout.NORTH); + gmailPanel.add(new JLabel(IconBox.miniFrostGmailView, + JLabel.LEFT), + BorderLayout.CENTER); + + outlookPanel.add(outlookView, BorderLayout.NORTH); + outlookPanel.add(new JLabel(IconBox.miniFrostOutlookView, + JLabel.LEFT), + BorderLayout.CENTER); + + + buttonGroup.add(gmailView); + buttonGroup.add(outlookView); + + + viewPanel.add(gmailPanel); + viewPanel.add(outlookPanel); + + southPanel.add(viewPanel, BorderLayout.CENTER); + + globalPanel.add(southPanel, BorderLayout.SOUTH); + + selectValues(); } @@ -94,16 +141,16 @@ configWindow.addObserver(this); configWindow.addTab(I18n.getMessage("thaw.plugin.miniFrost"), thaw.gui.IconBox.minReadComments, - panel); + globalPanel); } public void hide() { configWindow.deleteObserver(this); - configWindow.removeTab(panel); + configWindow.removeTab(globalPanel); } - private void selectValue() { + private void selectValues() { int max; @@ -135,6 +182,22 @@ } deleteAfter.setSelectedIndex(max-MIN_DAYS); + + + int view = MiniFrostPanel.DEFAULT_VIEW; + + if (config.getValue("miniFrostView") != null) { + view = Integer.parseInt(config.getValue("miniFrostView")); + Logger.info(this, "View : "+Integer.toString(view)); + } + + if (view == 0) { + outlookView.setSelected(false); + gmailView.setSelected(true); + } else { + gmailView.setSelected(false); + outlookView.setSelected(true); + } } @@ -156,9 +219,12 @@ config.setValue("miniFrostDeleteAfter", extractNumber(deleteAfter)); + config.setValue("miniFrostView", + (gmailView.isSelected() ? "0" : "1")); + } else if (param == configWindow.getCancelButton()) { - selectValue(); + selectValues(); } } Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostPanel.java 2007-09-03 20:20:11 UTC (rev 14943) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostPanel.java 2007-09-03 22:23:09 UTC (rev 14944) @@ -2,6 +2,7 @@ import javax.swing.JSplitPane; import javax.swing.JLabel; +import javax.swing.JComponent; import java.util.Observer; import java.util.Observable; @@ -28,6 +29,8 @@ * */ public class MiniFrostPanel implements Observer { + public final static int DEFAULT_VIEW = 0; /* 0 = Gmail ; 1 = Outlook */ + private Config config; private Hsqldb db; private BoardTree boardTree; @@ -38,7 +41,9 @@ private MiniFrost pluginCore; - private JSplitPane mainSplit; + private boolean gmailView = true; + private JSplitPane mainSplit = null; + private JSplitPane rightSplit = null; public MiniFrostPanel(Config config, Hsqldb db, MiniFrost pluginCore) { @@ -46,6 +51,12 @@ this.db = db; this.pluginCore = pluginCore; + gmailView = true; + + if (config.getValue("miniFrostView") == null + || "1".equals(config.getValue("miniFrostView"))) + gmailView = false; + /* board tree use some settings provided by the message tree table * to count the unread messages => it must instanciated after */ messageTreeTable = new MessageTreeTable(this); @@ -56,10 +67,22 @@ boardTree.addObserver(messageTreeTable); boardTree.addObserver(this); - /* so it will be vertical ... don't ask me why ... */ + + JComponent mainComponent; + + if (gmailView) { + mainComponent = messageTreeTable.getPanel(); + rightSplit = null; + } else { + rightSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, + messageTreeTable.getPanel(), + messagePanel.getPanel()); + mainComponent = rightSplit; + } + mainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, boardTree.getPanel(), - messageTreeTable.getPanel()); + mainComponent); } @@ -69,7 +92,11 @@ messagePanel.hided(); messageTreeTable.hided(); - mainSplit.setRightComponent(draftPanel.getPanel()); + if (gmailView) + mainSplit.setRightComponent(draftPanel.getPanel()); + else + rightSplit.setRightComponent(draftPanel.getPanel()); + mainSplit.validate(); draftPanel.redisplayed(); @@ -84,7 +111,11 @@ messagePanel.hided(); draftPanel.hided(); - mainSplit.setRightComponent(messageTreeTable.getPanel()); + if (gmailView) + mainSplit.setRightComponent(messageTreeTable.getPanel()); + else + rightSplit.setLeftComponent(messageTreeTable.getPanel()); + mainSplit.validate(); messageTreeTable.redisplayed(); @@ -98,7 +129,11 @@ messageTreeTable.hided(); draftPanel.hided(); - mainSplit.setRightComponent(messagePanel.getPanel()); + if (gmailView) + mainSplit.setRightComponent(messagePanel.getPanel()); + else + rightSplit.setRightComponent(messagePanel.getPanel()); + messagePanel.redisplayed(); mainSplit.validate(); @@ -177,6 +212,13 @@ else mainSplit.setDividerLocation(150); + rightSplit.setResizeWeight(0.5); + + if ((val = config.getValue("miniFrostRightSplitPosition")) != null) + rightSplit.setDividerLocation(Integer.parseInt(val)); + else + rightSplit.setDividerLocation(150); + boardTree.loadState(); } @@ -184,6 +226,8 @@ public void saveState() { config.setValue("miniFrostMainSplitPosition", Integer.toString(mainSplit.getDividerLocation())); + config.setValue("miniFrostRightSplitPosition", + Integer.toString(rightSplit.getDividerLocation())); boardTree.saveState(); } @@ -219,4 +263,8 @@ boardTree.updateDraftValues(waitings, postings); } + + public boolean isInGmailView() { + return gmailView; + } } From jflesch at freenetproject.org Mon Sep 3 22:34:34 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Mon, 3 Sep 2007 22:34:34 +0000 (UTC) Subject: [Thaw-dev] r14945 - in trunk/apps/Thaw/src/thaw: core plugins Message-ID: <20070903223434.3315047AED8@freenetproject.org> Author: jflesch Date: 2007-09-03 22:34:34 +0000 (Mon, 03 Sep 2007) New Revision: 14945 Modified: trunk/apps/Thaw/src/thaw/core/LibraryPlugin.java trunk/apps/Thaw/src/thaw/plugins/IndexWebGrapher.java Log: Make the indexWebGrapher plugin unregister from the hsqldb plugin correctly Modified: trunk/apps/Thaw/src/thaw/core/LibraryPlugin.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/LibraryPlugin.java 2007-09-03 22:23:09 UTC (rev 14944) +++ trunk/apps/Thaw/src/thaw/core/LibraryPlugin.java 2007-09-03 22:34:34 UTC (rev 14945) @@ -1,5 +1,11 @@ package thaw.core; +import thaw.core.Logger; + +import java.util.Vector; +import java.util.Iterator; + + /** * Plugins adding functionality for other plugins should extends this class. * Then plugins using these library plugins will be able to register them one by one. @@ -7,24 +13,53 @@ * realStop() is called when the last plugin has unregistered itself. */ public abstract class LibraryPlugin implements Plugin { - private int nmbRegistered = 0; + private Vector registered = null; public abstract boolean run(Core core); public abstract boolean stop(); + public void registerChild(final Plugin child) { - nmbRegistered++; + if (registered == null) + registered = new Vector(); - if(nmbRegistered == 1) + if (registered.size() == 0) realStart(); + + while (registered.remove(child)) { + Logger.warning(this, "Plugin '"+ + child.getClass().getName()+ + "' was already registered to '"+ + this.getClass().getName()+ + "'"); + } + + registered.add(child); } public void unregisterChild(final Plugin child) { - nmbRegistered--; + if (registered == null) { + Logger.warning(this, "Abnormal : '"+this.getClass().getName()+ + "' is unregistering child plugin '"+ + child.getClass().getName()+ + "' but "+ + "no plugin was registered ?!"); + registered = new Vector(); + } - if(nmbRegistered == 0) + while (registered.remove(child)) { } + + if(registered.size() == 0) { realStop(); + } else { + Logger.debug(this, "unregisterChild() : Children still registered to "+ + "'"+this.getClass().getName()+"' : "); + for (Iterator it = registered.iterator(); + it.hasNext();) { + Logger.debug(this, it.next().getClass().getName()); + } + } } public abstract void realStart(); Modified: trunk/apps/Thaw/src/thaw/plugins/IndexWebGrapher.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/IndexWebGrapher.java 2007-09-03 22:23:09 UTC (rev 14944) +++ trunk/apps/Thaw/src/thaw/plugins/IndexWebGrapher.java 2007-09-03 22:34:34 UTC (rev 14945) @@ -131,6 +131,7 @@ public boolean stop() { core.getMainWindow().removeTab(tabPanel); + db.unregisterChild(this); return true; } From jflesch at freenetproject.org Mon Sep 3 22:37:04 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Mon, 3 Sep 2007 22:37:04 +0000 (UTC) Subject: [Thaw-dev] r14946 - trunk/apps/Thaw/src/thaw/plugins/miniFrost Message-ID: <20070903223704.36A1347AEE5@freenetproject.org> Author: jflesch Date: 2007-09-03 22:37:04 +0000 (Mon, 03 Sep 2007) New Revision: 14946 Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java Log: Remove a label to reduce a layout issue Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java 2007-09-03 22:34:34 UTC (rev 14945) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java 2007-09-03 22:37:04 UTC (rev 14946) @@ -273,7 +273,7 @@ JPanel southEastPanel = new JPanel(new GridLayout(2, 1)); JPanel southEastPanelTop = new JPanel(new GridLayout(1, 3, 5, 5)); - southEastPanelTop.add(new JLabel(I18n.getMessage("thaw.plugin.miniFrost.seeMessages"))); + //southEastPanelTop.add(new JLabel(I18n.getMessage("thaw.plugin.miniFrost.seeMessages"))); southEastPanelTop.add(seeUnsigned); southEastPanelTop.add(seeArchived); southEastPanelTop.add(seeRead); From jflesch at freenetproject.org Mon Sep 3 22:50:50 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Mon, 3 Sep 2007 22:50:50 +0000 (UTC) Subject: [Thaw-dev] r14947 - trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK Message-ID: <20070903225050.CACF6479725@freenetproject.org> Author: jflesch Date: 2007-09-03 22:50:50 +0000 (Mon, 03 Sep 2007) New Revision: 14947 Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessage.java Log: Interrupt a board refresh if the board is deleted by the user Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java 2007-09-03 22:37:04 UTC (rev 14946) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java 2007-09-03 22:50:50 UTC (rev 14947) @@ -490,6 +490,9 @@ * @param initial true if one of the first downloads of the day */ protected void startNewMessageDownload(boolean initial) { + if (!refreshing) + return; + int slot; /* we search an empty slot */ @@ -851,6 +854,7 @@ public boolean destroy() { + refreshing = false; Hsqldb db = factory.getDb(); if (!KSKMessage.destroyAll(this, db)) Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java 2007-09-03 22:37:04 UTC (rev 14946) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java 2007-09-03 22:50:50 UTC (rev 14947) @@ -115,6 +115,9 @@ set.getBoolean("archived"), null, /* encryptedFor */ null /* board */); + Logger.info(this, "Destroying a message from "+ + set.getTimestamp("date")); + msg.destroy(db); } Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessage.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessage.java 2007-09-03 22:37:04 UTC (rev 14946) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessage.java 2007-09-03 22:50:50 UTC (rev 14947) @@ -529,6 +529,7 @@ public boolean destroy(Hsqldb db) { + if (!KSKFileAttachment.destroy(this, db) || !KSKBoardAttachment.destroy(this, db)) return false; From jflesch at freenetproject.org Mon Sep 3 23:31:22 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Mon, 3 Sep 2007 23:31:22 +0000 (UTC) Subject: [Thaw-dev] r14954 - trunk/apps/Thaw/src/thaw/plugins/index Message-ID: <20070903233122.7934347AEC8@freenetproject.org> Author: jflesch Date: 2007-09-03 23:31:22 +0000 (Mon, 03 Sep 2007) New Revision: 14954 Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java trunk/apps/Thaw/src/thaw/plugins/index/Link.java trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java Log: Change the behavior of the unknown index list : Display all the unknown indexes, and always sort them alphabetically Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java 2007-09-03 23:19:14 UTC (rev 14953) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java 2007-09-03 23:31:22 UTC (rev 14954) @@ -386,9 +386,11 @@ if (index) node = new Index(db, config, target_id); - else + else { node = new IndexFolder(db, config, target_id, false); + folders.remove(((IndexFolder)node).getName()); + } children.remove(node); } @@ -1076,6 +1078,11 @@ } + public String getName() { + return toString(); + } + + public String toString() { if (id < 0) return thaw.core.I18n.getMessage("thaw.plugin.index.yourIndexes"); Modified: trunk/apps/Thaw/src/thaw/plugins/index/Link.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Link.java 2007-09-03 23:19:14 UTC (rev 14953) +++ trunk/apps/Thaw/src/thaw/plugins/index/Link.java 2007-09-03 23:31:22 UTC (rev 14954) @@ -108,6 +108,24 @@ return (key_a.equals(key_b)); } + public boolean equals(final Object o) { + if (o == this) + return true; + + if (o instanceof Link) { + + final Link link = (Link)o; + return compare(link); + + } else if (o instanceof Index) { + + final Index index = (Index)o; + return compare(index); + } + + return false; + } + public boolean compare(final Index l) { String key_a; String key_b; @@ -251,7 +269,7 @@ public int compareTo(Object o) { if (o instanceof Link) { - return getIndexName().compareTo(((Link)o).getIndexName()); + return getIndexName().toLowerCase().compareTo(((Link)o).getIndexName().toLowerCase()); } return 0; Modified: trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java 2007-09-03 23:19:14 UTC (rev 14953) +++ trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java 2007-09-03 23:31:22 UTC (rev 14954) @@ -34,14 +34,8 @@ public class UnknownIndexList implements MouseListener, ActionListener { - public final static int MAX_INDEXES = 50; + private Vector linkList; /* only when < MAX_INDEXES */ - private int offset; - - private Link[] linkList; - private boolean full; - private Vector vList; /* only when < MAX_INDEXES */ - private JPanel panel; private JList list; @@ -52,8 +46,6 @@ private JPopupMenu rightClickMenu = null; private Vector rightClickActions = null; - private JMenuItem sortItem = null; - private ToolbarModifier toolbarModifier; private Vector toolbarActions; @@ -65,16 +57,10 @@ this.queueManager = queueManager; this.indexBrowser = indexBrowser; - offset = 0; - full = false; - vList = new Vector(); - linkList = new Link[UnknownIndexList.MAX_INDEXES+1]; + linkList = new Vector(); - for(int i = 0 ; i < linkList.length ; i++) - linkList[i] = null; + list = new JList(linkList); - list = new JList(vList); - list.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); panel = new JPanel(new BorderLayout()); @@ -117,36 +103,20 @@ } public boolean isInList(final Link l) { - if (l == null) - return false; - - for (int i = 0 ; i < linkList.length ; i++) { - if (linkList[i] == null) - continue; - - if (l.compare(linkList[i])) - return true; - } - - return false; + return (linkList.indexOf(l) >= 0); } - public void erase(int i) { - linkList[linkList.length-1] = null; - for (int j = i ; j < linkList.length-1; j++) { - linkList[j] = linkList[j+1]; - } - } public boolean removeLink(final Index index) { boolean ret = false; - for (int i = 0 ; i < linkList.length ; i++) { - if ((linkList[i] != null) && linkList[i].compare(index)) { - if (!full) - vList.remove(linkList[i]); - erase(i); + /* to avoid iterator collisions */ + + for (int i = 0 ; i < linkList.size() ; i++) { + Link l = (Link)linkList.get(i); + if (l.compare(index)) { ret = true; + linkList.remove(l); } } @@ -159,13 +129,8 @@ public boolean removeLink(final Link link) { boolean ret = false; - for (int i = 0 ; i < linkList.length ; i++) { - if ((linkList[i] != null) && linkList[i].compare(link)) { - if (!full) - vList.remove(linkList[i]); - erase(i); - ret = true; - } + while (linkList.remove(link)) { + ret = true; } refresh(); @@ -174,18 +139,14 @@ } - public void makePlace(int i) { - int j; - for (j = linkList.length - 1; j > i ; j--) { - linkList[j] = linkList[j-1]; - } - linkList[j] = null; + public boolean addLink(Link link) { + return addLink(link, true); } /** * will check that the link link to an unknown index before adding */ - public boolean addLink(final Link link) { + public boolean addLink(final Link link, boolean refresh) { if ((link == null) || link.isBlackListed() || Index.isAlreadyKnown(indexBrowser.getDb(), link.getPublicKey()) >= 0 @@ -193,25 +154,11 @@ || FreenetURIHelper.isObsolete(link.getPublicKey())) return false; - makePlace(0); - linkList[0] = link; + linkList.add(link); - if (!full) { - vList.add(0, link); - list.setListData(vList); - } else { - list.setListData(linkList); - } + if (refresh) + refresh(); - offset++; - - if (offset >= UnknownIndexList.MAX_INDEXES) { - offset = 0; - full = true; - } - - refresh(); - return true; } @@ -231,10 +178,13 @@ for (final Iterator it = ll.iterator(); it.hasNext();) { - if (addLink(((Link)it.next()))) + if (addLink(((Link)it.next()), false)) ret = true; } + if (ret) + refresh(); + return ret; } @@ -253,11 +203,7 @@ rightClickActions.add(new LinkManagementHelper.IndexAdder(item, queueManager, indexBrowser, false)); - sortItem = new JMenuItem(I18n.getMessage("thaw.plugin.index.sortAlphabetically")); - rightClickMenu.add(sortItem); - sortItem.addActionListener(this); - item = new JMenuItem(I18n.getMessage("thaw.plugin.index.copyKeys")); rightClickMenu.add(item); rightClickActions.add(new LinkManagementHelper.PublicKeyCopier(item)); @@ -312,6 +258,10 @@ public void refresh() { + java.util.Collections.sort(linkList); + + list.setListData(linkList); + list.revalidate(); list.repaint(); } @@ -338,36 +288,10 @@ } + public void actionPerformed(ActionEvent e) { - if (e.getSource() == sortItem) { + if (e.getSource() == autoSorting) { - Vector v; - - if (full) { - v = new Vector(linkList.length); - - for (int i = 0 ; i < linkList.length ; i++) { - if (linkList[i] != null) - v.add(linkList[i]); - } - } else - v = vList; - - java.util.Collections.sort(v); - - if (full) { - for (int i = 0 ; i < linkList.length ; i++) { - linkList[i] = null; - } - - v.toArray(linkList); - } else - vList = v; - - refresh(); - - } else if (e.getSource() == autoSorting) { - applyAutoSortingSetting(); } From jflesch at freenetproject.org Mon Sep 3 23:54:42 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Mon, 3 Sep 2007 23:54:42 +0000 (UTC) Subject: [Thaw-dev] r14955 - in trunk/apps/Thaw/src/thaw: i18n plugins/queueWatcher Message-ID: <20070903235442.7EBCD47AAA0@freenetproject.org> Author: jflesch Date: 2007-09-03 23:54:42 +0000 (Mon, 03 Sep 2007) New Revision: 14955 Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java Log: Use the trayicon to notify the user when a transfer ends Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-09-03 23:31:22 UTC (rev 14954) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-09-03 23:54:42 UTC (rev 14955) @@ -160,6 +160,12 @@ thaw.plugin.queueWatcher=Transfers +thaw.plugin.queueWatcher.downloadSuccessful='X' successfully downloaded +thaw.plugin.queueWatcher.downloadFailed=Download of 'X' has failed +thaw.plugin.queueWatcher.insertionSuccessful='X' successfully inserted +thaw.plugin.queueWatcher.insertionFailed=Insertion of 'X' has failed + + thaw.plugin.insert.fileToInsert=File to insert thaw.plugin.insert.filesToInsert=File(s) to insert thaw.plugin.insert.selectKey=Select the kind of key wanted Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java 2007-09-03 23:31:22 UTC (rev 14954) +++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java 2007-09-03 23:54:42 UTC (rev 14955) @@ -103,7 +103,9 @@ this.core = core; this.detailPanel = detailPanel; - tableModel = new QueueTableModel(isForInsertionQueue, core.getQueueManager()); + tableModel = new QueueTableModel(isForInsertionQueue, + core.getPluginManager(), + core.getQueueManager()); table = new Table(core.getConfig(), isForInsertionQueue ? "table_insertions" : "table_downloads", Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java 2007-09-03 23:31:22 UTC (rev 14954) +++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java 2007-09-03 23:54:42 UTC (rev 14955) @@ -20,8 +20,9 @@ import thaw.fcp.FCPTransferQuery; import thaw.fcp.FCPClientGet; import thaw.fcp.FCPClientPut; - import thaw.gui.IconBox; +import thaw.core.PluginManager; +import thaw.plugins.TrayIcon; public class QueueTableModel extends javax.swing.table.AbstractTableModel implements Observer { @@ -38,11 +39,14 @@ private int sortedColumn = -1; private FCPQueueManager queueManager; + private PluginManager pluginManager; - - public QueueTableModel(boolean isForInsertions, final FCPQueueManager queueManager) { + public QueueTableModel(boolean isForInsertions, + PluginManager pluginManager, + final FCPQueueManager queueManager) { super(); + this.pluginManager = pluginManager; this.queueManager = queueManager; this.isForInsertions = isForInsertions; @@ -294,6 +298,31 @@ } public void update(final Observable o, final Object arg) { + if (o instanceof FCPTransferQuery + && ((FCPTransferQuery)o).isFinished()) { + + String str = null; + + boolean success = ((FCPTransferQuery)o).isSuccessful(); + + if (o instanceof FCPClientGet) { + str = (success ? + I18n.getMessage("thaw.plugin.queueWatcher.downloadSuccessful") : + I18n.getMessage("thaw.plugin.queueWatcher.downloadFailed")); + } else if (o instanceof FCPClientPut) { + str = (success ? + I18n.getMessage("thaw.plugin.queueWatcher.insertionSuccessful") : + I18n.getMessage("thaw.plugin.queueWatcher.insertionFailed")); + } + + if (str != null) { + str = str.replaceAll("X", ((FCPTransferQuery)o).getFilename()); + TrayIcon.popMessage(pluginManager, "Thaw", + str, thaw.gui.SysTrayIcon.MSG_INFO); + } + } + + int oldPos = -1; int i = 0; From jflesch at freenetproject.org Mon Sep 3 23:57:49 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Mon, 3 Sep 2007 23:57:49 +0000 (UTC) Subject: [Thaw-dev] r14956 - in trunk/apps/Thaw/src/thaw: i18n plugins/index Message-ID: <20070903235749.7513147AEB2@freenetproject.org> Author: jflesch Date: 2007-09-03 23:57:49 +0000 (Mon, 03 Sep 2007) New Revision: 14956 Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java Log: I forgot to update the french translation Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-09-03 23:54:42 UTC (rev 14955) +++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-09-03 23:57:49 UTC (rev 14956) @@ -160,6 +160,11 @@ ## Plugins thaw.plugin.queueWatcher=Transferts +thaw.plugin.queueWatcher.downloadSuccessful='X' t?l?charg? avec succ?s +thaw.plugin.queueWatcher.downloadFailed=Le t?l?chargement de 'X' a ?chou? +thaw.plugin.queueWatcher.insertionSuccessful='X' ins?r? avec succ?s +thaw.plugin.queueWatcher.insertionFailed=L'insertion de 'X' a ?chou? + thaw.plugin.insert.fileToInsert=Fichier ? ins?rer thaw.plugin.insert.filesToInsert=Fichier(s) ? ins?rer thaw.plugin.insert.selectKey=Selectionner le type de clef voulu Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-09-03 23:54:42 UTC (rev 14955) +++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-09-03 23:57:49 UTC (rev 14956) @@ -160,6 +160,11 @@ ## Plugins thaw.plugin.queueWatcher=Transferts +thaw.plugin.queueWatcher.downloadSuccessful='X' t\u00e9l\u00e9charg\u00e9 avec succ\u00e8s +thaw.plugin.queueWatcher.downloadFailed=Le t\u00e9l\u00e9chargement de 'X' a \u00e9chou\u00e9 +thaw.plugin.queueWatcher.insertionSuccessful='X' ins\u00e9r\u00e9 avec succ\u00e8s +thaw.plugin.queueWatcher.insertionFailed=L'insertion de 'X' a \u00e9chou\u00e9 + thaw.plugin.insert.fileToInsert=Fichier \u00e0 ins\u00e9rer thaw.plugin.insert.filesToInsert=Fichier(s) \u00e0 ins\u00e9rer thaw.plugin.insert.selectKey=Selectionner le type de clef voulu Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java 2007-09-03 23:54:42 UTC (rev 14955) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java 2007-09-03 23:57:49 UTC (rev 14956) @@ -388,7 +388,7 @@ || "index".equals(rawName)) { /* links */ if (!index.addLink(attrs.getValue("key"))) { - throw new SAXException("Index parsing interrupted because of a backend error (did you delete the index while it was downloading ?)"); + throw new SAXException("Index parsing interrupted because of a backend error"); } return; @@ -397,7 +397,7 @@ if (!index.addFile(attrs.getValue("key"), Long.parseLong(attrs.getValue("size")), attrs.getValue("mime"))) { - throw new SAXException("Index parsing interrupted because of a backend error (did you delete the index while it was downloading ?)"); + throw new SAXException("Index parsing interrupted because of a backend error"); } } else if ("comments".equals(rawName)) { @@ -601,13 +601,13 @@ Logger.info(this, "Parsing done"); } catch(javax.xml.parsers.ParserConfigurationException e) { - Logger.error(this, "Error (1) while parsing index: "+e.toString()); + Logger.notice(this, "Error (1) while parsing index: "+e.toString()); } catch(org.xml.sax.SAXException e) { - Logger.error(this, "Error (2) while parsing index: "+e.toString()); + Logger.notice(this, "Error (2) while parsing index: "+e.toString()); } catch(java.io.IOException e) { - Logger.error(this, "Error (3) while parsing index: "+e.toString()); + Logger.notice(this, "Error (3) while parsing index: "+e.toString()); } catch(Exception e) { - Logger.error(this, "Error (4) while parsing index: "+e.toString()); + Logger.notice(this, "Error (4) while parsing index: "+e.toString()); } } From jflesch at freenetproject.org Wed Sep 5 03:48:56 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Wed, 5 Sep 2007 03:48:56 +0000 (UTC) Subject: [Thaw-dev] r14969 - trunk/apps/Thaw/src/thaw/plugins/miniFrost Message-ID: <20070905034856.4EDCD4797F9@freenetproject.org> Author: jflesch Date: 2007-09-05 03:48:55 +0000 (Wed, 05 Sep 2007) New Revision: 14969 Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java Log: Improve a little bit the layout in the minifrost tab Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java 2007-09-04 22:29:28 UTC (rev 14968) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java 2007-09-05 03:48:55 UTC (rev 14969) @@ -133,14 +133,22 @@ JPanel northPanel = new JPanel(new BorderLayout(5, 5)); JPanel northNorthPanel = new JPanel(new BorderLayout(5,5)); - northNorthPanel.add(new JLabel(""), BorderLayout.CENTER); + boolean gmailView = mainPanel.isInGmailView(); + + if (gmailView) + northNorthPanel.add(new JLabel(""), BorderLayout.CENTER); + else + northNorthPanel.add(new JScrollPane(subject), BorderLayout.CENTER); + northNorthPanel.add(actions, BorderLayout.EAST); northNorthPanel.add(buttonPanel, BorderLayout.WEST); northPanel.add(northNorthPanel, BorderLayout.CENTER); - northPanel.add(new JScrollPane(subject), BorderLayout.SOUTH); + if (gmailView) + northPanel.add(new JScrollPane(subject), BorderLayout.SOUTH); + panel.add(northPanel, BorderLayout.NORTH); } From jflesch at freenetproject.org Wed Sep 5 10:58:26 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Wed, 5 Sep 2007 10:58:26 +0000 (UTC) Subject: [Thaw-dev] r14970 - trunk/apps/Thaw/src/thaw/plugins/miniFrost Message-ID: <20070905105826.633A247B2F7@freenetproject.org> Author: jflesch Date: 2007-09-05 10:58:25 +0000 (Wed, 05 Sep 2007) New Revision: 14970 Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostPanel.java Log: Fix an NPE in the plugin miniFrost Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostPanel.java 2007-09-05 03:48:55 UTC (rev 14969) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostPanel.java 2007-09-05 10:58:25 UTC (rev 14970) @@ -212,12 +212,14 @@ else mainSplit.setDividerLocation(150); - rightSplit.setResizeWeight(0.5); + if (rightSplit != null) { + rightSplit.setResizeWeight(0.5); - if ((val = config.getValue("miniFrostRightSplitPosition")) != null) - rightSplit.setDividerLocation(Integer.parseInt(val)); - else - rightSplit.setDividerLocation(150); + if ((val = config.getValue("miniFrostRightSplitPosition")) != null) + rightSplit.setDividerLocation(Integer.parseInt(val)); + else + rightSplit.setDividerLocation(150); + } boardTree.loadState(); } From jflesch at freenetproject.org Wed Sep 5 13:57:44 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Wed, 5 Sep 2007 13:57:44 +0000 (UTC) Subject: [Thaw-dev] r14971 - trunk/apps/Thaw/src/thaw/plugins/miniFrost Message-ID: <20070905135744.D920747B2DC@freenetproject.org> Author: jflesch Date: 2007-09-05 13:57:44 +0000 (Wed, 05 Sep 2007) New Revision: 14971 Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostPanel.java Log: Fix another NPE in the plugin minifrost Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostPanel.java 2007-09-05 10:58:25 UTC (rev 14970) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostPanel.java 2007-09-05 13:57:44 UTC (rev 14971) @@ -228,8 +228,10 @@ public void saveState() { config.setValue("miniFrostMainSplitPosition", Integer.toString(mainSplit.getDividerLocation())); - config.setValue("miniFrostRightSplitPosition", - Integer.toString(rightSplit.getDividerLocation())); + if (rightSplit != null) { + config.setValue("miniFrostRightSplitPosition", + Integer.toString(rightSplit.getDividerLocation())); + } boardTree.saveState(); } From jflesch at freenetproject.org Wed Sep 5 14:54:38 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Wed, 5 Sep 2007 14:54:38 +0000 (UTC) Subject: [Thaw-dev] r14972 - trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK Message-ID: <20070905145438.01AA347B30F@freenetproject.org> Author: jflesch Date: 2007-09-05 14:54:37 +0000 (Wed, 05 Sep 2007) New Revision: 14972 Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java Log: Fix the plugin minifrost : deleting date and archiving date were not correcly computed Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java 2007-09-05 13:57:44 UTC (rev 14971) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java 2007-09-05 14:54:37 UTC (rev 14972) @@ -91,8 +91,14 @@ synchronized(db.dbLock) { PreparedStatement st; - java.sql.Timestamp timestamp = new java.sql.Timestamp(new Date().getTime() - (deleteAfter * 24 * 60*60*1000)); + java.sql.Timestamp timestamp = new java.sql.Timestamp(new Date().getTime() + - ( ((long)deleteAfter) * 24 * 60*60*1000)); + Logger.info(this, "Cleaning:"); + Logger.info(this, "Now: "+new Date().toString()); + Logger.info(this, "Delete older than: "+timestamp.toString() + + " ("+Integer.toString(deleteAfter)+")"); + st = db.getConnection().prepareStatement("SELECT "+ " id, msgId, inReplyToId, subject, "+ " nick, sigId, date, rev, read, "+ @@ -122,7 +128,10 @@ } - timestamp = new java.sql.Timestamp(new Date().getTime() - (archiveAfter * 24 * 60*60*1000)); + timestamp = new java.sql.Timestamp(new Date().getTime() + - ( ((long)archiveAfter) * 24 * 60*60*1000)); + Logger.info(this, "Archive older than: "+timestamp.toString()+ + " ("+Integer.toString(archiveAfter)+")"); st = db.getConnection().prepareStatement("UPDATE frostKSKMessages SET archived = TRUE WHERE date < ?"); st.setTimestamp(1, timestamp); From jflesch at freenetproject.org Thu Sep 6 00:19:42 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 6 Sep 2007 00:19:42 +0000 (UTC) Subject: [Thaw-dev] r14980 - in trunk/apps/Thaw/src/thaw/plugins: miniFrost queueWatcher Message-ID: <20070906001942.DA86047A3B6@freenetproject.org> Author: jflesch Date: 2007-09-06 00:19:42 +0000 (Thu, 06 Sep 2007) New Revision: 14980 Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostPanel.java trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java Log: Fix the draft panel : Wasn't hided correctly when the writing was finished Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java 2007-09-05 23:28:07 UTC (rev 14979) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java 2007-09-06 00:19:42 UTC (rev 14980) @@ -45,6 +45,7 @@ public class DraftPanel implements ActionListener, MouseListener { + public final static int ATTACHMENT_LIST_HEIGHT = 50; private Draft draft; private JPanel panel; @@ -137,13 +138,18 @@ JPanel southCenterPanel = new JPanel(new BorderLayout(3, 3)); addAttachment = new JButton(IconBox.attachment); addAttachment.addActionListener(this); + addAttachment.setPreferredSize(new java.awt.Dimension(ATTACHMENT_LIST_HEIGHT, ATTACHMENT_LIST_HEIGHT)); attachmentList = new JList(); attachmentList.setCellRenderer(new AttachmentRenderer()); attachmentList.addMouseListener(this); attachmentList.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + attachmentList.setPreferredSize(new java.awt.Dimension(ATTACHMENT_LIST_HEIGHT, ATTACHMENT_LIST_HEIGHT)); + JScrollPane attListScrollPanel = new JScrollPane(attachmentList); + attListScrollPanel.setPreferredSize(new java.awt.Dimension(ATTACHMENT_LIST_HEIGHT, ATTACHMENT_LIST_HEIGHT)); + southCenterPanel.add(addAttachment, BorderLayout.WEST); - southCenterPanel.add(new JScrollPane(attachmentList), BorderLayout.CENTER); + southCenterPanel.add(attListScrollPanel, BorderLayout.CENTER); centerPanel.add(new JScrollPane(textArea), BorderLayout.CENTER); centerPanel.add(southCenterPanel, BorderLayout.SOUTH); Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostPanel.java 2007-09-05 23:28:07 UTC (rev 14979) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MiniFrostPanel.java 2007-09-06 00:19:42 UTC (rev 14980) @@ -113,8 +113,10 @@ if (gmailView) mainSplit.setRightComponent(messageTreeTable.getPanel()); - else + else { rightSplit.setLeftComponent(messageTreeTable.getPanel()); + rightSplit.setRightComponent(messagePanel.getPanel()); + } mainSplit.validate(); Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java 2007-09-05 23:28:07 UTC (rev 14979) +++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java 2007-09-06 00:19:42 UTC (rev 14980) @@ -299,6 +299,7 @@ public void update(final Observable o, final Object arg) { if (o instanceof FCPTransferQuery + && queries.indexOf(o) >= 0 && ((FCPTransferQuery)o).isFinished()) { String str = null; @@ -332,19 +333,19 @@ sortTable(); - if( queries != null && (i = queries.indexOf(o)) >= 0) { + if (queries != null && (i = queries.indexOf(o)) >= 0) { if (oldPos != i) this.notifyObservers(oldPos); this.notifyObservers(i); return; } - if(arg == null) { + if (o == queueManager && arg == null) { reloadQueue(); return; } - if(o == queueManager) { + if (o == queueManager) { final FCPTransferQuery query = (FCPTransferQuery)arg; if((query.getQueryType() == 1) && isForInsertions) From jflesch at freenetproject.org Thu Sep 6 00:42:25 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 6 Sep 2007 00:42:25 +0000 (UTC) Subject: [Thaw-dev] r14981 - trunk/apps/Thaw/src/thaw/plugins/miniFrost Message-ID: <20070906004225.BA1DB4796C6@freenetproject.org> Author: jflesch Date: 2007-09-06 00:42:25 +0000 (Thu, 06 Sep 2007) New Revision: 14981 Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java Log: When clicking on the button 'next unread message', try to stick to the same thread Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java 2007-09-06 00:19:42 UTC (rev 14980) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java 2007-09-06 00:42:25 UTC (rev 14981) @@ -138,15 +138,18 @@ JPanel southCenterPanel = new JPanel(new BorderLayout(3, 3)); addAttachment = new JButton(IconBox.attachment); addAttachment.addActionListener(this); - addAttachment.setPreferredSize(new java.awt.Dimension(ATTACHMENT_LIST_HEIGHT, ATTACHMENT_LIST_HEIGHT)); + addAttachment.setPreferredSize(new java.awt.Dimension(ATTACHMENT_LIST_HEIGHT, + ATTACHMENT_LIST_HEIGHT)); attachmentList = new JList(); attachmentList.setCellRenderer(new AttachmentRenderer()); attachmentList.addMouseListener(this); attachmentList.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - attachmentList.setPreferredSize(new java.awt.Dimension(ATTACHMENT_LIST_HEIGHT, ATTACHMENT_LIST_HEIGHT)); + attachmentList.setPreferredSize(new java.awt.Dimension(ATTACHMENT_LIST_HEIGHT, + ATTACHMENT_LIST_HEIGHT)); JScrollPane attListScrollPanel = new JScrollPane(attachmentList); - attListScrollPanel.setPreferredSize(new java.awt.Dimension(ATTACHMENT_LIST_HEIGHT, ATTACHMENT_LIST_HEIGHT)); + attListScrollPanel.setPreferredSize(new java.awt.Dimension(ATTACHMENT_LIST_HEIGHT, + ATTACHMENT_LIST_HEIGHT)); southCenterPanel.add(addAttachment, BorderLayout.WEST); southCenterPanel.add(attListScrollPanel, BorderLayout.CENTER); Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java 2007-09-06 00:19:42 UTC (rev 14980) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java 2007-09-06 00:42:25 UTC (rev 14981) @@ -729,6 +729,15 @@ } + public MessageNode getNode(Message msg) { + int i; + + if ( (i = getRow(msg)) < 0 ) + return null; + + return (MessageNode)msgs.get(i); + } + public int getRow(Message msg) { boolean found = false; int i = 0; @@ -1039,14 +1048,64 @@ } + public Message getNextMessageInThread(Message currentMsg) { + MessageNode node = model.getNode(currentMsg); + + if (node == null) { + Logger.notice(this, "Can't find back the message in the tree ?!"); + return null; + } + + /* we first check if it has a child */ + + if (node.getChildCount() > 0) { + return ((MessageNode)node.getChildAt(0)).getMessage(); + } + + /* if it has no child, we check if it has a brother (or if its parents + * have brothers, etc) + */ + for (; + node != null; + node = (MessageNode)node.getParent()) { + + TreeNode treeParent = (TreeNode)node.getParent(); + + /* if it has no parent, we return null to let the calling function + * search a new thread in the database (ORDER BY date, etc) + */ + if (treeParent == null || treeParent instanceof RootMessageNode) + return null; + + MessageNode parent = (MessageNode)treeParent; + + int i = parent.getIndex(node); + + if (i < parent.getChildCount()-1) { + /* then it has a brother */ + return ((MessageNode)parent.getChildAt(i+1)).getMessage(); + } + + } + + return null; + } + + public boolean nextUnread() { if (targetBoard == null) { - Logger.warning(this, "No message selected atm ; can't get the next unread message"); + Logger.warning(this, "No board selected atm ; can't get the next unread message"); return false; } - Message newMsg = targetBoard.getNextUnreadMessage(seeUnsigned.isSelected(), + Message newMsg = null; + + if (mainPanel.getMessagePanel().getMessage() != null) + newMsg = getNextMessageInThread(mainPanel.getMessagePanel().getMessage()); + + if (newMsg == null) + newMsg = targetBoard.getNextUnreadMessage(seeUnsigned.isSelected(), seeArchived.isSelected(), minTrustLevelInt); From jflesch at freenetproject.org Thu Sep 6 00:59:22 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 6 Sep 2007 00:59:22 +0000 (UTC) Subject: [Thaw-dev] r14982 - trunk/apps/Thaw/src/thaw/plugins/miniFrost Message-ID: <20070906005922.B4B9A479FED@freenetproject.org> Author: jflesch Date: 2007-09-06 00:59:22 +0000 (Thu, 06 Sep 2007) New Revision: 14982 Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java Log: Fix file downloads / attachments in minifrost : Thaw should remember the last used directory Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java 2007-09-06 00:42:25 UTC (rev 14981) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java 2007-09-06 00:59:22 UTC (rev 14982) @@ -337,7 +337,12 @@ } public void run() { - FileChooser chooser = new FileChooser(); + String initialPath = mainPanel.getConfig().getValue("lastSourceDirectory"); + + FileChooser chooser; + + chooser = ((initialPath != null) ? new FileChooser(initialPath) : new FileChooser()); + chooser.setTitle(I18n.getMessage("thaw.plugin.transferLogs.chooseFile")); chooser.setDirectoryOnly(false); chooser.setDialogType(JFileChooser.OPEN_DIALOG); @@ -349,6 +354,10 @@ return; } + if (files.size() > 0) { + mainPanel.getConfig().setValue("lastSourceDirectory", chooser.getFinalDirectory()); + } + for (Iterator it = files.iterator(); it.hasNext(); ) { draft.addAttachment((File)it.next()); Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java 2007-09-06 00:42:25 UTC (rev 14981) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java 2007-09-06 00:59:22 UTC (rev 14982) @@ -81,10 +81,17 @@ private JLabel subject; + private KeyActionMenu keyActionMenu; public MessagePanel(MiniFrostPanel mainPanel) { this.mainPanel = mainPanel; + + /* keyActionMenu == Right click menu when you click on an highlighted key + */ + keyActionMenu = new KeyActionMenu(chkActions, indexActions); + + insidePanel = null; panel = new JPanel(new BorderLayout(15, 15)); @@ -535,7 +542,7 @@ } - protected static class KeyActionMenu extends JPopupMenu implements ActionListener { + protected class KeyActionMenu extends JPopupMenu implements ActionListener { private String key; private JMenuItem[] chkActions; private JMenuItem[] indexActions; @@ -631,32 +638,44 @@ } else if (e.getSource() == chkActions[0]) { /* download this key */ - thaw.gui.FileChooser chooser = new thaw.gui.FileChooser(); + String lastPath = mainPanel.getConfig().getValue("lastDestinationDirectory"); + thaw.gui.FileChooser chooser = (lastPath != null ? + new thaw.gui.FileChooser(lastPath) : + new thaw.gui.FileChooser()); + chooser.setTitle(I18n.getMessage("thaw.plugin.fetch.chooseDestination")); chooser.setDirectoryOnly(true); - chooser.setDialogType(javax.swing.JFileChooser.OPEN_DIALOG); + chooser.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG); java.io.File file = chooser.askOneFile(); if (file == null) return; + mainPanel.getConfig().setValue("lastDestinationDirectory", file.getPath()); + download(key, file); } else if (e.getSource() == chkActions[1]) { /* download all the keys */ - thaw.gui.FileChooser chooser = new thaw.gui.FileChooser(); + String lastPath = mainPanel.getConfig().getValue("lastDestinationDirectory"); + thaw.gui.FileChooser chooser = (lastPath != null ? + new thaw.gui.FileChooser(lastPath) : + new thaw.gui.FileChooser()); + chooser.setTitle(I18n.getMessage("thaw.plugin.fetch.chooseDestination")); chooser.setDirectoryOnly(true); - chooser.setDialogType(javax.swing.JFileChooser.OPEN_DIALOG); + chooser.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG); java.io.File file = chooser.askOneFile(); if (file == null) return; + mainPanel.getConfig().setValue("lastDestinationDirectory", file.getPath()); + Vector v = messagePanel.getCHKKeys(); for (Iterator it = v.iterator(); @@ -683,9 +702,7 @@ } - public final static KeyActionMenu keyActionMenu = new KeyActionMenu(chkActions, indexActions); - public void popMenuOnKey(MouseEvent e, String key) { keyActionMenu.setKeys(this, key); keyActionMenu.show(e.getComponent(), e.getX(), e.getY()); From jflesch at freenetproject.org Thu Sep 6 01:17:50 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 6 Sep 2007 01:17:50 +0000 (UTC) Subject: [Thaw-dev] r14983 - in trunk/apps/Thaw/src/thaw/plugins: miniFrost/frostKSK queueWatcher Message-ID: <20070906011750.2CEC647997F@freenetproject.org> Author: jflesch Date: 2007-09-06 01:17:49 +0000 (Thu, 06 Sep 2007) New Revision: 14983 Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKFileAttachment.java trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java Log: Try to fix the use of the tray icon by the plugin queueWatcher Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKFileAttachment.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKFileAttachment.java 2007-09-06 00:59:22 UTC (rev 14982) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKFileAttachment.java 2007-09-06 01:17:49 UTC (rev 14983) @@ -190,8 +190,11 @@ public void apply(Hsqldb db, FCPQueueManager queueManager, String action) { if (action.equals(I18n.getMessage("thaw.common.copyKeyToClipboard"))) { + thaw.gui.GUIHelper.copyToClipboard(key); + } else if (action.equals(I18n.getMessage("thaw.plugin.miniFrost.copyAllKeys"))) { + String keys = ""; Vector a = msg.getAttachments(); @@ -207,12 +210,15 @@ thaw.gui.GUIHelper.copyToClipboard(keys); } else if (action.equals(I18n.getMessage("thaw.common.action.download"))) { + keysToDownload = new Vector(); keysToDownload.add(key); Thread th = new Thread(this); th.start(); + } else if (action.equals(I18n.getMessage("thaw.plugin.miniFrost.downloadAll"))) { + keysToDownload = new Vector(); Vector a = msg.getAttachments(); @@ -227,6 +233,7 @@ Thread th = new Thread(this); th.start(); + } } @@ -235,7 +242,10 @@ /* yeah, I didn't realize that I may need the config here :/ */ Config config = ((KSKBoard)msg.getBoard()).getFactory().getCore().getConfig(); - FileChooser ch = new FileChooser(config.getValue("lastDestinationDirectory")); + String lastPath = config.getValue("lastDestinationDirectory"); + + FileChooser ch = ((lastPath != null) ? new FileChooser(lastPath) : new FileChooser()); + ch.setTitle(I18n.getMessage("thaw.plugin.fetch.chooseDestination")); ch.setDirectoryOnly(true); ch.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG); Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java 2007-09-06 00:59:22 UTC (rev 14982) +++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java 2007-09-06 01:17:49 UTC (rev 14983) @@ -298,6 +298,34 @@ } public void update(final Observable o, final Object arg) { + if (o == queueManager && arg == null) { + /* unclear change */ + reloadQueue(); + return; + } + + + if (o == queueManager) { + final FCPTransferQuery query = (FCPTransferQuery)arg; + + if((query.getQueryType() == 1) && isForInsertions) + return; + + if((query.getQueryType() == 2) && !isForInsertions) + return; + + if(queueManager.isInTheQueues(query)) { // then it's an adding + addQuery(query); + return; + } + + if(queries.contains(query)) { // then it's a removing + removeQuery(query); + return; + } + } + + if (o instanceof FCPTransferQuery && queries.indexOf(o) >= 0 && ((FCPTransferQuery)o).isFinished()) { @@ -340,31 +368,7 @@ return; } - if (o == queueManager && arg == null) { - reloadQueue(); - return; - } - if (o == queueManager) { - final FCPTransferQuery query = (FCPTransferQuery)arg; - - if((query.getQueryType() == 1) && isForInsertions) - return; - - if((query.getQueryType() == 2) && !isForInsertions) - return; - - if(queueManager.isInTheQueues(query)) { // then it's an adding - addQuery(query); - return; - } - - if(queries.contains(query)) { // then it's a removing - removeQuery(query); - return; - } - } - Logger.debug(this, "update(): unknow change"); reloadQueue(); } From jflesch at freenetproject.org Thu Sep 6 01:46:04 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 6 Sep 2007 01:46:04 +0000 (UTC) Subject: [Thaw-dev] r14984 - trunk/apps/Thaw/src/thaw/fcp Message-ID: <20070906014604.066CC4796EF@freenetproject.org> Author: jflesch Date: 2007-09-06 01:46:03 +0000 (Thu, 06 Sep 2007) New Revision: 14984 Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java Log: FCPClientGet should not notify its observers if the transfers is alread finished and that someone calls FCPClientGet.stop() Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2007-09-06 01:17:49 UTC (rev 14983) +++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2007-09-06 01:46:03 UTC (rev 14984) @@ -906,6 +906,8 @@ if(!removeRequest()) return false; + boolean wasFinished = isFinished(); + if (progress < 100) successful = false; @@ -914,7 +916,7 @@ fatal = true; status = "Stopped"; - if (!restartIfFailed) { + if (!restartIfFailed && !wasFinished) { setChanged(); this.notifyObservers(); } From jflesch at freenetproject.org Thu Sep 6 03:35:51 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 6 Sep 2007 03:35:51 +0000 (UTC) Subject: [Thaw-dev] r14985 - trunk/apps/Thaw/src/thaw/plugins/miniFrost Message-ID: <20070906033551.A250A47AAA5@freenetproject.org> Author: jflesch Date: 2007-09-06 03:35:51 +0000 (Thu, 06 Sep 2007) New Revision: 14985 Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java Log: Fix the button 'next unread message' in minifrost Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java 2007-09-06 01:46:03 UTC (rev 14984) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java 2007-09-06 03:35:51 UTC (rev 14985) @@ -499,7 +499,7 @@ } } - public java.util.Enumeration children() { + public Enumeration children() { synchronized(children) { return children.elements(); } @@ -1056,12 +1056,16 @@ return null; } - /* we first check if it has a child */ + /* we first check if it has an unread child */ - if (node.getChildCount() > 0) { - return ((MessageNode)node.getChildAt(0)).getMessage(); + for (Enumeration e = node.children(); + e.hasMoreElements();) { + MessageNode child = (MessageNode)e.nextElement(); + if (!child.getMessage().isRead()) + return child.getMessage(); } + /* if it has no child, we check if it has a brother (or if its parents * have brothers, etc) */ @@ -1081,11 +1085,12 @@ int i = parent.getIndex(node); - if (i < parent.getChildCount()-1) { - /* then it has a brother */ - return ((MessageNode)parent.getChildAt(i+1)).getMessage(); + for (i++ ; i < parent.getChildCount() ; i++) { + MessageNode child = (MessageNode)parent.getChildAt(i); + + if (!child.getMessage().isRead()) + return child.getMessage(); } - } return null; From jflesch at freenetproject.org Thu Sep 6 15:03:55 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 6 Sep 2007 15:03:55 +0000 (UTC) Subject: [Thaw-dev] r14986 - trunk/apps/Thaw/src/thaw/fcp Message-ID: <20070906150355.F3D0547AEB8@freenetproject.org> Author: jflesch Date: 2007-09-06 15:03:55 +0000 (Thu, 06 Sep 2007) New Revision: 14986 Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java Log: FCPClientPut should not notify its observers if the transfers is alread finished and that someone calls FCPClientPut.stop() Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2007-09-06 03:35:51 UTC (rev 14985) +++ trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2007-09-06 15:03:55 UTC (rev 14986) @@ -502,6 +502,8 @@ public boolean stop(final FCPQueueManager queueManager) { if(removeRequest()) { + boolean wasFinished = isFinished(); + status = "Stopped"; if (!finished) @@ -511,8 +513,10 @@ fatal= true; running = false; - setChanged(); - this.notifyObservers(); + if (!wasFinished) { + setChanged(); + this.notifyObservers(); + } return true; } From jflesch at freenetproject.org Wed Sep 12 18:00:44 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Wed, 12 Sep 2007 18:00:44 +0000 (UTC) Subject: [Thaw-dev] r15129 - trunk/apps/Thaw/src/thaw/plugins/miniFrost Message-ID: <20070912180044.BAC1B47A23A@freenetproject.org> Author: jflesch Date: 2007-09-12 18:00:44 +0000 (Wed, 12 Sep 2007) New Revision: 15129 Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java Log: Fix scrollbar adjustment in the message list + select the current message in the message list when using the button 'next unread message' Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java 2007-09-12 08:11:58 UTC (rev 15128) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java 2007-09-12 18:00:44 UTC (rev 15129) @@ -1042,8 +1042,12 @@ if (value < min) value = min; + if (value > max) + value = max; tableScrollPane.getVerticalScrollBar().setValue(value); + model.setSelectedAll(false); + model.switchSelection(line, true); } } From jflesch at freenetproject.org Wed Sep 12 19:28:26 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Wed, 12 Sep 2007 19:28:26 +0000 (UTC) Subject: [Thaw-dev] r15130 - trunk/apps/Thaw/src/thaw/plugins/miniFrost Message-ID: <20070912192826.2906147A33D@freenetproject.org> Author: jflesch Date: 2007-09-12 19:28:25 +0000 (Wed, 12 Sep 2007) New Revision: 15130 Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java Log: Improve the 'outlook' layout in minifrost Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java 2007-09-12 18:00:44 UTC (rev 15129) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java 2007-09-12 19:28:25 UTC (rev 15130) @@ -101,12 +101,6 @@ msgsPanel = new JPanel(new BorderLayout(0, 20)); msgsPanel.add(new JLabel(""), BorderLayout.CENTER); - scrollPane = new JScrollPane(msgsPanel, - JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - panel.add(scrollPane, BorderLayout.CENTER); - - /* actions */ actions = new JComboBox(ACTIONS); @@ -142,21 +136,31 @@ boolean gmailView = mainPanel.isInGmailView(); - if (gmailView) + if (gmailView) { northNorthPanel.add(new JLabel(""), BorderLayout.CENTER); - else - northNorthPanel.add(new JScrollPane(subject), BorderLayout.CENTER); + northNorthPanel.add(actions, BorderLayout.EAST); + northNorthPanel.add(buttonPanel, BorderLayout.WEST); + northPanel.add(northNorthPanel, BorderLayout.CENTER); + northPanel.add(new JScrollPane(subject), BorderLayout.SOUTH); - northNorthPanel.add(actions, BorderLayout.EAST); - northNorthPanel.add(buttonPanel, BorderLayout.WEST); + panel.add(northPanel, BorderLayout.NORTH); - northPanel.add(northNorthPanel, BorderLayout.CENTER); + scrollPane = new JScrollPane(msgsPanel, + JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - if (gmailView) - northPanel.add(new JScrollPane(subject), BorderLayout.SOUTH); + } else { /* => if outlook layout */ + JPanel globalPanel = new JPanel(new BorderLayout(10, 10)); + globalPanel.add(subject, BorderLayout.NORTH); + globalPanel.add(msgsPanel, BorderLayout.CENTER); - panel.add(northPanel, BorderLayout.NORTH); + scrollPane = new JScrollPane(globalPanel, + JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + } + + panel.add(scrollPane, BorderLayout.CENTER); } Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java 2007-09-12 18:00:44 UTC (rev 15129) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java 2007-09-12 19:28:25 UTC (rev 15130) @@ -92,7 +92,7 @@ }; - public final static String[] ACTIONS = new String[] { + public final static String[] GMAIL_ACTIONS = new String[] { I18n.getMessage("thaw.plugin.miniFrost.actions"), I18n.getMessage("thaw.plugin.miniFrost.selectAll"), I18n.getMessage("thaw.plugin.miniFrost.selectNone"), @@ -103,7 +103,19 @@ I18n.getMessage("thaw.plugin.miniFrost.unarchivate") }; + public final static String[] OUTLOOK_ACTIONS = new String[] { + I18n.getMessage("thaw.plugin.miniFrost.actions"), + I18n.getMessage("thaw.plugin.miniFrost.reply"), + I18n.getMessage("thaw.plugin.miniFrost.selectAll"), + I18n.getMessage("thaw.plugin.miniFrost.selectNone"), + I18n.getMessage("thaw.plugin.miniFrost.markAsRead"), + I18n.getMessage("thaw.plugin.miniFrost.markAsNonRead"), + I18n.getMessage("thaw.plugin.miniFrost.newMessage"), + I18n.getMessage("thaw.plugin.miniFrost.archivate"), + I18n.getMessage("thaw.plugin.miniFrost.unarchivate") + }; + public final static int FIRST_COLUMN_SIZE = 25; public final static int DEFAULT_ROW_HEIGHT = 20; @@ -140,6 +152,7 @@ private int minTrustLevelInt; private boolean advancedMode; + private boolean gmailView; /** for the thread tree **/ private MessageNodeTree messageNodeTree; @@ -147,6 +160,7 @@ public MessageTreeTable(MiniFrostPanel mainPanel) { this.mainPanel = mainPanel; + this.gmailView = mainPanel.isInGmailView(); orderBy = Board.ORDER_DATE; desc = true; @@ -186,7 +200,11 @@ northPanel.add(searchPanel, BorderLayout.CENTER); - actions = new JComboBox(ACTIONS); + if (gmailView) + actions = new JComboBox(GMAIL_ACTIONS); + else + actions = new JComboBox(OUTLOOK_ACTIONS); + actions.addActionListener(this); northPanel.add(actions, BorderLayout.EAST); @@ -1189,9 +1207,16 @@ if (sel <= 0) return; - if (sel == 3 || sel == 4) { /* mark as (non-)read */ - boolean markAsRead = (sel == 3); + if (gmailView) + sel += 1; + if (sel == 1) { /* reply */ + + mainPanel.getMessagePanel().reply(); + + } else if (sel == 4 || sel == 5) { /* mark as (non-)read */ + boolean markAsRead = (sel == 4); + for (int i = 0 ; i < selected.length ; i++) { if (selected[i]) { model.getMsg(i).setRead(markAsRead); @@ -1200,8 +1225,8 @@ } mainPanel.getBoardTree().refresh(targetBoard); - } else if (sel == 6 || sel == 7) { /* (un)archive */ - boolean archive = (sel == 6); + } else if (sel == 7 || sel == 8) { /* (un)archive */ + boolean archive = (sel == 7); for (int i = 0 ; i < selected.length ; i++) { if (selected[i]) @@ -1210,11 +1235,11 @@ refresh(); mainPanel.getBoardTree().refresh(targetBoard); - } else if (sel == 1 || sel == 2) { /* (un)select all */ - boolean select = (sel == 1); + } else if (sel == 2 || sel == 3) { /* (un)select all */ + boolean select = (sel == 2); model.setSelectedAll(select); model.refresh(); - } else if (sel == 5) { /* new message */ + } else if (sel == 6) { /* new message */ if (targetBoard != null) { Draft draft = targetBoard.getDraft(null); mainPanel.getDraftPanel().setDraft(draft); From jflesch at freenetproject.org Wed Sep 12 19:35:02 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Wed, 12 Sep 2007 19:35:02 +0000 (UTC) Subject: [Thaw-dev] r15131 - trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK Message-ID: <20070912193502.B26E447AEE6@freenetproject.org> Author: jflesch Date: 2007-09-12 19:35:02 +0000 (Wed, 12 Sep 2007) New Revision: 15131 Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java Log: Fix the dates in the list of sent messages Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java 2007-09-12 19:28:25 UTC (rev 15130) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java 2007-09-12 19:35:02 UTC (rev 15131) @@ -413,7 +413,7 @@ identity.toString(), identity.getId(), identity, - set.getDate("date"), + set.getTimestamp("date"), set.getInt("rev"), set.getBoolean("read"), set.getBoolean("archived"), From jflesch at freenetproject.org Thu Sep 13 08:53:59 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 13 Sep 2007 08:53:59 +0000 (UTC) Subject: [Thaw-dev] r15133 - in trunk/apps/Thaw/src/thaw/plugins: . MDNS index indexWebGrapher Message-ID: <20070913085359.15B134798AD@freenetproject.org> Author: jflesch Date: 2007-09-13 08:53:58 +0000 (Thu, 13 Sep 2007) New Revision: 15133 Added: trunk/apps/Thaw/src/thaw/plugins/MDNS/ trunk/apps/Thaw/src/thaw/plugins/MDNS/MDNSDiscovery.java trunk/apps/Thaw/src/thaw/plugins/MDNS/MDNSDiscoveryPanel.java Modified: trunk/apps/Thaw/src/thaw/plugins/index/FileList.java trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java trunk/apps/Thaw/src/thaw/plugins/index/Index.java trunk/apps/Thaw/src/thaw/plugins/index/IndexContainer.java trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java trunk/apps/Thaw/src/thaw/plugins/index/LinkList.java trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java trunk/apps/Thaw/src/thaw/plugins/indexWebGrapher/Node.java Log: Index browser : Improve the performances with large indexes Copied: trunk/apps/Thaw/src/thaw/plugins/MDNS/MDNSDiscovery.java (from rev 14001, trunk/apps/Thaw/src/thaw/core/MDNSDiscovery.java) =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/MDNS/MDNSDiscovery.java (rev 0) +++ trunk/apps/Thaw/src/thaw/plugins/MDNS/MDNSDiscovery.java 2007-09-13 08:53:58 UTC (rev 15133) @@ -0,0 +1,90 @@ +/* This code is part of Freenet. It is distributed under the GNU General + * Public License, version 2 (or at your option any later version). See + * http://www.gnu.org/ for further details of the GPL. */ + +package thaw.core; + + +import java.util.LinkedList; + +import javax.jmdns.JmDNS; +import javax.jmdns.ServiceEvent; +import javax.jmdns.ServiceInfo; +import javax.jmdns.ServiceListener; + + +public class MDNSDiscovery { + // SYNC IT!!! + private final LinkedList foundNodes; + private final JmDNS jmdns; + private Core core; + + public MDNSDiscovery(Core core) { + this.core = core; + this.foundNodes = new LinkedList(); + + try { + // Spawn the mdns listener + Logger.info(this, "Starting JMDNS ..."); + this.jmdns = new JmDNS(); + + // Start listening for new nodes + jmdns.addServiceListener(MDNSDiscoveryPanel.FCP_SERVICE_TYPE, new FCPMDNSListener()); + + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Error loading MDNSDiscoveryPanel : " + e.getMessage()); + } + } + + + private class FCPMDNSListener implements ServiceListener { + public void serviceAdded(ServiceEvent event) { + Logger.notice(this, "Service added : " + event.getName()+"."+event.getType()); + // Force the gathering of informations + jmdns.getServiceInfo(MDNSDiscoveryPanel.FCP_SERVICE_TYPE, event.getName()); + } + + public void serviceRemoved(ServiceEvent event) { + Logger.notice(this, "Service removed : " + event.getName()+"."+event.getType()); + ServiceInfo service = event.getInfo(); + + synchronized (foundNodes) { + foundNodes.remove(service); + synchronized (core.getConfigWindow().getNodeConfigPanel().getMdnsPanel()) { + core.getConfigWindow().getNodeConfigPanel().getMdnsPanel().notifyAll(); + } + } + } + + public void serviceResolved(ServiceEvent event) { + Logger.debug(this, "Service resolved: " + event.getInfo()); + ServiceInfo service = event.getInfo(); + + synchronized (foundNodes) { + foundNodes.add(service); + synchronized (core.getConfigWindow().getNodeConfigPanel().getMdnsPanel()) { + core.getConfigWindow().getNodeConfigPanel().getMdnsPanel().notifyAll(); + } + } + } + } + + + public boolean isHasTheSameIPAddress(ServiceInfo host) { + try{ + return (jmdns.getInterface().equals(host.getAddress()) ? true : false); + } catch (java.io.IOException e) { + return false; + } + } + + public LinkedList getFoundNodes() { + return foundNodes; + } + + public void stop() { + Logger.info(this, "Stopping JMDNS ..."); + jmdns.close(); + } +} Copied: trunk/apps/Thaw/src/thaw/plugins/MDNS/MDNSDiscoveryPanel.java (from rev 14001, trunk/apps/Thaw/src/thaw/core/MDNSDiscoveryPanel.java) =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/MDNS/MDNSDiscoveryPanel.java (rev 0) +++ trunk/apps/Thaw/src/thaw/plugins/MDNS/MDNSDiscoveryPanel.java 2007-09-13 08:53:58 UTC (rev 15133) @@ -0,0 +1,216 @@ +/* This code is part of Freenet. It is distributed under the GNU General + * Public License, version 2 (or at your option any later version). See + * http://www.gnu.org/ for further details of the GPL. */ + +package thaw.core; + +import javax.jmdns.ServiceInfo; +import javax.swing.DefaultListModel; + +import java.awt.Dialog; +import java.awt.GridLayout; +import java.awt.BorderLayout; +import javax.swing.JPanel; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JScrollPane; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.io.IOException; +import java.net.Socket; +import java.util.HashMap; +import java.util.Iterator; + +import javax.swing.JButton; + +import thaw.core.Logger; + +/** + * This panel implements Zeroconf (called Bonjour/RendezVous by apple) discovery for Thaw + * + * WARNING: for it to work, you must have a running freenet node on the same network subnet, using the MDNSDiscovery panel + * + * @author Florent Daignière <nextgens at freenetproject.org> + * + * @see http://wiki.freenetproject.org/MDNSDiscoverypanel + * + * @see http://www.dns-sd.org/ServiceTypes.html + * @see http://www.multicastdns.org/ + * @see http://jmdns.sourceforge.net/ + * + * TODO: implement the "Manual" mode + * TODO: maybe we should have a small progressbar shown in a new popup to introduce a "delay" at startup + */ +public class MDNSDiscoveryPanel extends JDialog implements ActionListener, Runnable { + public interface MDNSDiscoveryPanelCallback { + /** + * Called upon exit from MDNSDiscoveryPanelCallback + * It runs on its own thread but still, don't abuse it :) + */ + public void onMDNSDiscoverPanelClosure(boolean hasBeenCancelled); + } + private static final long serialVersionUID = 1L; + + public static final String FCP_SERVICE_TYPE = "_fcp._tcp.local."; + + private boolean goon; + private boolean cancelledByUser = false; + private ServiceInfo selectedValue; + private final MDNSDiscoveryPanelCallback cb; + private final Dialog owner; + private final HashMap displayedServiceInfos; + + private final JList list; + private final DefaultListModel listModel; + private final JLabel label; + + private final Core core; + + private JButton okButton; + private JButton cancelButton; + + + public MDNSDiscoveryPanel(Dialog owner, Core core, MDNSDiscoveryPanelCallback cb) { + super(owner, "ZeroConf"); + this.core = core; + this.owner = owner; + this.cb = cb; + this.displayedServiceInfos = new HashMap(); + + // The UI + list = new JList(); + listModel = new DefaultListModel(); + label = new JLabel(); + + list.setModel(listModel); + list.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); + + label.setText(I18n.getMessage("thaw.zeroconf.searchingNode") + +" ; "+ + I18n.getMessage("thaw.zeroconf.nodeList")); + + getContentPane().setLayout(new BorderLayout()); + getContentPane().add(label, BorderLayout.NORTH); + getContentPane().add(new JScrollPane(list), BorderLayout.CENTER); + + okButton = new JButton(I18n.getMessage("thaw.common.ok")); + cancelButton = new JButton(I18n.getMessage("thaw.common.cancel")); + + okButton.addActionListener(this); + cancelButton.addActionListener(this); + + JPanel buttonPanel = new JPanel(new GridLayout(1, 2)); + buttonPanel.add(okButton); + buttonPanel.add(cancelButton); + + getContentPane().add(buttonPanel, BorderLayout.SOUTH); + pack(); + } + + + + /** + * The user has selected something: notify the main loop and process the data. + */ + public void actionPerformed(ActionEvent e) { + Object source = e.getSource(); + + if ((source == okButton) || (source == cancelButton)){ + goon = false; + if(source == okButton) { + if(list.getSelectedValue() == null) return; + selectedValue = (ServiceInfo) displayedServiceInfos.get(list.getSelectedValue()); + } else + cancelledByUser = true; + + synchronized (this) { + notifyAll(); + } + Logger.info(this, "User has selected : " + selectedValue); + } + } + + /** + * The main loop : TheRealMeat(TM) + * + */ + public void run() { + super.setLocationRelativeTo(this.getParent()); + this.setVisible(true); + owner.setEnabled(false); + + Logger.notice(this, "Show the MDNSDiscoveryPanel"); + Socket testSocket = null; + boolean isConfigValid = false; + goon = true; + + do { + // Loop until a selection is done + while(goon) { + synchronized (core.getMDNSDiscovery().getFoundNodes()) { + if(core.getMDNSDiscovery().getFoundNodes().size() > 0) { + listModel.clear(); + Iterator it = core.getMDNSDiscovery().getFoundNodes().iterator(); + while(it.hasNext()) { + ServiceInfo current = (ServiceInfo) it.next(); + listModel.addElement(current.getName()); + displayedServiceInfos.put(current.getName(), current); + } + list.repaint(); + } + } + + try { + synchronized (this) { + wait(Integer.MAX_VALUE); + } + } catch (InterruptedException e) {} + } + + if(cancelledByUser) break; + else if(selectedValue == null) continue; + + Logger.debug(this, "We got something from the UI : let's try to connect"); + + try { + // We try to connect to the server + // TODO: implement a proper test! + testSocket = new Socket(selectedValue.getHostAddress(), selectedValue.getPort()); + isConfigValid = testSocket.isConnected(); + + // Close the fcp socket we have openned, cleanup + testSocket.close(); + } catch (IOException e) { + isConfigValid = false; + } + + Logger.debug(this, "isConfigValid ="+isConfigValid); + + // Reload, just in case it failed... + goon = true; + list.removeSelectionInterval(0, core.getMDNSDiscovery().getFoundNodes().size()); + } while(!isConfigValid); + + + this.setVisible(false); + owner.setEnabled(true); + + if (!cancelledByUser) { + Logger.debug(this, "We got something that looks valid from the UI : let's propagate changes to the config"); + // Save the config. now that we know it's valid + core.getConfig().setValue("nodeAddress", selectedValue.getHostAddress()); + core.getConfig().setValue("nodePort", new Integer(selectedValue.getPort()).toString()); + core.getConfig().setValue("sameComputer", String.valueOf(core.getMDNSDiscovery().isHasTheSameIPAddress(selectedValue))); + + + Logger.info(this, "We are done : configuration has been saved sucessfully."); + + }else + Logger.info(this, "The user has cancelled!"); + cb.onMDNSDiscoverPanelClosure(cancelledByUser); + Logger.notice(this, "We got back from the MDNSDiscoveryPanel callback"); + } + + +} Modified: trunk/apps/Thaw/src/thaw/plugins/index/FileList.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/FileList.java 2007-09-13 06:19:00 UTC (rev 15132) +++ trunk/apps/Thaw/src/thaw/plugins/index/FileList.java 2007-09-13 08:53:58 UTC (rev 15133) @@ -7,5 +7,5 @@ */ public interface FileList { - public Vector getFileList(String columnToSort, boolean asc); + public File[] getFileList(String columnToSort, boolean asc); } Modified: trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java 2007-09-13 06:19:00 UTC (rev 15132) +++ trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java 2007-09-13 08:53:58 UTC (rev 15133) @@ -206,11 +206,11 @@ protected Vector getSelectedFiles(final int[] selectedRows) { //final Vector srcList = fileList.getFileList(fileListModel.getColumnNameInDb(columnToSort), sortAsc); - final Vector srcList = fileListModel.getFiles(); + final File[] srcList = fileListModel.getFiles(); final Vector files = new Vector(); for(int i = 0 ; i < selectedRows.length ; i++) { - files.add(srcList.get(selectedRows[i])); + files.add(srcList[selectedRows[i]]); } return files; @@ -310,7 +310,7 @@ }; - public Vector files = null; /* thaw.plugins.index.File Vector */ + public File[] files = null; public FileList fileList; @@ -324,7 +324,7 @@ refresh(); } - public Vector getFiles() { + public File[] getFiles() { return files; } @@ -332,7 +332,7 @@ if (files == null) return 0; - return files.size(); + return files.length; } public int getColumnCount() { @@ -363,10 +363,10 @@ if (files == null) return null; - if (row >= files.size()) + if (row >= files.length) return null; - final thaw.plugins.index.File file = (thaw.plugins.index.File)files.get(row); + final thaw.plugins.index.File file = (thaw.plugins.index.File)files[row]; if(column == 0) return file.getFilename(); @@ -428,7 +428,7 @@ } public void run() { - int i, max; + int max; while(running) { try { @@ -443,14 +443,11 @@ if (fileListModel.getFiles() == null) continue; - i = 0; + File[] files = fileListModel.getFiles(); - Vector files = fileListModel.getFiles(); + for (int i = 0 ; i < files.length ; i++) { + thaw.plugins.index.File file = (thaw.plugins.index.File)files[i]; - for (Iterator it = files.iterator() ; - it.hasNext(); i++) { - thaw.plugins.index.File file = (thaw.plugins.index.File)it.next(); - if (file.getPublicKey() == null || !FreenetURIHelper.isAKey(file.getPublicKey())) { FCPTransferQuery transfer; Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-09-13 06:19:00 UTC (rev 15132) +++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-09-13 08:53:58 UTC (rev 15133) @@ -1,7 +1,6 @@ package thaw.plugins.index; -import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.OutputStream; @@ -44,9 +43,9 @@ import thaw.plugins.Hsqldb; import thaw.plugins.insertPlugin.DefaultMIMETypes; import thaw.plugins.signatures.Identity; +import thaw.plugins.index.File; - public class Index extends Observable implements MutableTreeNode, IndexTreeNode, Observer, @@ -726,7 +725,7 @@ else tmpdir = tmpdir + java.io.File.separator; - File targetFile = new java.io.File(tmpdir + getRealName() +".frdx"); + java.io.File targetFile = new java.io.File(tmpdir + getRealName() +".frdx"); Logger.info(this, "Generating index ..."); @@ -1159,15 +1158,15 @@ ////// FILE LIST //////// - public Vector getFileList() { + public File[] getFileList() { return getFileList(null, false); } - public Vector getFileList(String columnToSort, boolean asc) { + public File[] getFileList(String columnToSort, boolean asc) { synchronized(db.dbLock) { try { - Vector files = new Vector(); + java.util.LinkedList files = new java.util.LinkedList(); PreparedStatement st; @@ -1199,7 +1198,7 @@ files.add(file); } - return files; + return (File[])files.toArray(new File[0]); } catch(SQLException e) { Logger.error(this, "SQLException while getting file list: "+e.toString()); @@ -1244,15 +1243,15 @@ //// LINKS //// - public Vector getLinkList() { + public Link[] getLinkList() { return getLinkList(null, false); } - public Vector getLinkList(String columnToSort, boolean asc) { + public Link[] getLinkList(String columnToSort, boolean asc) { synchronized(db.dbLock) { try { - Vector links = new Vector(); + java.util.LinkedList links = new java.util.LinkedList(); PreparedStatement st; @@ -1270,7 +1269,7 @@ links.add(l); } - return links; + return (Link[])links.toArray(new Link[0]); } catch(SQLException e) { Logger.error(this, "SQLException while getting link list: "+e.toString()); Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexContainer.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexContainer.java 2007-09-13 06:19:00 UTC (rev 15132) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexContainer.java 2007-09-13 08:53:58 UTC (rev 15133) @@ -1,8 +1,8 @@ package thaw.plugins.index; import java.util.Vector; +import thaw.plugins.index.File; - /** * This is what you need to implements to use IndexParser. */ @@ -11,12 +11,12 @@ /** * @return a vector of FileContainer */ - public Vector getFileList(); + public File[] getFileList(); /** * @return a vector of LinkContainer */ - public Vector getLinkList(); + public Link[] getLinkList(); /** Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-09-13 06:19:00 UTC (rev 15132) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-09-13 08:53:58 UTC (rev 15133) @@ -1869,17 +1869,16 @@ } else if (node instanceof Index) { - Vector files = ((Index)node).getFileList(null, true); + thaw.plugins.index.File[] files = ((Index)node).getFileList(null, true); - nmbFilesInt = files.size(); - nmbLinksInt = ((Index)node).getLinkList(null, true).size(); + nmbFilesInt = files.length; + nmbLinksInt = ((Index)node).getLinkList(null, true).length; insertionDate = ((Index)node).getDate(); totalSize = 0; - for (Iterator it = files.iterator(); - it.hasNext();) { - totalSize += ((thaw.plugins.index.File)it.next()).getSize(); + for (int i = 0 ; i < files.length ; i++) { + totalSize += ((thaw.plugins.index.File)files[i]).getSize(); } } Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java 2007-09-13 06:19:00 UTC (rev 15132) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java 2007-09-13 08:53:58 UTC (rev 15133) @@ -192,10 +192,10 @@ public Element getXMLLinks(final Document xmlDoc) { final Element linksEl = xmlDoc.createElement("indexes"); - Vector links = index.getLinkList(); + LinkContainer[] links = index.getLinkList(); - for(Iterator it = links.iterator(); it.hasNext() ; ) { - LinkContainer link = (LinkContainer)it.next(); + for(int i = 0 ; i < links.length ; i++) { + LinkContainer link = links[i]; String key = index.findTheLatestKey(link.getPublicKey()); @@ -213,11 +213,11 @@ public Element getXMLFileList(final Document xmlDoc) { final Element filesEl = xmlDoc.createElement("files"); - Vector files = index.getFileList(); + FileContainer[] files = index.getFileList(); - for(Iterator it = files.iterator(); it.hasNext();) { + for(int i = 0 ; i < files.length ; i++) { - FileContainer file = (FileContainer)it.next(); + FileContainer file = (FileContainer)files[i]; String pubKey = file.getPublicKey(); Modified: trunk/apps/Thaw/src/thaw/plugins/index/LinkList.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/LinkList.java 2007-09-13 06:19:00 UTC (rev 15132) +++ trunk/apps/Thaw/src/thaw/plugins/index/LinkList.java 2007-09-13 08:53:58 UTC (rev 15133) @@ -4,6 +4,6 @@ public interface LinkList { - public Vector getLinkList(String columnToSort, boolean asc); + public Link[] getLinkList(String columnToSort, boolean asc); } Modified: trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java 2007-09-13 06:19:00 UTC (rev 15132) +++ trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java 2007-09-13 08:53:58 UTC (rev 15133) @@ -171,11 +171,11 @@ protected Vector getSelectedLinks(final int[] selectedRows) { //final Vector srcList = linkList.getLinkList(null, false); - final Vector srcList = linkListModel.getLinks(); + final Link[] srcList = linkListModel.getLinks(); final Vector links = new Vector(); for(int i = 0 ; i < selectedRows.length ; i++) { - final Link link = (Link)srcList.get(selectedRows[i]); + final Link link = (Link)srcList[selectedRows[i]]; links.add(link); } @@ -268,7 +268,7 @@ public Vector columnNames; - public Vector links = null; /* thaw.plugins.index.Link Vector */ + public Link[] links = null; /* thaw.plugins.index.Link Vector */ public LinkList linkList; @@ -290,7 +290,7 @@ } - public Vector getLinks() { + public Link[] getLinks() { return links; } @@ -298,7 +298,7 @@ if (links == null) return 0; - return links.size(); + return links.length; } public int getColumnCount() { @@ -310,7 +310,7 @@ } public Object getValueAt(final int row, final int column) { - final thaw.plugins.index.Link link = (thaw.plugins.index.Link)links.get(row); + final thaw.plugins.index.Link link = (thaw.plugins.index.Link)links[row]; switch(column) { case(0): return link.getIndexName(); Modified: trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java 2007-09-13 06:19:00 UTC (rev 15132) +++ trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java 2007-09-13 08:53:58 UTC (rev 15133) @@ -65,12 +65,12 @@ } } - public Vector getFileList(String col, boolean asc) { + public File[] getFileList(String col, boolean asc) { if (col == null) col = "filename"; - Vector v = new Vector(); + java.util.LinkedList v = new java.util.LinkedList(); synchronized(db.dbLock) { try { @@ -100,11 +100,11 @@ } } - return v; + return (File[])v.toArray(new File[0]); } - public Vector getLinkList(String col, boolean asc) { - Vector v = new Vector(); + public Link[] getLinkList(String col, boolean asc) { + java.util.LinkedList v = new java.util.LinkedList(); synchronized(db.dbLock) { try { @@ -131,7 +131,7 @@ } } - return v; + return (Link[])v.toArray(new Link[0]); } } Modified: trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java 2007-09-13 06:19:00 UTC (rev 15132) +++ trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java 2007-09-13 08:53:58 UTC (rev 15133) @@ -34,7 +34,7 @@ public class UnknownIndexList implements MouseListener, ActionListener { - private Vector linkList; /* only when < MAX_INDEXES */ + private Vector linkList; private JPanel panel; private JList list; @@ -162,30 +162,55 @@ return true; } - /** - * will add the link from that index (if links link to unknown indexes) - */ - public boolean addLinks(final LinkList index) { - boolean ret = false; + private class LinkAdder implements Runnable { + private LinkList index; + private boolean running; - if (index == null) - return false; + public LinkAdder(LinkList index) { + this.index = index; + this.running = true; + } - final Vector ll = index.getLinkList(null, false); + public void run() { + boolean ret = false; - if ((ll == null) || (ll.size() == 0)) - return false; + final Link[] ll = index.getLinkList(null, false); - for (final Iterator it = ll.iterator(); - it.hasNext();) { - if (addLink(((Link)it.next()), false)) - ret = true; + if ((ll == null) || (ll.length == 0)) + return; + + for (int i = 0 ; i < ll.length && running ; i++) { + if (addLink(ll[i], false)) + ret = true; + } + + if (ret) + refresh(); + + return; } - if (ret) - refresh(); + public void stop() { + running = false; + } + } - return ret; + private LinkAdder lastLinkAdder = null; + + + /** + * will add the link from that index (if links link to unknown indexes) + */ + public void addLinks(final LinkList index) { + if (index == null) + return; + + if (lastLinkAdder != null) + lastLinkAdder.stop(); + + lastLinkAdder = new LinkAdder(index); + Thread th = new Thread(lastLinkAdder); + th.start(); } Modified: trunk/apps/Thaw/src/thaw/plugins/indexWebGrapher/Node.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/indexWebGrapher/Node.java 2007-09-13 06:19:00 UTC (rev 15132) +++ trunk/apps/Thaw/src/thaw/plugins/indexWebGrapher/Node.java 2007-09-13 08:53:58 UTC (rev 15133) @@ -119,7 +119,7 @@ private double velocityX = 0.0; private double velocityY = 0.0; - public final static double TIMESTEP = 0.001; + public final static double TIMESTEP = 0.01; public final static int NMB_STEPS = 50000; public final static double FACTOR_ATTRACTION = 0.5; public final static double FACTOR_REPULSION = 1; @@ -129,106 +129,45 @@ public final static double MIN_KINETIC = 0.1; /* will stop if < */ /** - * attracted by its peers/neightbours + * see http://en.wikipedia.org/wiki/Force-based_algorithms * @return velocity */ - private double[] attraction(Node node) { - double attrX = 0.0; - double attrY = 0.0; - - attrX = (node.getX() - x)*FACTOR_ATTRACTION; - attrY = (node.getY() - y)*FACTOR_ATTRACTION; - - return new double[] {attrX, attrY}; - } - - /** - * repulsed by all the node != peers / neightbours - */ - private double[] repulsion(Node node) { - double repX = 0.0; - double repY = 0.0; - - if (x != node.getX()) { - repX = (1/(x-node.getX())*FACTOR_REPULSION); - } - - if (y != node.getY()) { - repY = (1/(y-node.getY())*FACTOR_REPULSION); - } - - - if (repX > REPULSE_LIMIT) repX = REPULSE_LIMIT; - if (repY > REPULSE_LIMIT) repY = REPULSE_LIMIT; - if (repX < -REPULSE_LIMIT) repX = -REPULSE_LIMIT; - if (repY < -REPULSE_LIMIT) repY = -REPULSE_LIMIT; - - - return new double[] {repX, repY}; - } - - /** - * see http://en.wikipedia.org/wiki/Force-based_algorithms - * @return velocity - */ public double computeVelocity(Vector nodeList) { double netForceX = 0.0; double netForceY = 0.0; - /* repulsion */ - for (Iterator it = nodeList.iterator(); - it.hasNext();) { - Node node = (Node)it.next(); + if ( ((linkTo.size() + linkedFrom.size()) > 1) + && (linkTo.size() > 1 || linkedFrom.size() > 1) ) + { + double sumX = 0.0; + double sumY = 0.0; - /* - if (node == this - || linkTo.indexOf(node) >= 0 - || linkedFrom.indexOf(node) >= 0) - continue; - */ - if (node == this) - continue; + for (Iterator it = linkTo.iterator(); + it.hasNext();) { + Node node = (Node)it.next(); + sumX += node.getX(); + sumY += node.getY(); + } - double[] repuls = repulsion(node); - netForceX += repuls[0]; - netForceY += repuls[1]; - } + for (Iterator it = linkedFrom.iterator(); + it.hasNext();) { + Node node = (Node)it.next(); + sumX += node.getX(); + sumY += node.getY(); + } - /* attraction */ + double centerX = sumX / (linkedFrom.size() + linkTo.size()); + double centerY = sumY / (linkedFrom.size() + linkTo.size()); - for (Iterator it = linkTo.iterator(); - it.hasNext();) { - Node node = (Node)it.next(); - - if (node == this) - continue; - - double[] attr = attraction(node); - netForceX += attr[0]; - netForceY += attr[1]; + netForceX = centerX - x; + netForceY = centerY - y; } + //velocityX = velocityX/FACTOR_DECELERATION; + //velocityY = velocityY/FACTOR_DECELERATION; - /* attraction */ + velocityX = netForceX; + velocityY = netForceY; - for (Iterator it = linkedFrom.iterator(); - it.hasNext();) { - Node node = (Node)it.next(); - - if (node == this || linkTo.indexOf(node) >= 0) - continue; - - double[] attr = attraction(node); - netForceX += attr[0]; - netForceY += attr[1]; - } - - - velocityX = velocityX/FACTOR_DECELERATION; - velocityY = velocityY/FACTOR_DECELERATION; - - velocityX += netForceX; - velocityY += netForceY; - return Math.sqrt( Math.pow(velocityX,2) + Math.pow(velocityY, 2)); } @@ -241,7 +180,6 @@ x += velocityX * TIMESTEP; y += velocityY * TIMESTEP; - return true; } From jflesch at freenetproject.org Thu Sep 13 09:08:19 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 13 Sep 2007 09:08:19 +0000 (UTC) Subject: [Thaw-dev] r15134 - in trunk/apps/Thaw/src/thaw/plugins: . miniFrost Message-ID: <20070913090819.29FD6479802@freenetproject.org> Author: jflesch Date: 2007-09-13 09:08:18 +0000 (Thu, 13 Sep 2007) New Revision: 15134 Removed: trunk/apps/Thaw/src/thaw/plugins/MDNS/ Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/SubMessagePanel.java Log: Remove some unknown/useless files Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/SubMessagePanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/miniFrost/SubMessagePanel.java 2007-09-13 08:53:58 UTC (rev 15133) +++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/SubMessagePanel.java 2007-09-13 09:08:18 UTC (rev 15134) @@ -202,7 +202,6 @@ { "USK@", ".frdx" }, }; - public final static String KEY_ATTRIBUTE = "key"; From nextgens at freenetproject.org Thu Sep 13 12:20:26 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Thu, 13 Sep 2007 12:20:26 +0000 (UTC) Subject: [Thaw-dev] r15138 - in trunk/apps/Thaw/src/thaw: fcp plugins/transferLogs Message-ID: <20070913122026.4D35D47A371@freenetproject.org> Author: nextgens Date: 2007-09-13 12:20:26 +0000 (Thu, 13 Sep 2007) New Revision: 15138 Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java trunk/apps/Thaw/src/thaw/plugins/transferLogs/Transfer.java Log: Thaw: implement bits of something meant to make the TransfertPlugin more accurate Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2007-09-13 11:47:07 UTC (rev 15137) +++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2007-09-13 12:20:26 UTC (rev 15138) @@ -30,6 +30,8 @@ private String filename = null; /* Extract from the key */ private int priority = DEFAULT_PRIORITY; private int persistence = PERSISTENCE_FOREVER; + private long startupTime = -1; + private long completionTime = -1; private boolean globalQueue = true; private String destinationDir = null; private String finalPath = null; @@ -559,6 +561,8 @@ running = true; successful = true; progress = 99; + startupTime = Long.valueOf(message.getValue("StartupTime")).longValue(); + completionTime = Long.valueOf(message.getValue("CompletionTime")).longValue(); status = "Writing to disk"; Logger.info(this, "Receiving file ..."); @@ -1145,4 +1149,14 @@ public int getProtocolErrorCode() { return protocolErrorCode; } + + + public long getCompletionTime() { + return completionTime; + } + + + public long getStartupTime() { + return startupTime; + } } Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2007-09-13 11:47:07 UTC (rev 15137) +++ trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2007-09-13 12:20:26 UTC (rev 15138) @@ -34,6 +34,8 @@ private String privateKey; /* must finish by '/' (cf SSKKeypair) */ private String publicKey; /* publicKey contains the filename etc */ private int priority = DEFAULT_PRIORITY; + private long startupTime = -1; + private long completionTime = -1; private boolean global = true; private int persistence = PERSISTENCE_FOREVER; private boolean getCHKOnly = false; @@ -588,11 +590,13 @@ return; } - if("PutSuccessful".equals( msg.getMessageName() )) { + if("PutSuccessful".equals(msg.getMessageName())) { successful = true; finished = true; running = false; - + + startupTime = Long.valueOf(msg.getValue("StartupTime")).longValue(); + completionTime = Long.valueOf(msg.getValue("CompletionTime")).longValue(); publicKey = msg.getValue("URI"); if (publicKey == null) { @@ -1118,4 +1122,12 @@ public int getPutFailedCode() { return putFailedCode; } + + public long getStartupTime() { + return startupTime; + } + + public long getCompletionTime() { + return completionTime; + } } Modified: trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java 2007-09-13 11:47:07 UTC (rev 15137) +++ trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java 2007-09-13 12:20:26 UTC (rev 15138) @@ -38,6 +38,17 @@ public int getFCPPriority(); /** + * When did the request start ? + */ + public long getStartupTime(); + + /** + * When did the request finish ? + * @return -1 if not finished + */ + public long getCompletionTime(); + + /** * call updatePersistentRequest() after to apply the change (Please note that the change * will be visible even if you don't call it). */ Modified: trunk/apps/Thaw/src/thaw/plugins/transferLogs/Transfer.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/transferLogs/Transfer.java 2007-09-13 11:47:07 UTC (rev 15137) +++ trunk/apps/Thaw/src/thaw/plugins/transferLogs/Transfer.java 2007-09-13 12:20:26 UTC (rev 15138) @@ -10,7 +10,6 @@ import thaw.fcp.FCPTransferQuery; import thaw.fcp.FCPClientPut; -import thaw.fcp.FCPClientGet; import thaw.fcp.FreenetURIHelper; import thaw.plugins.Hsqldb; @@ -198,8 +197,12 @@ "VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); st.setTimestamp(1, now); - if (query.isFinished()) - st.setTimestamp(2, now); + long tstamp = query.getStartupTime(); + if(tstamp != -1) + st.setTimestamp(1, new Timestamp(tstamp)); + tstamp = query.getCompletionTime(); + if (tstamp != -1) + st.setTimestamp(2, new Timestamp(tstamp)); else st.setNull(2, Types.TIMESTAMP); From nextgens at freenetproject.org Thu Sep 13 14:45:56 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Thu, 13 Sep 2007 14:45:56 +0000 (UTC) Subject: [Thaw-dev] r15141 - trunk/apps/Thaw/src/thaw/plugins/transferLogs Message-ID: <20070913144556.139DA479617@freenetproject.org> Author: nextgens Date: 2007-09-13 14:45:55 +0000 (Thu, 13 Sep 2007) New Revision: 15141 Modified: trunk/apps/Thaw/src/thaw/plugins/transferLogs/Transfer.java Log: Thaw: Fix/finish last commit Modified: trunk/apps/Thaw/src/thaw/plugins/transferLogs/Transfer.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/transferLogs/Transfer.java 2007-09-13 14:13:51 UTC (rev 15140) +++ trunk/apps/Thaw/src/thaw/plugins/transferLogs/Transfer.java 2007-09-13 14:45:55 UTC (rev 15141) @@ -143,6 +143,7 @@ if (entryFound) { /* we check if we must update the entry */ boolean mustUpdateKey = false; + boolean mustUpdateDateStart = false; boolean mustUpdateDateEnd = false; boolean mustUpdateSize = false; @@ -156,6 +157,9 @@ && !qKey.equals(this.key)) /* the key has changed ? can it happen ? */ mustUpdateKey = true; + if((query.getStartupTime() != dateStart.getTime()) && (query.getStartupTime() != -1)) + mustUpdateDateStart = true; + if (query.isFinished() && this.dateEnd == null) mustUpdateDateEnd = true; @@ -163,14 +167,16 @@ && query.getFileSize() >= size) mustUpdateSize = true; - if (mustUpdateKey) { updateKey(qKey); } - + if (mustUpdateDateStart) { + updateDateStart(); + } + if (mustUpdateDateEnd) { - updateDateEnd(query.isSuccessful()); + updateDateEnd(); } if (mustUpdateSize) { @@ -197,12 +203,8 @@ "VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); st.setTimestamp(1, now); - long tstamp = query.getStartupTime(); - if(tstamp != -1) - st.setTimestamp(1, new Timestamp(tstamp)); - tstamp = query.getCompletionTime(); - if (tstamp != -1) - st.setTimestamp(2, new Timestamp(tstamp)); + if (query.isFinished()) + st.setTimestamp(2, now); else st.setNull(2, Types.TIMESTAMP); @@ -268,23 +270,39 @@ } - private void updateDateEnd(boolean success) { + private void updateDateEnd() { Logger.info(this, "Updating end date in logs"); try { PreparedStatement st = db.getConnection().prepareStatement("UPDATE transferLogs SET "+ - "dateEnd = ?, isSuccess = ? "+ + "dateEnd = ?"+ "WHERE id = ?"); - st.setTimestamp(1, TransferLogs.getNow()); - st.setBoolean(2, success); - st.setInt(3, this.id); + dateEnd = new Timestamp(query.getCompletionTime()); + st.setTimestamp(1, dateEnd); + st.setInt(2, this.id); st.execute(); } catch(SQLException e) { Logger.error(this, "Unable to update dateEnd in transfer logs because : "+e.toString()); } } + + private void updateDateStart() { + Logger.info(this, "Updating start date in logs"); + try { + PreparedStatement st = db.getConnection().prepareStatement("UPDATE transferLogs SET "+ + "dateStart = ?"+ + "WHERE id = ?"); + dateStart = new Timestamp(query.getStartupTime()); + st.setTimestamp(1, dateStart); + st.setInt(2, 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, @@ -405,7 +423,7 @@ if (query.isFinished()) { o.deleteObserver(this); - updateDateEnd(query.isSuccessful()); + updateDateEnd(); hasChanged = true; } From jflesch at freenetproject.org Thu Sep 20 22:25:49 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 20 Sep 2007 22:25:49 +0000 (UTC) Subject: [Thaw-dev] r15218 - in trunk/apps/Thaw/src/thaw/plugins: . transferLogs Message-ID: <20070920222549.386C03C0410@freenetproject.org> Author: jflesch Date: 2007-09-20 22:25:49 +0000 (Thu, 20 Sep 2007) New Revision: 15218 Modified: trunk/apps/Thaw/src/thaw/plugins/TrayIcon.java trunk/apps/Thaw/src/thaw/plugins/transferLogs/Transfer.java Log: Make it possible to disable tray icon popups (no visible option in the GUI : edit thaw.conf.xml) Modified: trunk/apps/Thaw/src/thaw/plugins/TrayIcon.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/TrayIcon.java 2007-09-20 22:22:23 UTC (rev 15217) +++ trunk/apps/Thaw/src/thaw/plugins/TrayIcon.java 2007-09-20 22:25:49 UTC (rev 15218) @@ -25,6 +25,7 @@ import java.awt.BorderLayout; import thaw.core.Core; +import thaw.core.Config; import thaw.core.Logger; import thaw.core.I18n; @@ -35,6 +36,7 @@ import thaw.gui.IconBox; import thaw.gui.WarningWindow; + public class TrayIcon implements thaw.core.Plugin, MouseListener, WindowListener, @@ -42,6 +44,8 @@ thaw.core.LogListener { private Core core; + private Config config; + private SysTrayIcon icon; private JDialog dialog; @@ -58,6 +62,7 @@ public boolean run(Core core) { this.core = core; + this.config = core.getConfig(); if (!Core.checkJavaVersion(1, 6)) { new WarningWindow(core, @@ -65,6 +70,8 @@ return false; } + config.setValue("disableTrayIconPopups", "false"); + icon = new SysTrayIcon(thaw.gui.IconBox.blueBunny); icon.setToolTip("Thaw "+thaw.core.Main.VERSION); icon.addMouseListener(this); @@ -132,6 +139,12 @@ if (icon == null || !icon.canWork()) return false; + String cfg; + + if ( (cfg = config.getValue("disableTrayIconPopups")) != null ) + if (Boolean.TRUE.equals(cfg)) + return false; + icon.popMessage(title, message, msgType); return true; Modified: trunk/apps/Thaw/src/thaw/plugins/transferLogs/Transfer.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/transferLogs/Transfer.java 2007-09-20 22:22:23 UTC (rev 15217) +++ trunk/apps/Thaw/src/thaw/plugins/transferLogs/Transfer.java 2007-09-20 22:25:49 UTC (rev 15218) @@ -184,7 +184,8 @@ } } else { /* we insert a new one */ - /* except if this query has already ended, because it means we weren't + /* 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; From jflesch at freenetproject.org Thu