Author: jflesch
Date: 2006-06-16 22:46:12 +0000 (Fri, 16 Jun 2006)
New Revision: 9236
Added:
trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java
trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java
trunk/apps/Thaw/src/thaw/plugins/fetchPlugin/
trunk/apps/Thaw/src/thaw/plugins/insertPlugin/
trunk/apps/Thaw/src/thaw/plugins/queueWatcher/
trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java
trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java
Modified:
trunk/apps/Thaw/build.xml
trunk/apps/Thaw/src/thaw/core/Config.java
trunk/apps/Thaw/src/thaw/core/ConfigWindow.java
trunk/apps/Thaw/src/thaw/core/Core.java
trunk/apps/Thaw/src/thaw/core/MainWindow.java
trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java
trunk/apps/Thaw/src/thaw/core/Plugin.java
trunk/apps/Thaw/src/thaw/core/PluginConfigPanel.java
trunk/apps/Thaw/src/thaw/core/PluginManager.java
trunk/apps/Thaw/src/thaw/i18n/thaw.properties
trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java
Log:
2 plugins on 3 have now an UI (but nothing behind)
Modified: trunk/apps/Thaw/build.xml
===================================================================
--- trunk/apps/Thaw/build.xml 2006-06-16 22:32:10 UTC (rev 9235)
+++ trunk/apps/Thaw/build.xml 2006-06-16 22:46:12 UTC (rev 9236)
@@ -58,9 +58,8 @@
<target name="javadoc">
- <javadoc sourcepath="${src.dir}" destdir="${javadoc}">
+ <javadoc sourcepath="${src.dir}" destdir="${javadoc.dir}">
<fileset dir="${src.dir}" includes="**/*.java" />
- <fileset dir="${lib.dir}" includes="hsqldb.jar" />
</javadoc>
</target>
Modified: trunk/apps/Thaw/src/thaw/core/Config.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Config.java 2006-06-16 22:32:10 UTC (rev
9235)
+++ trunk/apps/Thaw/src/thaw/core/Config.java 2006-06-16 22:46:12 UTC (rev
9236)
@@ -283,4 +283,19 @@
return true;
}
+
+ public boolean isEmpty() {
+ if(parameters.keySet().size() == 0)
+ return true;
+ return false;
+ }
+
+
+ public void setDefaultValues() {
+ setValue("nodeAddress", "127.0.0.1");
+ setValue("nodePort", "9481");
+ setValue("maxSimultaneousDownloads", "5");
+ setValue("maxSimultaneousInsertions", "2");
+ }
+
}
Modified: trunk/apps/Thaw/src/thaw/core/ConfigWindow.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 2006-06-16 22:32:10 UTC
(rev 9235)
+++ trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 2006-06-16 22:46:12 UTC
(rev 9236)
@@ -18,7 +18,8 @@
* ConfigWindow. Create the window used by user to config everything.
* Composed by a tabbed pane containing a NodeConfigPanel and a
PluginConfigPanel, and below the tabbed pane,
* a JButton to validate.
- * Notify observer when a button (Ok / Cancel) is clicked (gives the button in
arg).
+ * Notify observer when a button (Ok / Cancel) is clicked (gives the button in
arg), or when
+ * window is set visible (arg == null).
*/
public class ConfigWindow extends Observable implements ActionListener,
java.awt.event.WindowListener {
private JFrame configWin;
@@ -81,6 +82,11 @@
* Make [dis]appear the config window.
*/
public void setVisible(boolean v) {
+ if(v == true) {
+ setChanged();
+ notifyObservers(null);
+ }
+
configWin.setVisible(v);
}
Modified: trunk/apps/Thaw/src/thaw/core/Core.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Core.java 2006-06-16 22:32:10 UTC (rev
9235)
+++ trunk/apps/Thaw/src/thaw/core/Core.java 2006-06-16 22:46:12 UTC (rev
9236)
@@ -96,11 +96,8 @@
config = new Config();
config.loadConfig();
- if(config.getValue("nodeAddress") == null)
- config.setValue("nodeAddress", "127.0.0.1");
-
- if(config.getValue("nodePort") == null)
- config.setValue("nodePort", "9481");
+ if(config.isEmpty())
+ config.setDefaultValues();
return true;
}
Modified: trunk/apps/Thaw/src/thaw/core/MainWindow.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/MainWindow.java 2006-06-16 22:32:10 UTC
(rev 9235)
+++ trunk/apps/Thaw/src/thaw/core/MainWindow.java 2006-06-16 22:46:12 UTC
(rev 9236)
@@ -1,6 +1,7 @@
package thaw.core;
import javax.swing.JFrame;
+import javax.swing.JPanel;
import javax.swing.JMenuBar;
import javax.swing.JTabbedPane;
import javax.swing.JLabel;
@@ -18,18 +19,19 @@
*
* Main window is divided in three parts:
*
+ * <pre>
* ------------------------------------
- * |?MenuBar |
+ * | MenuBar |
* ------------------------------------
* | Tabbed Pane |
- * |? |
- * |? |
* | |
+ * | |
+ * | |
* ------------------------------------
- * |?JLabel (status) |
+ * | JLabel (status) |
* ------------------------------------
+ * </pre>
*
- *
* @author <a href="mailto:jflesch at nerim.net">Jerome Flesch</a>
*/
public class MainWindow implements java.awt.event.ActionListener,
java.awt.event.WindowListener {
@@ -75,11 +77,12 @@
statusBar.setSize(500, 30);
mainWindow.setLayout(new BorderLayout());
+
mainWindow.add(menuBar, BorderLayout.NORTH);
mainWindow.add(tabbedPane, BorderLayout.CENTER);
mainWindow.add(statusBar, BorderLayout.SOUTH);
- mainWindow.setSize(700, 500);
+ mainWindow.setSize(790, 550);
mainWindow.addWindowListener(this);
}
@@ -94,16 +97,39 @@
/**
- * Used by plugins to add their own tab.
+ * Should not be used.
+ * @see #addTab(String, JPanel)
+ * @return In the future, it's possible that it will sometimes return
null.
*/
public JTabbedPane getTabbedPane() {
return tabbedPane;
}
+ /**
+ * Used to add a tab in the main window.
+ */
+ public boolean addTab(String tabName, java.awt.Component panel) {
+ tabbedPane.addTab(tabName, panel);
+
+ return true;
+ }
+
/**
- * Used by plugins to add their own menu.
+ * Used to remove a tab from the main window.
*/
+ public boolean removeTab(java.awt.Component panel) {
+ tabbedPane.remove(panel);
+
+ return true;
+ }
+
+
+ /**
+ * Used by plugins to add their own menu. Not recommanded for the
moment.
+ * Need to find a more elegant way.
+ * @return Check it does not return null.
+ */
public JMenuBar getMenuBar() {
return menuBar;
}
Modified: trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java 2006-06-16 22:32:10 UTC
(rev 9235)
+++ trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java 2006-06-16 22:46:12 UTC
(rev 9236)
@@ -26,15 +26,21 @@
private final static String[] paramNames = {
I18n.getMessage("thaw.config.nodeAddress"),
- I18n.getMessage("thaw.config.nodePort")
+ I18n.getMessage("thaw.config.nodePort"),
+ I18n.getMessage("thaw.config.maxSimultaneousDownloads"),
+ I18n.getMessage("thaw.config.maxSimultaneousInsertions")
};
+
private final static String[] configNames = {
"nodeAddress",
- "nodePort"
+ "nodePort",
+ "maxSimultaneousDownloads",
+ "maxSimultaneousInsertions"
};
- private JLabel[] paramLabels = { null, null };
- private JTextField[] paramFields = { null, null };
+ private JLabel[] paramLabels = new JLabel[paramNames.length];
+ private JTextField[] paramFields = new JTextField[configNames.length];
+
public NodeConfigPanel(ConfigWindow configWindow, Core core) {
Modified: trunk/apps/Thaw/src/thaw/core/Plugin.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Plugin.java 2006-06-16 22:32:10 UTC (rev
9235)
+++ trunk/apps/Thaw/src/thaw/core/Plugin.java 2006-06-16 22:46:12 UTC (rev
9236)
@@ -2,22 +2,30 @@
/**
* Define what methods a plugin must implements.
+ * WARNING: Constructor will probably not be called (to check).
*/
public interface Plugin {
- /*
- * Plugin constructor must not take any argument.
- */
-
/**
* Called when the plugin is runned.
* @param core A ref to the core of the program.
+ * @return false means that plugin has troubles and should not be
considered as running.
*/
public boolean run(Core core);
+
/**
* Called when the plugin is stopped (often at the end of the program).
+ * @return false means that plugin has troubles and should not be
unload.
*/
public boolean stop();
+
+
+ /**
+ * Gives plugin name. The same name as used for the tabs is recommanded.
+ * Result of this function is used only to inform user.
+ */
+ public String getNameForUser();
+
}
Modified: trunk/apps/Thaw/src/thaw/core/PluginConfigPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/PluginConfigPanel.java 2006-06-16
22:32:10 UTC (rev 9235)
+++ trunk/apps/Thaw/src/thaw/core/PluginConfigPanel.java 2006-06-16
22:46:12 UTC (rev 9236)
@@ -17,6 +17,7 @@
import java.util.Observer;
import java.util.Observable;
import java.util.Vector;
+import java.util.Iterator;
import thaw.i18n.I18n;
@@ -53,15 +54,18 @@
pluginNames = core.getConfig().getPluginNames();
pluginList = new JList();
- pluginList.setListData(core.getConfig().getPluginNames());
+ // List is leave empty until windows is displayed (see update())
-
pluginToAdd = new JTextField("", 30);
buttonPanel = new JPanel();
- buttonPanel.setLayout(new GridLayout(2, 1));
+ GridLayout layout = new GridLayout(2, 1);
+ layout.setVgap(10);
+ buttonPanel.setLayout(layout);
+
subButtonPanel = new JPanel();
+
subButtonPanel.setLayout(new GridLayout(1, 2));
addButton = new JButton(I18n.getMessage("thaw.common.add"));
@@ -93,9 +97,34 @@
* user change something.
*/
public void update(Observable o, Object arg) {
+ if(arg == null) // Warns us window is now visible
+ refreshList();
+ }
+ public void refreshList() {
+ //pluginList.setListData(core.getConfig().getPluginNames());
+
+ Iterator pluginNames =
core.getConfig().getPluginNames().iterator();
+
+ Vector toPutInTheList = new Vector();
+
+ while(pluginNames.hasNext()) {
+ String name = (String)pluginNames.next();
+ toPutInTheList.add(name +
+ "
("+core.getPluginManager().getPlugin(name).getNameForUser()+")");
+ }
+
+ pluginList.setListData(toPutInTheList);
}
+
+ /**
+ * Return the class name contained in an option name from the list.
+ */
+ public String getClassName(String optionName) {
+ String[] part = optionName.split(" ");
+ return part[0];
+ }
public void actionPerformed(ActionEvent e) {
if(e.getSource() == addButton) {
@@ -103,7 +132,7 @@
&&
core.getPluginManager().runPlugin(pluginToAdd.getText())) {
core.getConfig().addPlugin(pluginToAdd.getText());
-
pluginList.setListData(core.getConfig().getPluginNames());
+ refreshList();
} else {
Logger.error(this, "Unable to load
'"+pluginToAdd.getText()+"'");
@@ -116,15 +145,17 @@
if(e.getSource() == removeButton) {
-
if(core.getPluginManager().stopPlugin((String)pluginList.getSelectedValue())
- &&
core.getPluginManager().unloadPlugin((String)pluginList.getSelectedValue())) {
+ String pluginName =
getClassName((String)pluginList.getSelectedValue());
+
+ if(core.getPluginManager().stopPlugin(pluginName)
+ && core.getPluginManager().unloadPlugin(pluginName))
{
-
core.getConfig().removePlugin((String)pluginList.getSelectedValue());
-
pluginList.setListData(core.getConfig().getPluginNames());
+ core.getConfig().removePlugin(pluginName);
+ refreshList();
} else {
- Logger.error(this, "Unable to unload
'"+pluginToAdd.getText()+"'");
+ Logger.error(this, "Unable to unload
'"+pluginName+"'");
JOptionPane.showMessageDialog(core.getConfigWindow().getFrame(),
- "Unable to unload
plugin '"+pluginToAdd.getText()+"'",
+ "Unable to unload
plugin '"+pluginName+"'",
"Unable to unload
plugin",
JOptionPane.ERROR_MESSAGE);
}
Modified: trunk/apps/Thaw/src/thaw/core/PluginManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/PluginManager.java 2006-06-16 22:32:10 UTC
(rev 9235)
+++ trunk/apps/Thaw/src/thaw/core/PluginManager.java 2006-06-16 22:46:12 UTC
(rev 9236)
@@ -1,6 +1,6 @@
package thaw.core;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.Vector;
import java.util.Iterator;
@@ -8,11 +8,14 @@
* Manages plugins :)
*/
public class PluginManager {
- private final static String[] defaultPlugins =
{"thaw.plugins.QueueWatcher"};
+ private final static String[] defaultPlugins =
{"thaw.plugins.QueueWatcher",
+
"thaw.plugins.InsertPlugin",
+
"thaw.plugins.FetchPlugin" };
private Core core = null;
- private HashMap plugins = null; // String (pluginName) -> Plugin
+ // LinkedHashMap because I want to keep a predictible plugin order.
+ private LinkedHashMap plugins = null; // String (pluginName) -> Plugin
/**
@@ -20,10 +23,18 @@
*/
public PluginManager(Core core) {
this.core = core;
- this.plugins = new HashMap();
+ this.plugins = new LinkedHashMap();
}
+ /**
+ * Returns the whole plugin list.
+ */
+ public LinkedHashMap getPlugins() {
+ return plugins;
+ }
+
+
/**
* Load plugin from config or from default list.
*/
@@ -39,8 +50,11 @@
pluginNames = core.getConfig().getPluginNames();
- for(int i=0 ; i < pluginNames.size(); i++) {
- loadPlugin((String)pluginNames.get(i));
+ Iterator pluginIt = pluginNames.iterator();
+
+ while(pluginIt.hasNext()) {
+ String pluginName = (String)pluginIt.next();
+ loadPlugin(pluginName);
}
return true;
@@ -59,9 +73,11 @@
Plugin plugin = (Plugin)pluginIt.next();
try {
+ Logger.info(this, "Running plugin
'"+plugin.getClass().getName()+"'");
plugin.run(core);
} catch(Exception e) {
- Logger.error(this, "Unable to run the
plugin '"+plugin.getClass().getName()+"'");
+ Logger.error(this, "Unable to run the
plugin '"+plugin.getClass().getName()+"' because: "+e+":");
+ e.printStackTrace();
}
@@ -110,6 +126,8 @@
* Load a given plugin (without adding it to the config or running it).
*/
public boolean loadPlugin(String className) {
+ Logger.info(this, "Loading plugin: '"+className+"'");
+
try {
if(plugins.get(className) != null) {
Logger.warning(this, "loadPlugin(): Plugin
'"+className+"' already loaded");
@@ -131,6 +149,8 @@
* Run a given plugin.
*/
public boolean runPlugin(String className) {
+ Logger.info(this, "Starting plugin: '"+className+"'");
+
try {
((Plugin)plugins.get(className)).run(core);
@@ -147,6 +167,8 @@
* Stop a given plugin.
*/
public boolean stopPlugin(String className) {
+ Logger.info(this, "Stopping plugin: '"+className+"'");
+
try {
((Plugin)plugins.get(className)).stop();
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2006-06-16 22:32:10 UTC
(rev 9235)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2006-06-16 22:46:12 UTC
(rev 9236)
@@ -2,11 +2,30 @@
# 2006(c)
## Commons
+# Note for devs and translators: These words must be/are always used alone.
thaw.common.node=Node
thaw.common.plugins=Plugins
thaw.common.add=Add
thaw.common.remove=Remove
+thaw.common.status=Status
+thaw.common.insertion=Insertion
+thaw.common.download=Download
+thaw.common.insertions=Insertions
+thaw.common.downloads=Downloads
+
+thaw.common.file=File
+thaw.common.progress=Progress
+thaw.common.size=Size
+
+thaw.common.localPath=Local path
+thaw.common.priority=Priority
+thaw.common.try=Try
+thaw.common.key=Key
+
+thaw.common.selectFiles=Select file(s)
+
+
## Menus
thaw.menu.file=File
thaw.menu.item.options=Options
@@ -24,4 +43,31 @@
thaw.config.nodeAddress=Node address
thaw.config.nodePort=Node port (FCP)
-thaw.config.pluginsLoaded=Plugins loaded:
\ No newline at end of file
+thaw.config.maxSimultaneousDownloads=Maximum simultaneous downloads
+thaw.config.maxSimultaneousInsertions=Maximum simultaneous insertions
+
+thaw.config.pluginsLoaded=Plugins loaded:
+
+##?Plugins
+thaw.plugin.copySelectedAndInsertedKeys=Copy selected and inserted keys to
clipboard
+thaw.plugin.copySelectedAndDownloadedKeys=Copy selected and downloaded keys to
clipboard
+
+thaw.plugin.insert.filesToInsert=File(s) to insert
+thaw.plugin.insert.selectKey=Select the kind of key wanted
+thaw.plugin.insert.KSK=KSK (not recommanded)
+thaw.plugin.insert.CHK=CHK (recommanded)
+thaw.plugin.insert.SSK=SSK
+thaw.plugin.insert.selectRev=Revision
+thaw.plugin.insert.selectName=Name
+thaw.plugin.insert.publicKey=Public key
+thaw.plugin.insert.privateKey=Private key
+thaw.plugin.insert.insertAction=Insert
+thaw.plugin.insert.priority=Priority
+thaw.plugin.insert.p0=0 (max, *not* recommanded)
+thaw.plugin.insert.p1=1
+thaw.plugin.insert.p2=2 (default)
+thaw.plugin.insert.p3=3 (recommanded)
+thaw.plugin.insert.p4=4
+thaw.plugin.insert.p5=5
+thaw.plugin.insert.p6=6 (min)
+
Added: trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2006-06-16 22:32:10 UTC
(rev 9235)
+++ trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2006-06-16 22:46:12 UTC
(rev 9236)
@@ -0,0 +1,45 @@
+package thaw.plugins;
+
+import javax.swing.JPanel;
+
+import thaw.core.*;
+import thaw.i18n.I18n;
+
+
+public class FetchPlugin implements thaw.core.Plugin {
+ private Core core;
+
+ private JPanel mainPanel;
+
+
+ public FetchPlugin() {
+
+ }
+
+
+ public boolean run(Core core) {
+ this.core = core;
+
+ Logger.info(this, "Starting plugin \"FetchPlugin\" ...");
+
+ mainPanel = new JPanel();
+
+
core.getMainWindow().addTab(I18n.getMessage("thaw.common.download"), mainPanel);
+
+ return true;
+ }
+
+
+ public boolean stop() {
+ Logger.info(this, "Stopping plugin \"FetchPlugin\" ...");
+
+ core.getMainWindow().removeTab(mainPanel);
+
+ return true;
+ }
+
+ public String getNameForUser() {
+ return I18n.getMessage("thaw.common.download");
+ }
+
+}
Added: trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java 2006-06-16 22:32:10 UTC
(rev 9235)
+++ trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java 2006-06-16 22:46:12 UTC
(rev 9236)
@@ -0,0 +1,188 @@
+package thaw.plugins;
+
+import java.awt.GridLayout;
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import javax.swing.JComboBox;
+import javax.swing.JPanel;
+import javax.swing.JLabel;
+import javax.swing.JButton;
+import javax.swing.ButtonGroup;
+import javax.swing.JRadioButton;
+import javax.swing.JTextField;
+
+import thaw.core.*;
+import thaw.i18n.I18n;
+
+
+public class InsertPlugin implements thaw.core.Plugin {
+ private Core core;
+
+ private JPanel globalPanel;
+
+ private JPanel mainPanel;
+
+ private JPanel subPanel; /* because we won't use the whole space */
+
+
+ private JLabel browseLabel;
+ private JTextField selectedFiles;
+ private JButton browseButton;
+
+ private JLabel selectKeyLabel;
+ private ButtonGroup keyRadioGroup;
+ private JRadioButton[] keyRadioButtons;
+
+ private JLabel selectRevLabel;
+ private JTextField revField;
+
+ private JLabel selectNameLabel;
+ private JTextField nameField;
+
+ private JLabel publicKeyLabel;
+ private JTextField publicKeyField;
+ private JLabel privateKeyLabel;
+ private JTextField privateKeyField;
+
+ private String[] priorities;
+ private JLabel priorityLabel;
+ private JComboBox prioritySelecter;
+
+ private JButton letsGoButton;
+
+ public InsertPlugin() {
+
+ }
+
+
+ public boolean run(Core core) {
+ this.core = core;
+
+ Logger.info(this, "Starting plugin \"InsertPlugin\" ...");
+
+ globalPanel = new JPanel();
+
+ mainPanel = new JPanel();
+ mainPanel.setLayout(new BorderLayout(10, 10));
+
+ subPanel = new JPanel();
+
+ subPanel.setLayout(new GridLayout(3,2, 40, 40));
+
+
+ JPanel subSubPanel = new JPanel();
+ subSubPanel.setLayout(new GridLayout(3, 1));
+ browseLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.filesToInsert"));
+ subSubPanel.add(browseLabel);
+ selectedFiles = new JTextField(20);
+ selectedFiles.setEditable(false);
+ subSubPanel.add(selectedFiles);
+ browseButton = new
JButton(I18n.getMessage("thaw.common.selectFiles"));
+ subSubPanel.add(browseButton);
+
+ subPanel.add(subSubPanel);
+
+
+ subSubPanel = new JPanel();
+ subSubPanel.setLayout(new GridLayout(4, 1));
+ selectKeyLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.selectKey"));
+ subSubPanel.add(selectKeyLabel);
+ keyRadioButtons = new JRadioButton[3];
+ keyRadioButtons[0] = new
JRadioButton(I18n.getMessage("thaw.plugin.insert.KSK"));
+ keyRadioButtons[1] = new
JRadioButton(I18n.getMessage("thaw.plugin.insert.CHK"));
+ keyRadioButtons[1].setSelected(true);
+ keyRadioButtons[2] = new
JRadioButton(I18n.getMessage("thaw.plugin.insert.SSK"));
+ keyRadioGroup = new ButtonGroup();
+ for(int i = 0 ; i < keyRadioButtons.length ; i++) {
+ keyRadioGroup.add(keyRadioButtons[i]);
+ subSubPanel.add(keyRadioButtons[i]);
+ }
+
+ subPanel.add(subSubPanel);
+
+
+ subSubPanel = new JPanel();
+ subSubPanel.setLayout(new GridLayout(4, 1));
+
+ selectRevLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.selectRev"));
+ subSubPanel.add(selectRevLabel);
+ revField = new JTextField(4);
+ revField.setEditable(false);
+ subSubPanel.add(revField);
+
+ selectNameLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.selectName"));
+ subSubPanel.add(selectNameLabel);
+ nameField = new JTextField(10);
+ nameField.setEditable(false);
+ subSubPanel.add(nameField);
+
+ subPanel.add(subSubPanel);
+
+
+ subSubPanel = new JPanel();
+ subSubPanel.setLayout(new GridLayout(4, 1));
+
+ publicKeyLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.publicKey"));
+ subSubPanel.add(publicKeyLabel);
+ publicKeyField = new JTextField(20);
+ publicKeyField.setEditable(false);
+ subSubPanel.add(publicKeyField);
+
+ privateKeyLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.privateKey"));
+ subSubPanel.add(privateKeyLabel);
+ privateKeyField = new JTextField(20);
+ privateKeyField.setEditable(false);
+ subSubPanel.add(privateKeyField);
+
+ subPanel.add(subSubPanel);
+
+ priorities = new String[] {
+ I18n.getMessage("thaw.plugin.insert.p0"),
+ I18n.getMessage("thaw.plugin.insert.p1"),
+ I18n.getMessage("thaw.plugin.insert.p2"),
+ I18n.getMessage("thaw.plugin.insert.p3"),
+ I18n.getMessage("thaw.plugin.insert.p4"),
+ I18n.getMessage("thaw.plugin.insert.p5")
+ };
+
+ subSubPanel = new JPanel();
+ subSubPanel.setLayout(new GridLayout(4, 1));
+ priorityLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.priority"));
+ subSubPanel.add(priorityLabel);
+ prioritySelecter = new JComboBox(priorities);
+
prioritySelecter.setSelectedItem(I18n.getMessage("thaw.plugin.insert.p3"));
+ subSubPanel.add(prioritySelecter);
+
+ subPanel.add(subSubPanel);
+
+
+ mainPanel.add(subPanel, BorderLayout.CENTER);
+
+ letsGoButton = new
JButton(I18n.getMessage("thaw.plugin.insert.insertAction"));
+ mainPanel.add(letsGoButton, BorderLayout.SOUTH);
+
+ mainPanel.setSize(400, 400);
+
+ globalPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 50,
50));
+
+ globalPanel.add(mainPanel);
+
+
core.getMainWindow().addTab(I18n.getMessage("thaw.common.insertion"),
globalPanel);
+
+ return true;
+ }
+
+
+ public boolean stop() {
+ Logger.info(this, "Stopping plugin \"InsertPlugin\" ...");
+
+ core.getMainWindow().removeTab(mainPanel);
+
+ return true;
+ }
+
+
+ public String getNameForUser() {
+ return I18n.getMessage("thaw.common.insertion");
+ }
+}
Modified: trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-06-16 22:32:10 UTC
(rev 9235)
+++ trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-06-16 22:46:12 UTC
(rev 9236)
@@ -1,23 +1,95 @@
package thaw.plugins;
+import javax.swing.JPanel;
+import javax.swing.JSplitPane;
+import java.awt.GridLayout;
+import java.awt.BorderLayout;
+import javax.swing.JPanel;
+import javax.swing.JButton;
+
import thaw.core.*;
+import thaw.i18n.I18n;
+import thaw.plugins.queueWatcher.*;
+
public class QueueWatcher implements thaw.core.Plugin {
+ private Core core;
+ private JPanel mainPanel;
+
+ private QueuePanel[] queuePanels = new QueuePanel[2];
+ private DetailPanel detailPanel;
+ private JPanel panel;
+
+
+ private JPanel buttonPanel;
+ private JButton buttonCopyInsertedKeys;
+ private JButton buttonCopyDownloadedKeys;
+
public QueueWatcher() {
}
public boolean run(Core core) {
+ this.core = core;
+
+ Logger.info(this, "Starting plugin \"QueueWatcher\" ...");
+ mainPanel = new JPanel();
+
+ mainPanel.setLayout(new BorderLayout());
+
+ queuePanels[0] = new QueuePanel(core, false); /* download */
+ queuePanels[1] = new QueuePanel(core, true); /* upload */
+ detailPanel = new DetailPanel(core);
+
+ panel = new JPanel();
+
+ GridLayout layout = new GridLayout(2, 1);
+ layout.setVgap(10);
+ panel.setLayout(layout);
+
+ mainPanel.add(panel, BorderLayout.CENTER);
+
+ if(queuePanels[0].getPanel() != null)
+ panel.add(queuePanels[0].getPanel());
+
+ if(queuePanels[1].getPanel() != null)
+ panel.add(queuePanels[1].getPanel());
+
+
+ if(detailPanel.getPanel() != null) {
+ mainPanel.add(detailPanel.getPanel(),
BorderLayout.EAST);
+ }
+
+ buttonPanel = new JPanel();
+ buttonPanel.setLayout(new GridLayout(1, 2));
+
+ buttonCopyInsertedKeys = new
JButton(I18n.getMessage("thaw.plugin.copySelectedAndInsertedKeys"));
+ buttonCopyDownloadedKeys = new
JButton(I18n.getMessage("thaw.plugin.copySelectedAndDownloadedKeys"));
+
+ buttonPanel.add(buttonCopyInsertedKeys);
+ buttonPanel.add(buttonCopyDownloadedKeys);
+
+ mainPanel.add(buttonPanel, BorderLayout.SOUTH);
+
+
core.getMainWindow().addTab(I18n.getMessage("thaw.common.status"), mainPanel);
+
return true;
}
public boolean stop() {
+ Logger.info(this, "Stopping plugin \"QueueWatcher\" ...");
+ core.getMainWindow().removeTab(panel);
+
return true;
}
+ public String getNameForUser() {
+ return I18n.getMessage("thaw.common.status");
+ }
+
}
Added: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java
2006-06-16 22:32:10 UTC (rev 9235)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java
2006-06-16 22:46:12 UTC (rev 9236)
@@ -0,0 +1,80 @@
+package thaw.plugins.queueWatcher;
+
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import javax.swing.JPanel;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+
+import thaw.core.*;
+import thaw.i18n.I18n;
+
+
+public class DetailPanel {
+
+ private Core core;
+
+ private JPanel subPanel;
+ private JPanel panel;
+
+ private JTextField file = new JTextField();
+ private JTextField size = new JTextField();
+ private JTextField progress = new JTextField();
+ private JTextField key = new JTextField();
+ private JTextField path = new JTextField();
+ private JTextField priority = new JTextField();
+ private JTextField attempt = new JTextField();
+
+ private final static Dimension dim = new Dimension(300, 275);
+
+ public DetailPanel(Core core) {
+ this.core = core;
+
+ panel = new JPanel();
+ subPanel = new JPanel();
+
+ String[] fieldNames = { I18n.getMessage("thaw.common.file"),
+ I18n.getMessage("thaw.common.size"),
+ I18n.getMessage("thaw.common.progress"),
+ I18n.getMessage("thaw.common.key"),
+
I18n.getMessage("thaw.common.localPath"),
+ I18n.getMessage("thaw.common.priority"),
+ I18n.getMessage("thaw.common.try")+" #"
};
+
+ subPanel.setLayout(new GridLayout(fieldNames.length*2, 1));
+
+ for(int i=0; i < (fieldNames.length * 2) ; i++) {
+
+ if(i%2 == 0) {
+ JLabel newLabel = new JLabel(fieldNames[i/2]);
+ subPanel.add(newLabel);
+ } else {
+ JTextField field = null;
+
+ switch(((int)i/2)) {
+ case(0): field = file; break;
+ case(1): field = size; break;
+ case(2): field = progress; break;
+ case(3): field = key; break;
+ case(4): field = path; break;
+ case(5): field = priority; break;
+ case(6): field = attempt; break;
+ default: Logger.warning(this, "Gouli goula ?
... is going to crash :p"); break;
+ }
+ field.setEditable(false);
+ subPanel.add(field);
+ }
+
+ } /* for (i < fieldNames.length) */
+
+ subPanel.setPreferredSize(dim);
+
+ panel.add(subPanel);
+
+ }
+
+
+ public JPanel getPanel() {
+ return panel;
+ }
+}
Added: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
2006-06-16 22:32:10 UTC (rev 9235)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
2006-06-16 22:46:12 UTC (rev 9236)
@@ -0,0 +1,46 @@
+package thaw.plugins.queueWatcher;
+
+import javax.swing.JPanel;
+import javax.swing.JTable;
+import javax.swing.JLabel;
+import javax.swing.JScrollPane;
+import java.awt.BorderLayout;
+import java.util.Vector;
+
+import thaw.core.*;
+import thaw.i18n.I18n;
+
+
+public class QueuePanel {
+ private Core core;
+
+ private JLabel label;
+ private JTable table = null;
+ private JPanel panel;
+
+
+ public QueuePanel(Core core, boolean isForInsertionQueue) {
+ this.core = core;
+
+ table = new JTable(new QueueTableModel(isForInsertionQueue));
+
+ table.setShowGrid(true);
+
+ if(isForInsertionQueue) {
+ label = new
JLabel(I18n.getMessage("thaw.common.insertions"));
+ } else {
+ label = new
JLabel(I18n.getMessage("thaw.common.downloads"));
+ }
+
+ panel = new JPanel();
+ panel.setLayout(new BorderLayout());
+
+ panel.add(label, BorderLayout.NORTH);
+ panel.add(new JScrollPane(table), BorderLayout.CENTER);
+ }
+
+ public JPanel getPanel() {
+ return panel;
+ }
+}
+
Added: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java
2006-06-16 22:32:10 UTC (rev 9235)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java
2006-06-16 22:46:12 UTC (rev 9236)
@@ -0,0 +1,44 @@
+package thaw.plugins.queueWatcher;
+
+
+import java.util.Vector;
+
+import thaw.core.*;
+import thaw.i18n.I18n;
+
+
+public class QueueTableModel extends javax.swing.table.AbstractTableModel {
+ Vector columnNames = new Vector();
+
+ public QueueTableModel(boolean isForInsertions) {
+ super();
+
+ columnNames.add(I18n.getMessage("thaw.common.file"));
+ columnNames.add(I18n.getMessage("thaw.common.size"));
+ columnNames.add(I18n.getMessage("thaw.common.status"));
+ columnNames.add(I18n.getMessage("thaw.common.progress"));
+ }
+
+
+ public int getRowCount() {
+ return 0;
+ }
+
+ public int getColumnCount() {
+ return columnNames.size();
+ }
+
+ public String getColumnName(int col) {
+ return (String)columnNames.get(col);
+ }
+
+ public Object getValueAt(int row, int column) {
+ return null;
+ }
+
+ public boolean isCellEditable(int row, int column) {
+ return false;
+ }
+
+}
+