Author: nextgens
Date: 2006-12-06 18:21:00 +0000 (Wed, 06 Dec 2006)
New Revision: 11273
Modified:
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/FileChooser.java
trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java
trunk/apps/Thaw/src/thaw/core/GUIHelper.java
trunk/apps/Thaw/src/thaw/core/I18n.java
trunk/apps/Thaw/src/thaw/core/IconBox.java
trunk/apps/Thaw/src/thaw/core/LibraryPlugin.java
trunk/apps/Thaw/src/thaw/core/Logger.java
trunk/apps/Thaw/src/thaw/core/Main.java
trunk/apps/Thaw/src/thaw/core/MainWindow.java
trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java
trunk/apps/Thaw/src/thaw/core/PluginConfigPanel.java
trunk/apps/Thaw/src/thaw/core/PluginManager.java
trunk/apps/Thaw/src/thaw/core/QueueKeeper.java
trunk/apps/Thaw/src/thaw/core/SplashScreen.java
trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java
trunk/apps/Thaw/src/thaw/core/WarningWindow.java
trunk/apps/Thaw/src/thaw/fcp/FCPBufferedStream.java
trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
trunk/apps/Thaw/src/thaw/fcp/FCPClientHello.java
trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java
trunk/apps/Thaw/src/thaw/fcp/FCPGenerateSSK.java
trunk/apps/Thaw/src/thaw/fcp/FCPListPersistentRequests.java
trunk/apps/Thaw/src/thaw/fcp/FCPMessage.java
trunk/apps/Thaw/src/thaw/fcp/FCPQueryManager.java
trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java
trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java
trunk/apps/Thaw/src/thaw/fcp/FCPWatchGlobal.java
trunk/apps/Thaw/src/thaw/gui/JDragTree.java
trunk/apps/Thaw/src/thaw/plugins/Console.java
trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java
trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java
trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java
trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java
trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java
trunk/apps/Thaw/src/thaw/plugins/Restarter.java
trunk/apps/Thaw/src/thaw/plugins/SqlConsole.java
trunk/apps/Thaw/src/thaw/plugins/StatusBar.java
trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java
trunk/apps/Thaw/src/thaw/plugins/fetchPlugin/FetchPanel.java
trunk/apps/Thaw/src/thaw/plugins/fetchPlugin/KeyFileFilter.java
trunk/apps/Thaw/src/thaw/plugins/index/File.java
trunk/apps/Thaw/src/thaw/plugins/index/FileDetailsEditor.java
trunk/apps/Thaw/src/thaw/plugins/index/FileManagementHelper.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/IndexBrowserPanel.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexSelecter.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
trunk/apps/Thaw/src/thaw/plugins/index/Link.java
trunk/apps/Thaw/src/thaw/plugins/index/LinkManagementHelper.java
trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java
trunk/apps/Thaw/src/thaw/plugins/index/SearchBar.java
trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java
trunk/apps/Thaw/src/thaw/plugins/index/TableCreator.java
trunk/apps/Thaw/src/thaw/plugins/index/Tables.java
trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java
trunk/apps/Thaw/src/thaw/plugins/insertPlugin/DefaultMIMETypes.java
trunk/apps/Thaw/src/thaw/plugins/insertPlugin/InsertPanel.java
trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java
trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DragAndDropManager.java
trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java
Log:
Thaw: Code cleanup, fix the database locking mechanism : I got the green light
from Jflesh :)
Modified: trunk/apps/Thaw/src/thaw/core/Config.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Config.java 2006-12-06 18:18:48 UTC (rev
11272)
+++ trunk/apps/Thaw/src/thaw/core/Config.java 2006-12-06 18:21:00 UTC (rev
11273)
@@ -1,22 +1,22 @@
package thaw.core;
+import java.io.File;
import java.util.HashMap;
-import java.util.Vector;
-import java.io.File;
import java.util.Iterator;
import java.util.Random;
+import java.util.Vector;
-/* XML */
-import org.w3c.dom.Document;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.DocumentBuilder;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
import org.w3c.dom.DOMImplementation;
-import javax.xml.transform.stream.StreamResult;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.OutputKeys;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -39,22 +39,22 @@
this(null);
}
- public Config(String filename) {
+ public Config(final String filename) {
if(filename != null)
- this.configFile = new File(filename);
+ configFile = new File(filename);
- this.parameters = new HashMap();
- this.pluginNames = new Vector();
+ parameters = new HashMap();
+ pluginNames = new Vector();
}
/**
* Returns the corresponding value
* @return null if the value doesn't exit in the config.
*/
- public String getValue(String key) {
+ public String getValue(final String key) {
try {
- return ((String)this.parameters.get(key));
- } catch(Exception e) { /* I should see for the correct
exception */
+ return ((String)parameters.get(key));
+ } catch(final Exception e) { /* I should see for the correct
exception */
Logger.notice(this, "Unknow key in configuration:
'"+key+"'");
return null;
}
@@ -63,44 +63,44 @@
/**
* Set the value in the config.
*/
- public void setValue(String key, String value) {
+ public void setValue(final String key, final String value) {
if(value != null)
Logger.info(this, "Setting value '"+key+"' to
'"+value+"'");
else
Logger.info(this, "Setting value '"+key+"' to null");
- this.parameters.put(key, value);
+ parameters.put(key, value);
}
/**
* Add the plugin at the end of the plugin list.
*/
- public void addPlugin(String name) {
- this.pluginNames.add(name);
+ public void addPlugin(final String name) {
+ pluginNames.add(name);
}
/**
* Add the plugin at the end of the given position (shifting already
existing).
*/
- public void addPlugin(String name, int position) {
- this.pluginNames.add(position, name);
+ public void addPlugin(final String name, final int position) {
+ pluginNames.add(position, name);
}
/**
* Give a vector containing the whole list of plugins.
*/
public Vector getPluginNames() {
- return this.pluginNames;
+ return pluginNames;
}
/**
* Remove the given plugin.
*/
- public void removePlugin(String name) {
- for(int i = 0; i < this.pluginNames.size() ; i++) {
- String currentPlugin = (String)this.pluginNames.get(i);
+ public void removePlugin(final String name) {
+ for(int i = 0; i < pluginNames.size() ; i++) {
+ final String currentPlugin = (String)pluginNames.get(i);
if(currentPlugin.equals(name))
- this.pluginNames.remove(i);
+ pluginNames.remove(i);
}
}
@@ -110,13 +110,13 @@
* @return true if success, else false.
*/
public boolean loadConfig() {
- if(this.configFile == null) {
+ if(configFile == null) {
Logger.error(this, "loadConfig(): No file specified !");
return false;
}
- if(!this.configFile.exists() || !this.configFile.canRead()) {
- Logger.notice(this, "Unable to read config file
'"+this.configFile.getPath()+"'");
+ if(!configFile.exists() || !configFile.canRead()) {
+ Logger.notice(this, "Unable to read config file
'"+configFile.getPath()+"'");
return false;
}
@@ -131,17 +131,17 @@
try {
xmlBuilder = xmlFactory.newDocumentBuilder();
- } catch(javax.xml.parsers.ParserConfigurationException e) {
+ } catch(final javax.xml.parsers.ParserConfigurationException e)
{
Logger.warning(this, "Unable to load config because:
"+e);
return false;
}
try {
- xmlDoc = xmlBuilder.parse(this.configFile);
- } catch(org.xml.sax.SAXException e) {
+ xmlDoc = xmlBuilder.parse(configFile);
+ } catch(final org.xml.sax.SAXException e) {
Logger.warning(this, "Unable to load config because:
"+e);
return false;
- } catch(java.io.IOException e) {
+ } catch(final java.io.IOException e) {
Logger.warning(this, "Unable to load config because:
"+e);
return false;
}
@@ -149,28 +149,28 @@
rootEl = xmlDoc.getDocumentElement();
- NodeList params = rootEl.getElementsByTagName("param");
+ final NodeList params = rootEl.getElementsByTagName("param");
for(int i = 0;i < params.getLength(); i++) {
Element paramEl;
- Node paramNode = params.item(i);
+ final Node paramNode = params.item(i);
- if(paramNode != null && paramNode.getNodeType() ==
Node.ELEMENT_NODE) {
+ if((paramNode != null) && (paramNode.getNodeType() ==
Node.ELEMENT_NODE)) {
paramEl = (Element)paramNode;
-
this.parameters.put(paramEl.getAttribute("name"),
paramEl.getAttribute("value"));
+ parameters.put(paramEl.getAttribute("name"),
paramEl.getAttribute("value"));
}
}
- NodeList plugins = rootEl.getElementsByTagName("plugin");
+ final NodeList plugins = rootEl.getElementsByTagName("plugin");
for(int i = 0;i < plugins.getLength(); i++) {
Element pluginEl;
- Node pluginNode = plugins.item(i);
+ final Node pluginNode = plugins.item(i);
- if(pluginNode != null && pluginNode.getNodeType() ==
Node.ELEMENT_NODE) {
+ if((pluginNode != null) && (pluginNode.getNodeType() ==
Node.ELEMENT_NODE)) {
pluginEl = (Element)pluginNode;
-
this.pluginNames.add(pluginEl.getAttribute("name"));
+ pluginNames.add(pluginEl.getAttribute("name"));
}
}
@@ -186,24 +186,24 @@
public boolean saveConfig() {
StreamResult configOut;
- if(this.configFile == null) {
+ if(configFile == null) {
Logger.error(this, "saveConfig(): No file specified !");
return false;
}
try {
- if( (!this.configFile.exists() &&
!this.configFile.createNewFile())
- || !this.configFile.canWrite()) {
- Logger.warning(this, "Unable to write config
file '"+this.configFile.getPath()+"' (can't write)");
+ if( (!configFile.exists() &&
!configFile.createNewFile())
+ || !configFile.canWrite()) {
+ Logger.warning(this, "Unable to write config
file '"+configFile.getPath()+"' (can't write)");
return false;
}
- } catch(java.io.IOException e) {
+ } catch(final java.io.IOException e) {
Logger.warning(this, "Error while checking perms to
save config: "+e);
}
- configOut = new StreamResult(this.configFile);
+ configOut = new StreamResult(configFile);
Document xmlDoc = null;
DocumentBuilderFactory xmlFactory = null;
@@ -216,7 +216,7 @@
try {
xmlBuilder = xmlFactory.newDocumentBuilder();
- } catch(javax.xml.parsers.ParserConfigurationException e) {
+ } catch(final javax.xml.parsers.ParserConfigurationException e)
{
Logger.error(this, "Unable to save configuration
because: "+e.toString());
return false;
}
@@ -229,24 +229,24 @@
rootEl = xmlDoc.getDocumentElement();
- Iterator entries = this.parameters.keySet().iterator();
+ final Iterator entries = parameters.keySet().iterator();
while(entries.hasNext()) {
- String entry = (String)entries.next();
- String value = (String)this.parameters.get(entry);
+ final String entry = (String)entries.next();
+ final String value = (String)parameters.get(entry);
- Element paramEl = xmlDoc.createElement("param");
+ final Element paramEl = xmlDoc.createElement("param");
paramEl.setAttribute("name", entry);
paramEl.setAttribute("value", value);
rootEl.appendChild(paramEl);
}
- Iterator plugins = this.pluginNames.iterator();
+ final Iterator plugins = pluginNames.iterator();
while(plugins.hasNext()) {
- String pluginName = (String)plugins.next();
- Element pluginEl = xmlDoc.createElement("plugin");
+ final String pluginName = (String)plugins.next();
+ final Element pluginEl = xmlDoc.createElement("plugin");
pluginEl.setAttribute("name", pluginName);
@@ -255,14 +255,14 @@
/* Serialization */
- DOMSource domSource = new DOMSource(xmlDoc);
- TransformerFactory transformFactory =
TransformerFactory.newInstance();
+ final DOMSource domSource = new DOMSource(xmlDoc);
+ final TransformerFactory transformFactory =
TransformerFactory.newInstance();
Transformer serializer;
try {
serializer = transformFactory.newTransformer();
- } catch(javax.xml.transform.TransformerConfigurationException
e) {
+ } catch(final
javax.xml.transform.TransformerConfigurationException e) {
Logger.error(this, "Unable to save configuration
because: "+e.toString());
return false;
}
@@ -273,7 +273,7 @@
/* final step */
try {
serializer.transform(domSource, configOut);
- } catch(javax.xml.transform.TransformerException e) {
+ } catch(final javax.xml.transform.TransformerException e) {
Logger.error(this, "Unable to save configuration
because: "+e.toString());
return false;
}
@@ -284,7 +284,7 @@
public boolean isEmpty() {
- if(this.parameters.keySet().size() == 0)
+ if(parameters.keySet().size() == 0)
return true;
return false;
}
@@ -292,21 +292,21 @@
/**
* Set the value only if it doesn't exits.
*/
- public void setDefaultValue(String name, String val) {
- if (this.getValue(name) == null)
- this.setValue(name, val);
+ public void setDefaultValue(final String name, final String val) {
+ if (getValue(name) == null)
+ setValue(name, val);
}
public void setDefaultValues() {
- this.setDefaultValue("nodeAddress", "127.0.0.1");
- this.setDefaultValue("nodePort", "9481");
- this.setDefaultValue("maxSimultaneousDownloads", "-1");
- this.setDefaultValue("maxSimultaneousInsertions", "-1");
- this.setDefaultValue("maxUploadSpeed", "-1");
- this.setDefaultValue("thawId", "thaw_"+Integer.toString((new
Random()).nextInt(1000)));
- this.setDefaultValue("advancedMode", "false");
- this.setDefaultValue("userNickname", "Another anonymous");
- this.setDefaultValue("multipleSockets", "true");
+ setDefaultValue("nodeAddress", "127.0.0.1");
+ setDefaultValue("nodePort", "9481");
+ setDefaultValue("maxSimultaneousDownloads", "-1");
+ setDefaultValue("maxSimultaneousInsertions", "-1");
+ setDefaultValue("maxUploadSpeed", "-1");
+ setDefaultValue("thawId", "thaw_"+Integer.toString((new
Random()).nextInt(1000)));
+ setDefaultValue("advancedMode", "false");
+ setDefaultValue("userNickname", "Another anonymous");
+ setDefaultValue("multipleSockets", "true");
}
}
Modified: trunk/apps/Thaw/src/thaw/core/ConfigWindow.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,17 +1,17 @@
package thaw.core;
-import javax.swing.JFrame;
-import javax.swing.JDialog;
-import javax.swing.JPanel;
-import javax.swing.JTabbedPane;
import java.awt.BorderLayout;
+import java.awt.GridLayout;
import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
-import java.awt.event.ActionListener;
+import java.util.Observable;
+
import javax.swing.JButton;
-import java.util.Observable;
-import java.awt.GridLayout;
+import javax.swing.JDialog;
import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTabbedPane;
@@ -40,50 +40,50 @@
private boolean needConnectionReset = false;
- public ConfigWindow(Core core) {
+ public ConfigWindow(final Core core) {
this.core = core;
- this.needConnectionReset = false;
+ needConnectionReset = false;
- this.advancedMode =
Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue();
+ advancedMode =
Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue();
- this.configWin = new
JDialog(core.getMainWindow().getMainFrame(),
I18n.getMessage("thaw.config.windowName"));
+ configWin = new JDialog(core.getMainWindow().getMainFrame(),
I18n.getMessage("thaw.config.windowName"));
- this.tabs = new JTabbedPane();
+ tabs = new JTabbedPane();
- this.buttons = new JPanel();
- this.buttons.setLayout(new GridLayout(1, 2));
+ buttons = new JPanel();
+ buttons.setLayout(new GridLayout(1, 2));
- this.okButton = new
JButton(I18n.getMessage("thaw.config.okButton"));
- this.cancelButton = new
JButton(I18n.getMessage("thaw.config.cancelButton"));
+ okButton = new JButton(I18n.getMessage("thaw.config.okButton"));
+ cancelButton = new
JButton(I18n.getMessage("thaw.config.cancelButton"));
- this.buttons.add(this.okButton);
- this.buttons.add(this.cancelButton);
+ buttons.add(okButton);
+ buttons.add(cancelButton);
- this.nodeConfigPanel = new NodeConfigPanel(this, core);
- this.pluginConfigPanel = new PluginConfigPanel(this, core);
- this.thawConfigPanel = new ThawConfigPanel(this, core);
+ nodeConfigPanel = new NodeConfigPanel(this, core);
+ pluginConfigPanel = new PluginConfigPanel(this, core);
+ thawConfigPanel = new ThawConfigPanel(this, core);
- this.addTabs();
+ addTabs();
- BorderLayout borderLayout = new BorderLayout();
+ final BorderLayout borderLayout = new BorderLayout();
borderLayout.setVgap(20);
borderLayout.setVgap(20);
- this.configWin.getContentPane().setLayout(borderLayout);
+ configWin.getContentPane().setLayout(borderLayout);
- this.configWin.getContentPane().add(this.tabs,
BorderLayout.CENTER);
- this.configWin.getContentPane().add(this.buttons,
BorderLayout.SOUTH);
+ configWin.getContentPane().add(tabs, BorderLayout.CENTER);
+ configWin.getContentPane().add(buttons, BorderLayout.SOUTH);
- this.tabs.setSize(600, 350);
- this.okButton.setSize(100, 50);
+ tabs.setSize(600, 350);
+ okButton.setSize(100, 50);
- this.configWin.setSize(600, 400);
- this.configWin.setResizable(false);
+ configWin.setSize(600, 400);
+ configWin.setResizable(false);
- this.okButton.addActionListener(this);
- this.cancelButton.addActionListener(this);
+ okButton.addActionListener(this);
+ cancelButton.addActionListener(this);
- this.configWin.addWindowListener(this);
+ configWin.addWindowListener(this);
}
@@ -91,36 +91,36 @@
* Remove them and re-add them.
*/
private void addTabs() {
- this.tabs.remove( this.thawConfigPanel.getPanel() );
- this.tabs.remove( this.nodeConfigPanel.getPanel() );
- this.tabs.remove( this.pluginConfigPanel.getPanel() );
+ tabs.remove( thawConfigPanel.getPanel() );
+ tabs.remove( nodeConfigPanel.getPanel() );
+ tabs.remove( pluginConfigPanel.getPanel() );
- this.tabs.add("Thaw", this.thawConfigPanel.getPanel());
- this.tabs.add(I18n.getMessage("thaw.common.node"),
this.nodeConfigPanel.getPanel());
- if(this.advancedMode)
- this.tabs.add(I18n.getMessage("thaw.common.plugins"),
this.pluginConfigPanel.getPanel());
+ tabs.add("Thaw", thawConfigPanel.getPanel());
+ tabs.add(I18n.getMessage("thaw.common.node"),
nodeConfigPanel.getPanel());
+ if(advancedMode)
+ tabs.add(I18n.getMessage("thaw.common.plugins"),
pluginConfigPanel.getPanel());
}
/**
* Make [dis]appear the config window.
*/
- public void setVisible(boolean v) {
+ public void setVisible(final boolean v) {
if(v == true) {
- this.setChanged();
+ setChanged();
this.notifyObservers(null);
}
- this.configWin.setVisible(v);
+ configWin.setVisible(v);
}
- public boolean addTab(String name, java.awt.Component panel) {
- this.tabs.add(name, panel);
+ public boolean addTab(final String name, final java.awt.Component
panel) {
+ tabs.add(name, panel);
return true;
}
- public boolean removeTab(java.awt.Component panel) {
- this.tabs.remove(panel);
+ public boolean removeTab(final java.awt.Component panel) {
+ tabs.remove(panel);
return true;
}
@@ -128,14 +128,14 @@
* Get a ref to the JFrame.
*/
public JDialog getFrame() {
- return this.configWin;
+ return configWin;
}
/**
* Get a ref to validation button.
*/
public JButton getOkButton() {
- return this.okButton;
+ return okButton;
}
@@ -143,19 +143,19 @@
* Get a ref to cancel button.
*/
public JButton getCancelButton() {
- return this.cancelButton;
+ return cancelButton;
}
public void willNeedConnectionReset() {
- this.needConnectionReset = true;
+ needConnectionReset = true;
}
/**
* Called when apply button is pressed.
*/
- public void actionPerformed(ActionEvent e) {
- if(e.getSource() == this.okButton &&
!this.core.canDisconnect()) {
- int ret =
JOptionPane.showOptionDialog((java.awt.Component)null,
+ public void actionPerformed(final ActionEvent e) {
+ if((e.getSource() == okButton) && !core.canDisconnect()) {
+ final int ret =
JOptionPane.showOptionDialog((java.awt.Component)null,
I18n.getMessage("thaw.warning.isWritingSoApplyLater"),
I18n.getMessage("thaw.warning.title"),
JOptionPane.YES_NO_OPTION,
@@ -163,67 +163,67 @@
(javax.swing.Icon)null,
(java.lang.Object[])null,
(java.lang.Object)null);
- if(ret == JOptionPane.CLOSED_OPTION || ret > 0)
+ if((ret == JOptionPane.CLOSED_OPTION) || (ret > 0))
return;
}
- if(e.getSource() == this.okButton
- || e.getSource() == this.cancelButton) {
+ if((e.getSource() == okButton)
+ || (e.getSource() == cancelButton)) {
- this.setChanged();
+ setChanged();
this.notifyObservers(e.getSource());
- this.setVisible(false);
+ setVisible(false);
}
- if(e.getSource() == this.okButton) {
- this.advancedMode =
Boolean.valueOf(this.core.getConfig().getValue("advancedMode")).booleanValue();
+ if(e.getSource() == okButton) {
+ advancedMode =
Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue();
/* should reinit the whole connection correctly */
- this.core.getPluginManager().stopPlugins();
+ core.getPluginManager().stopPlugins();
- if(this.needConnectionReset &&
!this.core.initNodeConnection()) {
- new WarningWindow(this.core,
I18n.getMessage("thaw.warning.unableToConnectTo")+ "
"+this.core.getConfig().getValue("nodeAddress")+":"+
this.core.getConfig().getValue("nodePort"));
+ if(needConnectionReset && !core.initNodeConnection()) {
+ new WarningWindow(core,
I18n.getMessage("thaw.warning.unableToConnectTo")+ "
"+core.getConfig().getValue("nodeAddress")+":"+
core.getConfig().getValue("nodePort"));
}
- this.needConnectionReset = false;
+ needConnectionReset = false;
- this.core.getPluginManager().loadPlugins();
- this.core.getPluginManager().runPlugins();
+ core.getPluginManager().loadPlugins();
+ core.getPluginManager().runPlugins();
/* reinit config win */
- this.addTabs();
+ addTabs();
}
}
- public void windowActivated(WindowEvent e) {
+ public void windowActivated(final WindowEvent e) {
}
- public void windowClosing(WindowEvent e) {
- this.setChanged();
- this.notifyObservers(this.cancelButton); /* Equivalent to a
click on the cancel button */
+ public void windowClosing(final WindowEvent e) {
+ setChanged();
+ this.notifyObservers(cancelButton); /* Equivalent to a click on
the cancel button */
}
- public void windowClosed(WindowEvent e) {
+ public void windowClosed(final WindowEvent e) {
// add potential warnings here
}
- public void windowDeactivated(WindowEvent e) {
+ public void windowDeactivated(final WindowEvent e) {
// C'est pas comme si on en avait quelque chose a foutre :p
}
- public void windowDeiconified(WindowEvent e) {
+ public void windowDeiconified(final WindowEvent e) {
// idem
}
- public void windowIconified(WindowEvent e) {
+ public void windowIconified(final WindowEvent e) {
// idem
}
- public void windowOpened(WindowEvent e) {
+ public void windowOpened(final WindowEvent e) {
// idem
}
Modified: trunk/apps/Thaw/src/thaw/core/Core.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Core.java 2006-12-06 18:18:48 UTC (rev
11272)
+++ trunk/apps/Thaw/src/thaw/core/Core.java 2006-12-06 18:21:00 UTC (rev
11273)
@@ -1,18 +1,23 @@
package thaw.core;
+import java.util.Observable;
import java.util.Observer;
-import java.util.Observable;
import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
import javax.swing.JPanel;
-import javax.swing.JLabel;
-import javax.swing.JFrame;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
-import javax.swing.JOptionPane;
import javax.swing.WindowConstants;
-import thaw.fcp.*;
+import thaw.fcp.FCPClientHello;
+import thaw.fcp.FCPConnection;
+import thaw.fcp.FCPQueryManager;
+import thaw.fcp.FCPQueueLoader;
+import thaw.fcp.FCPQueueManager;
+import thaw.fcp.FCPWatchGlobal;
/**
* A "core" contains references to all the main parts of Thaw.
@@ -51,35 +56,35 @@
* Gives a ref to the object containing the config.
*/
public Config getConfig() {
- return this.config;
+ return config;
}
/**
* Gives a ref to the object managing the splash screen.
*/
public SplashScreen getSplashScreen() {
- return this.splashScreen;
+ return splashScreen;
}
/**
* Gives a ref to the object managing the main window.
*/
public MainWindow getMainWindow() {
- return this.mainWindow;
+ return mainWindow;
}
/**
* Gives a ref to the object managing the config window.
*/
public ConfigWindow getConfigWindow() {
- return this.configWindow;
+ return configWindow;
}
/**
* Gives a ref to the plugin manager.
*/
public PluginManager getPluginManager() {
- return this.pluginManager;
+ return pluginManager;
}
@@ -88,37 +93,37 @@
* @return true is success, false if not
*/
public boolean initAll() {
- this.splashScreen = new SplashScreen();
+ splashScreen = new SplashScreen();
- this.splashScreen.display();
+ splashScreen.display();
- this.splashScreen.setProgressionAndStatus(0, "Loading
configuration ...");
- if(!this.initConfig())
+ splashScreen.setProgressionAndStatus(0, "Loading configuration
...");
+ if(!initConfig())
return false;
- this.splashScreen.setProgressionAndStatus(10, "Connecting ...");
- if(!this.initNodeConnection())
+ splashScreen.setProgressionAndStatus(10, "Connecting ...");
+ if(!initNodeConnection())
new WarningWindow(this,
I18n.getMessage("thaw.warning.unableToConnectTo")+
- "
"+this.config.getValue("nodeAddress")+
- ":"+
this.config.getValue("nodePort"));
+ " "+config.getValue("nodeAddress")+
+ ":"+ config.getValue("nodePort"));
- this.splashScreen.setProgressionAndStatus(30, "Preparing the
main window ...");
- if(!this.initGraphics())
+ splashScreen.setProgressionAndStatus(30, "Preparing the main
window ...");
+ if(!initGraphics())
return false;
- this.splashScreen.setProgressionAndStatus(40, "Loading plugins
...");
- if(!this.initPluginManager())
+ splashScreen.setProgressionAndStatus(40, "Loading plugins ...");
+ if(!initPluginManager())
return false;
- this.splashScreen.setProgressionAndStatus(100, "Ready");
+ splashScreen.setProgressionAndStatus(100, "Ready");
- this.mainWindow.setStatus("Thaw "+Main.VERSION+" :
"+I18n.getMessage("thaw.statusBar.ready"));
+ mainWindow.setStatus("Thaw "+Main.VERSION+" :
"+I18n.getMessage("thaw.statusBar.ready"));
- this.splashScreen.hide();
+ splashScreen.hide();
- this.mainWindow.setVisible(true);
+ mainWindow.setVisible(true);
return true;
}
@@ -129,10 +134,10 @@
* Init configuration. May re-set I18n.
*/
public boolean initConfig() {
- this.config = new Config();
- this.config.loadConfig();
+ config = new Config();
+ config.loadConfig();
- this.config.setDefaultValues();
+ config.setDefaultValues();
return true;
}
@@ -145,107 +150,106 @@
* @see #canDisconnect()
*/
public boolean initNodeConnection() {
- if(this.getMainWindow() != null)
-
this.getMainWindow().setStatus(I18n.getMessage("thaw.statusBar.connecting"));
+ if(getMainWindow() != null)
+
getMainWindow().setStatus(I18n.getMessage("thaw.statusBar.connecting"));
try {
- if(this.queueManager != null)
- this.queueManager.stopScheduler();
+ if(queueManager != null)
+ queueManager.stopScheduler();
- if(this.connection != null &&
this.connection.isConnected()) {
- this.disconnect();
+ if((connection != null) && connection.isConnected()) {
+ disconnect();
}
- if(this.connection == null) {
- this.connection = new
FCPConnection(this.config.getValue("nodeAddress"),
-
Integer.parseInt(this.config.getValue("nodePort")),
-
Integer.parseInt(this.config.getValue("maxUploadSpeed")),
-
Boolean.valueOf(this.config.getValue("multipleSockets")).booleanValue());
+ if(connection == null) {
+ connection = new
FCPConnection(config.getValue("nodeAddress"),
+
Integer.parseInt(config.getValue("nodePort")),
+
Integer.parseInt(config.getValue("maxUploadSpeed")),
+
Boolean.valueOf(config.getValue("multipleSockets")).booleanValue());
} else {
-
this.connection.setNodeAddress(this.config.getValue("nodeAddress"));
-
this.connection.setNodePort(Integer.parseInt(this.config.getValue("nodePort")));
-
this.connection.setMaxUploadSpeed(Integer.parseInt(this.config.getValue("maxUploadSpeed")));
+
connection.setNodeAddress(config.getValue("nodeAddress"));
+
connection.setNodePort(Integer.parseInt(config.getValue("nodePort")));
+
connection.setMaxUploadSpeed(Integer.parseInt(config.getValue("maxUploadSpeed")));
}
- if(!this.connection.connect()) {
+ if(!connection.connect()) {
Logger.warning(this, "Unable to connect !");
}
- if(this.queryManager == null)
- this.queryManager = new
FCPQueryManager(this.connection);
+ if(queryManager == null)
+ queryManager = new FCPQueryManager(connection);
- if(this.queueManager == null)
- this.queueManager = new
FCPQueueManager(this.queryManager,
-
this.config.getValue("thawId"),
-
Integer.parseInt(this.config.getValue("maxSimultaneousDownloads")),
-
Integer.parseInt(this.config.getValue("maxSimultaneousInsertions")));
+ if(queueManager == null)
+ queueManager = new FCPQueueManager(queryManager,
+
config.getValue("thawId"),
+
Integer.parseInt(config.getValue("maxSimultaneousDownloads")),
+
Integer.parseInt(config.getValue("maxSimultaneousInsertions")));
else {
-
this.queueManager.setThawId(this.config.getValue("thawId"));
-
this.queueManager.setMaxDownloads(Integer.parseInt(this.config.getValue("maxSimultaneousDownloads")));
-
this.queueManager.setMaxInsertions(Integer.parseInt(this.config.getValue("maxSimultaneousInsertions")));
+
queueManager.setThawId(config.getValue("thawId"));
+
queueManager.setMaxDownloads(Integer.parseInt(config.getValue("maxSimultaneousDownloads")));
+
queueManager.setMaxInsertions(Integer.parseInt(config.getValue("maxSimultaneousInsertions")));
}
- if(this.connection.isConnected()) {
- this.queryManager.startListening();
+ if(connection.isConnected()) {
+ queryManager.startListening();
- QueueKeeper.loadQueue(this.queueManager,
"thaw.queue.xml");
+ QueueKeeper.loadQueue(queueManager,
"thaw.queue.xml");
- this.clientHello = new
FCPClientHello(this.queryManager, this.config.getValue("thawId"));
+ clientHello = new FCPClientHello(queryManager,
config.getValue("thawId"));
- if(!this.clientHello.start(null)) {
+ if(!clientHello.start(null)) {
Logger.warning(this, "Id already used
!");
- this.connection.disconnect();
- new WarningWindow(this, "Unable to
connect to
"+this.config.getValue("nodeAddress")+":"+this.config.getValue("nodePort"));
+ connection.disconnect();
+ new WarningWindow(this, "Unable to
connect to "+config.getValue("nodeAddress")+":"+config.getValue("nodePort"));
return false;
} else {
Logger.debug(this, "Hello successful");
- Logger.debug(this, "Node name :
"+this.clientHello.getNodeName());
- Logger.debug(this, "FCP version :
"+this.clientHello.getNodeFCPVersion());
- Logger.debug(this, "Node version :
"+this.clientHello.getNodeVersion());
+ Logger.debug(this, "Node name :
"+clientHello.getNodeName());
+ Logger.debug(this, "FCP version :
"+clientHello.getNodeFCPVersion());
+ Logger.debug(this, "Node version :
"+clientHello.getNodeVersion());
- this.queueManager.startScheduler();
+ queueManager.startScheduler();
-
this.queueManager.restartNonPersistent();
+ queueManager.restartNonPersistent();
- FCPWatchGlobal watchGlobal = new
FCPWatchGlobal(true);
- watchGlobal.start(this.queueManager);
+ final FCPWatchGlobal watchGlobal = new
FCPWatchGlobal(true);
+ watchGlobal.start(queueManager);
- FCPQueueLoader queueLoader = new
FCPQueueLoader(this.config.getValue("thawId"));
- queueLoader.start(this.queueManager);
+ final FCPQueueLoader queueLoader = new
FCPQueueLoader(config.getValue("thawId"));
+ queueLoader.start(queueManager);
}
- } else {
+ } else
return false;
- }
- } catch(Exception e) { /* A little bit not ... "nice" ... */
+ } catch(final Exception e) { /* A little bit not ... "nice" ...
*/
Logger.warning(this, "Exception while connecting :
"+e.toString()+" ; "+e.getMessage() + " ; "+e.getCause());
e.printStackTrace();
return false;
}
- if(this.connection.isConnected())
- this.connection.addObserver(this);
+ if(connection.isConnected())
+ connection.addObserver(this);
- if(this.getMainWindow() != null)
-
this.getMainWindow().setStatus(I18n.getMessage("thaw.statusBar.ready"));
+ if(getMainWindow() != null)
+
getMainWindow().setStatus(I18n.getMessage("thaw.statusBar.ready"));
return true;
}
public FCPConnection getConnectionManager() {
- return this.connection;
+ return connection;
}
public FCPQueueManager getQueueManager() {
- return this.queueManager;
+ return queueManager;
}
/**
@@ -253,7 +257,7 @@
* was initiated.
*/
public FCPClientHello getClientHello() {
- return this.clientHello;
+ return clientHello;
}
@@ -261,8 +265,8 @@
* To call before initGraphics() !
* @param lAndF LookAndFeel name
*/
- public static void setLookAndFeel(String lAndF) {
- lookAndFeel = lAndF;
+ public static void setLookAndFeel(final String lAndF) {
+ Core.lookAndFeel = lAndF;
}
@@ -276,12 +280,12 @@
JDialog.setDefaultLookAndFeelDecorated(false);
try {
- if (lookAndFeel == null) {
+ if (Core.lookAndFeel == null) {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} else {
- UIManager.setLookAndFeel(lookAndFeel);
+ UIManager.setLookAndFeel(Core.lookAndFeel);
}
- } catch (Exception e) {
+ } catch (final Exception e) {
Logger.warning(this, "Exception while setting the L&F :
" + e.getMessage());
Logger.warning(this, "Using the default lookAndFeel");
}
@@ -293,14 +297,14 @@
* Init graphics.
*/
public boolean initGraphics() {
- this.initializeLookAndFeel();
+ initializeLookAndFeel();
IconBox.loadIcons();
- this.mainWindow = new MainWindow(this);
+ mainWindow = new MainWindow(this);
- this.configWindow = new ConfigWindow(this);
- this.configWindow.setVisible(false);
+ configWindow = new ConfigWindow(this);
+ configWindow.setVisible(false);
return true;
}
@@ -309,12 +313,12 @@
* Init plugin manager.
*/
public boolean initPluginManager() {
- this.pluginManager = new PluginManager(this);
+ pluginManager = new PluginManager(this);
- if(!this.pluginManager.loadPlugins())
+ if(!pluginManager.loadPlugins())
return false;
- if(!this.pluginManager.runPlugins())
+ if(!pluginManager.runPlugins())
return false;
return true;
@@ -333,18 +337,18 @@
*/
public void disconnect() {
Logger.info(this, "Disconnecting");
- this.connection.deleteObserver(this);
- this.connection.disconnect();
+ connection.deleteObserver(this);
+ connection.disconnect();
Logger.info(this, "Saving queue state");
- QueueKeeper.saveQueue(this.queueManager, "thaw.queue.xml");
+ QueueKeeper.saveQueue(queueManager, "thaw.queue.xml");
}
/**
* Check if the connection can be interrupted safely.
*/
public boolean canDisconnect() {
- return this.connection == null || !this.connection.isWriting();
+ return (connection == null) || !connection.isWriting();
}
/**
@@ -354,26 +358,26 @@
*/
public void exit(boolean force) {
if(!force) {
- if(!this.canDisconnect()) {
- if(!this.askDeconnectionConfirmation())
+ if(!canDisconnect()) {
+ if(!askDeconnectionConfirmation())
return;
}
}
Logger.info(this, "Stopping scheduler ...");
- if(this.queueManager != null)
- this.queueManager.stopScheduler();
+ if(queueManager != null)
+ queueManager.stopScheduler();
Logger.info(this, "Hidding main window ...");
- this.mainWindow.setVisible(false);
+ mainWindow.setVisible(false);
Logger.info(this, "Stopping plugins ...");
- this.pluginManager.stopPlugins();
+ pluginManager.stopPlugins();
- this.disconnect();
+ disconnect();
Logger.info(this, "Saving configuration ...");
- if(!this.config.saveConfig()) {
+ if(!config.saveConfig()) {
Logger.error(this, "Config was not saved correctly !");
}
@@ -383,7 +387,7 @@
public boolean askDeconnectionConfirmation() {
- int ret = JOptionPane.showOptionDialog((java.awt.Component)null,
+ final int ret =
JOptionPane.showOptionDialog((java.awt.Component)null,
I18n.getMessage("thaw.warning.isWriting"),
"Thaw -
"+I18n.getMessage("thaw.warning.title"),
JOptionPane.YES_NO_OPTION,
@@ -391,31 +395,31 @@
(javax.swing.Icon)null,
(java.lang.Object[])null,
(java.lang.Object)null);
- if(ret == JOptionPane.CLOSED_OPTION
- || ret == JOptionPane.CANCEL_OPTION
- || ret == JOptionPane.NO_OPTION)
+ if((ret == JOptionPane.CLOSED_OPTION)
+ || (ret == JOptionPane.CANCEL_OPTION)
+ || (ret == JOptionPane.NO_OPTION))
return false;
return true;
}
- public void update(Observable o, Object target) {
+ public void update(final Observable o, final Object target) {
Logger.debug(this, "Move on the connection (?)");
- if(o == this.connection && !this.connection.isConnected()) {
- this.disconnect();
+ if((o == connection) && !connection.isConnected()) {
+ disconnect();
int nmbReconnect = 0;
- JDialog warningDialog = new
JDialog(getMainWindow().getMainFrame());
+ final JDialog warningDialog = new
JDialog(getMainWindow().getMainFrame());
warningDialog.setTitle("Thaw - reconnection");
warningDialog.setModal(false);
warningDialog.setSize(500, 40);
warningDialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
- JPanel warningPanel = new JPanel();
+ final JPanel warningPanel = new JPanel();
- JLabel warningLabel = new
JLabel(I18n.getMessage("thaw.warning.autoreconnecting"),
+ final JLabel warningLabel = new
JLabel(I18n.getMessage("thaw.warning.autoreconnecting"),
SwingConstants.CENTER);
warningPanel.add(warningLabel);
warningDialog.setContentPane(warningPanel);
@@ -423,27 +427,27 @@
warningDialog.setVisible(true);
for(nmbReconnect = 0;
- nmbReconnect < MAX_CONNECT_TRIES ;
+ nmbReconnect < Core.MAX_CONNECT_TRIES ;
nmbReconnect++) {
try {
- Thread.sleep(TIME_BETWEEN_EACH_TRY);
- } catch(java.lang.InterruptedException e) {
+
Thread.sleep(Core.TIME_BETWEEN_EACH_TRY);
+ } catch(final java.lang.InterruptedException e)
{
// brouzouf
}
Logger.notice(this, "Trying to reconnect ... :
"+ Integer.toString(nmbReconnect));
- if(this.initNodeConnection())
+ if(initNodeConnection())
break;
}
warningDialog.setVisible(false);
- if(nmbReconnect == MAX_CONNECT_TRIES) {
- while(!this.initNodeConnection()) {
- int ret =
JOptionPane.showOptionDialog((java.awt.Component)null,
+ if(nmbReconnect == Core.MAX_CONNECT_TRIES) {
+ while(!initNodeConnection()) {
+ final int ret =
JOptionPane.showOptionDialog((java.awt.Component)null,
I18n.getMessage("thaw.warning.disconnected"),
"Thaw - "+I18n.getMessage("thaw.warning.title"),
JOptionPane.YES_NO_OPTION,
@@ -451,17 +455,17 @@
(javax.swing.Icon)null,
(java.lang.Object[])null,
(java.lang.Object)null);
- if(ret == JOptionPane.CLOSED_OPTION
- || ret == JOptionPane.CANCEL_OPTION
- || ret == JOptionPane.NO_OPTION)
+ if((ret == JOptionPane.CLOSED_OPTION)
+ || (ret == JOptionPane.CANCEL_OPTION)
+ || (ret == JOptionPane.NO_OPTION))
break;
}
}
- this.getPluginManager().stopPlugins();
- this.getPluginManager().loadPlugins();
- this.getPluginManager().runPlugins();
+ getPluginManager().stopPlugins();
+ getPluginManager().loadPlugins();
+ getPluginManager().runPlugins();
}
}
Modified: trunk/apps/Thaw/src/thaw/core/FileChooser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/FileChooser.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/core/FileChooser.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,9 +1,10 @@
package thaw.core;
-import javax.swing.JFileChooser;
import java.io.File;
import java.util.Vector;
+import javax.swing.JFileChooser;
+
/**
* FileChooser helps to create and use simple JFileChooser.
* Don't block any swing component.
@@ -12,43 +13,43 @@
private JFileChooser fileChooser = null;
public FileChooser() {
- this.fileChooser = new JFileChooser();
+ fileChooser = new JFileChooser();
}
- public FileChooser(String path) {
- this.fileChooser = new JFileChooser(path);
- this.fileChooser.setDragEnabled(true);
+ public FileChooser(final String path) {
+ fileChooser = new JFileChooser(path);
+ fileChooser.setDragEnabled(true);
}
- public void setTitle(String title) {
- this.fileChooser.setDialogTitle(title);
+ public void setTitle(final String title) {
+ fileChooser.setDialogTitle(title);
}
- public void setDirectoryOnly(boolean v) {
+ public void setDirectoryOnly(final boolean v) {
if(v)
-
this.fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
else
-
this.fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); /*
Directories -> Recursivity */
+
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); /*
Directories -> Recursivity */
}
/**
* @param type JFileChooser.OPEN_DIALOG / JFileChooser.SAVE_DIALOG
* @see javax.swing.JFileChooser#setDialogType(int)
*/
- public void setDialogType(int type) {
- this.fileChooser.setDialogType(type);
+ public void setDialogType(final int type) {
+ fileChooser.setDialogType(type);
}
protected boolean showDialog() {
int result = 0;
- if(this.fileChooser.getDialogType() ==
JFileChooser.OPEN_DIALOG) {
- result = this.fileChooser.showOpenDialog(null);
+ if(fileChooser.getDialogType() == JFileChooser.OPEN_DIALOG) {
+ result = fileChooser.showOpenDialog(null);
}
- if(this.fileChooser.getDialogType() ==
JFileChooser.SAVE_DIALOG) {
- result = this.fileChooser.showSaveDialog(null);
+ if(fileChooser.getDialogType() == JFileChooser.SAVE_DIALOG) {
+ result = fileChooser.showSaveDialog(null);
}
if(result == JFileChooser.APPROVE_OPTION)
@@ -71,13 +72,13 @@
}
- protected void expandRecursivly(File file, Vector vec) {
+ protected void expandRecursivly(final File file, final Vector vec) {
if (file.isFile()) {
vec.add(file);
return;
}
- File[] files = file.listFiles();
+ final File[] files = file.listFiles();
if (files == null) {
Logger.notice(this, "Unable to parse directory
'"+file.getPath()+"'");
@@ -93,9 +94,9 @@
}
- protected Vector expandRecursivly(File[] selectedFiles)
+ protected Vector expandRecursivly(final File[] selectedFiles)
{
- Vector files= new Vector();
+ final Vector files= new Vector();
for (int i = 0 ; i < selectedFiles.length ; i++) {
this.expandRecursivly(selectedFiles[i], files);
@@ -108,12 +109,12 @@
* @return null if nothing choosed.
*/
public Vector askManyFiles() {
- this.fileChooser.setMultiSelectionEnabled(true);
+ fileChooser.setMultiSelectionEnabled(true);
- if(!this.showDialog())
+ if(!showDialog())
return null;
- return
this.expandRecursivly(this.fileChooser.getSelectedFiles());
+ return this.expandRecursivly(fileChooser.getSelectedFiles());
}
}
Modified: trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,6 +1,5 @@
package thaw.core;
-import thaw.core.Logger;
public class FreenetURIHelper {
@@ -18,14 +17,14 @@
try {
uri = java.net.URLDecoder.decode(uri, "UTF-8");
- } catch (java.io.UnsupportedEncodingException e) {
+ } catch (final java.io.UnsupportedEncodingException e) {
Logger.warning(new FreenetURIHelper(),
"UnsupportedEncodingException (UTF-8): "+e.toString());
}
- if (uri.indexOf("CHK@") < 0
- && uri.indexOf("USK@") < 0
- && uri.indexOf("KSK@") < 0
- && uri.indexOf("SSK@") < 0) {
+ if ((uri.indexOf("CHK@") < 0)
+ && (uri.indexOf("USK@") < 0)
+ && (uri.indexOf("KSK@") < 0)
+ && (uri.indexOf("SSK@") < 0)) {
Logger.notice(new FreenetURIHelper(), "Not a valid key:
"+uri);
return null;
}
@@ -34,9 +33,9 @@
}
- public static String getFilenameFromKey(String key) {
+ public static String getFilenameFromKey(final String key) {
String filename;
- String cutcut[] = key.split("/");
+ final String cutcut[] = key.split("/");
if (key == null)
return null;
@@ -52,12 +51,12 @@
public static String convertSSKtoUSK(String SSK) {
- if (SSK == null || SSK.startsWith("USK@"))
+ if ((SSK == null) || SSK.startsWith("USK@"))
return SSK;
SSK.replaceFirst("SSK@", "USK@");
- String[] split = SSK.split("/");
+ final String[] split = SSK.split("/");
SSK = "";
@@ -67,7 +66,7 @@
SSK = split[i];
break;
case(1):
- String subsplit[] = split[i].split("-");
+ final String subsplit[] = split[i].split("-");
SSK = SSK + "/";
@@ -90,11 +89,11 @@
}
- public static String abs(String val) {
+ public static String abs(final String val) {
try {
- java.math.BigDecimal bd = new java.math.BigDecimal(val);
+ final java.math.BigDecimal bd = new
java.math.BigDecimal(val);
return bd.abs().toString();
- } catch(java.lang.NumberFormatException e) {
+ } catch(final java.lang.NumberFormatException e) {
Logger.warning(new FreenetURIHelper(),
"NumberFormatException while parsing '"+val+"'");
return "0";
}
@@ -102,12 +101,12 @@
public static String convertUSKtoSSK(String USK) {
- if (USK == null || USK.startsWith("SSK@"))
+ if ((USK == null) || USK.startsWith("SSK@"))
return USK;
USK = USK.replaceFirst("USK@", "SSK@");
- String[] split = USK.split("/");
+ final String[] split = USK.split("/");
USK = "";
@@ -117,7 +116,7 @@
USK = split[i];
break;
case(2):
- USK = USK + "-" + abs(split[i]);
+ USK = USK + "-" +
FreenetURIHelper.abs(split[i]);
break;
default:
USK = USK + "/" + split[i];
@@ -130,9 +129,9 @@
public static String getPublicInsertionSSK(String key) {
- key = convertUSKtoSSK(key);
+ key = FreenetURIHelper.convertUSKtoSSK(key);
- String split[] = key.split("/");
+ final String split[] = key.split("/");
key = "";
@@ -147,7 +146,7 @@
}
- protected static String changeRev(String revStr, int rev, int offset) {
+ protected static String changeRev(final String revStr, final int rev,
final int offset) {
if (rev >= 0)
return Integer.toString(rev);
@@ -157,12 +156,12 @@
/**
* @param rev if < 0, then rev is changed according to the given offset
*/
- public static String changeSSKRevision(String key, int rev, int offset)
{
+ public static String changeSSKRevision(String key, final int rev, final
int offset) {
if (key == null)
return null;
- String[] split = key.split("/");
+ final String[] split = key.split("/");
key = "";
@@ -172,7 +171,7 @@
key = key + split[i];
break;
case(1):
- String[] subsplit = split[i].split("-");
+ final String[] subsplit = split[i].split("-");
for (int j = 0 ; j < subsplit.length-1 ; j++) {
if (j == 0)
@@ -181,7 +180,7 @@
key = key + "-" + subsplit[j];
}
- key = key + "-" +
changeRev(subsplit[subsplit.length-1], rev, offset);
+ key = key + "-" +
FreenetURIHelper.changeRev(subsplit[subsplit.length-1], rev, offset);
break;
default:
key = key + "/" + split[i];
@@ -192,7 +191,7 @@
}
- public static int getUSKRevision(String key) {
+ public static int getUSKRevision(final String key) {
String[] split;
if (key == null)
Modified: trunk/apps/Thaw/src/thaw/core/GUIHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/GUIHelper.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/core/GUIHelper.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -4,9 +4,8 @@
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
-
-import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import javax.swing.AbstractButton;
import javax.swing.text.JTextComponent;
@@ -20,25 +19,25 @@
public static class PasteHelper implements ActionListener {
JTextComponent txtComp;
- public PasteHelper(AbstractButton src, JTextComponent txtComp) {
+ public PasteHelper(final AbstractButton src, final
JTextComponent txtComp) {
if (src != null)
src.addActionListener(this);
this.txtComp = txtComp;
}
- public void actionPerformed(ActionEvent evt) {
- pasteToComponent(txtComp);
+ public void actionPerformed(final ActionEvent evt) {
+ GUIHelper.pasteToComponent(txtComp);
}
}
- public static void pasteToComponent(JTextComponent txtComp) {
- Toolkit tk = Toolkit.getDefaultToolkit();
- Clipboard cp = tk.getSystemClipboard();
+ public static void pasteToComponent(final JTextComponent txtComp) {
+ final Toolkit tk = Toolkit.getDefaultToolkit();
+ final Clipboard cp = tk.getSystemClipboard();
String result;
- Transferable contents = cp.getContents(null);
+ final Transferable contents = cp.getContents(null);
- boolean hasTransferableText = ((contents != null) &&
+ final boolean hasTransferableText = ((contents != null) &&
contents.isDataFlavorSupported(DataFlavor.stringFlavor));
try {
@@ -48,9 +47,9 @@
} else {
Logger.notice(new GUIHelper(), "Nothing to get
from clipboard");
}
- } catch(java.awt.datatransfer.UnsupportedFlavorException e) {
+ } catch(final java.awt.datatransfer.UnsupportedFlavorException
e) {
Logger.error(new GUIHelper(), "Error while pasting:
UnsupportedFlavorException: "+e.toString());
- } catch(java.io.IOException e) {
+ } catch(final java.io.IOException e) {
Logger.error(new GUIHelper(), "Error while pasting:
IOException: "+e.toString());
}
}
Modified: trunk/apps/Thaw/src/thaw/core/I18n.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/I18n.java 2006-12-06 18:18:48 UTC (rev
11272)
+++ trunk/apps/Thaw/src/thaw/core/I18n.java 2006-12-06 18:21:00 UTC (rev
11273)
@@ -42,28 +42,28 @@
}
public static Locale getLocale() {
- if (currentLocale == null)
- currentLocale = Locale.getDefault();
- return currentLocale;
+ if (I18n.currentLocale == null)
+ I18n.currentLocale = Locale.getDefault();
+ return I18n.currentLocale;
}
- public static void setLocale(Locale locale) {
- currentLocale = locale;
+ public static void setLocale(final Locale locale) {
+ I18n.currentLocale = locale;
Locale.setDefault(locale);
}
public static ResourceBundle getResourceBundle() {
- return getResourceBundle(getLocale());
+ return I18n.getResourceBundle(I18n.getLocale());
}
- public static ResourceBundle getResourceBundle(Locale locale) {
- return ResourceBundle.getBundle("thaw.i18n.thaw", getLocale());
+ public static ResourceBundle getResourceBundle(final Locale locale) {
+ return ResourceBundle.getBundle("thaw.i18n.thaw",
I18n.getLocale());
}
- public static String getMessage(String key) {
+ public static String getMessage(final String key) {
try {
- return getResourceBundle().getString(key);
- } catch(Exception e) {
+ return I18n.getResourceBundle().getString(key);
+ } catch(final Exception e) {
Logger.warning(new I18n(),/* we need a ref -> random
ref -> this is *bad* */
"Unable to find translation for
'"+key+"'");
return key;
Modified: trunk/apps/Thaw/src/thaw/core/IconBox.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/IconBox.java 2006-12-06 18:18:48 UTC (rev
11272)
+++ trunk/apps/Thaw/src/thaw/core/IconBox.java 2006-12-06 18:21:00 UTC (rev
11273)
@@ -1,8 +1,9 @@
package thaw.core;
-import javax.swing.ImageIcon;
import java.net.URL;
+import javax.swing.ImageIcon;
+
/**
* This class is simply an helper to find and load quickly some common icons.
*/
@@ -69,8 +70,7 @@
}
- protected static ImageIcon loadIcon(String fileName) {
- ImageIcon imageIcon;
+ protected static ImageIcon loadIcon(final String fileName) {
URL url;
Class daClass;
ClassLoader classLoader;
@@ -100,36 +100,36 @@
}
public static void loadIcons() {
- blueBunny = loadIcon("blueBunny.png");
- connectAction = loadIcon("go-jump.png");
- minConnectAction = loadIcon("min-go-jump.png");
- disconnectAction = loadIcon("process-stop.png");
- queue = loadIcon("system-search.png");
- minQueue = loadIcon("min-system-search.png");
- insertions = loadIcon("go-next.png");
- minInsertions = loadIcon("min-go-next.png");
- minIndex = loadIcon("index.png");
- indexNew = loadIcon("index-new.png");
- indexReuse = loadIcon("index-existing.png");
- downloads = loadIcon("go-first.png");
- minDownloads = loadIcon("min-go-first.png");
- clearAction = loadIcon("edit-clear.png");
- settings = loadIcon("preferences-system.png");
- minSettings = loadIcon("min-preferences-system.png");
- indexEditor = loadIcon("edit-find-replace.png");
- minIndexEditor = loadIcon("min-edit-find-replace.png");
- indexBrowser = loadIcon("edit-find.png");
- minIndexBrowser = loadIcon("min-edit-find.png");
- addToIndexAction = loadIcon("folder.png");
- insertAndAddToIndexAction = loadIcon("folder-new.png");
- makeALinkAction = loadIcon("application-internet.png");
- reconnectAction = loadIcon("view-refresh.png");
- minReconnectAction = loadIcon("min-view-refresh.png");
- refreshAction = loadIcon("view-refresh.png");
- quitAction = loadIcon("system-log-out.png");
- minQuitAction = loadIcon("min-system-log-out.png");
- search = loadIcon("system-search.png");
- key = loadIcon("key.png");
+ IconBox.blueBunny = IconBox.loadIcon("blueBunny.png");
+ IconBox.connectAction = IconBox.loadIcon("go-jump.png");
+ IconBox.minConnectAction = IconBox.loadIcon("min-go-jump.png");
+ IconBox.disconnectAction = IconBox.loadIcon("process-stop.png");
+ IconBox.queue = IconBox.loadIcon("system-search.png");
+ IconBox.minQueue = IconBox.loadIcon("min-system-search.png");
+ IconBox.insertions = IconBox.loadIcon("go-next.png");
+ IconBox.minInsertions = IconBox.loadIcon("min-go-next.png");
+ IconBox.minIndex = IconBox.loadIcon("index.png");
+ IconBox.indexNew = IconBox.loadIcon("index-new.png");
+ IconBox.indexReuse = IconBox.loadIcon("index-existing.png");
+ IconBox.downloads = IconBox.loadIcon("go-first.png");
+ IconBox.minDownloads = IconBox.loadIcon("min-go-first.png");
+ IconBox.clearAction = IconBox.loadIcon("edit-clear.png");
+ IconBox.settings = IconBox.loadIcon("preferences-system.png");
+ IconBox.minSettings =
IconBox.loadIcon("min-preferences-system.png");
+ IconBox.indexEditor = IconBox.loadIcon("edit-find-replace.png");
+ IconBox.minIndexEditor =
IconBox.loadIcon("min-edit-find-replace.png");
+ IconBox.indexBrowser = IconBox.loadIcon("edit-find.png");
+ IconBox.minIndexBrowser = IconBox.loadIcon("min-edit-find.png");
+ IconBox.addToIndexAction = IconBox.loadIcon("folder.png");
+ IconBox.insertAndAddToIndexAction =
IconBox.loadIcon("folder-new.png");
+ IconBox.makeALinkAction =
IconBox.loadIcon("application-internet.png");
+ IconBox.reconnectAction = IconBox.loadIcon("view-refresh.png");
+ IconBox.minReconnectAction =
IconBox.loadIcon("min-view-refresh.png");
+ IconBox.refreshAction = IconBox.loadIcon("view-refresh.png");
+ IconBox.quitAction = IconBox.loadIcon("system-log-out.png");
+ IconBox.minQuitAction =
IconBox.loadIcon("min-system-log-out.png");
+ IconBox.search = IconBox.loadIcon("system-search.png");
+ IconBox.key = IconBox.loadIcon("key.png");
}
}
Modified: trunk/apps/Thaw/src/thaw/core/LibraryPlugin.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/LibraryPlugin.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/core/LibraryPlugin.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -12,19 +12,19 @@
public abstract boolean run(Core core);
public abstract boolean stop();
- public void registerChild(Plugin child) {
- this.nmbRegistered++;
+ public void registerChild(final Plugin child) {
+ nmbRegistered++;
- if(this.nmbRegistered == 1)
- this.realStart();
+ if(nmbRegistered == 1)
+ realStart();
}
- public void unregisterChild(Plugin child) {
- this.nmbRegistered--;
+ public void unregisterChild(final Plugin child) {
+ nmbRegistered--;
- if(this.nmbRegistered == 0)
- this.realStop();
+ if(nmbRegistered == 0)
+ realStop();
}
public abstract void realStart();
Modified: trunk/apps/Thaw/src/thaw/core/Logger.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Logger.java 2006-12-06 18:18:48 UTC (rev
11272)
+++ trunk/apps/Thaw/src/thaw/core/Logger.java 2006-12-06 18:21:00 UTC (rev
11273)
@@ -1,7 +1,7 @@
package thaw.core;
+import java.util.Iterator;
import java.util.Vector;
-import java.util.Iterator;
/**
* Manage all log message.
@@ -25,78 +25,78 @@
private static Vector logListeners = null;
- protected static void displayErr(String msg) {
+ protected static void displayErr(final String msg) {
System.err.println(msg);
- notifyLogListeners(msg);
+ Logger.notifyLogListeners(msg);
}
- protected static void display(String msg) {
+ protected static void display(final String msg) {
System.out.println(msg);
- notifyLogListeners(msg);
+ Logger.notifyLogListeners(msg);
}
/**
* Errors.
*/
- public static void error(Object o, String message) {
- displayErr("[ ERROR ] "+o.getClass().getName()+": "+message);
+ public static void error(final Object o, final String message) {
+ Logger.displayErr("[ ERROR ] "+o.getClass().getName()+":
"+message);
}
/**
* Warnings.
*/
- public static void warning(Object o, String message) {
- if(LOG_LEVEL >= 1)
- displayErr("[WARNING] "+o.getClass().getName()+":
"+message);
+ public static void warning(final Object o, final String message) {
+ if(Logger.LOG_LEVEL >= 1)
+ Logger.displayErr("[WARNING]
"+o.getClass().getName()+": "+message);
}
/**
* Notices.
*/
- public static void notice(Object o, String msg) {
- if(LOG_LEVEL >= 2)
- display("[NOTICE ] " +o.getClass().getName()+": "+msg);
+ public static void notice(final Object o, final String msg) {
+ if(Logger.LOG_LEVEL >= 2)
+ Logger.display("[NOTICE ] " +o.getClass().getName()+":
"+msg);
}
- public static void info(Object o, String msg) {
- info(o, msg, false);
+ public static void info(final Object o, final String msg) {
+ Logger.info(o, msg, false);
}
/**
* Infos.
*/
- public static void info(Object o, String msg, boolean manda) {
- if(LOG_LEVEL >= 3 || manda)
- display("[ INFO ] "+o.getClass().getName()+": "+msg);
+ public static void info(final Object o, final String msg, final boolean
manda) {
+ if((Logger.LOG_LEVEL >= 3) || manda)
+ Logger.display("[ INFO ] "+o.getClass().getName()+":
"+msg);
}
/**
* Debug.
*/
- public static void debug(Object o, String msg) {
- if(LOG_LEVEL >= 4)
- display("[ DEBUG ] "+o.getClass().getName()+": "+msg);
+ public static void debug(final Object o, final String msg) {
+ if(Logger.LOG_LEVEL >= 4)
+ Logger.display("[ DEBUG ] "+o.getClass().getName()+":
"+msg);
}
/**
* Verbose. Too Verbose.
*/
- public static void verbose(Object o, String msg) {
- if(LOG_LEVEL >= 5) {
+ public static void verbose(final Object o, final String msg) {
+ if(Logger.LOG_LEVEL >= 5) {
System.out.println("[VERBOSE] "+
o.getClass().getName()+": "+msg);
- notifyLogListeners(msg);
+ Logger.notifyLogListeners(msg);
}
}
/**
* As it. Similar to verbose()
*/
- public static void asIt(Object o, String msg) {
- if(LOG_LEVEL >= 5) {
+ public static void asIt(final Object o, final String msg) {
+ if(Logger.LOG_LEVEL >= 5) {
System.out.println(msg);
- notifyLogListeners(msg);
+ Logger.notifyLogListeners(msg);
}
}
@@ -104,28 +104,28 @@
- public static void addLogListener(LogListener logListener) {
- if(logListeners == null)
- logListeners = new Vector();
+ public static void addLogListener(final LogListener logListener) {
+ if(Logger.logListeners == null)
+ Logger.logListeners = new Vector();
- logListeners.add(logListener);
+ Logger.logListeners.add(logListener);
}
- public static void removeLogListener(LogListener logListener) {
- if(logListeners == null)
+ public static void removeLogListener(final LogListener logListener) {
+ if(Logger.logListeners == null)
return;
- logListeners.remove(logListener);
+ Logger.logListeners.remove(logListener);
}
- private static void notifyLogListeners(String line) {
- if(logListeners == null)
+ private static void notifyLogListeners(final String line) {
+ if(Logger.logListeners == null)
return;
- for(Iterator it = logListeners.iterator();
+ for(final Iterator it = Logger.logListeners.iterator();
it.hasNext(); ) {
- LogListener logListener = (LogListener)it.next();
+ final LogListener logListener = (LogListener)it.next();
logListener.newLogLine(line);
}
Modified: trunk/apps/Thaw/src/thaw/core/Main.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Main.java 2006-12-06 18:18:48 UTC (rev
11272)
+++ trunk/apps/Thaw/src/thaw/core/Main.java 2006-12-06 18:21:00 UTC (rev
11273)
@@ -1,8 +1,9 @@
package thaw.core;
+import java.util.Locale;
+
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
-import java.util.Locale;
/**
@@ -19,7 +20,7 @@
_svnBuildNumber = "@custom@";
public final static String
- VERSION = _major + "." + _minor + " Beta r"+_svnBuildNumber;
+ VERSION = Main._major + "." + Main._minor + " Beta
r"+Main._svnBuildNumber;
/**
@@ -39,16 +40,16 @@
*
* @param args "-?", "-help", "--help", "/?", "/help", "-lf lookandfeel"
*/
- public static void main(String[] args) {
+ public static void main(final String[] args) {
Core core;
- parseCommandLine(args);
+ Main.parseCommandLine(args);
- if(locale != null)
- I18n.setLocale(new Locale(locale));
+ if(Main.locale != null)
+ I18n.setLocale(new Locale(Main.locale));
core = new Core();
- Core.setLookAndFeel(lookAndFeel);
+ Core.setLookAndFeel(Main.lookAndFeel);
core.initAll();
}
@@ -60,7 +61,7 @@
*
* @param args the arguments
*/
- private static void parseCommandLine(String[] args) {
+ private static void parseCommandLine(final String[] args) {
int count = 0;
@@ -70,20 +71,20 @@
|| "--help".equals( args[count]
)
|| "/?".equals( args[count] )
|| "/help".equals( args[count]
)) {
- showHelp();
+ Main.showHelp();
count++;
} else if ("-lf".equals( args[count] )) {
- lookAndFeel = args[count + 1];
+ Main.lookAndFeel = args[count + 1];
count = count + 2;
} else if ("-lc".equals( args[count] )) {
- locale = args[count + 1];
+ Main.locale = args[count + 1];
count = count + 2;
} else {
- showHelp();
+ Main.showHelp();
}
}
- } catch (ArrayIndexOutOfBoundsException exception) {
- showHelp();
+ } catch (final ArrayIndexOutOfBoundsException exception) {
+ Main.showHelp();
}
}
@@ -98,7 +99,7 @@
System.out.println("-lf Sets the 'Look and Feel' will
use.");
System.out.println(" (overriden by the skins
preferences)\n");
System.out.println(" These ones are currently
available:");
- LookAndFeelInfo[] feels = UIManager.getInstalledLookAndFeels();
+ final LookAndFeelInfo[] feels =
UIManager.getInstalledLookAndFeels();
for (int i = 0; i < feels.length; i++) {
System.out.println(" " +
feels[i].getClassName());
}
Modified: trunk/apps/Thaw/src/thaw/core/MainWindow.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/MainWindow.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/core/MainWindow.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,26 +1,25 @@
package thaw.core;
+import java.awt.BorderLayout;
+import java.awt.Font;
+import java.awt.event.ActionEvent;
+import java.awt.event.WindowEvent;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.swing.Icon;
+import javax.swing.JButton;
import javax.swing.JFrame;
-import javax.swing.JMenuBar;
-import javax.swing.JTabbedPane;
import javax.swing.JLabel;
-import javax.swing.WindowConstants;
-
-import java.awt.BorderLayout;
import javax.swing.JMenu;
+import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
-import java.awt.event.ActionEvent;
-import java.awt.event.WindowEvent;
import javax.swing.JOptionPane;
+import javax.swing.JTabbedPane;
import javax.swing.JToolBar;
-import javax.swing.JButton;
-import javax.swing.Icon;
-import java.awt.Font;
+import javax.swing.WindowConstants;
-import java.util.Vector;
-import java.util.Iterator;
-
/**
* MainWindow. This class create the main window.
*
@@ -81,93 +80,93 @@
* Creates a new <code>MainWindow</code> instance, and so a new Swing
window.
* @param core a <code>Core</code> value
*/
- public MainWindow(Core core) {
+ public MainWindow(final Core core) {
this.core = core;
- this.mainWindow = new JFrame("Thaw");
+ mainWindow = new JFrame("Thaw");
-
this.mainWindow.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
+
mainWindow.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- this.mainWindow.setVisible(false);
+ mainWindow.setVisible(false);
try {
-
this.mainWindow.setIconImage(IconBox.blueBunny.getImage());
- } catch(Throwable e) {
+ mainWindow.setIconImage(IconBox.blueBunny.getImage());
+ } catch(final Throwable e) {
Logger.notice(this, "No icon");
}
// MENUS
- this.menuBar = new JMenuBar();
- this.fileMenu = new JMenu(I18n.getMessage("thaw.menu.file"));
+ menuBar = new JMenuBar();
+ fileMenu = new JMenu(I18n.getMessage("thaw.menu.file"));
- this.reconnectionFileMenuItem = new
JMenuItem(I18n.getMessage("thaw.menu.item.reconnect"),
+ reconnectionFileMenuItem = new
JMenuItem(I18n.getMessage("thaw.menu.item.reconnect"),
IconBox.minReconnectAction);
- this.optionsFileMenuItem = new
JMenuItem(I18n.getMessage("thaw.menu.item.options"),
+ optionsFileMenuItem = new
JMenuItem(I18n.getMessage("thaw.menu.item.options"),
IconBox.minSettings);
- this.quitFileMenuItem = new
JMenuItem(I18n.getMessage("thaw.menu.item.quit"),
+ quitFileMenuItem = new
JMenuItem(I18n.getMessage("thaw.menu.item.quit"),
IconBox.minQuitAction);
- this.reconnectionFileMenuItem.addActionListener(this);
- this.optionsFileMenuItem.addActionListener(this);
- this.quitFileMenuItem.addActionListener(this);
+ reconnectionFileMenuItem.addActionListener(this);
+ optionsFileMenuItem.addActionListener(this);
+ quitFileMenuItem.addActionListener(this);
- this.fileMenu.add(this.reconnectionFileMenuItem);
- this.fileMenu.add(this.optionsFileMenuItem);
- this.fileMenu.add(this.quitFileMenuItem);
+ fileMenu.add(reconnectionFileMenuItem);
+ fileMenu.add(optionsFileMenuItem);
+ fileMenu.add(quitFileMenuItem);
- this.menuBar.add(this.fileMenu);
+ menuBar.add(fileMenu);
- this.helpMenu = new JMenu(I18n.getMessage("thaw.menu.help"));
+ helpMenu = new JMenu(I18n.getMessage("thaw.menu.help"));
- this.aboutHelpMenuItem = new
JMenuItem(I18n.getMessage("thaw.menu.item.about"));
- this.aboutHelpMenuItem.addActionListener(this);
+ aboutHelpMenuItem = new
JMenuItem(I18n.getMessage("thaw.menu.item.about"));
+ aboutHelpMenuItem.addActionListener(this);
- this.helpMenu.add(this.aboutHelpMenuItem);
+ helpMenu.add(aboutHelpMenuItem);
//menuBar.add(Box.createHorizontalGlue());
- this.menuBar.add(this.helpMenu);
+ menuBar.add(helpMenu);
// TOOLBAR
- this.connectButton = new JButton(IconBox.connectAction);
-
this.connectButton.setToolTipText(I18n.getMessage("thaw.toolbar.button.connect"));
- this.disconnectButton = new JButton(IconBox.disconnectAction);
-
this.disconnectButton.setToolTipText(I18n.getMessage("thaw.toolbar.button.disconnect"));
+ connectButton = new JButton(IconBox.connectAction);
+
connectButton.setToolTipText(I18n.getMessage("thaw.toolbar.button.connect"));
+ disconnectButton = new JButton(IconBox.disconnectAction);
+
disconnectButton.setToolTipText(I18n.getMessage("thaw.toolbar.button.disconnect"));
- this.settingsButton = new JButton(IconBox.settings);
-
this.settingsButton.setToolTipText(I18n.getMessage("thaw.toolbar.button.settings"));
+ settingsButton = new JButton(IconBox.settings);
+
settingsButton.setToolTipText(I18n.getMessage("thaw.toolbar.button.settings"));
- this.quitButton = new JButton(IconBox.quitAction);
-
this.quitButton.setToolTipText(I18n.getMessage("thaw.toolbar.button.quit"));
+ quitButton = new JButton(IconBox.quitAction);
+
quitButton.setToolTipText(I18n.getMessage("thaw.toolbar.button.quit"));
- this.connectButton.addActionListener(this);
- this.disconnectButton.addActionListener(this);
- this.settingsButton.addActionListener(this);
- this.quitButton.addActionListener(this);
+ connectButton.addActionListener(this);
+ disconnectButton.addActionListener(this);
+ settingsButton.addActionListener(this);
+ quitButton.addActionListener(this);
// TABBED PANE
- this.tabbedPane = new JTabbedPane();
+ tabbedPane = new JTabbedPane();
// STATUS BAR
- this.statusBar = new JLabel();
- this.setStatus(null);
- this.statusBar.setSize(500, 30);
+ statusBar = new JLabel();
+ setStatus(null);
+ statusBar.setSize(500, 30);
- this.mainWindow.getContentPane().setLayout(new BorderLayout());
+ mainWindow.getContentPane().setLayout(new BorderLayout());
- this.mainWindow.setJMenuBar(this.menuBar);
+ mainWindow.setJMenuBar(menuBar);
/* Toolbar adding: */ changeButtonsInTheToolbar(this, null);
- this.mainWindow.getContentPane().add(this.tabbedPane,
BorderLayout.CENTER);
- this.mainWindow.getContentPane().add(this.statusBar,
BorderLayout.SOUTH);
+ mainWindow.getContentPane().add(tabbedPane,
BorderLayout.CENTER);
+ mainWindow.getContentPane().add(statusBar, BorderLayout.SOUTH);
- this.mainWindow.setSize(DEFAULT_SIZE_X, DEFAULT_SIZE_Y);
+ mainWindow.setSize(MainWindow.DEFAULT_SIZE_X,
MainWindow.DEFAULT_SIZE_Y);
- this.mainWindow.addWindowListener(this);
+ mainWindow.addWindowListener(this);
core.getConnectionManager().addObserver(this);
}
@@ -176,13 +175,13 @@
/**
* Make the window visible or not.
*/
- public void setVisible(boolean v) {
- this.mainWindow.setVisible(v);
+ public void setVisible(final boolean v) {
+ mainWindow.setVisible(v);
}
public JFrame getMainFrame() {
- return this.mainWindow;
+ return mainWindow;
}
@@ -192,36 +191,35 @@
* @return In the future, it's possible that it will sometimes return
null.
*/
public JTabbedPane getTabbedPane() {
- return this.tabbedPane;
+ return tabbedPane;
}
/**
* @param modifier Correspond to the caller object: it's a security to
avoid that a modifier wipe out the buttons from another one
*/
- public void changeButtonsInTheToolbar(Object modifier, Vector
newButtons) {
+ public void changeButtonsInTheToolbar(final Object modifier, final
Vector newButtons) {
JToolBar newToolBar;
Logger.debug(this, "Called by "+modifier.getClass().getName());
- if (lastToolBarModifier == null || newButtons != null ||
lastToolBarModifier == modifier) {
+ if ((lastToolBarModifier == null) || (newButtons != null) ||
(lastToolBarModifier == modifier)) {
lastToolBarModifier = modifier;
- } else {
+ } else
/* Only the modifer who added the buttons can remove
them */
return;
- }
newToolBar = new
JToolBar(I18n.getMessage("thaw.toolbar.title"));
- newToolBar.add(this.connectButton);
- newToolBar.add(this.disconnectButton);
+ newToolBar.add(connectButton);
+ newToolBar.add(disconnectButton);
newToolBar.addSeparator();
- newToolBar.add(this.settingsButton);
+ newToolBar.add(settingsButton);
newToolBar.addSeparator();
if (newButtons != null) {
- for (Iterator it = newButtons.iterator();
+ for (final Iterator it = newButtons.iterator();
it.hasNext();) {
- JButton button = (JButton)it.next();
+ final JButton button = (JButton)it.next();
if (button != null)
newToolBar.add(button);
else
@@ -230,14 +228,14 @@
newToolBar.addSeparator();
}
- newToolBar.add(this.quitButton);
+ newToolBar.add(quitButton);
newToolBar.setFloatable(false);
- if (this.toolBar != null)
- this.mainWindow.getContentPane().remove(this.toolBar);
- this.toolBar = newToolBar;
- this.mainWindow.getContentPane().add(this.toolBar,
BorderLayout.NORTH);
- this.updateToolBar();
+ if (toolBar != null)
+ mainWindow.getContentPane().remove(toolBar);
+ toolBar = newToolBar;
+ mainWindow.getContentPane().add(toolBar, BorderLayout.NORTH);
+ updateToolBar();
}
public void resetLastKnowToolBarModifier() {
@@ -249,8 +247,8 @@
* Used to add a tab in the main window.
* In the future, even if the interface, this function should remain
available.
*/
- public boolean addTab(String tabName, java.awt.Component panel) {
- this.tabbedPane.addTab(tabName, panel);
+ public boolean addTab(final String tabName, final java.awt.Component
panel) {
+ tabbedPane.addTab(tabName, panel);
return true;
}
@@ -258,8 +256,8 @@
/**
*?@see #addTab(String, java.awt.Component)
*/
- public boolean addTab(String tabName, Icon icon, java.awt.Component
panel) {
- this.tabbedPane.addTab(tabName, icon, panel);
+ public boolean addTab(final String tabName, final Icon icon, final
java.awt.Component panel) {
+ tabbedPane.addTab(tabName, icon, panel);
return true;
}
@@ -267,8 +265,8 @@
/**
* Used to remove a tab from the main window.
*/
- public boolean removeTab(java.awt.Component panel) {
- this.tabbedPane.remove(panel);
+ public boolean removeTab(final java.awt.Component panel) {
+ tabbedPane.remove(panel);
return true;
}
@@ -279,71 +277,71 @@
* @return Check it does not return null.
*/
public JMenuBar getMenuBar() {
- return this.menuBar;
+ return menuBar;
}
/**
* Called when an element from the menu is called.
*/
- public void actionPerformed(ActionEvent e) {
- if(e.getSource() == this.connectButton) {
- this.core.getPluginManager().stopPlugins();
+ public void actionPerformed(final ActionEvent e) {
+ if(e.getSource() == connectButton) {
+ core.getPluginManager().stopPlugins();
- if(!this.core.initNodeConnection())
- this.unableToConnect();
+ if(!core.initNodeConnection())
+ unableToConnect();
- this.core.getPluginManager().runPlugins();
+ core.getPluginManager().runPlugins();
}
- if(e.getSource() == this.disconnectButton) {
- if(!this.core.canDisconnect()) {
- if(!this.core.askDeconnectionConfirmation())
+ if(e.getSource() == disconnectButton) {
+ if(!core.canDisconnect()) {
+ if(!core.askDeconnectionConfirmation())
return;
}
- this.core.getPluginManager().stopPlugins();
+ core.getPluginManager().stopPlugins();
- this.core.disconnect();
+ core.disconnect();
- this.core.getPluginManager().runPlugins();
+ core.getPluginManager().runPlugins();
}
- if(e.getSource() == this.settingsButton) {
- this.core.getConfigWindow().setVisible(true);
+ if(e.getSource() == settingsButton) {
+ core.getConfigWindow().setVisible(true);
}
- if(e.getSource() == this.quitButton) {
- this.core.exit();
+ if(e.getSource() == quitButton) {
+ core.exit();
}
- if(e.getSource() == this.reconnectionFileMenuItem) {
+ if(e.getSource() == reconnectionFileMenuItem) {
- if(!this.core.canDisconnect()) {
- if(!this.core.askDeconnectionConfirmation())
+ if(!core.canDisconnect()) {
+ if(!core.askDeconnectionConfirmation())
return;
}
- this.core.getPluginManager().stopPlugins();
+ core.getPluginManager().stopPlugins();
- if(!this.core.initNodeConnection())
- this.unableToConnect();
+ if(!core.initNodeConnection())
+ unableToConnect();
- this.core.getPluginManager().loadPlugins();
- this.core.getPluginManager().runPlugins();
+ core.getPluginManager().loadPlugins();
+ core.getPluginManager().runPlugins();
}
- if(e.getSource() == this.optionsFileMenuItem) {
- this.core.getConfigWindow().setVisible(true);
+ if(e.getSource() == optionsFileMenuItem) {
+ core.getConfigWindow().setVisible(true);
}
- if(e.getSource() == this.quitFileMenuItem) {
- this.endOfTheWorld();
+ if(e.getSource() == quitFileMenuItem) {
+ endOfTheWorld();
}
- if(e.getSource() == this.aboutHelpMenuItem) {
- this.showDialogAbout();
+ if(e.getSource() == aboutHelpMenuItem) {
+ showDialogAbout();
}
}
@@ -351,23 +349,23 @@
* Warns the user by a popup.
*/
protected void unableToConnect() {
- new WarningWindow(this.core,
+ new WarningWindow(core,
I18n.getMessage("thaw.warning.unableToConnectTo")+
- "
"+this.core.getConfig().getValue("nodeAddress")+":"+
this.core.getConfig().getValue("nodePort"));
+ "
"+core.getConfig().getValue("nodeAddress")+":"+
core.getConfig().getValue("nodePort"));
}
- public void update(java.util.Observable o, Object arg) {
- this.updateToolBar();
+ public void update(final java.util.Observable o, final Object arg) {
+ updateToolBar();
}
public void updateToolBar() {
- if(this.core.getConnectionManager().isConnected()) {
- this.connectButton.setEnabled(false);
- this.disconnectButton.setEnabled(true);
+ if(core.getConnectionManager().isConnected()) {
+ connectButton.setEnabled(false);
+ disconnectButton.setEnabled(true);
} else {
- this.connectButton.setEnabled(true);
- this.disconnectButton.setEnabled(false);
+ connectButton.setEnabled(true);
+ disconnectButton.setEnabled(false);
}
}
@@ -375,11 +373,11 @@
* Called when window is closed or 'quit' is choosed is the menu.
*/
public void endOfTheWorld() {
- if(this.core == null) {
+ if(core == null) {
Logger.error(this, "Warning, no ref to core, exiting
brutaly");
System.exit(0);
} else {
- this.core.exit();
+ core.exit();
}
}
@@ -388,21 +386,21 @@
* Change text in the status bar.
* @param status Null is accepted.
*/
- public void setStatus(String status) {
+ public void setStatus(final String status) {
if(status != null)
- this.statusBar.setText(status);
+ statusBar.setText(status);
else
- this.statusBar.setText(" ");/* not empty else the
status bar disappear */
+ statusBar.setText(" ");/* not empty else the status bar
disappear */
}
public String getStatus() {
- return this.statusBar.getText();
+ return statusBar.getText();
}
public void showDialogAbout() {
- JLabel[] labels = new JLabel[] {
+ final JLabel[] labels = new JLabel[] {
new JLabel(I18n.getMessage("thaw.about.l1")),
new JLabel(I18n.getMessage("thaw.about.l2")),
new JLabel(I18n.getMessage("thaw.about.l3")),
@@ -421,33 +419,33 @@
}
- public void windowActivated(WindowEvent e) {
+ public void windowActivated(final WindowEvent e) {
}
- public void windowClosing(WindowEvent e) {
+ public void windowClosing(final WindowEvent e) {
/* Should be in windowClosed(), but doesn't seem to work */
- if(e.getSource() == this.mainWindow)
- this.endOfTheWorld();
+ if(e.getSource() == mainWindow)
+ endOfTheWorld();
}
- public void windowClosed(WindowEvent e) {
+ public void windowClosed(final WindowEvent e) {
// gni
}
- public void windowDeactivated(WindowEvent e) {
+ public void windowDeactivated(final WindowEvent e) {
// C'est pas comme si on en avait quelque chose ? foutre :p
}
- public void windowDeiconified(WindowEvent e) {
+ public void windowDeiconified(final WindowEvent e) {
// idem
}
- public void windowIconified(WindowEvent e) {
+ public void windowIconified(final WindowEvent e) {
// idem
}
- public void windowOpened(WindowEvent e) {
+ public void windowOpened(final WindowEvent e) {
// idem
}
Modified: trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,14 +1,14 @@
package thaw.core;
+import java.awt.GridLayout;
+import java.util.Observable;
+import java.util.Observer;
+
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
import javax.swing.JPanel;
-import java.awt.GridLayout;
import javax.swing.JTextField;
-import javax.swing.JLabel;
-import javax.swing.JCheckBox;
-import java.util.Observer;
-import java.util.Observable;
-
/**
* NodeConfigPanel. Creates and manages the panel containing all the things to
configure
* the settings to access the node.
@@ -39,98 +39,98 @@
private final static String[] currentValues = new String[6];
- private JLabel[] paramLabels = new JLabel[paramNames.length];
- private JTextField[] paramFields = new JTextField[configNames.length];
+ private final JLabel[] paramLabels = new
JLabel[NodeConfigPanel.paramNames.length];
+ private final JTextField[] paramFields = new
JTextField[NodeConfigPanel.configNames.length];
private JCheckBox multipleSockets = null;
private ConfigWindow configWindow = null;
- public NodeConfigPanel(ConfigWindow configWindow, Core core) {
+ public NodeConfigPanel(final ConfigWindow configWindow, final Core
core) {
this.core = core;
this.configWindow = configWindow;
- this.nodeConfigPanel = new JPanel();
- this.nodeConfigPanel.setLayout(new GridLayout(15, 1));
+ nodeConfigPanel = new JPanel();
+ nodeConfigPanel.setLayout(new GridLayout(15, 1));
- for(int i=0; i < paramNames.length ; i++) {
+ for(int i=0; i < NodeConfigPanel.paramNames.length ; i++) {
String value;
- if( (value = core.getConfig().getValue(configNames[i]))
== null)
+ if( (value =
core.getConfig().getValue(NodeConfigPanel.configNames[i])) == null)
value = "";
- this.paramLabels[i] = new JLabel(paramNames[i]);
- this.paramFields[i] = new JTextField(value);
- currentValues[i] = value;
+ paramLabels[i] = new
JLabel(NodeConfigPanel.paramNames[i]);
+ paramFields[i] = new JTextField(value);
+ NodeConfigPanel.currentValues[i] = value;
- this.nodeConfigPanel.add(this.paramLabels[i]);
- this.nodeConfigPanel.add(this.paramFields[i]);
+ nodeConfigPanel.add(paramLabels[i]);
+ nodeConfigPanel.add(paramFields[i]);
}
- this.multipleSockets = new
JCheckBox(I18n.getMessage("thaw.config.multipleSockets"),
+ multipleSockets = new
JCheckBox(I18n.getMessage("thaw.config.multipleSockets"),
Boolean.valueOf(core.getConfig().getValue("multipleSockets")).booleanValue());
- this.nodeConfigPanel.add(new JLabel(" "));
- this.nodeConfigPanel.add(this.multipleSockets);
+ nodeConfigPanel.add(new JLabel(" "));
+ nodeConfigPanel.add(multipleSockets);
-
this.setVisibility(Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue());
+
setVisibility(Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue());
configWindow.addObserver(this);
}
public JPanel getPanel() {
- return this.nodeConfigPanel;
+ return nodeConfigPanel;
}
- private void setVisibility(boolean advancedMode) {
- for(int i= 2; i < paramNames.length;i++) {
- this.paramLabels[i].setVisible(advancedMode);
- this.paramFields[i].setVisible(advancedMode);
+ private void setVisibility(final boolean advancedMode) {
+ for(int i= 2; i < NodeConfigPanel.paramNames.length;i++) {
+ paramLabels[i].setVisible(advancedMode);
+ paramFields[i].setVisible(advancedMode);
}
- this.multipleSockets.setVisible(advancedMode);
+ multipleSockets.setVisible(advancedMode);
}
public boolean hasAValueChanged() {
- for(int i=0; i < paramNames.length ; i++) {
- if
(!this.paramFields[i].getText().equals(currentValues[i]))
+ for(int i=0; i < NodeConfigPanel.paramNames.length ; i++) {
+ if
(!paramFields[i].getText().equals(NodeConfigPanel.currentValues[i]))
return true;
}
- if (this.core.getConfig().getValue("multipleSockets") == null
- ||
!this.core.getConfig().getValue("multipleSockets").equals(Boolean.toString(this.multipleSockets.isSelected())))
+ if ((core.getConfig().getValue("multipleSockets") == null)
+ ||
!core.getConfig().getValue("multipleSockets").equals(Boolean.toString(multipleSockets.isSelected())))
return true;
return false;
}
- public void update(Observable o, Object arg) {
- if(arg == this.core.getConfigWindow().getOkButton()) {
- if (this.hasAValueChanged())
- this.configWindow.willNeedConnectionReset();
+ public void update(final Observable o, final Object arg) {
+ if(arg == core.getConfigWindow().getOkButton()) {
+ if (hasAValueChanged())
+ configWindow.willNeedConnectionReset();
- for(int i=0;i < paramNames.length;i++) {
- this.core.getConfig().setValue(configNames[i],
this.paramFields[i].getText());
+ for(int i=0;i < NodeConfigPanel.paramNames.length;i++) {
+
core.getConfig().setValue(NodeConfigPanel.configNames[i],
paramFields[i].getText());
}
- this.core.getConfig().setValue("multipleSockets",
Boolean.toString(this.multipleSockets.isSelected()));
+ core.getConfig().setValue("multipleSockets",
Boolean.toString(multipleSockets.isSelected()));
-
this.setVisibility(Boolean.valueOf(this.core.getConfig().getValue("advancedMode")).booleanValue());
+
setVisibility(Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue());
}
- if(arg == this.core.getConfigWindow().getCancelButton()) {
- for(int i=0;i < paramNames.length;i++) {
+ if(arg == core.getConfigWindow().getCancelButton()) {
+ for(int i=0;i < NodeConfigPanel.paramNames.length;i++) {
String value;
- if( (value =
this.core.getConfig().getValue(configNames[i])) == null)
+ if( (value =
core.getConfig().getValue(NodeConfigPanel.configNames[i])) == null)
value = "";
- this.paramFields[i].setText(value);
+ paramFields[i].setText(value);
}
-
this.multipleSockets.setSelected(Boolean.valueOf(this.core.getConfig().getValue("multipleSockets")).booleanValue());
+
multipleSockets.setSelected(Boolean.valueOf(core.getConfig().getValue("multipleSockets")).booleanValue());
}
}
Modified: trunk/apps/Thaw/src/thaw/core/PluginConfigPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/PluginConfigPanel.java 2006-12-06
18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/core/PluginConfigPanel.java 2006-12-06
18:21:00 UTC (rev 11273)
@@ -1,112 +1,108 @@
package thaw.core;
-import javax.swing.JPanel;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.JTextField;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import javax.swing.JButton;
-import javax.swing.JOptionPane;
-
-import java.util.Observer;
+import java.util.Iterator;
import java.util.Observable;
+import java.util.Observer;
import java.util.Vector;
-import java.util.Iterator;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
/**
* PluginConfigPanel. Creates and manages the panel containing all the things
to configure
* the list of plugins.
*/
public class PluginConfigPanel implements Observer, ActionListener {
private Core core;
- private JPanel pluginConfigPanel = null;
+ private JPanel pluginConfigPanel;
- private JLabel pluginsLoaded = null;
- private JList pluginList = null;
+ private JLabel pluginsLoaded;
+ private JList pluginList;
- private JPanel buttonPanel = null;
- private JButton removeButton = null;
+ private JPanel buttonPanel;
+ private JButton removeButton;
- private JPanel subButtonPanel = null;
- private JTextField pluginToAdd = null;
- private JButton addButton = null;
+ private JPanel subButtonPanel;
+ private JTextField pluginToAdd;
+ private JButton addButton;
-
- public PluginConfigPanel(ConfigWindow configWindow, Core core) {
- Vector pluginNames;
-
+ public PluginConfigPanel(final ConfigWindow configWindow, final Core
core) {
this.core = core;
- this.pluginConfigPanel = new JPanel();
+ pluginConfigPanel = new JPanel();
- this.pluginConfigPanel.setLayout(new BorderLayout());
+ pluginConfigPanel.setLayout(new BorderLayout());
- this.pluginsLoaded = new
JLabel(I18n.getMessage("thaw.config.pluginsLoaded"));
+ pluginsLoaded = new
JLabel(I18n.getMessage("thaw.config.pluginsLoaded"));
- pluginNames = core.getConfig().getPluginNames();
- this.pluginList = new JList();
+ pluginList = new JList();
// List is leave empty until windows is displayed (see update())
- this.pluginToAdd = new JTextField("", 30);
- this.pluginToAdd.addActionListener(this);
+ pluginToAdd = new JTextField("", 30);
+ pluginToAdd.addActionListener(this);
- this.buttonPanel = new JPanel();
+ buttonPanel = new JPanel();
- GridLayout layout = new GridLayout(2, 1);
+ final GridLayout layout = new GridLayout(2, 1);
layout.setVgap(10);
- this.buttonPanel.setLayout(layout);
+ buttonPanel.setLayout(layout);
- this.subButtonPanel = new JPanel();
+ subButtonPanel = new JPanel();
- this.subButtonPanel.setLayout(new GridLayout(1, 2));
+ subButtonPanel.setLayout(new GridLayout(1, 2));
- this.addButton = new
JButton(I18n.getMessage("thaw.common.add"));
- this.removeButton = new
JButton(I18n.getMessage("thaw.common.remove"));
+ addButton = new JButton(I18n.getMessage("thaw.common.add"));
+ removeButton = new
JButton(I18n.getMessage("thaw.common.remove"));
- this.addButton.addActionListener(this);
- this.removeButton.addActionListener(this);
+ addButton.addActionListener(this);
+ removeButton.addActionListener(this);
- this.buttonPanel.add(this.removeButton);
+ buttonPanel.add(removeButton);
- this.subButtonPanel.add(this.pluginToAdd);
- this.subButtonPanel.add(this.addButton);
- this.buttonPanel.add(this.subButtonPanel);
+ subButtonPanel.add(pluginToAdd);
+ subButtonPanel.add(addButton);
+ buttonPanel.add(subButtonPanel);
- this.pluginConfigPanel.add(this.pluginsLoaded,
BorderLayout.NORTH);
- this.pluginConfigPanel.add(this.pluginList,
BorderLayout.CENTER);
- this.pluginConfigPanel.add(this.buttonPanel,
BorderLayout.SOUTH);
+ pluginConfigPanel.add(pluginsLoaded, BorderLayout.NORTH);
+ pluginConfigPanel.add(pluginList, BorderLayout.CENTER);
+ pluginConfigPanel.add(buttonPanel, BorderLayout.SOUTH);
configWindow.addObserver(this);
}
public JPanel getPanel() {
- return this.pluginConfigPanel;
+ return pluginConfigPanel;
}
/**
* In fact, it's not used here, because config is immediatly updated
when
* user change something.
*/
- public void update(Observable o, Object arg) {
+ public void update(final Observable o, final Object arg) {
if(arg == null) // Warns us window is now visible
- this.refreshList();
+ refreshList();
}
public void refreshList() {
//pluginList.setListData(core.getConfig().getPluginNames());
- Iterator pluginNames =
this.core.getConfig().getPluginNames().iterator();
+ final Iterator pluginNames =
core.getConfig().getPluginNames().iterator();
- Vector toPutInTheList = new Vector();
+ final Vector toPutInTheList = new Vector();
while(pluginNames.hasNext()) {
- String name = (String)pluginNames.next();
- Plugin plugin = core.getPluginManager().getPlugin(name);
+ final String name = (String)pluginNames.next();
+ final Plugin plugin =
core.getPluginManager().getPlugin(name);
if (plugin != null) {
toPutInTheList.add(name +
@@ -117,30 +113,30 @@
}
}
- this.pluginList.setListData(toPutInTheList);
+ pluginList.setListData(toPutInTheList);
}
/**
* Return the class name contained in an option name from the list.
*/
- public String getClassName(String optionName) {
- String[] part = optionName.split(" ");
+ public String getClassName(final String optionName) {
+ final String[] part = optionName.split(" ");
return part[0];
}
- public void actionPerformed(ActionEvent e) {
- if(e.getSource() == this.addButton || e.getSource() ==
this.pluginToAdd) {
-
if(this.core.getPluginManager().loadPlugin(this.pluginToAdd.getText())
- &&
this.core.getPluginManager().runPlugin(this.pluginToAdd.getText())) {
+ public void actionPerformed(final ActionEvent e) {
+ if((e.getSource() == addButton) || (e.getSource() ==
pluginToAdd)) {
+
if(core.getPluginManager().loadPlugin(pluginToAdd.getText())
+ &&
core.getPluginManager().runPlugin(pluginToAdd.getText())) {
-
this.core.getConfig().addPlugin(this.pluginToAdd.getText());
- this.refreshList();
+
core.getConfig().addPlugin(pluginToAdd.getText());
+ refreshList();
} else {
- Logger.error(this, "Unable to load
'"+this.pluginToAdd.getText()+"'");
-
JOptionPane.showMessageDialog(this.core.getConfigWindow().getFrame(),
- "Unable to load
plugin '"+this.pluginToAdd.getText()+"'",
+ Logger.error(this, "Unable to load
'"+pluginToAdd.getText()+"'");
+
JOptionPane.showMessageDialog(core.getConfigWindow().getFrame(),
+ "Unable to load
plugin '"+pluginToAdd.getText()+"'",
"Unable to load
plugin",
JOptionPane.ERROR_MESSAGE);
}
@@ -148,7 +144,7 @@
if(e.getSource() == removeButton) {
- String pluginName =
getClassName((String)pluginList.getSelectedValue());
+ final String pluginName =
getClassName((String)pluginList.getSelectedValue());
if
(((String)pluginList.getSelectedValue()).indexOf("Plugin missing") > 0) {
core.getConfig().removePlugin(pluginName);
Modified: trunk/apps/Thaw/src/thaw/core/PluginManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/PluginManager.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/core/PluginManager.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,8 +1,8 @@
package thaw.core;
+import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Vector;
-import java.util.Iterator;
/**
* Manages plugins :)
@@ -23,9 +23,9 @@
/**
* Need a ref to the core to pass it to the plugins (and to access
config)
*/
- public PluginManager(Core core) {
+ public PluginManager(final Core core) {
this.core = core;
- this.plugins = new LinkedHashMap();
+ plugins = new LinkedHashMap();
}
@@ -33,7 +33,7 @@
* Returns the whole plugin list.
*/
public LinkedHashMap getPlugins() {
- return this.plugins;
+ return plugins;
}
@@ -42,31 +42,31 @@
* Reload if already loaded.
*/
public boolean loadPlugins() {
- this.plugins = new LinkedHashMap();
+ plugins = new LinkedHashMap();
Vector pluginNames;
- if(this.core.getConfig().getPluginNames().size() == 0) {
+ if(core.getConfig().getPluginNames().size() == 0) {
/* Then we load the config with the default plugins */
- for(int i = 0 ; i < defaultPlugins.length ; i++) {
-
this.core.getConfig().addPlugin(defaultPlugins[i]);
+ for(int i = 0 ; i < PluginManager.defaultPlugins.length
; i++) {
+
core.getConfig().addPlugin(PluginManager.defaultPlugins[i]);
}
}
- pluginNames = this.core.getConfig().getPluginNames();
+ pluginNames = core.getConfig().getPluginNames();
- Iterator pluginIt = pluginNames.iterator();
+ final Iterator pluginIt = pluginNames.iterator();
- int progressJump = 10 / pluginNames.size();
- this.core.getSplashScreen().setProgression(40);
+ final int progressJump = 10 / pluginNames.size();
+ core.getSplashScreen().setProgression(40);
while(pluginIt.hasNext()) {
- String pluginName = (String)pluginIt.next();
+ final String pluginName = (String)pluginIt.next();
-
this.core.getSplashScreen().setProgressionAndStatus(this.core.getSplashScreen().getProgression()+progressJump,
+
core.getSplashScreen().setProgressionAndStatus(core.getSplashScreen().getProgression()+progressJump,
"Loading
plugin '"+pluginName+"' ...");
- this.loadPlugin(pluginName);
+ loadPlugin(pluginName);
}
return true;
@@ -78,33 +78,33 @@
public boolean runPlugins() {
Iterator pluginIt;
- if (this.plugins == null) {
+ if (plugins == null) {
Logger.error(this, "No plugin to run ?!");
return false;
}
- pluginIt = (new Vector(this.plugins.values())).iterator();
+ pluginIt = (new Vector(plugins.values())).iterator();
- int progressJump = 50 / this.plugins.size();
+ final int progressJump = 50 / plugins.size();
- this.core.getSplashScreen().setProgression(50);
+ core.getSplashScreen().setProgression(50);
while(pluginIt.hasNext()) {
- Plugin plugin = (Plugin)pluginIt.next();
+ final Plugin plugin = (Plugin)pluginIt.next();
try {
if (plugin != null) {
Logger.info(this, "Running plugin
'"+plugin.getClass().getName()+"'");
-
this.core.getSplashScreen().setProgressionAndStatus(this.core.getSplashScreen().getProgression()+progressJump,
+
core.getSplashScreen().setProgressionAndStatus(core.getSplashScreen().getProgression()+progressJump,
"Starting plugin '"+plugin.getClass().getName()+"' ...");
- plugin.run(this.core);
+ plugin.run(core);
}
else
Logger.notice(this, "Plugin == null ?");
- } catch(Exception e) {
+ } catch(final Exception e) {
Logger.error(this, "Unable to run the plugin
'"+plugin.getClass().getName()+"' because: "+e+":");
e.printStackTrace();
}
@@ -120,23 +120,23 @@
public boolean stopPlugins() {
Iterator pluginIt;
- if (this.plugins == null) {
+ if (plugins == null) {
Logger.error(this, "No plugin to stop ?!");
return false;
}
- pluginIt = this.plugins.values().iterator();
+ pluginIt = plugins.values().iterator();
while(pluginIt.hasNext()) {
- Plugin plugin = (Plugin)pluginIt.next();
+ final Plugin plugin = (Plugin)pluginIt.next();
try {
if (plugin != null)
plugin.stop();
else
Logger.notice(this, "Plugin == null
?!!");
- } catch(Exception e) {
+ } catch(final Exception e) {
Logger.error(this, "Unable to stop the plugin "+
"'"+plugin.getClass().getName()+"'"+
", because: "+e.toString());
@@ -151,18 +151,18 @@
/**
* Load a given plugin (without adding it to the config or running it).
*/
- public boolean loadPlugin(String className) {
+ public boolean loadPlugin(final String className) {
Logger.info(this, "Loading plugin: '"+className+"'");
try {
- if(this.plugins.get(className) != null) {
+ if(plugins.get(className) != null) {
Logger.warning(this, "loadPlugin(): Plugin
'"+className+"' already loaded");
return false;
}
- this.plugins.put(className,
Class.forName(className).newInstance());
+ plugins.put(className,
Class.forName(className).newInstance());
- } catch(Exception e) {
+ } catch(final Exception e) {
Logger.warning(this, "loadPlugin('"+className+"'):
Exception: "+e);
return false;
}
@@ -174,13 +174,13 @@
/**
* Run a given plugin.
*/
- public boolean runPlugin(String className) {
+ public boolean runPlugin(final String className) {
Logger.info(this, "Starting plugin: '"+className+"'");
try {
- ((Plugin)this.plugins.get(className)).run(this.core);
+ ((Plugin)plugins.get(className)).run(core);
- } catch(Exception e) {
+ } catch(final Exception e) {
Logger.warning(this, "runPlugin('"+className+"'):
Exception: "+e);
return false;
}
@@ -192,13 +192,13 @@
/**
* Stop a given plugin.
*/
- public boolean stopPlugin(String className) {
+ public boolean stopPlugin(final String className) {
Logger.info(this, "Stopping plugin: '"+className+"'");
try {
- ((Plugin)this.plugins.get(className)).stop();
+ ((Plugin)plugins.get(className)).stop();
- } catch(Exception e) {
+ } catch(final Exception e) {
Logger.warning(this, "runPlugin('"+className+"'):
Exception: "+e);
return false;
}
@@ -210,16 +210,16 @@
/**
* Unload a given plugin (without adding it to the config or running
it).
*/
- public boolean unloadPlugin(String className) {
+ public boolean unloadPlugin(final String className) {
try {
- if(this.plugins.get(className) == null) {
+ if(plugins.get(className) == null) {
Logger.warning(this, "unloadPlugin(): Plugin
'"+className+"' already unloaded");
return false;
}
- this.plugins.remove(className);
+ plugins.remove(className);
- } catch(Exception e) {
+ } catch(final Exception e) {
Logger.warning(this, "unloadPlugin('"+className+"'):
Exception: "+e);
return false;
}
@@ -227,7 +227,7 @@
return true;
}
- public Plugin getPlugin(String className) {
- return (Plugin)this.plugins.get(className);
+ public Plugin getPlugin(final String className) {
+ return (Plugin)plugins.get(className);
}
}
Modified: trunk/apps/Thaw/src/thaw/core/QueueKeeper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/QueueKeeper.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/core/QueueKeeper.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,25 +1,29 @@
package thaw.core;
+import java.io.File;
import java.util.HashMap;
-import java.io.File;
import java.util.Iterator;
import java.util.Vector;
-/* XML */
-import org.w3c.dom.Document;
+
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.DocumentBuilder;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
import org.w3c.dom.DOMImplementation;
-import javax.xml.transform.stream.StreamResult;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.OutputKeys;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import thaw.fcp.*;
+import thaw.fcp.FCPClientGet;
+import thaw.fcp.FCPClientPut;
+import thaw.fcp.FCPQueueManager;
+import thaw.fcp.FCPTransferQuery;
/**
* Used when Thaw start and stop: Save the query not running (-> waiting in
the Thaw queue)
@@ -35,24 +39,24 @@
}
- private static void loadQuery(FCPQueueManager queueManager, Element
queryEl, boolean runningQueue) {
+ private static void loadQuery(final FCPQueueManager queueManager, final
Element queryEl, final boolean runningQueue) {
FCPTransferQuery newQuery = null;
- HashMap params = new HashMap();
+ final HashMap params = new HashMap();
- NodeList paramList = queryEl.getElementsByTagName("param");
+ final NodeList paramList =
queryEl.getElementsByTagName("param");
for(int i = 0;i < paramList.getLength(); i++) {
- Node param = paramList.item(i);
+ final Node param = paramList.item(i);
- if(param != null && param.getNodeType() ==
Node.ELEMENT_NODE) {
- Element paramEl = (Element)param;
+ if((param != null) && (param.getNodeType() ==
Node.ELEMENT_NODE)) {
+ final Element paramEl = (Element)param;
params.put(paramEl.getAttribute("name"),
paramEl.getAttribute("value"));
}
}
- if(queryEl.getAttribute("type") == null
+ if((queryEl.getAttribute("type") == null)
|| "1".equals( queryEl.getAttribute("type") )) {
newQuery = new FCPClientGet(queueManager, params);
} else {
@@ -67,21 +71,21 @@
}
- private static void loadQueries(FCPQueueManager queueManager, Element
queriesEl, boolean runningQueue) {
- NodeList queries = queriesEl.getElementsByTagName("query");
+ private static void loadQueries(final FCPQueueManager queueManager,
final Element queriesEl, final boolean runningQueue) {
+ final NodeList queries =
queriesEl.getElementsByTagName("query");
for(int i = 0;i < queries.getLength(); i++) {
- Node queryNode = queries.item(i);
+ final Node queryNode = queries.item(i);
- if(queryNode != null && queryNode.getNodeType() ==
Node.ELEMENT_NODE) {
- loadQuery(queueManager, (Element)queryNode,
runningQueue);
+ if((queryNode != null) && (queryNode.getNodeType() ==
Node.ELEMENT_NODE)) {
+ QueueKeeper.loadQuery(queueManager,
(Element)queryNode, runningQueue);
}
}
}
- public static boolean loadQueue(FCPQueueManager queueManager, String
fileName) {
- File file = new File(fileName);
+ public static boolean loadQueue(final FCPQueueManager queueManager,
final String fileName) {
+ final File file = new File(fileName);
if(!file.exists() || !file.canRead()) {
Logger.info(new QueueKeeper(), "Unable to find previous
queue state file '"+file.getPath()+"' => Not reloaded from file.");
@@ -99,17 +103,17 @@
try {
xmlBuilder = xmlFactory.newDocumentBuilder();
- } catch(javax.xml.parsers.ParserConfigurationException e) {
+ } catch(final javax.xml.parsers.ParserConfigurationException e)
{
Logger.warning(new QueueKeeper(), "Unable to load queue
because: "+e.toString());
return false;
}
try {
xmlDoc = xmlBuilder.parse(file);
- } catch(org.xml.sax.SAXException e) {
+ } catch(final org.xml.sax.SAXException e) {
Logger.warning(new QueueKeeper(), "Unable to load queue
because: "+e.toString());
return false;
- } catch(java.io.IOException e) {
+ } catch(final java.io.IOException e) {
Logger.warning(new QueueKeeper(), "Unable to load queue
because: "+e.toString());
return false;
}
@@ -117,25 +121,25 @@
rootEl = xmlDoc.getDocumentElement();
- NodeList runningQueues =
rootEl.getElementsByTagName("runningQueue");
+ final NodeList runningQueues =
rootEl.getElementsByTagName("runningQueue");
for(int i = 0;i < runningQueues.getLength(); i++) {
- Node runningQueueNode = runningQueues.item(i);
+ final Node runningQueueNode = runningQueues.item(i);
- if(runningQueueNode != null &&
runningQueueNode.getNodeType() == Node.ELEMENT_NODE) {
- loadQueries(queueManager,
(Element)runningQueueNode, true);
+ if((runningQueueNode != null) &&
(runningQueueNode.getNodeType() == Node.ELEMENT_NODE)) {
+ QueueKeeper.loadQueries(queueManager,
(Element)runningQueueNode, true);
}
}
- NodeList pendingQueues =
rootEl.getElementsByTagName("pendingQueue");
+ final NodeList pendingQueues =
rootEl.getElementsByTagName("pendingQueue");
for(int i = 0;i < pendingQueues.getLength(); i++) {
- Node pendingQueueNode = pendingQueues.item(i);
+ final Node pendingQueueNode = pendingQueues.item(i);
- if(pendingQueueNode != null &&
pendingQueueNode.getNodeType() == Node.ELEMENT_NODE) {
- loadQueries(queueManager,
(Element)pendingQueueNode, false);
+ if((pendingQueueNode != null) &&
(pendingQueueNode.getNodeType() == Node.ELEMENT_NODE)) {
+ QueueKeeper.loadQueries(queueManager,
(Element)pendingQueueNode, false);
}
}
@@ -143,25 +147,25 @@
}
- private static Element saveQuery(FCPTransferQuery query, Document
xmlDoc) {
+ private static Element saveQuery(final FCPTransferQuery query, final
Document xmlDoc) {
if(!query.isPersistent())
return null;
if(query.isPersistent() && (query.isRunning() ||
query.isFinished()))
return null;
- HashMap params = query.getParameters();
+ final HashMap params = query.getParameters();
- Element queryEl = xmlDoc.createElement("query");
+ final Element queryEl = xmlDoc.createElement("query");
queryEl.setAttribute("type",
Integer.toString(query.getQueryType()));
- for(Iterator keys = params.keySet().iterator();
+ for(final Iterator keys = params.keySet().iterator();
keys.hasNext();) {
- String key = (String)keys.next();
+ final String key = (String)keys.next();
- Element paramEl = xmlDoc.createElement("param");
+ final Element paramEl = xmlDoc.createElement("param");
paramEl.setAttribute("name", key);
paramEl.setAttribute("value", ((String)params.get(key))
);
@@ -173,8 +177,8 @@
}
- public static boolean saveQueue(FCPQueueManager queueManager, String
fileName) {
- Vector[] pendingQueues = queueManager.getPendingQueues();
+ public static boolean saveQueue(final FCPQueueManager queueManager,
final String fileName) {
+ final Vector[] pendingQueues = queueManager.getPendingQueues();
boolean needed = false;
@@ -187,12 +191,12 @@
if(!needed) {
Logger.info(new QueueKeeper(), "Nothing in the pending
queue to save.");
- File file = new File(fileName);
+ final File file = new File(fileName);
file.delete(); // Else we may reload something that we
shouldn't when restarting
return true;
}
- File file = new File(fileName);
+ final File file = new File(fileName);
StreamResult fileOut;
try {
@@ -201,7 +205,7 @@
Logger.warning(new QueueKeeper(), "Unable to
write config file '"+file.getPath()+"' (can't write)");
return false;
}
- } catch(java.io.IOException e) {
+ } catch(final java.io.IOException e) {
Logger.warning(new QueueKeeper(), "Error while checking
perms to save config: "+e);
}
@@ -219,7 +223,7 @@
try {
xmlBuilder = xmlFactory.newDocumentBuilder();
- } catch(javax.xml.parsers.ParserConfigurationException e) {
+ } catch(final javax.xml.parsers.ParserConfigurationException e)
{
Logger.error(new QueueKeeper(), "Unable to save queue
because: "+e.toString());
return false;
}
@@ -231,16 +235,16 @@
rootEl = xmlDoc.getDocumentElement();
- Element pendingQueueEl = xmlDoc.createElement("pendingQueue");
+ final Element pendingQueueEl =
xmlDoc.createElement("pendingQueue");
- for(int i = 0 ; i <= MIN_PRIORITY ; i++) {
+ for(int i = 0 ; i <= QueueKeeper.MIN_PRIORITY ; i++) {
- for(Iterator runIt = pendingQueues[i].iterator() ;
+ for(final Iterator runIt = pendingQueues[i].iterator() ;
runIt.hasNext(); ) {
- FCPTransferQuery query =
(FCPTransferQuery)runIt.next();
+ final FCPTransferQuery query =
(FCPTransferQuery)runIt.next();
- Element toSave = saveQuery(query, xmlDoc);
+ final Element toSave =
QueueKeeper.saveQuery(query, xmlDoc);
if(toSave != null)
pendingQueueEl.appendChild(toSave);
@@ -252,14 +256,14 @@
rootEl.appendChild(pendingQueueEl);
/* Serialization */
- DOMSource domSource = new DOMSource(xmlDoc);
- TransformerFactory transformFactory =
TransformerFactory.newInstance();
+ final DOMSource domSource = new DOMSource(xmlDoc);
+ final TransformerFactory transformFactory =
TransformerFactory.newInstance();
Transformer serializer;
try {
serializer = transformFactory.newTransformer();
- } catch(javax.xml.transform.TransformerConfigurationException
e) {
+ } catch(final
javax.xml.transform.TransformerConfigurationException e) {
Logger.error(new QueueKeeper(), "Unable to save queue
because: "+e.toString());
return false;
}
@@ -270,7 +274,7 @@
/* final step */
try {
serializer.transform(domSource, fileOut);
- } catch(javax.xml.transform.TransformerException e) {
+ } catch(final javax.xml.transform.TransformerException e) {
Logger.error(new QueueKeeper(), "Unable to save queue
because: "+e.toString());
return false;
}
Modified: trunk/apps/Thaw/src/thaw/core/SplashScreen.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/SplashScreen.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/core/SplashScreen.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,15 +1,16 @@
package thaw.core;
-import javax.swing.JDialog;
-import javax.swing.JProgressBar;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Dimension;
+import java.awt.Font;
import java.awt.Toolkit;
-import java.awt.Font;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JProgressBar;
+
public class SplashScreen {
public final static int SIZE_X = 500;
public final static int SIZE_Y = 100;
@@ -24,70 +25,70 @@
}
public void display() {
- JPanel panel = new JPanel();
- this.splashScreen = new JDialog();
+ final JPanel panel = new JPanel();
+ splashScreen = new JDialog();
- this.splashScreen.setUndecorated(true);
- this.splashScreen.setResizable(false);
+ splashScreen.setUndecorated(true);
+ splashScreen.setResizable(false);
panel.setLayout(new BorderLayout(10, 10));
- JLabel thawLabel = new JLabel(" Thaw");
+ final JLabel thawLabel = new JLabel(" Thaw");
thawLabel.setFont(new Font("Dialog", Font.BOLD, 30));
panel.add(thawLabel, BorderLayout.CENTER);
- this.progressBar = new JProgressBar(0, 100);
- this.progressBar.setStringPainted(true);
- this.progressBar.setString("Wake up Neo ...");
+ progressBar = new JProgressBar(0, 100);
+ progressBar.setStringPainted(true);
+ progressBar.setString("Wake up Neo ...");
- panel.add(this.progressBar, BorderLayout.SOUTH);
+ panel.add(progressBar, BorderLayout.SOUTH);
- this.splashScreen.getContentPane().add(panel);
+ splashScreen.getContentPane().add(panel);
- this.splashScreen.setSize(SIZE_X, SIZE_Y);
+ splashScreen.setSize(SplashScreen.SIZE_X, SplashScreen.SIZE_Y);
- Dimension screenSize =
+ final Dimension screenSize =
Toolkit.getDefaultToolkit().getScreenSize();
- Dimension splashSize = this.splashScreen.getSize();
- this.splashScreen.setLocation(screenSize.width/2 -
(splashSize.width/2),
+ final Dimension splashSize = splashScreen.getSize();
+ splashScreen.setLocation(screenSize.width/2 -
(splashSize.width/2),
screenSize.height/2 -
(splashSize.height/2));
- this.splashScreen.setVisible(true);
+ splashScreen.setVisible(true);
- this.splashScreen.setSize(SIZE_X, SIZE_Y);
+ splashScreen.setSize(SplashScreen.SIZE_X, SplashScreen.SIZE_Y);
}
/**
* @param progress In pourcent
*/
- public void setProgression(int progress) {
- if(this.progressBar != null)
- this.progressBar.setValue(progress);
+ public void setProgression(final int progress) {
+ if(progressBar != null)
+ progressBar.setValue(progress);
}
public int getProgression() {
- if(this.progressBar != null)
- return this.progressBar.getValue();
+ if(progressBar != null)
+ return progressBar.getValue();
else
return -1;
}
- public void setStatus(String status) {
- if(this.progressBar != null)
- this.progressBar.setString(status);
+ public void setStatus(final String status) {
+ if(progressBar != null)
+ progressBar.setString(status);
}
- public void setProgressionAndStatus(int progress, String status) {
- this.setProgression(progress);
- this.setStatus(status);
+ public void setProgressionAndStatus(final int progress, final String
status) {
+ setProgression(progress);
+ setStatus(status);
}
Modified: trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/core/ThawConfigPanel.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,14 +1,14 @@
package thaw.core;
-import javax.swing.JPanel;
import java.awt.GridLayout;
+import java.util.Observable;
+import java.util.Observer;
+
import javax.swing.JCheckBox;
import javax.swing.JLabel;
+import javax.swing.JPanel;
import javax.swing.JTextField;
-import java.util.Observer;
-import java.util.Observable;
-
/**
* Creates and manages the panel containing all the things to configure
related to Thaw and only Thaw.
*/
@@ -24,51 +24,51 @@
private boolean advancedMode;
- public ThawConfigPanel(ConfigWindow configWindow, Core core) {
+ public ThawConfigPanel(final ConfigWindow configWindow, final Core
core) {
this.core = core;
if(core.getConfig().getValue("advancedMode") == null)
core.getConfig().setValue("advancedMode", "false");
- this.advancedMode =
Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue();
+ advancedMode =
Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue();
- this.thawConfigPanel = new JPanel();
- this.thawConfigPanel.setLayout(new GridLayout(15, 1));
+ thawConfigPanel = new JPanel();
+ thawConfigPanel.setLayout(new GridLayout(15, 1));
- this.advancedModeBox = new
JCheckBox(I18n.getMessage("thaw.config.advancedMode"), this.advancedMode);
+ advancedModeBox = new
JCheckBox(I18n.getMessage("thaw.config.advancedMode"), advancedMode);
- this.nicknameLabel = new
JLabel(I18n.getMessage("thaw.config.nickname"));
+ nicknameLabel = new
JLabel(I18n.getMessage("thaw.config.nickname"));
if (core.getConfig().getValue("userNickname") == null)
- this.nicknameField = new JTextField("Another
anonymous");
+ nicknameField = new JTextField("Another anonymous");
else
- this.nicknameField = new
JTextField(core.getConfig().getValue("userNickname"));
+ nicknameField = new
JTextField(core.getConfig().getValue("userNickname"));
- this.thawConfigPanel.add(this.advancedModeBox);
- this.thawConfigPanel.add(new JLabel(" "));
- this.thawConfigPanel.add(this.nicknameLabel);
- this.thawConfigPanel.add(this.nicknameField);
+ thawConfigPanel.add(advancedModeBox);
+ thawConfigPanel.add(new JLabel(" "));
+ thawConfigPanel.add(nicknameLabel);
+ thawConfigPanel.add(nicknameField);
configWindow.addObserver(this);
}
public JPanel getPanel() {
- return this.thawConfigPanel;
+ return thawConfigPanel;
}
- public void update(Observable o, Object arg) {
- if(arg == this.core.getConfigWindow().getOkButton()) {
- this.advancedMode = this.advancedModeBox.isSelected();
- this.core.getConfig().setValue("advancedMode",
Boolean.toString(this.advancedMode));
- this.core.getConfig().setValue("userNickname",
this.nicknameField.getText());
+ public void update(final Observable o, final Object arg) {
+ if(arg == core.getConfigWindow().getOkButton()) {
+ advancedMode = advancedModeBox.isSelected();
+ core.getConfig().setValue("advancedMode",
Boolean.toString(advancedMode));
+ core.getConfig().setValue("userNickname",
nicknameField.getText());
}
- if(arg == this.core.getConfigWindow().getCancelButton()) {
- this.advancedModeBox.setSelected(this.advancedMode);
-
this.nicknameField.setText(this.core.getConfig().getValue("userNickname"));
+ if(arg == core.getConfigWindow().getCancelButton()) {
+ advancedModeBox.setSelected(advancedMode);
+
nicknameField.setText(core.getConfig().getValue("userNickname"));
}
}
Modified: trunk/apps/Thaw/src/thaw/core/WarningWindow.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/WarningWindow.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/core/WarningWindow.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -11,10 +11,10 @@
public class WarningWindow {
- public WarningWindow(Core core,
- String warning)
+ public WarningWindow(final Core core,
+ final String warning)
{
- if(core != null && core.getMainWindow() != null) {
+ if((core != null) && (core.getMainWindow() != null)) {
JOptionPane.showMessageDialog(core.getMainWindow().getMainFrame(),
warning,
"Thaw -
"+I18n.getMessage("thaw.warning.title"),
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPBufferedStream.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPBufferedStream.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPBufferedStream.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -26,14 +26,14 @@
- public FCPBufferedStream(FCPConnection connection,
- int maxUploadSpeed) {
+ public FCPBufferedStream(final FCPConnection connection,
+ final int maxUploadSpeed) {
this.connection = connection;
this.maxUploadSpeed = maxUploadSpeed;
if(maxUploadSpeed >= 0) {
- this.outputBuffer = new byte[OUTPUT_BUFFER_SIZE];
- this.packetSize = (maxUploadSpeed * 1024) /
(1000/INTERVAL);
+ outputBuffer = new
byte[FCPBufferedStream.OUTPUT_BUFFER_SIZE];
+ packetSize = (maxUploadSpeed * 1024) /
(1000/FCPBufferedStream.INTERVAL);
}
}
@@ -41,24 +41,23 @@
* Add to the buffer. Can block if buffer is full !
* Never send more than OUTPUT_BUFFER_SIZE.
*/
- public synchronized boolean write(byte[] data) {
- if(this.maxUploadSpeed == -1) {
- return this.connection.realRawWrite(data);
- }
+ public synchronized boolean write(final byte[] data) {
+ if(maxUploadSpeed == -1)
+ return connection.realRawWrite(data);
- while(this.waiting + data.length > OUTPUT_BUFFER_SIZE) {
- this.sleep(INTERVAL);
+ while(waiting + data.length >
FCPBufferedStream.OUTPUT_BUFFER_SIZE) {
+ sleep(FCPBufferedStream.INTERVAL);
}
- this.waiting += data.length;
+ waiting += data.length;
for(int i = 0 ; i < data.length ; i++) {
- this.outputBuffer[this.writeCursor] = data[i];
+ outputBuffer[writeCursor] = data[i];
- this.writeCursor++;
+ writeCursor++;
- if(this.writeCursor >= OUTPUT_BUFFER_SIZE)
- this.writeCursor = 0;
+ if(writeCursor >= FCPBufferedStream.OUTPUT_BUFFER_SIZE)
+ writeCursor = 0;
}
return true;
@@ -67,10 +66,10 @@
/**
* @see #write(byte[])
*/
- public boolean write(String data) {
+ public boolean write(final String data) {
try {
return this.write(data.getBytes("UTF-8"));
- } catch(java.io.UnsupportedEncodingException e) {
+ } catch(final java.io.UnsupportedEncodingException e) {
Logger.error(this, "UNSUPPORTED ENCODING EXCEPTION :
UTF-8");
return this.write(data.getBytes());
}
@@ -79,17 +78,17 @@
/**
* extract from the buffer
*/
- private boolean readOutputBuffer(byte[] data) {
+ private boolean readOutputBuffer(final byte[] data) {
for(int i = 0; i < data.length ; i++) {
- data[i] = this.outputBuffer[this.readCursor];
+ data[i] = outputBuffer[readCursor];
- this.readCursor++;
+ readCursor++;
- if(this.readCursor >= OUTPUT_BUFFER_SIZE)
- this.readCursor = 0;
+ if(readCursor >= FCPBufferedStream.OUTPUT_BUFFER_SIZE)
+ readCursor = 0;
}
- this.waiting -= data.length;
+ waiting -= data.length;
return true;
}
@@ -98,8 +97,8 @@
* wait for the buffer being empty.
*/
public void flush() {
- while(this.waiting > 0) {
- this.sleep(INTERVAL);
+ while(waiting > 0) {
+ sleep(FCPBufferedStream.INTERVAL);
}
}
@@ -107,21 +106,21 @@
public void run() {
byte[] data;
- while(this.running) { /* Wild and freeeeeee */
- if(this.waiting > 0) {
- int to_read = this.packetSize;
+ while(running) { /* Wild and freeeeeee */
+ if(waiting > 0) {
+ int to_read = packetSize;
- if(this.waiting < to_read)
- to_read = this.waiting;
+ if(waiting < to_read)
+ to_read = waiting;
data = new byte[to_read];
- this.readOutputBuffer(data);
+ readOutputBuffer(data);
- this.connection.realRawWrite(data);
+ connection.realRawWrite(data);
}
- this.sleep(INTERVAL);
+ sleep(FCPBufferedStream.INTERVAL);
}
}
@@ -129,16 +128,16 @@
* Start the thread sending data from the buffer to the OutputStream
(socket).
*/
public boolean startSender() {
- this.running = true;
+ running = true;
- if(this.maxUploadSpeed < 0) {
+ if(maxUploadSpeed < 0) {
Logger.notice(this, "startSender(): No upload limit.
Not needed");
return false;
}
- if(this.tractopelle == null) {
- this.tractopelle = new Thread(this);
- this.tractopelle.start();
+ if(tractopelle == null) {
+ tractopelle = new Thread(this);
+ tractopelle.start();
return true;
} else {
Logger.notice(this, "startSender(): Already started");
@@ -148,26 +147,26 @@
public boolean stopSender() {
- this.running = false;
- this.tractopelle = null;
+ running = false;
+ tractopelle = null;
return true;
}
public boolean isOutputBufferEmpty() {
- return (this.waiting == 0);
+ return (waiting == 0);
}
public boolean isOutputBufferFull() {
- return (this.maxUploadSpeed < 0 || this.waiting >=
(OUTPUT_BUFFER_SIZE-1));
+ return ((maxUploadSpeed < 0) || (waiting >=
(FCPBufferedStream.OUTPUT_BUFFER_SIZE-1)));
}
/**
* Just ignore the InterruptedException.
*/
- private void sleep(int ms) {
+ private void sleep(final int ms) {
try {
Thread.sleep(ms);
- } catch(java.lang.InterruptedException e) {
+ } catch(final java.lang.InterruptedException e) {
/* just iggnnnnnooored */
}
}
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -2,13 +2,11 @@
import java.io.File;
import java.io.FileOutputStream;
-import java.io.InputStream;
import java.io.OutputStream;
-import java.util.Observer;
+import java.util.HashMap;
import java.util.Observable;
+import java.util.Observer;
-import java.util.HashMap;
-
import thaw.core.Logger;
/**
@@ -52,16 +50,16 @@
/**
* See setParameters().
*/
- public FCPClientGet(FCPQueueManager queueManager, HashMap parameters) {
+ public FCPClientGet(final FCPQueueManager queueManager, final HashMap
parameters) {
this.queueManager = queueManager;
- this.setParameters(parameters);
+ setParameters(parameters);
- this.progressReliable = false;
- this.fromTheNodeProgress = 0;
+ progressReliable = false;
+ fromTheNodeProgress = 0;
/* If isPersistent(), then start() won't be called, so must
relisten the
queryManager by ourself */
- if(this.isPersistent() && this.identifier != null &&
!this.identifier.equals("")) {
+ if(isPersistent() && (identifier != null) &&
!identifier.equals("")) {
this.queueManager.getQueryManager().deleteObserver(this);
this.queueManager.getQueryManager().addObserver(this);
}
@@ -74,15 +72,15 @@
* Think of adding this FCPClientGet as a queryManager observer.
* @param destinationDir if null, then a temporary file will be create
(path determined only when the file is availabed ; this file will be deleted on
jvm exit)
*/
- public FCPClientGet(String id, String key, int priority,
- int persistence, boolean globalQueue,
- String destinationDir, String status, int progress,
- int maxRetries,
- FCPQueueManager queueManager) {
+ public FCPClientGet(final String id, final String key, final int
priority,
+ final int persistence, final boolean globalQueue,
+ final String destinationDir, String status, final
int progress,
+ final int maxRetries,
+ final FCPQueueManager queueManager) {
this(key, priority, persistence, globalQueue, maxRetries,
destinationDir);
- this.progressReliable = false;
+ progressReliable = false;
this.queueManager = queueManager;
@@ -94,16 +92,16 @@
status = "(null)";
}
- this.identifier = id;
+ identifier = id;
- this.successful = true;
- this.running = true;
+ successful = true;
+ running = true;
if(progress < 100) {
- this.fromTheNodeProgress = 0;
+ fromTheNodeProgress = 0;
} else {
- this.fromTheNodeProgress = 100;
- this.progressReliable = true;
+ fromTheNodeProgress = 100;
+ progressReliable = true;
}
}
@@ -114,17 +112,17 @@
* @param destinationDir if null => temporary file
* @param persistence 0 = Forever ; 1 = Until node reboot ; 2 = Until
the app disconnect
*/
- public FCPClientGet(String key, int priority,
- int persistence, boolean globalQueue,
- int maxRetries,
- String destinationDir) {
+ public FCPClientGet(final String key, final int priority,
+ final int persistence, boolean globalQueue,
+ final int maxRetries,
+ final String destinationDir) {
- if(globalQueue && persistence >= 2)
+ if(globalQueue && (persistence >= 2))
globalQueue = false; /* else protocol error */
- this.progressReliable = false;
- this.fromTheNodeProgress = 0;
+ progressReliable = false;
+ fromTheNodeProgress = 0;
this.maxRetries = maxRetries;
this.key = key;
@@ -133,58 +131,58 @@
this.globalQueue = globalQueue;
this.destinationDir = destinationDir;
- this.progress = 0;
- this.fileSize = 0;
- this.attempt = 0;
+ progress = 0;
+ fileSize = 0;
+ attempt = 0;
- this.status = "Waiting";
+ status = "Waiting";
- String cutcut[] = key.split("/");
+ final String cutcut[] = key.split("/");
if(!key.endsWith("/")) {
- this.filename = cutcut[cutcut.length-1];
+ filename = cutcut[cutcut.length-1];
} else {
- this.filename = "index.html";
+ filename = "index.html";
}
Logger.debug(this, "Query for getting "+key+" created");
}
- public boolean start(FCPQueueManager queueManager) {
- this.attempt++;
- this.running = true;
- this.progress = 0;
+ public boolean start(final FCPQueueManager queueManager) {
+ attempt++;
+ running = true;
+ progress = 0;
this.queueManager = queueManager;
- this.status = "Requesting";
+ status = "Requesting";
- if(this.identifier == null || "".equals( this.identifier ))
- this.identifier = queueManager.getAnID() +
"-"+this.filename;;
+ if((identifier == null) || "".equals( identifier ))
+ identifier = queueManager.getAnID() + "-"+filename;;
- Logger.info(this, "Requesting key : "+this.getFileKey());
+ Logger.info(this, "Requesting key : "+getFileKey());
- FCPMessage queryMessage = new FCPMessage();
+ final FCPMessage queryMessage = new FCPMessage();
queryMessage.setMessageName("ClientGet");
- queryMessage.setValue("URI", this.getFileKey());
- queryMessage.setValue("Identifier", this.identifier);
+ queryMessage.setValue("URI", getFileKey());
+ queryMessage.setValue("Identifier", identifier);
queryMessage.setValue("Verbosity", "1");
- queryMessage.setValue("MaxRetries",
Integer.toString(this.maxRetries));
- queryMessage.setValue("PriorityClass",
Integer.toString(this.priority));
+ queryMessage.setValue("MaxRetries",
Integer.toString(maxRetries));
+ queryMessage.setValue("PriorityClass",
Integer.toString(priority));
- if(this.destinationDir != null)
- queryMessage.setValue("ClientToken",
this.destinationDir);
+ if(destinationDir != null)
+ queryMessage.setValue("ClientToken", destinationDir);
- if(this.persistence == 0)
+ if(persistence == 0)
queryMessage.setValue("Persistence", "forever");
- if(this.persistence == 1)
+ if(persistence == 1)
queryMessage.setValue("Persistence", "reboot");
- if(this.persistence == 2)
+ if(persistence == 2)
queryMessage.setValue("Persistence", "connection");
- if(this.globalQueue)
+ if(globalQueue)
queryMessage.setValue("Global", "true");
else
queryMessage.setValue("Global", "false");
@@ -200,43 +198,43 @@
}
- public void update(Observable o, Object arg) {
+ public void update(final Observable o, final Object arg) {
FCPQueryManager queryManager = null;
- FCPMessage message = (FCPMessage)arg;
+ final FCPMessage message = (FCPMessage)arg;
if (o instanceof FCPQueryManager)
queryManager = (FCPQueryManager)o;
else
- queryManager = this.queueManager.getQueryManager(); /*
default one */
+ queryManager = queueManager.getQueryManager(); /*
default one */
- if(message.getValue("Identifier") == null
- || !message.getValue("Identifier").equals(this.identifier))
+ if((message.getValue("Identifier") == null)
+ || !message.getValue("Identifier").equals(identifier))
return;
if("DataFound".equals( message.getMessageName() )) {
Logger.debug(this, "DataFound!");
- if(!this.isFinished()) {
- if(!this.alreadySaved) {
- this.alreadySaved = true;
+ if(!isFinished()) {
+ if(!alreadySaved) {
+ alreadySaved = true;
- this.fileSize = (new
Long(message.getValue("DataLength"))).longValue();
+ fileSize = (new
Long(message.getValue("DataLength"))).longValue();
- if(this.isPersistent()) {
- if(this.destinationDir != null)
{
+ if(isPersistent()) {
+ if(destinationDir != null) {
-
if(!this.fileExists(this.destinationDir)) {
- this.status =
"Requesting file from the node";
- this.progress =
99;
- this.running =
true;
- this.successful
= false;
-
this.saveFileTo(this.destinationDir, false);
+
if(!fileExists(destinationDir)) {
+ status =
"Requesting file from the node";
+ progress = 99;
+ running = true;
+ successful =
false;
+
this.saveFileTo(destinationDir, false);
} else {
- this.status =
"Available";
- this.progress =
100;
- this.running =
false;
- this.successful
= true;
+ status =
"Available";
+ progress = 100;
+ running = false;
+ successful =
true;
Logger.info(this, "File already existing. Not rewrited");
}
@@ -245,7 +243,7 @@
}
}
- this.setChanged();
+ setChanged();
this.notifyObservers();
}
}
@@ -256,10 +254,10 @@
if("IdentifierCollision".equals( message.getMessageName() )) {
Logger.notice(this, "IdentifierCollision ! Resending
with another id");
- this.identifier = null;
- this.start(this.queueManager);
+ identifier = null;
+ start(queueManager);
- this.setChanged();
+ setChanged();
this.notifyObservers();
return;
@@ -275,28 +273,28 @@
Logger.error(this, "=== PROTOCOL ERROR ===
\n"+message.toString());
- this.status = "Protocol Error
("+message.getValue("CodeDescription")+")";
- this.progress = 100;
- this.running = false;
- this.successful = false;
- this.fatal = true;
+ status = "Protocol Error
("+message.getValue("CodeDescription")+")";
+ progress = 100;
+ running = false;
+ successful = false;
+ fatal = true;
- this.setChanged();
+ setChanged();
this.notifyObservers();
- if(message.getValue("Fatal") != null &&
+ if((message.getValue("Fatal") != null) &&
message.getValue("Fatal").equals("false")) {
- this.fatal = false;
- this.status = this.status + " (non-fatal)";
+ fatal = false;
+ status = status + " (non-fatal)";
}
- if(this.isLockOwner) {
+ if(isLockOwner) {
if (duplicatedQueryManager != null)
duplicatedQueryManager.getConnection().removeFromWriterQueue();
- this.isLockOwner= false;
+ isLockOwner= false;
}
-
this.queueManager.getQueryManager().deleteObserver(this);
+ queueManager.getQueryManager().deleteObserver(this);
return;
}
@@ -306,47 +304,47 @@
if (message.getValue("RedirectURI") != null) {
Logger.debug(this, "Redirected !");
- this.key = message.getValue("RedirectURI");
- this.status = "Redirected ...";
- this.start(this.queueManager);
+ key = message.getValue("RedirectURI");
+ status = "Redirected ...";
+ start(queueManager);
return;
}
Logger.warning(this, "==== GET FAILED
===\n"+message.toString());
- if(!this.isRunning()) { /* Must be a "GetFailed:
cancelled by caller", so we simply ignore */
+ if(!isRunning()) { /* Must be a "GetFailed: cancelled
by caller", so we simply ignore */
Logger.info(this, "Cancellation confirmed.");
return;
}
//removeRequest();
- int code = Integer.parseInt(message.getValue("Code"));
+ final int code =
Integer.parseInt(message.getValue("Code"));
- if(this.maxRetries == -1 || this.attempt >=
this.maxRetries || code == 25) {
- this.status = "Failed
("+message.getValue("CodeDescription")+")";
- this.progress = 100;
- this.running = false;
- this.successful = false;
+ if((maxRetries == -1) || (attempt >= maxRetries) ||
(code == 25)) {
+ status = "Failed
("+message.getValue("CodeDescription")+")";
+ progress = 100;
+ running = false;
+ successful = false;
- this.fatal = true;
+ fatal = true;
- if(message.getValue("Fatal") != null &&
+ if((message.getValue("Fatal") != null) &&
message.getValue("Fatal").equals("false")) {
- this.fatal = false;
- this.status = this.status + " (non-fatal)";
+ fatal = false;
+ status = status + " (non-fatal)";
}
-
this.queueManager.getQueryManager().deleteObserver(this);
+ queueManager.getQueryManager().deleteObserver(this);
} else {
- this.status = "Retrying";
- this.running = true;
- this.successful = true;
- this.progress = 0;
- this.start(this.queueManager);
+ status = "Retrying";
+ running = true;
+ successful = true;
+ progress = 0;
+ start(queueManager);
}
- this.setChanged();
+ setChanged();
this.notifyObservers();
return;
@@ -355,27 +353,27 @@
if(message.getMessageName().equals("SimpleProgress")) {
Logger.debug(this, "SimpleProgress !");
- this.progress = 0;
+ progress = 0;
- if(message.getValue("Total") != null
- && message.getValue("Succeeded") != null) {
- this.fileSize =
Long.parseLong(message.getValue("Total"))*BLOCK_SIZE;
- long required =
Long.parseLong(message.getValue("Total"));
- long succeeded =
Long.parseLong(message.getValue("Succeeded"));
+ if((message.getValue("Total") != null)
+ && (message.getValue("Succeeded") != null)) {
+ fileSize =
Long.parseLong(message.getValue("Total"))*FCPClientGet.BLOCK_SIZE;
+ final long required =
Long.parseLong(message.getValue("Total"));
+ final long succeeded =
Long.parseLong(message.getValue("Succeeded"));
- this.progress = (int) ((long)((succeeded * 98)
/ required));
+ progress = (int) ((long)((succeeded * 98) /
required));
- this.status = "Fetching";
+ status = "Fetching";
- if(message.getValue("FinalizedTotal") != null &&
+ if((message.getValue("FinalizedTotal") != null)
&&
message.getValue("FinalizedTotal").equals("true")) {
- this.progressReliable = true;
+ progressReliable = true;
}
- this.successful = true;
- this.running = true;
+ successful = true;
+ running = true;
- this.setChanged();
+ setChanged();
this.notifyObservers();
}
@@ -383,27 +381,27 @@
}
if(message.getMessageName().equals("AllData")) {
- Logger.debug(this, "AllData ! : " + this.identifier);
+ Logger.debug(this, "AllData ! : " + identifier);
- this.fileSize = message.getAmountOfDataWaiting();
+ fileSize = message.getAmountOfDataWaiting();
- this.running = true;
- this.successful = true;
- this.progress = 99;
- this.status = "Writing to disk";
+ running = true;
+ successful = true;
+ progress = 99;
+ status = "Writing to disk";
Logger.info(this, "Receiving file ...");
- this.setChanged();
+ setChanged();
this.notifyObservers();
- if(this.fetchDirectly(queryManager.getConnection(),
this.fileSize, true)) {
- this.successful = true;
- this.status = "Available";
+ if(fetchDirectly(queryManager.getConnection(),
fileSize, true)) {
+ successful = true;
+ status = "Available";
} else {
Logger.warning(this, "Unable to fetch correctly
the file. This may create problems on socket");
- this.successful = false;
- this.status = "Error while receveing the file";
+ successful = false;
+ status = "Error while receveing the file";
}
Logger.info(this, "File received");
@@ -411,20 +409,20 @@
if (duplicatedQueryManager != null)
duplicatedQueryManager.getConnection().removeFromWriterQueue();
- this.isLockOwner= false;
+ isLockOwner= false;
- this.running = false;
- this.progress = 100;
+ running = false;
+ progress = 100;
queryManager.deleteObserver(this);
- if (queryManager !=
this.queueManager.getQueryManager()) {
-
this.queueManager.getQueryManager().deleteObserver(this);
+ if (queryManager != queueManager.getQueryManager()) {
+
queueManager.getQueryManager().deleteObserver(this);
queryManager.getConnection().disconnect();
- this.duplicatedQueryManager = null;
+ duplicatedQueryManager = null;
}
- this.setChanged();
+ setChanged();
this.notifyObservers();
@@ -445,7 +443,7 @@
FCPConnection connection;
String dir;
- public UnlockWaiter(FCPClientGet clientGet, FCPConnection
connection, String dir) {
+ public UnlockWaiter(final FCPClientGet clientGet, final
FCPConnection connection, final String dir) {
this.clientGet = clientGet;
this.dir = dir;
this.connection = connection;
@@ -453,25 +451,25 @@
public void run() {
connection.addToWriterQueue();
- FCPClientGet.this.isLockOwner = true;
+ isLockOwner = true;
Logger.debug(this, "I take the lock !");
- if(this.dir == null) {
+ if(dir == null) {
Logger.warning(this, "UnlockWaiter.run() : Wtf
?");
}
- this.clientGet.continueSaveFileTo(this.dir);
+ clientGet.continueSaveFileTo(dir);
return;
}
}
- public boolean saveFileTo(String dir) {
+ public boolean saveFileTo(final String dir) {
return this.saveFileTo(dir, true);
}
- public synchronized boolean saveFileTo(String dir, boolean checkStatus)
{
- this.fromTheNodeProgress = 0;
+ public synchronized boolean saveFileTo(final String dir, final boolean
checkStatus) {
+ fromTheNodeProgress = 0;
Logger.info(this, "Saving file to '"+dir+"'");
@@ -480,80 +478,80 @@
return false;
}
- this.destinationDir = dir;
+ destinationDir = dir;
- if(checkStatus && (!this.isFinished() || !this.isSuccessful()))
{
+ if(checkStatus && (!isFinished() || !isSuccessful())) {
Logger.warning(this, "Unable to fetch a file not
finished");
return false;
}
- if(!this.isPersistent()) {
+ if(!isPersistent()) {
Logger.warning(this, "Not persistent, so unable to
ask");
return false;
}
Logger.info(this, "Duplicating socket ...");
- duplicatedQueryManager =
this.queueManager.getQueryManager().duplicate(this.identifier);
+ duplicatedQueryManager =
queueManager.getQueryManager().duplicate(identifier);
duplicatedQueryManager.addObserver(this);
Logger.info(this, "Waiting for socket ...");
- this.status = "Waiting for socket availability ...";
- this.progress = 99;
- this.running = true;
+ status = "Waiting for socket availability ...";
+ progress = 99;
+ running = true;
- this.setChanged();
+ setChanged();
this.notifyObservers();
- Thread fork = new Thread(new UnlockWaiter(this,
duplicatedQueryManager.getConnection(), dir));
+ final Thread fork = new Thread(new UnlockWaiter(this,
duplicatedQueryManager.getConnection(), dir));
fork.start();
return true;
}
- public synchronized boolean continueSaveFileTo(String dir) {
+ public synchronized boolean continueSaveFileTo(final String dir) {
- Logger.info(this, "Asking file '"+this.filename+"' to the
node...");
+ Logger.info(this, "Asking file '"+filename+"' to the node...");
- this.destinationDir = dir;
+ destinationDir = dir;
- this.status = "Requesting file";
- this.progress = 99;
- this.running = true;
- this.setChanged();
+ status = "Requesting file";
+ progress = 99;
+ running = true;
+ setChanged();
this.notifyObservers();
- if(this.destinationDir == null) {
+ if(destinationDir == null) {
Logger.warning(this, "saveFileTo() : Wtf ?");
}
- FCPMessage getRequestStatus = new FCPMessage();
+ final FCPMessage getRequestStatus = new FCPMessage();
getRequestStatus.setMessageName("GetRequestStatus");
- getRequestStatus.setValue("Identifier", this.identifier);
- if(this.globalQueue)
+ getRequestStatus.setValue("Identifier", identifier);
+ if(globalQueue)
getRequestStatus.setValue("Global", "true");
else
getRequestStatus.setValue("Global", "false");
getRequestStatus.setValue("OnlyData", "true");
- this.duplicatedQueryManager.writeMessage(getRequestStatus,
false);
+ duplicatedQueryManager.writeMessage(getRequestStatus, false);
return true;
}
- private boolean fileExists(String dir) {
- this.destinationDir = dir;
- File newFile = new File(this.getPath());
+ private boolean fileExists(final String dir) {
+ destinationDir = dir;
+ final File newFile = new File(getPath());
return newFile.exists();
}
- private boolean fetchDirectly(FCPConnection connection, long size,
boolean reallyWrite) {
- String file = this.getPath();
+ private boolean fetchDirectly(final FCPConnection connection, long
size, final boolean reallyWrite) {
+ final String file = getPath();
File newFile = null;
OutputStream outputStream = null;
@@ -565,7 +563,7 @@
newFile = File.createTempFile("thaw_", ".tmp");
finalPath = newFile.getPath();
newFile.deleteOnExit();
- } catch(java.io.IOException e) {
+ } catch(final java.io.IOException e) {
Logger.error(this, "Error while creating
temporary file: "+e.toString());
}
}
@@ -575,9 +573,9 @@
try {
outputStream = new FileOutputStream(newFile);
- } catch(java.io.IOException e) {
+ } catch(final java.io.IOException e) {
Logger.error(this, "Unable to write file on
disk ... disk space / perms ? : "+e.toString());
- this.status = "Write error";
+ status = "Write error";
return false;
}
@@ -586,14 +584,14 @@
}
/* size == bytes remaining on socket */
- long origSize = size;
+ final long origSize = size;
long startTime = System.currentTimeMillis();
boolean writingSuccessful = true;
while(size > 0) {
- int packet = PACKET_SIZE;
+ int packet = FCPClientGet.PACKET_SIZE;
byte[] read;
int amount;
@@ -606,8 +604,8 @@
if(amount <= -1) {
Logger.error(this, "Socket closed, damn !");
- this.status = "Read error";
- this.successful = false;
+ status = "Read error";
+ successful = false;
writingSuccessful = false;
break;
}
@@ -615,11 +613,11 @@
if(reallyWrite) {
try {
outputStream.write(read, 0, amount);
- } catch(java.io.IOException e) {
+ } catch(final java.io.IOException e) {
Logger.error(this, "Unable to write
file on disk ... out of space ? : "+e.toString());
- this.status = "Write error";
+ status = "Write error";
writingSuccessful = false;
- this.successful = false;
+ successful = false;
return false;
}
}
@@ -627,25 +625,25 @@
size = size - amount;
if( System.currentTimeMillis() >= (startTime+3000)) {
- this.status = "Writing to disk";
- this.fromTheNodeProgress = (int)
(((origSize-size) * 100) / origSize);
- this.setChanged();
+ status = "Writing to disk";
+ fromTheNodeProgress = (int) (((origSize-size) *
100) / origSize);
+ setChanged();
this.notifyObservers();
startTime = System.currentTimeMillis();
}
}
- this.fromTheNodeProgress = 100;
+ fromTheNodeProgress = 100;
if(reallyWrite) {
try {
outputStream.close();
- if(!writingSuccessful && newFile != null)
+ if(!writingSuccessful && (newFile != null))
newFile.delete();
- } catch(java.io.IOException e) {
+ } catch(final java.io.IOException e) {
Logger.notice(this, "Unable to close correctly
file on disk !? : "+e.toString());
}
}
@@ -659,106 +657,105 @@
public boolean removeRequest() {
- FCPMessage stopMessage = new FCPMessage();
+ final FCPMessage stopMessage = new FCPMessage();
- if(!this.isPersistent()) {
+ if(!isPersistent()) {
Logger.notice(this, "Can't remove non persistent
request.");
return false;
}
- if(this.identifier == null) {
+ if(identifier == null) {
Logger.notice(this, "Can't remove non-started queries");
return true;
}
stopMessage.setMessageName("RemovePersistentRequest");
- if(this.globalQueue)
+ if(globalQueue)
stopMessage.setValue("Global", "true");
else
stopMessage.setValue("Global", "false");
- stopMessage.setValue("Identifier", this.identifier);
+ stopMessage.setValue("Identifier", identifier);
- this.queueManager.getQueryManager().writeMessage(stopMessage);
+ queueManager.getQueryManager().writeMessage(stopMessage);
- this.running = false;
+ running = false;
return true;
}
- public boolean pause(FCPQueueManager queryManager) {
+ public boolean pause(final FCPQueueManager queryManager) {
/* TODO ? : Reduce the priority
instead of stopping */
- Logger.info(this, "Pausing fetching of the key :
"+this.getFileKey());
+ Logger.info(this, "Pausing fetching of the key :
"+getFileKey());
- this.removeRequest();
+ removeRequest();
- this.progress = 0;
- this.running = false;
- this.successful = false;
- this.status = "Delayed";
+ progress = 0;
+ running = false;
+ successful = false;
+ status = "Delayed";
- this.setChanged();
+ setChanged();
this.notifyObservers();
return true;
}
- public boolean stop(FCPQueueManager queryManager) {
- Logger.info(this, "Stop fetching of the key :
"+this.getFileKey());
+ public boolean stop(final FCPQueueManager queryManager) {
+ Logger.info(this, "Stop fetching of the key : "+getFileKey());
- if(!this.removeRequest()) {
+ if(!removeRequest())
return false;
- }
- this.progress = 100;
- this.running = false;
- this.successful = false;
- this.fatal = true;
- this.status = "Stopped";
- this.setChanged();
+ progress = 100;
+ running = false;
+ successful = false;
+ fatal = true;
+ status = "Stopped";
+ setChanged();
this.notifyObservers();
return true;
}
- public void updatePersistentRequest(boolean clientToken) {
- if(!this.isPersistent())
+ public void updatePersistentRequest(final boolean clientToken) {
+ if(!isPersistent())
return;
- FCPMessage msg = new FCPMessage();
+ final FCPMessage msg = new FCPMessage();
msg.setMessageName("ModifyPersistentRequest");
- msg.setValue("Global", Boolean.toString(this.globalQueue));
- msg.setValue("Identifier", this.identifier);
- msg.setValue("PriorityClass", Integer.toString(this.priority));
+ msg.setValue("Global", Boolean.toString(globalQueue));
+ msg.setValue("Identifier", identifier);
+ msg.setValue("PriorityClass", Integer.toString(priority));
- if(clientToken && this.destinationDir != null)
- msg.setValue("ClientToken", this.destinationDir);
+ if(clientToken && (destinationDir != null))
+ msg.setValue("ClientToken", destinationDir);
- this.queueManager.getQueryManager().writeMessage(msg);
+ queueManager.getQueryManager().writeMessage(msg);
}
public int getThawPriority() {
- return this.priority;
+ return priority;
}
public int getFCPPriority() {
- return this.priority;
+ return priority;
}
- public void setFCPPriority(int prio) {
+ public void setFCPPriority(final int prio) {
Logger.info(this, "Setting priority to
"+Integer.toString(prio));
- this.priority = prio;
+ priority = prio;
- this.setChanged();
+ setChanged();
this.notifyObservers();
}
@@ -767,128 +764,128 @@
}
public String getStatus() {
- return this.status;
+ return status;
}
public int getProgression() {
- return this.progress;
+ return progress;
}
public boolean isProgressionReliable() {
- if(this.progress == 0 || this.progress >= 99)
+ if((progress == 0) || (progress >= 99))
return true;
- return this.progressReliable;
+ return progressReliable;
}
public String getFileKey() {
- return this.key;
+ return key;
}
public boolean isFinished() {
- if(this.progress >= 100)
+ if(progress >= 100)
return true;
return false;
}
public long getFileSize() {
- return this.fileSize;
+ return fileSize;
}
public String getPath() {
if (finalPath != null)
return finalPath;
- if(this.destinationDir != null)
- return this.destinationDir + File.separator +
this.filename;
+ if(destinationDir != null)
+ return destinationDir + File.separator + filename;
return null;
}
public String getFilename() {
- return this.filename;
+ return filename;
}
public int getAttempt() {
- return this.attempt;
+ return attempt;
}
- public void setAttempt(int x) {
- this.attempt = x;
+ public void setAttempt(final int x) {
+ attempt = x;
if(x == 0) {
/* We suppose it's a restart */
- this.progress = 0;
+ progress = 0;
}
}
public int getMaxAttempt() {
- return this.maxRetries;
+ return maxRetries;
}
public boolean isSuccessful() {
- return this.successful;
+ return successful;
}
public boolean isFatallyFailed() {
- return ((!this.successful) && this.fatal);
+ return ((!successful) && fatal);
}
public boolean isRunning() {
- return this.running;
+ return running;
}
public HashMap getParameters() {
- HashMap result = new HashMap();
+ final HashMap result = new HashMap();
- result.put("URI", this.key);
- result.put("Filename", this.filename);
- result.put("Priority", Integer.toString(this.priority));
- result.put("Persistence", Integer.toString(this.persistence));
- result.put("Global", Boolean.toString(this.globalQueue));
- result.put("ClientToken", this.destinationDir);
- result.put("Attempt", Integer.toString(this.attempt));
+ result.put("URI", key);
+ result.put("Filename", filename);
+ result.put("Priority", Integer.toString(priority));
+ result.put("Persistence", Integer.toString(persistence));
+ result.put("Global", Boolean.toString(globalQueue));
+ result.put("ClientToken", destinationDir);
+ result.put("Attempt", Integer.toString(attempt));
- result.put("status", this.status);
+ result.put("status", status);
- result.put("Identifier", this.identifier);
- result.put("Progress", Integer.toString(this.progress));
- result.put("FileSize", Long.toString(this.fileSize));
- result.put("Running", Boolean.toString(this.running));
- result.put("Successful", Boolean.toString(this.successful));
- result.put("MaxRetries", Integer.toString(this.maxRetries));
+ result.put("Identifier", identifier);
+ result.put("Progress", Integer.toString(progress));
+ result.put("FileSize", Long.toString(fileSize));
+ result.put("Running", Boolean.toString(running));
+ result.put("Successful", Boolean.toString(successful));
+ result.put("MaxRetries", Integer.toString(maxRetries));
return result;
}
- public boolean setParameters(HashMap parameters) {
+ public boolean setParameters(final HashMap parameters) {
- this.key = (String)parameters.get("URI");
+ key = (String)parameters.get("URI");
- Logger.debug(this, "Resuming key : "+this.key);
+ Logger.debug(this, "Resuming key : "+key);
- this.filename = (String)parameters.get("Filename");
- this.priority =
Integer.parseInt((String)parameters.get("Priority"));
- this.persistence =
Integer.parseInt((String)parameters.get("Persistence"));
- this.globalQueue =
Boolean.valueOf((String)parameters.get("Global")).booleanValue();
- this.destinationDir = (String)parameters.get("ClientToken");
- this.attempt =
Integer.parseInt((String)parameters.get("Attempt"));
- this.status = (String)parameters.get("Status");
- this.identifier = (String)parameters.get("Identifier");
+ filename = (String)parameters.get("Filename");
+ priority =
Integer.parseInt((String)parameters.get("Priority"));
+ persistence =
Integer.parseInt((String)parameters.get("Persistence"));
+ globalQueue =
Boolean.valueOf((String)parameters.get("Global")).booleanValue();
+ destinationDir = (String)parameters.get("ClientToken");
+ attempt =
Integer.parseInt((String)parameters.get("Attempt"));
+ status = (String)parameters.get("Status");
+ identifier = (String)parameters.get("Identifier");
- Logger.info(this, "Resuming id : "+this.identifier);
+ Logger.info(this, "Resuming id : "+identifier);
- this.progress =
Integer.parseInt((String)parameters.get("Progress"));
- this.fileSize =
Long.parseLong((String)parameters.get("FileSize"));
- this.running =
Boolean.valueOf((String)parameters.get("Running")).booleanValue();
- this.successful =
Boolean.valueOf((String)parameters.get("Successful")).booleanValue();
- this.maxRetries =
Integer.parseInt((String)parameters.get("MaxRetries"));
+ progress =
Integer.parseInt((String)parameters.get("Progress"));
+ fileSize =
Long.parseLong((String)parameters.get("FileSize"));
+ running =
Boolean.valueOf((String)parameters.get("Running")).booleanValue();
+ successful =
Boolean.valueOf((String)parameters.get("Successful")).booleanValue();
+ maxRetries =
Integer.parseInt((String)parameters.get("MaxRetries"));
- if(this.persistence == 2 && !this.isFinished()) {
- this.progress = 0;
- this.running = false;
- this.status = "Waiting";
+ if((persistence == 2) && !isFinished()) {
+ progress = 0;
+ running = false;
+ status = "Waiting";
}
return true;
@@ -896,22 +893,22 @@
public boolean isPersistent() {
- return (this.persistence < 2);
+ return (persistence < 2);
}
public String getIdentifier() {
- if(this.identifier == null || this.identifier.equals(""))
+ if((identifier == null) || identifier.equals(""))
return null;
- return this.identifier;
+ return identifier;
}
public boolean isGlobal() {
- return this.globalQueue;
+ return globalQueue;
}
public int getTransferWithTheNodeProgression() {
- return this.fromTheNodeProgress;
+ return fromTheNodeProgress;
}
}
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientHello.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientHello.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientHello.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,7 +1,8 @@
package thaw.fcp;
-import java.util.Observer;
import java.util.Observable;
+import java.util.Observer;
+
import thaw.core.Logger;
/**
@@ -13,82 +14,79 @@
public class FCPClientHello implements FCPQuery, Observer {
private final static String FCP_EXPECTED_VERSION = "2.0";
- private String id = null;
+ private String id;
- private String nodeFCPVersion = null;
- private String nodeVersion = null;
+ private String nodeFCPVersion;
+ private String nodeVersion;
private String nodeName = null;
private boolean testnet = false; /* Hmm, in fact, we shouldn't have to
bother about this one */
private int nmbCompressionCodecs = -1;
private boolean receiveAnswer = false;
- private boolean successful = false;
- private FCPQueryManager queryManager = null;
+ private final FCPQueryManager queryManager;
-
/**
* Need to know the id of the application (see FCP specs).
*/
- public FCPClientHello(FCPQueryManager queryManager, String id) {
- this.setID(id);
+ public FCPClientHello(final FCPQueryManager queryManager, final String
id) {
+ this.id = id;
this.queryManager = queryManager;
}
-
-
- public void setID(String id) {
+
+ public void setID(final String id) {
this.id = id;
}
public String getNodeFCPVersion() {
- return this.nodeFCPVersion;
+ return nodeFCPVersion;
}
public String getNodeVersion() {
- return this.nodeVersion;
+ return nodeVersion;
}
public String getNodeName() {
- return this.nodeName;
+ return nodeName;
}
public boolean isOnTestnet() {
- return this.testnet;
+ return testnet;
}
public int getNmbCompressionCodecs() {
- return this.nmbCompressionCodecs;
+ return nmbCompressionCodecs;
}
/**
* Warning: This query is blocking (only this one) !
*/
- public boolean start(FCPQueueManager queueManager) {
+ public boolean start(final FCPQueueManager queueManager) {
- FCPMessage message = new FCPMessage();
+ final FCPMessage message = new FCPMessage();
message.setMessageName("ClientHello");
- message.setValue("Name", this.id);
- message.setValue("ExpectedVersion", FCP_EXPECTED_VERSION);
+ message.setValue("Name", id);
+ message.setValue("ExpectedVersion",
FCPClientHello.FCP_EXPECTED_VERSION);
- this.queryManager.addObserver(this);
+ queryManager.addObserver(this);
- if(!this.queryManager.writeMessage(message)) {
+ if(!queryManager.writeMessage(message)) {
Logger.warning(this, "Unable to say hello ... ;(");
return false;
}
- while(!this.receiveAnswer) {
+ while(!receiveAnswer) {
try {
Thread.sleep(500);
- } catch(java.lang.InterruptedException e) {
+ } catch(final java.lang.InterruptedException e) {
/* Dodo j'ai dis ! */
}
}
- if(this.nodeName != null) {
- Logger.info(this, "Hello "+this.nodeName+", I'm Thaw
:)");
+ if(nodeName != null) {
+ Logger.info(this, "Hello "+nodeName+", I'm Thaw :)");
} else {
Logger.warning(this, "Unable to connect, ID is probably
already taken");
return false;
@@ -98,39 +96,38 @@
}
- public void update(Observable o, Object arg) {
+ public void update(final Observable o, final Object arg) {
if(arg == null)
return;
- FCPMessage answer = (FCPMessage)arg;
+ final FCPMessage answer = (FCPMessage)arg;
- if(o == this.queryManager) {
+ if(o == queryManager) {
if("NodeHello".equals( answer.getMessageName() )) {
- this.successful = true;
Logger.info(this, "Received a nodeHello");
- this.nodeFCPVersion =
answer.getValue("FCPVersion");
- this.nodeVersion = answer.getValue("Version");
- this.nodeName = answer.getValue("Node");
- this.testnet =
Boolean.valueOf(answer.getValue("Testnet")).booleanValue();
- this.nmbCompressionCodecs =
Integer.parseInt(answer.getValue("CompressionCodecs"));
+ nodeFCPVersion = answer.getValue("FCPVersion");
+ nodeVersion = answer.getValue("Version");
+ nodeName = answer.getValue("Node");
+ testnet =
Boolean.valueOf(answer.getValue("Testnet")).booleanValue();
+ nmbCompressionCodecs =
Integer.parseInt(answer.getValue("CompressionCodecs"));
- this.queryManager.deleteObserver(this);
+ queryManager.deleteObserver(this);
- this.receiveAnswer = true;
+ receiveAnswer = true;
}
if("CloseConnectionDuplicateClientName".equals(
answer.getMessageName() )) {
/* Damn ... ! */
Logger.warning(this, "According to the node,
Thaw ID is already used. Please change it in the configuration");
- this.queryManager.deleteObserver(this);
- this.queryManager.getConnection().disconnect();
- this.receiveAnswer = true;
+ queryManager.deleteObserver(this);
+ queryManager.getConnection().disconnect();
+ receiveAnswer = true;
}
}
- if(!this.receiveAnswer) {
+ if(!receiveAnswer) {
Logger.warning(this, "This message wasn't for us ?! :
"+answer.getMessageName());
}
}
@@ -138,7 +135,7 @@
/**
* Not used.
*/
- public boolean stop(FCPQueueManager queueManager) {
+ public boolean stop(final FCPQueueManager queueManager) {
return true;
}
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,12 +1,12 @@
package thaw.fcp;
-import java.util.HashMap;
import java.io.File;
-import java.util.Observer;
-import java.util.Observable;
import java.io.FileInputStream;
-
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Observable;
+import java.util.Observer;
import thaw.core.Logger;
@@ -16,16 +16,15 @@
public class FCPClientPut extends Observable implements FCPTransferQuery,
Observer {
public final static int DEFAULT_INSERTION_PRIORITY = 4;
- private FCPQueueManager queueManager = null;
- private final static int BLOCK_SIZE = 32768;
+ private FCPQueueManager queueManager;
- private File localFile = null;
+ private File localFile;
private long fileSize = 0;
private int keyType = 0;
private int rev = 0;
- private String name = null;
- private String privateKey = null; /* must finish by '/' (cf SSKKeypair)
*/
- private String publicKey = null; /* publicKey contains the filename etc
*/
+ private String name;
+ private String privateKey; /* must finish by '/' (cf SSKKeypair) */
+ private String publicKey; /* publicKey contains the filename etc */
private int priority = -1;
private boolean global = true;
private int persistence = 2;
@@ -33,11 +32,11 @@
private int progress = 0;
private int toTheNodeProgress = 0;
- private String status = null;
+ private String status;
private int attempt = 0;
- private String identifier = null;
+ private String identifier;
private boolean running = false;
private boolean finished = false;
@@ -45,19 +44,19 @@
private boolean fatal = true;
private boolean sending = false;
- private FCPGenerateSSK sskGenerator = null;
+ private FCPGenerateSSK sskGenerator;
private boolean lockOwner = false;
- private HashMap metadatas = null;
+ private final HashMap metadatas = new LinkedHashMap();
private final static int PACKET_SIZE = 1024;
/**
* To resume query from file. (see core.QueueKeeper)
*/
- public FCPClientPut(FCPQueueManager queueManager, HashMap parameters) {
+ public FCPClientPut(final FCPQueueManager queueManager, final HashMap
parameters) {
this.queueManager = queueManager;
- this.setParameters(parameters);
+ setParameters(parameters);
}
/**
@@ -68,10 +67,10 @@
* @param privateKey : ignored if key == CHK/KSK ; can be null if it
has to be generated ; USK@[...]/
* @param persistence 0 = Forever ; 1 = Until node reboot ; 2 = Until
the app disconnect
*/
- public FCPClientPut(File file, int keyType,
- int rev, String name,
- String privateKey, int priority,
- boolean global, int persistence) {
+ public FCPClientPut(final File file, final int keyType,
+ final int rev, final String name,
+ final String privateKey, final int priority,
+ final boolean global, final int persistence) {
this(file, keyType, rev, name, privateKey, priority, global,
persistence,
false);
}
@@ -79,20 +78,20 @@
/**
* To start a new insertion.
*/
- public FCPClientPut(File file, int keyType,
- int rev, String name,
- String privateKey, int priority,
- boolean global, int persistence,
- boolean getCHKOnly) {
+ public FCPClientPut(final File file, final int keyType,
+ final int rev, final String name,
+ final String privateKey, final int priority,
+ final boolean global, final int persistence,
+ final boolean getCHKOnly) {
this.getCHKOnly = getCHKOnly;
- this.localFile = file;
+ localFile = file;
if (file != null) {
this.name = file.getName();
- this.fileSize = file.length();
+ fileSize = file.length();
} else {
this.name = name;
- this.fileSize = 0;
+ fileSize = 0;
}
this.keyType = keyType;
@@ -106,21 +105,21 @@
this.privateKey = privateKey;
}
- this.publicKey = null;
+ publicKey = null;
this.priority = priority;
this.global = global;
this.persistence = persistence;
- this.status = "Waiting";
- this.progress = 0;
- this.attempt = 0;
+ status = "Waiting";
+ progress = 0;
+ attempt = 0;
- this.identifier = null;
+ identifier = null;
- this.running = false;
- this.finished = false;
- this.successful = false;
- this.fatal = true;
+ running = false;
+ finished = false;
+ successful = false;
+ fatal = true;
}
@@ -128,61 +127,61 @@
* Used for resuming from a PersistentPut.
* @param publicKey : Complete key (with filename, etc)
*/
- public FCPClientPut(String identifier, String publicKey,
- int priority, int persistence, boolean global,
- String filePath, String fileName, String status,
int progress,
- long fileSize, FCPQueueManager queueManager) {
+ public FCPClientPut(final String identifier, final String publicKey,
+ final int priority, final int persistence, final
boolean global,
+ final String filePath, final String fileName, final
String status, final int progress,
+ final long fileSize, final FCPQueueManager
queueManager) {
if(fileSize > 0)
this.fileSize = fileSize;
- this.toTheNodeProgress = 100;
+ toTheNodeProgress = 100;
this.queueManager = queueManager;
this.identifier = identifier;
if(publicKey.startsWith("CHK"))
- this.keyType = 0;
+ keyType = 0;
if(publicKey.startsWith("KSK"))
- this.keyType = 1;
+ keyType = 1;
if(publicKey.startsWith("SSK"))
- this.keyType = 2;
+ keyType = 2;
if(publicKey.startsWith("USK"))
- this.keyType = 2;
+ keyType = 2;
this.publicKey = publicKey;
- if(filePath != null && filePath.startsWith("thaw")) {
+ if((filePath != null) && filePath.startsWith("thaw")) {
- String[] plop =
filePath.split(File.separator.replaceAll("\\\\", "\\\\\\\\"));
- this.name = plop[plop.length-1];
+ final String[] plop =
filePath.split(File.separator.replaceAll("\\\\", "\\\\\\\\"));
+ name = plop[plop.length-1];
- this.localFile = new File(filePath);
- if(this.localFile.length() > 0)
- this.fileSize = this.localFile.length();
+ localFile = new File(filePath);
+ if(localFile.length() > 0)
+ this.fileSize = localFile.length();
} else {
String[] plop = publicKey.split("/");
- this.name = plop[plop.length-1];
+ name = plop[plop.length-1];
- if(this.keyType != 0) {
- plop = this.name.split("\\-");
+ if(keyType != 0) {
+ plop = name.split("\\-");
if(plop.length >= 2) {
- this.name = "";
+ name = "";
for(int i = 0 ; i < plop.length-1; i++)
{
- this.name = this.name + plop[i];
+ name = name + plop[i];
if(i < plop.length-2)
- this.name = this.name
+"-";
+ name = name +"-";
}
}
}
- if("null".equals( this.name ) || "CHK@".equals(
this.name )) {
+ if("null".equals( name ) || "CHK@".equals( name )) {
Logger.warning(this, "The node returns \"null\"
as filename. Using id !");
Logger.warning(this, "( URI="+publicKey +" )");
Logger.warning(this, "(
Identifier="+identifier+" )");
@@ -190,11 +189,11 @@
plop = this.identifier.split("\\-");
if(plop.length >= 2) {
- this.name = "";
+ name = "";
for(int i = 1 ; i < plop.length; i++) {
if(i != 1)
- this.name = this.name
+"-";
- this.name = this.name + plop[i];
+ name = name +"-";
+ name = name + plop[i];
}
}
@@ -205,7 +204,7 @@
}
if (fileName != null) { /* We want to force the filename */ /*
See PersistentPut.TargetFilename */
- this.name = fileName;
+ name = fileName;
}
this.publicKey = null;
@@ -218,27 +217,27 @@
this.progress = progress;
this.status = status;
- this.running = true;
- this.finished = false;
- this.successful = false;
- this.fatal = true;
+ running = true;
+ finished = false;
+ successful = false;
+ fatal = true;
}
- public boolean start(FCPQueueManager queueManager) {
+ public boolean start(final FCPQueueManager queueManager) {
this.queueManager = queueManager;
- if(this.localFile != null && this.localFile.length() <= 0) {
- Logger.warning(this, "Empty or unreachable
file:"+this.localFile.getPath());
+ if((localFile != null) && (localFile.length() <= 0)) {
+ Logger.warning(this, "Empty or unreachable
file:"+localFile.getPath());
- this.status = "EMPTY OR UNREACHABLE FILE";
+ status = "EMPTY OR UNREACHABLE FILE";
- this.successful = false;
- this.fatal = true;
- this.finished = true;
- this.running = false;
+ successful = false;
+ fatal = true;
+ finished = true;
+ running = false;
- this.setChanged();
+ setChanged();
this.notifyObservers();
return false;
@@ -247,20 +246,20 @@
queueManager.getQueryManager().addObserver(this);
- this.progress = 0;
- this.finished = false;
- this.successful = false;
- this.running = false;
+ progress = 0;
+ finished = false;
+ successful = false;
+ running = false;
- if(this.keyType == 2 && this.privateKey == null) {
- this.generateSSK();
+ if((keyType == 2) && (privateKey == null)) {
+ generateSSK();
}
- if( (this.keyType == 2 && this.privateKey != null) ||
this.keyType != 2) {
- this.startInsert();
+ if( ((keyType == 2) && (privateKey != null)) || (keyType != 2))
{
+ startInsert();
}
- this.setChanged();
+ setChanged();
this.notifyObservers();
return true;
@@ -270,12 +269,12 @@
* doesn't set running = true. startInsert() will.
*/
public void generateSSK() {
- this.status = "Generating keys";
+ status = "Generating keys";
- this.sskGenerator = new FCPGenerateSSK();
+ sskGenerator = new FCPGenerateSSK();
- this.sskGenerator.addObserver(this);
- this.sskGenerator.start(this.queueManager);
+ sskGenerator.addObserver(this);
+ sskGenerator.start(queueManager);
}
@@ -284,7 +283,7 @@
FCPClientPut clientPut;
FCPConnection connection;
- public UnlockWaiter(FCPClientPut clientPut, FCPConnection
connection) {
+ public UnlockWaiter(final FCPClientPut clientPut, final
FCPConnection connection) {
this.clientPut = clientPut;
this.connection = connection;
}
@@ -292,9 +291,9 @@
public void run() {
connection.addToWriterQueue();
- FCPClientPut.this.lockOwner = true;
+ lockOwner = true;
- this.clientPut.continueInsert();
+ clientPut.continueInsert();
return;
}
}
@@ -302,15 +301,15 @@
public boolean startInsert() {
- FCPConnection connection =
this.queueManager.getQueryManager().getConnection();
+ final FCPConnection connection =
queueManager.getQueryManager().getConnection();
- this.toTheNodeProgress= 0;
+ toTheNodeProgress= 0;
- this.status = "Waiting for socket availability";
+ status = "Waiting for socket availability";
Logger.info(this, "Another file is being uploaded ... waiting
...");
- Thread fork = new Thread(new UnlockWaiter(this, connection));
+ final Thread fork = new Thread(new UnlockWaiter(this,
connection));
fork.start();
@@ -318,40 +317,40 @@
}
public boolean continueInsert() {
- this.running = true; /* Here we are really running */
- this.sending = true;
+ running = true; /* Here we are really running */
+ sending = true;
- FCPConnection connection =
this.queueManager.getQueryManager().getConnection();
+ final FCPConnection connection =
queueManager.getQueryManager().getConnection();
- this.status = "Sending to the node";
+ status = "Sending to the node";
- if (this.localFile != null)
- this.identifier = this.queueManager.getAnID() + "-"+
this.localFile.getName();
+ if (localFile != null)
+ identifier = queueManager.getAnID() + "-"+
localFile.getName();
else
- this.identifier = this.queueManager.getAnID();
+ identifier = queueManager.getAnID();
- this.setChanged();
+ setChanged();
this.notifyObservers();
- FCPMessage msg = new FCPMessage();
+ final FCPMessage msg = new FCPMessage();
msg.setMessageName("ClientPut");
- msg.setValue("URI", this.getInsertionKey());
+ msg.setValue("URI", getInsertionKey());
- if(this.metadatas != null) {
- for(Iterator keyIt = this.metadatas.keySet().iterator();
+ if(!metadatas.isEmpty()) {
+ for(final Iterator keyIt =
metadatas.keySet().iterator();
keyIt.hasNext();) {
- String key = (String)keyIt.next();
- String value = (String)this.metadatas.get(key);
+ final String key = (String)keyIt.next();
+ final String value = (String)metadatas.get(key);
msg.setValue("Metadata."+key, value);
}
}
- msg.setValue("Identifier", this.identifier);
+ msg.setValue("Identifier", identifier);
msg.setValue("MaxRetries", "-1");
- msg.setValue("PriorityClass", Integer.toString(this.priority));
+ msg.setValue("PriorityClass", Integer.toString(priority));
- if(this.getCHKOnly) {
+ if(getCHKOnly) {
msg.setValue("GetCHKOnly", "true");
//msg.setValue("Verbosity", "0");
} else {
@@ -360,66 +359,66 @@
}
msg.setValue("Verbosity", "512");
- if(this.global)
+ if(global)
msg.setValue("Global", "true");
else
msg.setValue("Global", "false");
- if (this.localFile != null)
- msg.setValue("ClientToken", this.localFile.getPath());
+ if (localFile != null)
+ msg.setValue("ClientToken", localFile.getPath());
- switch(this.persistence) {
+ switch(persistence) {
case(0): msg.setValue("Persistence", "forever"); break;
case(1): msg.setValue("Persistence", "reboot"); break;
case(2): msg.setValue("Persistence", "connection"); break;
default: Logger.notice(this, "Unknow persistence !?"); break;
}
- if (this.localFile != null)
- msg.setValue("TargetFilename",
this.localFile.getName());
+ if (localFile != null)
+ msg.setValue("TargetFilename", localFile.getName());
else
- msg.setValue("TargetFilename", this.name);
+ msg.setValue("TargetFilename", name);
msg.setValue("UploadFrom", "direct");
- msg.setAmountOfDataWaiting(this.fileSize);
- Logger.info(this, "Sending "+Long.toString(this.fileSize)+"
bytes on socket ...");
+ msg.setAmountOfDataWaiting(fileSize);
+ Logger.info(this, "Sending "+Long.toString(fileSize)+" bytes on
socket ...");
- this.queueManager.getQueryManager().writeMessage(msg, false);
+ queueManager.getQueryManager().writeMessage(msg, false);
Logger.info(this, "Sending file to the node");
- boolean ret = this.sendFile();
+ final boolean ret = sendFile();
Logger.info(this, "File sent (or not :p)");
connection.removeFromWriterQueue();
- this.lockOwner = false;
- this.sending = false;
+ lockOwner = false;
+ sending = false;
if(ret == true) {
- this.successful = false;
- this.fatal = true;
- this.finished = false;
- this.progress = 0;
- this.running = true;
+ successful = false;
+ fatal = true;
+ finished = false;
+ progress = 0;
+ running = true;
- if (!this.getCHKOnly)
- this.status = "Inserting";
+ if (!getCHKOnly)
+ status = "Inserting";
else
- this.status = "Computing";
+ status = "Computing";
- this.setChanged();
+ setChanged();
this.notifyObservers();
return true;
} else {
- this.successful = false;
- this.finished = true;
- this.progress = 0;
- this.running = false;
+ successful = false;
+ finished = true;
+ progress = 0;
+ running = false;
- this.status = "Unable to send the file to the node";
- this.setChanged();
+ status = "Unable to send the file to the node";
+ setChanged();
this.notifyObservers();
return false;
@@ -429,30 +428,30 @@
private boolean sendFile() {
- FCPConnection connection =
this.queueManager.getQueryManager().getConnection();
+ final FCPConnection connection =
queueManager.getQueryManager().getConnection();
- long remaining = this.fileSize;
+ long remaining = fileSize;
byte[] data = null;
FileInputStream in = null;
- if (this.localFile == null) {
- this.toTheNodeProgress = 100;
+ if (localFile == null) {
+ toTheNodeProgress = 100;
return true;
}
try {
- in = new FileInputStream(this.localFile);
- } catch(java.io.FileNotFoundException e) {
+ in = new FileInputStream(localFile);
+ } catch(final java.io.FileNotFoundException e) {
Logger.error(this, "FileNotFoundException ?! ohoh,
problems ...");
return false;
}
long startTime = System.currentTimeMillis();
- long origSize = remaining;
+ final long origSize = remaining;
while(remaining > 0) {
- int to_read = PACKET_SIZE;
+ int to_read = FCPClientPut.PACKET_SIZE;
if(remaining < to_read)
to_read = (int)remaining;
@@ -464,7 +463,7 @@
Logger.error(this, "Error while reading
file ?!");
return false;
}
- } catch(java.io.IOException e) {
+ } catch(final java.io.IOException e) {
Logger.error(this, "IOException while reading
file! proobleeem");
return false;
}
@@ -477,8 +476,8 @@
remaining = remaining - to_read;
if( System.currentTimeMillis() >= (startTime+3000) ) {
- this.toTheNodeProgress = (int) (((origSize -
remaining) * 100) / origSize);
- this.setChanged();
+ toTheNodeProgress = (int) (((origSize -
remaining) * 100) / origSize);
+ setChanged();
this.notifyObservers();
startTime = System.currentTimeMillis();
}
@@ -487,14 +486,14 @@
}
- this.toTheNodeProgress = 100;
+ toTheNodeProgress = 100;
try {
if(in.available() > 0) {
Logger.error(this, "File not send completly
?!");
return false;
}
- } catch(java.io.IOException e) {
+ } catch(final java.io.IOException e) {
/* we will suppose its ok ... */
Logger.notice(this, "available() die (hu ?)");
}
@@ -502,15 +501,15 @@
return true;
}
- public boolean stop(FCPQueueManager queueManager) {
- if(this.removeRequest()) {
- this.status = "Stopped";
- this.finished = true;
- this.successful = false;
- this.fatal= true;
- this.running = false;
+ public boolean stop(final FCPQueueManager queueManager) {
+ if(removeRequest()) {
+ status = "Stopped";
+ finished = true;
+ successful = false;
+ fatal= true;
+ running = false;
- this.setChanged();
+ setChanged();
this.notifyObservers();
return true;
@@ -519,10 +518,10 @@
return false;
}
- public void update(Observable o, Object param) {
+ public void update(final Observable o, final Object param) {
if(o == sskGenerator) {
privateKey = sskGenerator.getPrivateKey();
- publicKey = sskGenerator.getPublicKey() + "/" +
this.name;
+ publicKey = sskGenerator.getPublicKey() + "/" + name;
setChanged();
notifyObservers();
@@ -532,167 +531,167 @@
}
if(o == queueManager.getQueryManager()) {
- FCPMessage msg = (FCPMessage)param;
+ final FCPMessage msg = (FCPMessage)param;
- if(msg == null
- || msg.getValue("Identifier") == null
- ||
!msg.getValue("Identifier").equals(this.identifier))
+ if((msg == null)
+ || (msg.getValue("Identifier") == null)
+ || !msg.getValue("Identifier").equals(identifier))
return;
if("URIGenerated".equals( msg.getMessageName() )
|| "PutFetchable".equals( msg.getMessageName() )) {
- this.running = true;
- this.finished = false;
- this.successful = false;
+ running = true;
+ finished = false;
+ successful = false;
- this.publicKey = msg.getValue("URI");
+ publicKey = msg.getValue("URI");
- this.publicKey =
this.publicKey.replaceAll("freenet:", "");
+ publicKey = publicKey.replaceAll("freenet:",
"");
- Logger.info(this, msg.getMessageName()+":
"+this.publicKey);
+ Logger.info(this, msg.getMessageName()+":
"+publicKey);
- if(this.getCHKOnly) {
- this.status = "CHK";
+ if(getCHKOnly) {
+ status = "CHK";
- this.progress = 100;
- this.toTheNodeProgress = 100;
- this.running = false;
- this.finished = true;
- this.successful = true;
- this.fatal = false;
- this.sending = false;
+ progress = 100;
+ toTheNodeProgress = 100;
+ running = false;
+ finished = true;
+ successful = true;
+ fatal = false;
+ sending = false;
- this.setChanged();
+ setChanged();
this.notifyObservers();
-
this.queueManager.getQueryManager().deleteObserver(this);
+
queueManager.getQueryManager().deleteObserver(this);
return;
}
- this.status = "Inserting";
+ status = "Inserting";
- this.setChanged();
+ setChanged();
this.notifyObservers();
return;
}
if("PutSuccessful".equals( msg.getMessageName() )) {
- this.successful = true;
- this.finished = true;
- this.running = false;
+ successful = true;
+ finished = true;
+ running = false;
- this.publicKey = msg.getValue("URI");
+ publicKey = msg.getValue("URI");
- if (this.publicKey == null) {
- this.status = "[Warning]";
+ if (publicKey == null) {
+ status = "[Warning]";
Logger.warning(this, "PutSuccessful
message without URI field ?!");
- this.setChanged();
+ setChanged();
this.notifyObservers();
return;
}
- this.publicKey =
this.publicKey.replaceAll("freenet:", "");
+ publicKey = publicKey.replaceAll("freenet:",
"");
- if(this.keyType == 1)
- this.publicKey = "KSK@"+this.name+"-" +
Integer.toString(this.rev);
+ if(keyType == 1)
+ publicKey = "KSK@"+name+"-" +
Integer.toString(rev);
//if(keyType == 2)
// publicKey = publicKey + "/" + name +
"-" + Integer.toString(rev);
- this.status = "Finished";
+ status = "Finished";
- this.progress = 100;
+ progress = 100;
- this.setChanged();
+ setChanged();
this.notifyObservers();
return;
}
if("PutFailed".equals( msg.getMessageName() )) {
- this.successful = false;
- this.running = false;
- this.finished = true;
- this.fatal = true;
+ successful = false;
+ running = false;
+ finished = true;
+ fatal = true;
- this.status = "Failed
("+msg.getValue("CodeDescription")+")";
+ status = "Failed
("+msg.getValue("CodeDescription")+")";
- if(msg.getValue("Fatal") != null &&
+ if((msg.getValue("Fatal") != null) &&
msg.getValue("Fatal").equals("false")) {
- this.status = this.status + "
(non-fatal)";
- this.fatal = false;
+ status = status + " (non-fatal)";
+ fatal = false;
}
Logger.warning(this, "==== PUT FAILED ===");
Logger.warning(this, msg.toString());
- this.setChanged();
+ setChanged();
this.notifyObservers();
return;
}
if("ProtocolError".equals( msg.getMessageName() )) {
- this.successful = false;
- this.running = false;
- this.fatal = true;
- this.finished = true;
+ successful = false;
+ running = false;
+ fatal = true;
+ finished = true;
- if(this.lockOwner) {
- this.lockOwner = false;
-
this.queueManager.getQueryManager().getConnection().removeFromWriterQueue();
+ if(lockOwner) {
+ lockOwner = false;
+
queueManager.getQueryManager().getConnection().removeFromWriterQueue();
}
- this.status = "Protocol error
("+msg.getValue("CodeDescription")+")";
+ status = "Protocol error
("+msg.getValue("CodeDescription")+")";
- if(msg.getValue("Fatal") != null &&
+ if((msg.getValue("Fatal") != null) &&
msg.getValue("Fatal").equals("false")) {
- this.status = this.status + "
(non-fatal)";
- this.fatal = false;
+ status = status + " (non-fatal)";
+ fatal = false;
}
- this.setChanged();
+ setChanged();
this.notifyObservers();
return;
}
if(msg.getMessageName().equals("IdentifierCollision")) {
- this.status = "Identifier collision";
- this.start(this.queueManager); /* et hop ca
repart :) */
+ status = "Identifier collision";
+ start(queueManager); /* et hop ca repart :) */
return;
}
if(msg.getMessageName().equals("PersistentPut")) {
- this.status = "Inserting";
+ status = "Inserting";
//publicKey = msg.getValue("URI");
return;
}
if(msg.getMessageName().equals("StartedCompression")) {
- this.status = "Compressing";
+ status = "Compressing";
- this.setChanged();
+ setChanged();
this.notifyObservers();
return;
}
if(msg.getMessageName().equals("FinishedCompression")) {
- this.status = "Inserting";
+ status = "Inserting";
- if(msg.getValue("OrigSize") == null
- || msg.getValue("CompressedSize") == null) {
- this.setChanged();
+ if((msg.getValue("OrigSize") == null)
+ || (msg.getValue("CompressedSize") == null))
{
+ setChanged();
this.notifyObservers();
return;
}
- int rate = (int)( ((new
Long(msg.getValue("OrigSize"))).longValue() * 100) / (new
Long(msg.getValue("CompressedSize"))).longValue() );
+ final int rate = (int)( ((new
Long(msg.getValue("OrigSize"))).longValue() * 100) / (new
Long(msg.getValue("CompressedSize"))).longValue() );
Logger.info(this, "Compression: "+
Integer.toString(rate));
- this.setChanged();
+ setChanged();
this.notifyObservers();
return;
@@ -700,28 +699,28 @@
if(msg.getMessageName().equals("SimpleProgress")) {
- if(msg.getValue("Total") != null
- && msg.getValue("Succeeded") != null) {
+ if((msg.getValue("Total") != null)
+ && (msg.getValue("Succeeded") != null)) {
- long total = (new
Long(msg.getValue("Total"))).longValue();
+ final long total = (new
Long(msg.getValue("Total"))).longValue();
//long required = (new
Long(msg.getValue("Required"))).longValue();
- long succeeded = (new
Long(msg.getValue("Succeeded"))).longValue();
+ final long succeeded = (new
Long(msg.getValue("Succeeded"))).longValue();
- this.progress = (int)((succeeded * 99)
/ total);
+ progress = (int)((succeeded * 99) /
total);
- this.running = true;
- this.finished = false;
- this.successful = false;
+ running = true;
+ finished = false;
+ successful = false;
//if(fileSize == 0)
// fileSize = BLOCK_SIZE *
required; // NOT RELIABLE
- if (!this.getCHKOnly)
- this.status = "Inserting";
+ if (!getCHKOnly)
+ status = "Inserting";
else
- this.status = "Computing";
+ status = "Computing";
- this.setChanged();
+ setChanged();
this.notifyObservers();
}
@@ -741,47 +740,47 @@
return 2;
}
- public boolean pause(FCPQueueManager queueManager) {
- this.progress = 0;
- this.status = "Delayed";
+ public boolean pause(final FCPQueueManager queueManager) {
+ progress = 0;
+ status = "Delayed";
- this.running = false;
- this.successful = false;
- this.finished = false;
- this.fatal = true;
+ running = false;
+ successful = false;
+ finished = false;
+ fatal = true;
- this.removeRequest();
+ removeRequest();
return false;
}
public boolean removeRequest() {
- this.setChanged();
+ setChanged();
this.notifyObservers();
- if(this.sending) {
+ if(sending) {
Logger.notice(this, "Can't interrupt while sending to
the node ...");
- this.status = this.status + " (can't interrupt while
sending to the node)";
- this.setChanged();
+ status = status + " (can't interrupt while sending to
the node)";
+ setChanged();
this.notifyObservers();
return false;
}
- if(this.isRunning() || this.isFinished()) {
- FCPMessage msg = new FCPMessage();
+ if(isRunning() || isFinished()) {
+ final FCPMessage msg = new FCPMessage();
msg.setMessageName("RemovePersistentRequest");
- msg.setValue("Identifier", this.identifier);
+ msg.setValue("Identifier", identifier);
- if(this.global)
+ if(global)
msg.setValue("Global", "true");
else
msg.setValue("Global", "false");
- this.queueManager.getQueryManager().writeMessage(msg);
+ queueManager.getQueryManager().writeMessage(msg);
- this.running = false;
+ running = false;
-
this.queueManager.getQueryManager().deleteObserver(this);
+ queueManager.getQueryManager().deleteObserver(this);
} else {
Logger.notice(this, "Nothing to remove");
}
@@ -790,48 +789,48 @@
return true;
}
- public void updatePersistentRequest(boolean clientToken) {
+ public void updatePersistentRequest(final boolean clientToken) {
//if(!isPersistent())
// return;
- FCPMessage msg = new FCPMessage();
+ final FCPMessage msg = new FCPMessage();
msg.setMessageName("ModifyPersistentRequest");
- msg.setValue("Global", Boolean.toString(this.global));
- msg.setValue("Identifier", this.identifier);
- msg.setValue("PriorityClass", Integer.toString(this.priority));
+ msg.setValue("Global", Boolean.toString(global));
+ msg.setValue("Identifier", identifier);
+ msg.setValue("PriorityClass", Integer.toString(priority));
- if(clientToken && this.getPath() != null)
- msg.setValue("ClientToken", this.getPath());
+ if(clientToken && (getPath() != null))
+ msg.setValue("ClientToken", getPath());
- this.queueManager.getQueryManager().writeMessage(msg);
+ queueManager.getQueryManager().writeMessage(msg);
}
public int getThawPriority() {
- return this.priority;
+ return priority;
}
public int getFCPPriority() {
- return this.priority;
+ return priority;
}
- public void setFCPPriority(int prio) {
+ public void setFCPPriority(final int prio) {
Logger.info(this, "Setting priority to
"+Integer.toString(prio));
- this.priority = prio;
+ priority = prio;
- this.setChanged();
+ setChanged();
this.notifyObservers();
}
public String getStatus() {
- return this.status;
+ return status;
}
public int getProgression() {
- return this.progress;
+ return progress;
}
public boolean isProgressionReliable() {
@@ -852,42 +851,42 @@
public String getInsertionKey() {
String key = null;
- if(this.keyType == 0 && this.publicKey != null)
- key = this.publicKey;
- if(this.keyType == 0 && this.publicKey == null)
+ if((keyType == 0) && (publicKey != null))
+ key = publicKey;
+ if((keyType == 0) && (publicKey == null))
key = "CHK@";
- if(this.keyType == 1)
- key = "KSK@" + this.name + "-"+
Integer.toString(this.rev);
- if(this.keyType == 2)
- key = this.privateKey + this.name+"-"+this.rev;
+ if(keyType == 1)
+ key = "KSK@" + name + "-"+ Integer.toString(rev);
+ if(keyType == 2)
+ key = privateKey + name+"-"+rev;
return key;
}
public long getFileSize() {
- return this.fileSize; /* a "file length" ? why not "file size"
as usual ? */
+ return fileSize; /* a "file length" ? why not "file size" as
usual ? */
}
public String getPath() {
- if(this.localFile != null)
- return this.localFile.getPath();
+ if(localFile != null)
+ return localFile.getPath();
else
return null;
}
public String getFilename() {
- if(this.localFile != null)
- return this.localFile.getName();
+ if(localFile != null)
+ return localFile.getName();
else
- return this.name;
+ return name;
}
public int getAttempt() {
- return this.attempt;
+ return attempt;
}
- public void setAttempt(int x) {
- this.attempt = x;
+ public void setAttempt(final int x) {
+ attempt = x;
}
public int getMaxAttempt() {
@@ -895,89 +894,89 @@
}
public boolean isRunning() {
- return this.running;
+ return running;
}
public boolean isFinished() {
- return this.finished;
+ return finished;
}
public boolean isSuccessful() {
- return this.successful;
+ return successful;
}
public boolean isFatallyFailed() {
- return ((!this.successful) && this.fatal);
+ return ((!successful) && fatal);
}
public HashMap getParameters() {
- HashMap result = new HashMap();
+ final HashMap result = new HashMap();
- result.put("localFile", this.localFile.getPath());
- result.put("keyType", Integer.toString(this.keyType));
- result.put("Revision", Integer.toString(this.rev));
- result.put("Name", this.name);
- if(this.privateKey != null)
- result.put("privateKey", this.privateKey);
- if(this.publicKey != null)
- result.put("publicKey", this.publicKey);
- result.put("priority", Integer.toString(this.priority));
- result.put("global", Boolean.toString(this.global));
- result.put("persistence", Integer.toString(this.persistence));
+ result.put("localFile", localFile.getPath());
+ result.put("keyType", Integer.toString(keyType));
+ result.put("Revision", Integer.toString(rev));
+ result.put("Name", name);
+ if(privateKey != null)
+ result.put("privateKey", privateKey);
+ if(publicKey != null)
+ result.put("publicKey", publicKey);
+ result.put("priority", Integer.toString(priority));
+ result.put("global", Boolean.toString(global));
+ result.put("persistence", Integer.toString(persistence));
- result.put("progress", Integer.toString(this.progress));
+ result.put("progress", Integer.toString(progress));
- result.put("status", this.status);
+ result.put("status", status);
- result.put("attempt", Integer.toString(this.attempt));
- if(this.identifier != null)
- result.put("identifier", this.identifier);
- result.put("running", Boolean.toString(this.running));
- result.put("successful", Boolean.toString(this.successful));
- result.put("finished", Boolean.toString(this.finished));
+ result.put("attempt", Integer.toString(attempt));
+ if(identifier != null)
+ result.put("identifier", identifier);
+ result.put("running", Boolean.toString(running));
+ result.put("successful", Boolean.toString(successful));
+ result.put("finished", Boolean.toString(finished));
return result;
}
- public boolean setParameters(HashMap parameters) {
+ public boolean setParameters(final HashMap parameters) {
- this.localFile = new File((String)parameters.get("localFile"));
+ localFile = new File((String)parameters.get("localFile"));
- this.fileSize = this.localFile.length();
+ fileSize = localFile.length();
- this.keyType =
Integer.parseInt((String)parameters.get("keyType"));
- this.rev = Integer.parseInt((String)parameters.get("Revision"));
- this.name = (String)parameters.get("name");
+ keyType = Integer.parseInt((String)parameters.get("keyType"));
+ rev = Integer.parseInt((String)parameters.get("Revision"));
+ name = (String)parameters.get("name");
- this.privateKey = (String)parameters.get("privateKey");
- if(this.privateKey == null || this.privateKey.equals(""))
- this.privateKey = null;
+ privateKey = (String)parameters.get("privateKey");
+ if((privateKey == null) || privateKey.equals(""))
+ privateKey = null;
- this.publicKey = (String)parameters.get("publicKey");
- if(this.privateKey == null || this.publicKey == null ||
this.publicKey.equals(""))
- this.publicKey = null;
+ publicKey = (String)parameters.get("publicKey");
+ if((privateKey == null) || (publicKey == null) ||
publicKey.equals(""))
+ publicKey = null;
- this.priority =
Integer.parseInt((String)parameters.get("priority"));
+ priority = Integer.parseInt((String)parameters.get("priority"));
- this.global =
Boolean.valueOf((String)parameters.get("global")).booleanValue();
+ global =
Boolean.valueOf((String)parameters.get("global")).booleanValue();
- this.persistence =
Integer.parseInt((String)parameters.get("persistence"));
- this.progress =
Integer.parseInt(((String)parameters.get("progress")));
- this.status = (String)parameters.get("status");
- this.attempt =
Integer.parseInt((String)parameters.get("attempt"));
+ persistence =
Integer.parseInt((String)parameters.get("persistence"));
+ progress =
Integer.parseInt(((String)parameters.get("progress")));
+ status = (String)parameters.get("status");
+ attempt = Integer.parseInt((String)parameters.get("attempt"));
- this.identifier = (String)parameters.get("identifier");
- if(this.identifier == null || this.identifier.equals(""))
- this.identifier = null;
+ identifier = (String)parameters.get("identifier");
+ if((identifier == null) || identifier.equals(""))
+ identifier = null;
- this.running =
Boolean.valueOf((String)parameters.get("running")).booleanValue();
- this.successful =
Boolean.valueOf((String)parameters.get("successful")).booleanValue();
- this.finished =
Boolean.valueOf((String)parameters.get("finished")).booleanValue();
+ running =
Boolean.valueOf((String)parameters.get("running")).booleanValue();
+ successful =
Boolean.valueOf((String)parameters.get("successful")).booleanValue();
+ finished =
Boolean.valueOf((String)parameters.get("finished")).booleanValue();
- if(this.persistence == 2 && !this.isFinished()) {
- this.progress = 0;
- this.status = "Waiting";
+ if((persistence == 2) && !isFinished()) {
+ progress = 0;
+ status = "Waiting";
}
return true;
@@ -985,52 +984,49 @@
public boolean isPersistent() {
- return this.persistence < 2;
+ return persistence < 2;
}
public boolean isGlobal() {
- return this.global;
+ return global;
}
public String getIdentifier() {
- return this.identifier;
+ return identifier;
}
public String getPrivateKey() {
- return this.privateKey;
+ return privateKey;
}
public String getPublicKey() {
- return this.publicKey;
+ return publicKey;
}
/**
* Do nothing.
*/
- public boolean saveFileTo(String dir) {
+ public boolean saveFileTo(final String dir) {
return false;
}
public int getTransferWithTheNodeProgression() {
- return this.toTheNodeProgress;
+ return toTheNodeProgress;
}
public HashMap getMetadatas() {
- return this.metadatas;
+ return metadatas;
}
- public void setMetadata(String name, String val) {
- if(this.metadatas == null)
- this.metadatas = new HashMap();
-
+ public void setMetadata(final String name, final String val) {
if(val == null)
- this.metadatas.remove(name);
+ metadatas.remove(name);
else
- this.metadatas.put(name, val);
+ metadatas.put(name, val);
}
- public String getMetadata(String name) {
- return (String)this.metadatas.get(name);
+ public String getMetadata(final String name) {
+ return (String)metadatas.get(name);
}
}
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,12 +1,11 @@
package thaw.fcp;
-import java.net.Socket;
+import java.io.BufferedInputStream;
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.BufferedInputStream;
+import java.net.Socket;
import java.util.Observable;
-/* Should be the only real dep of the FCP package */
import thaw.core.Logger;
@@ -26,7 +25,7 @@
private final static boolean DEBUG_MODE = false;
private final static int MAX_RECV = 1024;
- private byte[] recvBytes = new byte[MAX_RECV]; /* global to avoid each
time free() / malloc() */
+ private final byte[] recvBytes = new byte[FCPConnection.MAX_RECV]; /*
global to avoid each time free() / malloc() */
private FCPBufferedStream bufferedOut = null;
private int maxUploadSpeed = 0;
@@ -55,12 +54,12 @@
* @param maxUploadSpeed in KB: -1 means no limit
* @param duplicationAllowed FCPClientGet and FCPClientPut will be
allowed to open a separate socket to transfer the files
*/
- public FCPConnection(String nodeAddress,
- int port,
+ public FCPConnection(final String nodeAddress,
+ final int port,
int maxUploadSpeed,
- boolean duplicationAllowed)
+ final boolean duplicationAllowed)
{
- if(DEBUG_MODE) {
+ if(FCPConnection.DEBUG_MODE) {
Logger.notice(this, "DEBUG_MODE ACTIVATED");
}
@@ -68,51 +67,51 @@
maxUploadSpeed = -1;
- this.setNodeAddress(nodeAddress);
- this.setNodePort(port);
- this.setMaxUploadSpeed(maxUploadSpeed);
- this.setDuplicationAllowed(duplicationAllowed);
+ setNodeAddress(nodeAddress);
+ setNodePort(port);
+ setMaxUploadSpeed(maxUploadSpeed);
+ setDuplicationAllowed(duplicationAllowed);
writersWaiting = 0;
}
- public void setNodeAddress(String nodeAddress) {
+ public void setNodeAddress(final String nodeAddress) {
this.nodeAddress = nodeAddress;
}
- public void setNodePort(int port) {
+ public void setNodePort(final int port) {
this.port = port;
}
- public void setMaxUploadSpeed(int max) {
- this.maxUploadSpeed = max;
+ public void setMaxUploadSpeed(final int max) {
+ maxUploadSpeed = max;
}
- public void setDuplicationAllowed(boolean allowed) {
- this.duplicationAllowed = allowed;
+ public void setDuplicationAllowed(final boolean allowed) {
+ duplicationAllowed = allowed;
}
public void disconnect() {
try {
- if(this.isConnected())
- this.socket.close();
+ if(isConnected())
+ socket.close();
else {
Logger.info(this, "Disconnect(): Already
disconnected.");
}
- } catch(java.io.IOException e) {
+ } catch(final java.io.IOException e) {
Logger.warning(this, "Unable to close cleanly the
connection : "+e.toString() +" ; "+e.getMessage());
}
- this.socket = null;
- this.in = null;
- this.out = null;
- if(this.bufferedOut != null) {
- this.bufferedOut.stopSender();
- this.bufferedOut = null;
+ socket = null;
+ in = null;
+ out = null;
+ if(bufferedOut != null) {
+ bufferedOut.stopSender();
+ bufferedOut = null;
}
- this.setChanged();
+ setChanged();
this.notifyObservers();
}
@@ -122,69 +121,69 @@
* @return true if successful
*/
public boolean connect() {
- if(this.nodeAddress == null || this.port == 0) {
+ if((nodeAddress == null) || (port == 0)) {
Logger.warning(this, "Address or port not defined !
Unable to connect\n");
return false;
}
- Logger.info(this, "Connection to "+this.nodeAddress+":"+
Integer.toString(this.port) +"...");
+ Logger.info(this, "Connection to "+nodeAddress+":"+
Integer.toString(port) +"...");
- if(this.socket != null && !this.socket.isClosed())
- this.disconnect();
+ if((socket != null) && !socket.isClosed())
+ disconnect();
try {
- this.socket = new Socket(this.nodeAddress, this.port);
+ socket = new Socket(nodeAddress, port);
- } catch(java.net.UnknownHostException e) {
- Logger.error(this, "Error while trying to connect to
"+this.nodeAddress+":"+this.port+" : "+
+ } catch(final java.net.UnknownHostException e) {
+ Logger.error(this, "Error while trying to connect to
"+nodeAddress+":"+port+" : "+
e.toString());
- this.socket = null;
+ socket = null;
return false;
- } catch(java.io.IOException e) {
- Logger.error(this, "Error while trying to connect to
"+this.nodeAddress+":"+this.port+" : "+
+ } catch(final java.io.IOException e) {
+ Logger.error(this, "Error while trying to connect to
"+nodeAddress+":"+port+" : "+
e.toString() + " ; "+e.getMessage());
- this.socket = null;
+ socket = null;
return false;
}
- if(!this.socket.isConnected()) {
+ if(!socket.isConnected()) {
Logger.warning(this, "Unable to connect, but no
exception ?! WTF ?\n");
Logger.warning(this, "Will try to continue ...\n");
}
try {
- this.in = this.socket.getInputStream();
- this.out = this.socket.getOutputStream();
- } catch(java.io.IOException e) {
+ in = socket.getInputStream();
+ out = socket.getOutputStream();
+ } catch(final java.io.IOException e) {
Logger.error(this, "Socket and connection established,
but unable to get in/output streams ?! : "+e.toString()+ " ; "+e.getMessage() );
return false;
}
- this.reader = new BufferedInputStream(this.in);
- this.bufferedOut = new FCPBufferedStream(this,
this.maxUploadSpeed);
- this.bufferedOut.startSender();
+ reader = new BufferedInputStream(in);
+ bufferedOut = new FCPBufferedStream(this, maxUploadSpeed);
+ bufferedOut.startSender();
- this.rawBytesWaiting = 0;
+ rawBytesWaiting = 0;
writersWaiting = 0;
- this.lastWrite = 0;
+ lastWrite = 0;
Logger.info(this, "Connected");
- this.setChanged();
+ setChanged();
this.notifyObservers();
return true;
}
public boolean isOutputBufferEmpty() {
- return this.bufferedOut.isOutputBufferEmpty();
+ return bufferedOut.isOutputBufferEmpty();
}
public boolean isConnected() {
- if(this.socket == null)
+ if(socket == null)
return false;
else
- return this.socket.isConnected();
+ return socket.isConnected();
}
@@ -192,12 +191,12 @@
/**
* Doesn't check the lock state ! You have to manage it yourself.
*/
- public boolean rawWrite(byte[] data) {
- if(this.bufferedOut != null)
- return this.bufferedOut.write(data);
+ public boolean rawWrite(final byte[] data) {
+ if(bufferedOut != null)
+ return bufferedOut.write(data);
else {
Logger.notice(this, "rawWrite(), bufferedOut == null ?
Socket closed ?");
- this.disconnect();
+ disconnect();
return false;
}
}
@@ -205,16 +204,16 @@
/**
* Should be call by FCPBufferedStream. Not you.
*/
- public boolean realRawWrite(byte[] data) {
- if(this.out != null && this.socket != null &&
this.socket.isConnected()) {
+ public boolean realRawWrite(final byte[] data) {
+ if((out != null) && (socket != null) && socket.isConnected()) {
try {
- this.lastWrite = System.currentTimeMillis();
+ lastWrite = System.currentTimeMillis();
- this.out.write(data);
- this.out.flush();
- } catch(java.io.IOException e) {
+ out.write(data);
+ out.flush();
+ } catch(final java.io.IOException e) {
Logger.warning(this, "Unable to write() on the
socket ?! : "+ e.toString()+ " ; "+e.getMessage());
- this.disconnect();
+ disconnect();
return false;
}
} else {
@@ -235,7 +234,7 @@
if (writersWaiting > 1) {
try {
monitor.wait();
- } catch(java.lang.InterruptedException e) {
+ } catch(final java.lang.InterruptedException e)
{
Logger.warning(this, "Interrupted while
waiting ?!");
}
}
@@ -256,17 +255,17 @@
}
public boolean isWriting() {
- if( !this.isConnected() )
+ if( !isConnected() )
return false;
- return ( writersWaiting > 0 || ((System.currentTimeMillis() -
this.lastWrite) < 300) );
+ return ( (writersWaiting > 0) || ((System.currentTimeMillis() -
lastWrite) < 300) );
}
- public boolean write(String toWrite) {
+ public boolean write(final String toWrite) {
return this.write(toWrite, true);
}
- public boolean write(String toWrite, boolean checkLock) {
+ public boolean write(final String toWrite, final boolean checkLock) {
if (checkLock) {
addToWriterQueue();
@@ -276,10 +275,10 @@
Logger.asIt(this, toWrite);
- if(this.out != null && this.socket != null &&
this.socket.isConnected()) {
+ if((out != null) && (socket != null) && socket.isConnected()) {
try {
bufferedOut.write(toWrite.getBytes("UTF-8"));
- } catch(java.io.UnsupportedEncodingException e) {
+ } catch(final java.io.UnsupportedEncodingException e) {
Logger.error(this, "UNSUPPORTED ENCODING
EXCEPTION : UTF-8");
bufferedOut.write(toWrite.getBytes());
}
@@ -299,14 +298,14 @@
* For security : FCPQueryManager uses this function to tells
FCPConnection
* how many raw bytes are waited (to avoid to *serious* problems).
*/
- public void setRawDataWaiting(long waiting) {
- this.rawBytesWaiting = waiting;
+ public void setRawDataWaiting(final long waiting) {
+ rawBytesWaiting = waiting;
}
/**
* @see #read(int, byte[])
*/
- public int read(byte[] buf) {
+ public int read(final byte[] buf) {
return read(buf.length, buf);
}
@@ -314,22 +313,22 @@
* @param lng Obsolete.
* @return -1 Disconnection.
*/
- public int read(int lng, byte[] buf) {
+ public int read(final int lng, final byte[] buf) {
int rdBytes = 0;
try {
- rdBytes = this.reader.read(buf);
+ rdBytes = reader.read(buf);
if(rdBytes < 0) {
Logger.error(this, "Error while reading on the
socket => disconnection");
- this.disconnect();
+ disconnect();
}
- this.rawBytesWaiting = this.rawBytesWaiting - rdBytes;
+ rawBytesWaiting = rawBytesWaiting - rdBytes;
//Logger.verbose(this, "Remaining: "+rawBytesWaiting);
return rdBytes;
- } catch(java.io.IOException e) {
+ } catch(final java.io.IOException e) {
Logger.error(this, "IOException while reading raw bytes
on socket => disconnection:");
Logger.error(this, " =========");
Logger.error(this, e.getMessage() + ":");
@@ -338,7 +337,7 @@
Logger.error(this, e.getMessage() );
Logger.error(this, " =========");
- this.disconnect();
+ disconnect();
return -2; /* -1 can mean eof */
}
@@ -351,20 +350,20 @@
public String readLine() {
/* SECURITY */
- if(this.rawBytesWaiting > 0) {
+ if(rawBytesWaiting > 0) {
Logger.error(this, "RAW BYTES STILL WAITING ON SOCKET.
THIS IS ABNORMAL.");
Logger.error(this, "Will drop them.");
- while(this.rawBytesWaiting > 0) {
+ while(rawBytesWaiting > 0) {
int to_read = 1024;
- if(to_read > this.rawBytesWaiting)
- to_read = (int)this.rawBytesWaiting;
+ if(to_read > rawBytesWaiting)
+ to_read = (int)rawBytesWaiting;
- byte[] read = new byte[to_read];
+ final byte[] read = new byte[to_read];
this.read(to_read, read);
- this.rawBytesWaiting = this.rawBytesWaiting -
to_read;
+ rawBytesWaiting = rawBytesWaiting - to_read;
}
}
@@ -373,26 +372,26 @@
String result;
- if(this.in != null && this.reader != null && this.socket !=
null && this.socket.isConnected()) {
+ if((in != null) && (reader != null) && (socket != null) &&
socket.isConnected()) {
try {
- for(int i = 0; i < this.recvBytes.length ; i++)
- this.recvBytes[i] = 0;
+ for(int i = 0; i < recvBytes.length ; i++)
+ recvBytes[i] = 0;
result = "";
int c = 0;
int i = 0; /* position in recvBytes */
- while(c != '\n' && i < this.recvBytes.length) {
- c = this.reader.read();
+ while((c != '\n') && (i < recvBytes.length)) {
+ c = reader.read();
if(c == -1) {
- if(this.isConnected())
+ if(isConnected())
Logger.error(this,
"Unable to read but still connected");
else
Logger.notice(this,
"Disconnected");
- this.disconnect(); /* will warn
everybody */
+ disconnect(); /* will warn
everybody */
return null;
}
@@ -402,13 +401,13 @@
//result = result + new String(new
byte[] { (byte)c });
- this.recvBytes[i] = (byte)c;
+ recvBytes[i] = (byte)c;
i++;
}
- result = new String(this.recvBytes, 0, i,
"UTF-8");
+ result = new String(recvBytes, 0, i, "UTF-8");
- if(DEBUG_MODE) {
+ if(FCPConnection.DEBUG_MODE) {
if(result.matches("[\\-\\
\\?.a-zA-Z0-9\\,~%@/_=\\[\\]\\(\\)]*"))
Logger.asIt(this, "Thaw <<<
Node : "+result);
else
@@ -418,13 +417,13 @@
return result;
- } catch (java.io.IOException e) {
- if(this.isConnected())
+ } catch (final java.io.IOException e) {
+ if(isConnected())
Logger.error(this, "IOException while
reading but still connected, wtf? : "+e.toString()+ " ; "+e.getMessage() );
else
Logger.notice(this, "IOException.
Disconnected. : "+e.toString() + " ; "+e.getMessage());
- this.disconnect();
+ disconnect();
return null;
}
@@ -442,14 +441,14 @@
* The duplicate socket is just connected but not initialized
(ClientHello, etc).
*/
public FCPConnection duplicate() {
- if (!this.duplicationAllowed)
+ if (!duplicationAllowed)
return this;
Logger.info(this, "Duplicating connection to the node ...");
FCPConnection newConnection;
- newConnection = new FCPConnection(this.nodeAddress, this.port,
-1, this.duplicationAllowed); /* upload limit is useless here, since we can't
do a global limit on all the connections */
+ newConnection = new FCPConnection(nodeAddress, port, -1,
duplicationAllowed); /* upload limit is useless here, since we can't do a
global limit on all the connections */
if (!newConnection.connect()) {
Logger.warning(this, "Unable to duplicate socket !");
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPGenerateSSK.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPGenerateSSK.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPGenerateSSK.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,7 +1,7 @@
package thaw.fcp;
+import java.util.Observable;
import java.util.Observer;
-import java.util.Observable;
import thaw.core.Logger;
@@ -18,16 +18,16 @@
}
- public boolean start(FCPQueueManager queueManager) {
+ public boolean start(final FCPQueueManager queueManager) {
this.queueManager = queueManager;
queueManager.getQueryManager().addObserver(this);
- this.identifier = queueManager.getAnID();
+ identifier = queueManager.getAnID();
- FCPMessage msg = new FCPMessage();
+ final FCPMessage msg = new FCPMessage();
msg.setMessageName("GenerateSSK");
- msg.setValue("Identifier", this.identifier);
+ msg.setValue("Identifier", identifier);
queueManager.getQueryManager().writeMessage(msg);
@@ -35,26 +35,26 @@
}
- public void update (Observable o, Object param) {
- FCPMessage msg = (FCPMessage)param;
+ public void update (final Observable o, final Object param) {
+ final FCPMessage msg = (FCPMessage)param;
- if(msg.getValue("Identifier") == null
- || !msg.getValue("Identifier").equals(this.identifier))
+ if((msg.getValue("Identifier") == null)
+ || !msg.getValue("Identifier").equals(identifier))
return;
if("SSKKeypair".equals( msg.getMessageName() )) {
Logger.debug(this, "SSKKeypair !");
- this.privateKey = msg.getValue("InsertURI");
- this.publicKey = msg.getValue("RequestURI");
+ privateKey = msg.getValue("InsertURI");
+ publicKey = msg.getValue("RequestURI");
- this.privateKey =
this.privateKey.replaceFirst("freenet:", "");
- this.publicKey =
this.publicKey.replaceFirst("freenet:", "");
+ privateKey = privateKey.replaceFirst("freenet:", "");
+ publicKey = publicKey.replaceFirst("freenet:", "");
- this.setChanged();
+ setChanged();
this.notifyObservers();
- this.stop(this.queueManager);
+ stop(queueManager);
return;
}
@@ -63,7 +63,7 @@
}
- public boolean stop(FCPQueueManager queueManager) {
+ public boolean stop(final FCPQueueManager queueManager) {
queueManager.getQueryManager().deleteObserver(this);
return true;
@@ -78,14 +78,14 @@
* @return privateKey without the "freenet:" prefix.
*/
public String getPrivateKey() {
- return this.privateKey;
+ return privateKey;
}
/**
* @return publicKey without the "freenet:" prefix.
*/
public String getPublicKey() {
- return this.publicKey;
+ return publicKey;
}
}
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPListPersistentRequests.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPListPersistentRequests.java 2006-12-06
18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPListPersistentRequests.java 2006-12-06
18:21:00 UTC (rev 11273)
@@ -6,8 +6,8 @@
public FCPListPersistentRequests() { }
- public boolean start(FCPQueueManager queueManager) {
- FCPMessage newMessage = new FCPMessage();
+ public boolean start(final FCPQueueManager queueManager) {
+ final FCPMessage newMessage = new FCPMessage();
newMessage.setMessageName("ListPersistentRequests");
@@ -16,7 +16,7 @@
return true;
}
- public boolean stop(FCPQueueManager queueManager) {
+ public boolean stop(final FCPQueueManager queueManager) {
return true;
}
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPMessage.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPMessage.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPMessage.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,7 +1,7 @@
package thaw.fcp;
+import java.util.Enumeration;
import java.util.Hashtable;
-import java.util.Enumeration;
import thaw.core.Logger;
@@ -19,31 +19,31 @@
public FCPMessage() {
- this.fields = new Hashtable();
+ fields = new Hashtable();
}
/**
* As you can't fetch the value returns by loadFromRawMessage(), this
constructor is not recommanded.
*/
- public FCPMessage(String rawMessage) {
+ public FCPMessage(final String rawMessage) {
this();
- this.loadFromRawMessage(rawMessage);
+ loadFromRawMessage(rawMessage);
}
/**
* Raw message does not need to finish by "EndMessage" / "Data".
*/
- public boolean loadFromRawMessage(String rawMessage) {
+ public boolean loadFromRawMessage(final String rawMessage) {
int i;
- String[] lines = rawMessage.split("\n");
+ final String[] lines = rawMessage.split("\n");
for(i = 0 ; "".equals( lines[i] );) {
i++;
}
- this.setMessageName(lines[i]);
+ setMessageName(lines[i]);
Logger.info(this, "Message (Node >> Thaw): "+lines[i]);
for(i++; i < lines.length ; i++) {
@@ -52,18 +52,18 @@
if("".equals( lines[i] ) || !(lines[i].indexOf("=") >=
0))
continue;
- String[] affectation = lines[i].split("=");
+ final String[] affectation = lines[i].split("=");
if(affectation.length < 2) {
Logger.warning(this, "Malformed message");
continue;
}
- this.setValue(affectation[0], affectation[1]);
+ setValue(affectation[0], affectation[1]);
}
- if("ProtocolError".equals( this.getMessageName() )) {
- Logger.notice(this, "PROTOCOL ERROR:"+this.toString());
+ if("ProtocolError".equals( getMessageName() )) {
+ Logger.notice(this, "PROTOCOL ERROR:"+toString());
}
return true;
@@ -71,11 +71,11 @@
public String getMessageName() {
- return this.messageName;
+ return messageName;
}
- public void setMessageName(String name) {
- if(name == null || "".equals( name )) {
+ public void setMessageName(final String name) {
+ if((name == null) || "".equals( name )) {
Logger.notice(this, "Setting name to empty ? weird");
}
@@ -83,24 +83,24 @@
Logger.notice(this, "Name shouldn't contain '\n'");
}
- this.messageName = name;
+ messageName = name;
}
- public String getValue(String field) {
- return ((String)this.fields.get(field));
+ public String getValue(final String field) {
+ return ((String)fields.get(field));
}
- public void setValue(String field, String value) {
+ public void setValue(final String field, final String value) {
if("DataLength".equals( field )) {
- this.setAmountOfDataWaiting((new
Long(value)).longValue());
+ setAmountOfDataWaiting((new Long(value)).longValue());
}
if(value == null) {
- this.fields.remove(field);
+ fields.remove(field);
return;
}
- this.fields.put(field, value);
+ fields.put(field, value);
}
@@ -109,16 +109,16 @@
* @return if > 0 : Data are still waiting (except if the message name
is "PersistentPut" !), if == 0 : No data waiting, if < 0 : These data are now
unavailable.
*/
public long getAmountOfDataWaiting() {
- return this.dataWaiting;
+ return dataWaiting;
}
- public void setAmountOfDataWaiting(long amount) {
+ public void setAmountOfDataWaiting(final long amount) {
if(amount == 0) {
Logger.warning(this, "Setting amount of data waiting to
0 ?! Abnormal !");
}
- this.dataWaiting = amount;
+ dataWaiting = amount;
}
@@ -130,20 +130,20 @@
public String toString() {
String result = "";
- Logger.info(this, "Message (Node << Thaw):
"+this.getMessageName());
+ Logger.info(this, "Message (Node << Thaw): "+getMessageName());
- result = result + this.getMessageName() + "\n";
+ result = result + getMessageName() + "\n";
- for(Enumeration fieldNames = this.fields.keys() ;
fieldNames.hasMoreElements();) {
- String fieldName = ((String)fieldNames.nextElement());
+ for(final Enumeration fieldNames = fields.keys() ;
fieldNames.hasMoreElements();) {
+ final String fieldName =
((String)fieldNames.nextElement());
- result = result + fieldName + "=" +
this.getValue(fieldName) + "\n";
+ result = result + fieldName + "=" + getValue(fieldName)
+ "\n";
}
- if(this.getAmountOfDataWaiting() == 0)
+ if(getAmountOfDataWaiting() == 0)
result = result + "EndMessage\n";
else {
- result = result + "DataLength="+ (new
Long(this.getAmountOfDataWaiting())).toString() + "\n";
+ result = result + "DataLength="+ (new
Long(getAmountOfDataWaiting())).toString() + "\n";
result = result + "Data\n";
}
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPQueryManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPQueryManager.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPQueryManager.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -16,17 +16,17 @@
private FCPMessage latestMessage;
- public FCPQueryManager(FCPConnection connection) {
- this.me = null;
- this.latestMessage = null;
- this.setConnection(connection);
+ public FCPQueryManager(final FCPConnection connection) {
+ me = null;
+ latestMessage = null;
+ setConnection(connection);
}
/**
* If you call yourself this function, you will probably have to call
* resetQueue() of FCPQueueManager.
*/
- public void setConnection(FCPConnection connection) {
+ public void setConnection(final FCPConnection connection) {
this.connection = connection;
}
@@ -34,15 +34,15 @@
* Try to not directly call functions from FCPConnection.
*/
public FCPConnection getConnection() {
- return this.connection;
+ return connection;
}
- public boolean writeMessage(FCPMessage message) {
- return this.connection.write(message.toString());
+ public boolean writeMessage(final FCPMessage message) {
+ return connection.write(message.toString());
}
- public boolean writeMessage(FCPMessage message, boolean checkLock) {
- return this.connection.write(message.toString(), checkLock);
+ public boolean writeMessage(final FCPMessage message, final boolean
checkLock) {
+ return connection.write(message.toString(), checkLock);
}
@@ -52,7 +52,7 @@
*/
public FCPMessage readMessage() {
String whatsUp = new String("");
- FCPMessage result = new FCPMessage();
+ final FCPMessage result = new FCPMessage();
boolean withData;
withData = false;
@@ -61,7 +61,7 @@
String read = new String("");
- read = this.connection.readLine();
+ read = connection.readLine();
if(read == null) {
Logger.notice(this, "readLine() returned null
=> disconnected ?");
@@ -85,8 +85,8 @@
result.loadFromRawMessage(whatsUp);
if(withData) {
- long dataWaiting = (new
Long(result.getValue("DataLength"))).longValue();
- this.connection.setRawDataWaiting(dataWaiting);
+ final long dataWaiting = (new
Long(result.getValue("DataLength"))).longValue();
+ connection.setRawDataWaiting(dataWaiting);
Logger.info(this, "Achtung data: "+(new
Long(dataWaiting)).toString());
}
@@ -100,15 +100,15 @@
public void run() {
while(true) {
- this.latestMessage = this.readMessage();
+ latestMessage = readMessage();
Logger.verbose(this, "Message received. Notifying
observers");
- if(this.latestMessage != null) {
+ if(latestMessage != null) {
try {
- this.setChanged();
-
this.notifyObservers(this.latestMessage);
- } catch(Exception e) {
+ setChanged();
+ this.notifyObservers(latestMessage);
+ } catch(final Exception e) {
/* it's really bad ... because if data
are waiting on the socket ... */
Logger.error(this, "EXCEPTION FROM ONE
OF LISTENER : "+e.toString());
Logger.error(this, "ERROR :
"+e.getMessage());
@@ -127,9 +127,9 @@
* Create the thread listening for incoming message.
*/
public void startListening() {
- if(this.connection.isConnected()) {
- this.me = new Thread(this);
- this.me.start();
+ if(connection.isConnected()) {
+ me = new Thread(this);
+ me.start();
} else {
Logger.warning(this, "Not connected, so not listening
on the socket");
}
@@ -142,20 +142,20 @@
* A FCPClientHello is sent with the given id.
* @return This object if it cannot duplicate FCPConnection
*/
- public FCPQueryManager duplicate(String connectionId) {
+ public FCPQueryManager duplicate(final String connectionId) {
FCPConnection newConnection;
FCPQueryManager queryManager;
- newConnection = this.connection.duplicate();
+ newConnection = connection.duplicate();
- if (newConnection == this.connection)
+ if (newConnection == connection)
return this;
queryManager = new FCPQueryManager(newConnection);
queryManager.startListening();
- FCPClientHello clientHello = new FCPClientHello(queryManager,
connectionId);
+ final FCPClientHello clientHello = new
FCPClientHello(queryManager, connectionId);
if (!clientHello.start(null)) {
Logger.warning(this, "ID already used ?! Using initial
socket ...");
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,7 +1,7 @@
package thaw.fcp;
+import java.util.Observable;
import java.util.Observer;
-import java.util.Observable;
import thaw.core.Logger;
@@ -14,18 +14,18 @@
private FCPQueueManager queueManager;
private String thawId;
- public FCPQueueLoader(String thawId) {
+ public FCPQueueLoader(final String thawId) {
this.thawId = thawId;
}
- public boolean start(FCPQueueManager queueManager) {
+ public boolean start(final FCPQueueManager queueManager) {
this.queueManager = queueManager;
queueManager.getQueryManager().addObserver(this);
- FCPListPersistentRequests listPersistent = new
FCPListPersistentRequests();
- boolean ret = listPersistent.start(queueManager);
+ final FCPListPersistentRequests listPersistent = new
FCPListPersistentRequests();
+ final boolean ret = listPersistent.start(queueManager);
if(ret)
queueManager.getQueryManager().getConnection().addToWriterQueue();
@@ -34,7 +34,7 @@
}
- public boolean stop(FCPQueueManager queueManager) {
+ public boolean stop(final FCPQueueManager queueManager) {
queueManager.getQueryManager().deleteObserver(this);
return true;
}
@@ -44,8 +44,8 @@
}
- public void update(Observable o, Object param) {
- FCPMessage msg = (FCPMessage)param;
+ public void update(final Observable o, final Object param) {
+ final FCPMessage msg = (FCPMessage)param;
if("PersistentGet".equals( msg.getMessageName() )) {
Logger.info(this, "Resuming from PersistentGet");
@@ -62,20 +62,20 @@
String destinationDir = null;
- if(msg.getValue("Identifier").startsWith(this.thawId))
+ if(msg.getValue("Identifier").startsWith(thawId))
destinationDir = msg.getValue("ClientToken");
- int priority =
Integer.parseInt(msg.getValue("PriorityClass"));
+ final int priority =
Integer.parseInt(msg.getValue("PriorityClass"));
- FCPClientGet clientGet = new
FCPClientGet(msg.getValue("Identifier"),
+ final FCPClientGet clientGet = new
FCPClientGet(msg.getValue("Identifier"),
msg.getValue("URI"), // key
priority,
persistence, global,
destinationDir, "Fetching", 0,
- -1,
this.queueManager);
+ -1,
queueManager);
-
if(this.queueManager.addQueryToTheRunningQueue(clientGet, false))
-
this.queueManager.getQueryManager().addObserver(clientGet);
+ if(queueManager.addQueryToTheRunningQueue(clientGet,
false))
+
queueManager.getQueryManager().addObserver(clientGet);
else
Logger.info(this, "Already in the running
queue");
@@ -87,7 +87,7 @@
int persistence = 0;
- if(msg.getValue("PersistenceType") != null
+ if((msg.getValue("PersistenceType") != null)
&& msg.getValue("PersistenceType").equals("reboot"))
persistence = 1;
@@ -96,7 +96,7 @@
if("false".equals( msg.getValue("Global") ))
global = false;
- int priority =
Integer.parseInt(msg.getValue("PriorityClass"));
+ final int priority =
Integer.parseInt(msg.getValue("PriorityClass"));
long fileSize = 0;
@@ -105,19 +105,19 @@
String filePath=null;
- if(msg.getValue("Identifier").startsWith(this.thawId))
+ if(msg.getValue("Identifier").startsWith(thawId))
filePath = msg.getValue("ClientToken");
- FCPClientPut clientPut = new
FCPClientPut(msg.getValue("Identifier"),
+ final FCPClientPut clientPut = new
FCPClientPut(msg.getValue("Identifier"),
msg.getValue("URI"), // key
priority,
persistence, global,
filePath,
msg.getValue("TargetFilename"),
"Inserting",
0, fileSize,
-
this.queueManager);
+ queueManager);
-
if(this.queueManager.addQueryToTheRunningQueue(clientPut, false))
-
this.queueManager.getQueryManager().addObserver(clientPut);
+ if(queueManager.addQueryToTheRunningQueue(clientPut,
false))
+
queueManager.getQueryManager().addObserver(clientPut);
else
Logger.info(this, "Already in the running
queue");
@@ -126,8 +126,8 @@
if("EndListPersistentRequests".equals( msg.getMessageName() )) {
Logger.info(this, "End Of ListPersistentRequests.");
-
this.queueManager.getQueryManager().getConnection().removeFromWriterQueue();
- this.queueManager.setQueueCompleted();
+
queueManager.getQueryManager().getConnection().removeFromWriterQueue();
+ queueManager.setQueueCompleted();
return;
}
}
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,7 +1,7 @@
package thaw.fcp;
-import java.util.Vector;
import java.util.Iterator;
+import java.util.Vector;
import thaw.core.Logger;
@@ -19,7 +19,7 @@
/* offset in the array == priority */
/* Vector contains FCPQuery */
- private Vector[] pendingQueries = new Vector[PRIORITY_MIN+1];
+ private final Vector[] pendingQueries = new
Vector[FCPQueueManager.PRIORITY_MIN+1];
private Vector runningQueries;
private Thread scheduler;
@@ -33,53 +33,53 @@
/**
* Calls setQueryManager() and then resetQueues().
*/
- public FCPQueueManager(FCPQueryManager queryManager,
- String thawId,
- int maxDownloads, int maxInsertions) {
- this.lastId = 0;
- this.queueCompleted = false;
+ public FCPQueueManager(final FCPQueryManager queryManager,
+ final String thawId,
+ final int maxDownloads, final int maxInsertions)
{
+ lastId = 0;
+ queueCompleted = false;
- this.setThawId(thawId);
- this.setMaxDownloads(maxDownloads);
- this.setMaxInsertions(maxInsertions);
+ setThawId(thawId);
+ setMaxDownloads(maxDownloads);
+ setMaxInsertions(maxInsertions);
- this.setQueryManager(queryManager);
- this.resetQueues();
+ setQueryManager(queryManager);
+ resetQueues();
queryManager.getConnection().addObserver(this);
}
public boolean isQueueCompletlyLoaded() {
- return this.queueCompleted;
+ return queueCompleted;
}
public void setQueueCompleted() {
- this.queueCompleted = true;
+ queueCompleted = true;
}
/**
* Use it if you want to bypass the queue.
*/
public FCPQueryManager getQueryManager() {
- return this.queryManager;
+ return queryManager;
}
- public void setThawId(String thawId) {
+ public void setThawId(final String thawId) {
this.thawId = thawId;
}
- public void setMaxDownloads(int maxDownloads) {
+ public void setMaxDownloads(final int maxDownloads) {
this.maxDownloads = maxDownloads;
}
- public void setMaxInsertions(int maxInsertions) {
+ public void setMaxInsertions(final int maxInsertions) {
this.maxInsertions = maxInsertions;
}
/**
* You should call resetQueues() after calling this function.
*/
- public void setQueryManager(FCPQueryManager queryManager) {
+ public void setQueryManager(final FCPQueryManager queryManager) {
this.queryManager = queryManager;
}
@@ -88,17 +88,17 @@
* Will purge the current known queue.
*/
public void resetQueues() {
- this.runningQueries = new Vector();
+ runningQueries = new Vector();
- for(int i = 0; i <= PRIORITY_MIN ; i++)
- this.pendingQueries[i] = new Vector();
+ for(int i = 0; i <= FCPQueueManager.PRIORITY_MIN ; i++)
+ pendingQueries[i] = new Vector();
}
/**
* Take care: Can change while you're using it.
*/
public Vector[] getPendingQueues() {
- return this.pendingQueries;
+ return pendingQueries;
}
/**
@@ -106,41 +106,40 @@
* The running queue contains running request, but also finished/failed
ones.
*/
public Vector getRunningQueue() {
- return this.runningQueries;
+ return runningQueries;
}
/**
* @return < 0 if no limit
*/
public int getMaxDownloads() {
- return this.maxDownloads;
+ return maxDownloads;
}
/**
* @return < 0 if no limite
*/
public int getMaxInsertions() {
- return this.maxInsertions;
+ return maxInsertions;
}
/**
* @return false if already added.
*/
- public boolean addQueryToThePendingQueue(FCPTransferQuery query) {
- if(query.getThawPriority() < 0) {
+ public boolean addQueryToThePendingQueue(final FCPTransferQuery query) {
+ if(query.getThawPriority() < 0)
return this.addQueryToTheRunningQueue(query);
- }
- if(this.isAlreadyPresent(query)) {
+ if(isAlreadyPresent(query)) {
Logger.notice(this, "Key was already in one of the
queues : "+query.getFilename());
return false;
}
Logger.notice(this, "Adding query to the pending queue ...");
- this.pendingQueries[query.getThawPriority()].add(query);
+ pendingQueries[query.getThawPriority()].add(query);
- this.setChanged();
+ setChanged();
this.notifyObservers(query);
Logger.notice(this, "Adding done");
@@ -151,19 +150,19 @@
* will call start() function of the query.
* @return false if already added
*/
- public boolean addQueryToTheRunningQueue(FCPTransferQuery query) {
+ public boolean addQueryToTheRunningQueue(final FCPTransferQuery query) {
return this.addQueryToTheRunningQueue(query, true);
}
- public boolean addQueryToTheRunningQueue(FCPTransferQuery query,
boolean callStart) {
+ public boolean addQueryToTheRunningQueue(final FCPTransferQuery query,
boolean callStart) {
Logger.debug(this, "Adding query to the running queue ...");
- if(this.isAlreadyPresent(query)) {
+ if(isAlreadyPresent(query)) {
Logger.notice(this, "Key was already in one of the
queues");
return false;
}
- if(!callStart && query.getIdentifier().startsWith(this.thawId))
{
+ if(!callStart && query.getIdentifier().startsWith(thawId)) {
/* It's a resumed query => We to adapt the next Id
* to avoid collisions.
*/
@@ -172,19 +171,19 @@
try {
String[] subId =
query.getIdentifier().split("-");
subId = subId[0].split("_");
- int id =
Integer.parseInt(subId[subId.length-1]);
+ final int id =
Integer.parseInt(subId[subId.length-1]);
- if(id > this.lastId) {
- this.lastId = id;
+ if(id > lastId) {
+ lastId = id;
}
- } catch(Exception e) {
+ } catch(final Exception e) {
Logger.notice(this, "Exception while parsing
previous Id (Not really a problem)");
}
}
- this.runningQueries.add(query);
+ runningQueries.add(query);
- this.setChanged();
+ setChanged();
this.notifyObservers(query);
if(callStart)
@@ -200,9 +199,9 @@
/**
* *Doesn't* call stop() from the query.
*/
- public void moveFromRunningToPendingQueue(FCPTransferQuery query) {
- this.remove(query);
- this.addQueryToThePendingQueue(query);
+ public void moveFromRunningToPendingQueue(final FCPTransferQuery query)
{
+ remove(query);
+ addQueryToThePendingQueue(query);
}
@@ -213,9 +212,9 @@
public void restartNonPersistent() {
Logger.info(this, "Restarting non persistent query");
- for(Iterator queryIt = this.getRunningQueue().iterator() ;
+ for(final Iterator queryIt = getRunningQueue().iterator() ;
queryIt.hasNext();) {
- FCPTransferQuery query =
(FCPTransferQuery)queryIt.next();
+ final FCPTransferQuery query =
(FCPTransferQuery)queryIt.next();
if(!query.isPersistent() && !query.isFinished())
query.start(this);
@@ -224,23 +223,23 @@
Logger.info(this, "Restart done.");
}
- public void remove(FCPTransferQuery query) {
- this.runningQueries.remove(query);
+ public void remove(final FCPTransferQuery query) {
+ runningQueries.remove(query);
- for(int i = 0 ; i <= PRIORITY_MIN ; i++)
- this.pendingQueries[i].remove(query);
+ for(int i = 0 ; i <= FCPQueueManager.PRIORITY_MIN ; i++)
+ pendingQueries[i].remove(query);
- this.setChanged();
+ setChanged();
this.notifyObservers(query);
}
- private boolean isTheSame(FCPTransferQuery queryA,
- FCPTransferQuery queryB) {
+ private boolean isTheSame(final FCPTransferQuery queryA,
+ final FCPTransferQuery queryB) {
if(queryA.getQueryType() != queryB.getQueryType())
return false;
- if(queryA.getIdentifier() != null && queryB.getIdentifier() !=
null) {
+ if((queryA.getIdentifier() != null) && (queryB.getIdentifier()
!= null)) {
if(queryA.getIdentifier().equals(queryB.getIdentifier())) {
Logger.debug(this, "isTheSame(): Identifier");
return true;
@@ -248,7 +247,7 @@
return false;
}
- if(queryA.getFileKey() != null && queryB.getFileKey() != null) {
+ if((queryA.getFileKey() != null) && (queryB.getFileKey() !=
null)) {
if(queryA.getFileKey().equals(queryB.getFileKey())) {
Logger.debug(this, "isTheSame(): FileKey");
return true;
@@ -266,12 +265,12 @@
/**
* Compare only the refs.
*/
- public boolean isInTheQueues(FCPTransferQuery query) {
- if(this.runningQueries.contains(query))
+ public boolean isInTheQueues(final FCPTransferQuery query) {
+ if(runningQueries.contains(query))
return true;
- for(int i = 0 ; i < this.pendingQueries.length ; i++) {
- if(this.pendingQueries[i].contains(query))
+ for(int i = 0 ; i < pendingQueries.length ; i++) {
+ if(pendingQueries[i].contains(query))
return true;
}
@@ -282,7 +281,7 @@
/**
* Not very reliable ?
*/
- public FCPTransferQuery getTransfer(String key) {
+ public FCPTransferQuery getTransfer(final String key) {
boolean interrupted=true;
boolean isAKey = true;
Iterator it;
@@ -300,39 +299,39 @@
interrupted = false;
try {
- for(it = this.runningQueries.iterator();
+ for(it = runningQueries.iterator();
it.hasNext(); )
{
- FCPTransferQuery plop =
(FCPTransferQuery)it.next();
+ final FCPTransferQuery plop =
(FCPTransferQuery)it.next();
if (isAKey) {
- if (plop.getFileKey()
== key
+ if ((plop.getFileKey()
== key)
||
key.equals(plop.getFileKey()))
return plop;
} else {
- if (plop.getFilename()
== key
+ if ((plop.getFilename()
== key)
||
key.equals(plop.getFilename()))
return plop;
}
}
- for(int i = 0 ; i <= PRIORITY_MIN ; i++) {
- for(it =
this.pendingQueries[i].iterator();
+ for(int i = 0 ; i <=
FCPQueueManager.PRIORITY_MIN ; i++) {
+ for(it = pendingQueries[i].iterator();
it.hasNext(); )
{
- FCPTransferQuery plop =
(FCPTransferQuery)it.next();
+ final FCPTransferQuery
plop = (FCPTransferQuery)it.next();
if (isAKey) {
- if
(plop.getFileKey() == key
+ if
((plop.getFileKey() == key)
||
key.equals(plop.getFileKey()))
return
plop;
} else {
- if
(plop.getFilename() == key
+ if
((plop.getFilename() == key)
||
key.equals(plop.getFilename()))
return
plop;
}
}
}
- } catch(java.util.ConcurrentModificationException e) {
+ } catch(final java.util.ConcurrentModificationException
e) {
Logger.notice(this, "getTransfer(): Collission.
Reitering");
interrupted = true;
}
@@ -346,7 +345,7 @@
/**
* Not reliable
*/
- public FCPTransferQuery getTransferByFilename(String name) {
+ public FCPTransferQuery getTransferByFilename(final String name) {
boolean interrupted=true;
Iterator it;
@@ -358,29 +357,29 @@
interrupted = false;
try {
- for(it = this.runningQueries.iterator();
+ for(it = runningQueries.iterator();
it.hasNext(); )
{
- FCPTransferQuery plop =
(FCPTransferQuery)it.next();
+ final FCPTransferQuery plop =
(FCPTransferQuery)it.next();
- if (plop.getFilename() == name
+ if ((plop.getFilename() == name)
||
name.equals(plop.getFilename()))
return plop;
}
- for(int i = 0 ; i <= PRIORITY_MIN ; i++) {
- for(it =
this.pendingQueries[i].iterator();
+ for(int i = 0 ; i <=
FCPQueueManager.PRIORITY_MIN ; i++) {
+ for(it = pendingQueries[i].iterator();
it.hasNext(); )
{
- FCPTransferQuery plop =
(FCPTransferQuery)it.next();
+ final FCPTransferQuery
plop = (FCPTransferQuery)it.next();
- if (plop.getFilename()
== name
+ if ((plop.getFilename()
== name)
||
name.equals(plop.getFilename()))
return plop;
}
}
- } catch(java.util.ConcurrentModificationException e) {
+ } catch(final java.util.ConcurrentModificationException
e) {
Logger.notice(this, "getTransferByFilename():
Collission. Reitering");
interrupted = true;
}
@@ -394,7 +393,7 @@
/**
* Compare using the key.
*/
- public boolean isAlreadyPresent(FCPTransferQuery query) {
+ public boolean isAlreadyPresent(final FCPTransferQuery query) {
boolean interrupted=true;
Iterator it;
@@ -403,25 +402,25 @@
interrupted = false;
try {
- for(it = this.runningQueries.iterator();
+ for(it = runningQueries.iterator();
it.hasNext(); )
{
- FCPTransferQuery plop =
(FCPTransferQuery)it.next();
- if(this.isTheSame(plop, query))
+ final FCPTransferQuery plop =
(FCPTransferQuery)it.next();
+ if(isTheSame(plop, query))
return true;
}
- for(int i = 0 ; i <= PRIORITY_MIN ; i++) {
- for(it =
this.pendingQueries[i].iterator();
+ for(int i = 0 ; i <=
FCPQueueManager.PRIORITY_MIN ; i++) {
+ for(it = pendingQueries[i].iterator();
it.hasNext(); )
{
- FCPTransferQuery plop =
(FCPTransferQuery)it.next();
- if(this.isTheSame(plop,
query))
+ final FCPTransferQuery
plop = (FCPTransferQuery)it.next();
+ if(isTheSame(plop,
query))
return true;
}
}
- } catch(java.util.ConcurrentModificationException e) {
+ } catch(final java.util.ConcurrentModificationException
e) {
Logger.notice(this, "isAlreadyPresent():
Collission. Reitering");
interrupted = true;
}
@@ -439,14 +438,14 @@
int runningInsertions = 0;
int runningDownloads = 0;
- for(Iterator it = this.runningQueries.iterator();
it.hasNext(); ) {
- FCPTransferQuery query =
(FCPTransferQuery)it.next();
+ for(final Iterator it = runningQueries.iterator();
it.hasNext(); ) {
+ final FCPTransferQuery query =
(FCPTransferQuery)it.next();
- if(query.getQueryType() == 1 /* Download */
+ if((query.getQueryType() == 1 /* Download */)
&& !query.isFinished())
runningDownloads++;
- if(query.getQueryType() == 2 /* Insertion */
+ if((query.getQueryType() == 2 /* Insertion */)
&& !query.isFinished())
runningInsertions++;
}
@@ -454,28 +453,28 @@
/* We move queries from the pendingQueue to the
runningQueue until we got our quota */
for(int priority = 0;
- priority <= PRIORITY_MIN
- && ( (this.maxInsertions <= -1 ||
runningInsertions < this.maxInsertions)
- || (this.maxDownloads <= -1 ||
runningDownloads < this.maxDownloads) ) ;
+ (priority <= FCPQueueManager.PRIORITY_MIN)
+ && ( ((maxInsertions <= -1) ||
(runningInsertions < maxInsertions))
+ || ((maxDownloads <= -1) ||
(runningDownloads < maxDownloads)) ) ;
priority++) {
try {
- for(Iterator it =
this.pendingQueries[priority].iterator();
+ for(Iterator it =
pendingQueries[priority].iterator();
it.hasNext()
- && ( (this.maxInsertions <=
-1 || runningInsertions < this.maxInsertions)
- || (this.maxDownloads
<= -1 || runningDownloads < this.maxDownloads) ); ) {
+ && ( ((maxInsertions <= -1)
|| (runningInsertions < maxInsertions))
+ || ((maxDownloads <=
-1) || (runningDownloads < maxDownloads)) ); ) {
- FCPTransferQuery query =
(FCPTransferQuery)it.next();
+ final FCPTransferQuery query =
(FCPTransferQuery)it.next();
- if( (query.getQueryType() == 1
- && (this.maxDownloads <=
-1 || runningDownloads < this.maxDownloads) )
- || (query.getQueryType() ==
2
- && (this.maxInsertions
<= -1 || runningInsertions < this.maxInsertions)) ) {
+ if( ((query.getQueryType() == 1)
+ && ((maxDownloads <= -1)
|| (runningDownloads < maxDownloads)) )
+ || ((query.getQueryType()
== 2)
+ && ((maxInsertions <=
-1) || (runningInsertions < maxInsertions))) ) {
Logger.debug(this,
"Scheduler : Moving a query from pendingQueue to the runningQueue");
-
this.pendingQueries[priority].remove(query);
+
pendingQueries[priority].remove(query);
- it =
this.pendingQueries[priority].iterator(); /* We reset iterator */
+ it =
pendingQueries[priority].iterator(); /* We reset iterator */
this.addQueryToTheRunningQueue(query);
@@ -487,10 +486,10 @@
try {
Thread.sleep(300);
- }
catch(java.lang.InterruptedException e) { }
+ } catch(final
java.lang.InterruptedException e) { }
}
}
- }
catch(java.util.ConcurrentModificationException e) {
+ } catch(final
java.util.ConcurrentModificationException e) {
Logger.notice(this, "Collision.");
priority--;
}
@@ -503,18 +502,18 @@
public void run() {
try {
Thread.sleep(5000);
- } catch(java.lang.InterruptedException e) {
+ } catch(final java.lang.InterruptedException e) {
// I'm stupid. I'm stupid. I'm stupid. (r9654)
}
while(true) {
try {
Thread.sleep(500);
- } catch(java.lang.InterruptedException e) {
+ } catch(final java.lang.InterruptedException e) {
/* We don't care */
}
- if(this.stopThread)
+ if(stopThread)
return;
try {
@@ -522,12 +521,12 @@
&& !queryManager.getConnection().isWriting()
&& queueCompleted) {
- this.schedule();
+ schedule();
}
- } catch(java.util.ConcurrentModificationException e) {
+ } catch(final java.util.ConcurrentModificationException
e) {
Logger.notice(this, "Ordonnancor: Collision !");
- } catch(Exception e) {
+ } catch(final Exception e) {
Logger.error(this, "EXCEPTION FROM ORDONNANCOR
: "+e.toString());
Logger.error(this, "ERROR : "+e.getMessage());
e.printStackTrace();
@@ -537,36 +536,36 @@
}
public void startScheduler() {
- this.scheduler = new Thread(this);
- this.stopThread = false;
- this.scheduler.start();
+ scheduler = new Thread(this);
+ stopThread = false;
+ scheduler.start();
}
public void stopScheduler() {
- this.stopThread = true;
+ stopThread = true;
}
public String getAnID() {
- this.lastId++;
+ lastId++;
- if(this.lastId >= 65535) {
- this.lastId = 0;
+ if(lastId >= 65535) {
+ lastId = 0;
}
- return (this.thawId+"_"+ Integer.toString(this.lastId));
+ return (thawId+"_"+ Integer.toString(lastId));
}
- public void update(java.util.Observable o, Object arg) {
- if(o == this.queryManager.getConnection()
- && !this.queryManager.getConnection().isConnected()) {
+ public void update(final java.util.Observable o, final Object arg) {
+ if((o == queryManager.getConnection())
+ && !queryManager.getConnection().isConnected()) {
/* Only the running queue ...
* pending query are specifics to Thaw
*/
- this.runningQueries = new Vector();
+ runningQueries = new Vector();
- this.setChanged();
+ setChanged();
this.notifyObservers();
}
}
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPWatchGlobal.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPWatchGlobal.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPWatchGlobal.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -4,16 +4,16 @@
private boolean watch;
- public FCPWatchGlobal(boolean v) {
- this.watch = v;
+ public FCPWatchGlobal(final boolean v) {
+ watch = v;
}
- public boolean start(FCPQueueManager queueManager) {
- FCPMessage message = new FCPMessage();
+ public boolean start(final FCPQueueManager queueManager) {
+ final FCPMessage message = new FCPMessage();
message.setMessageName("WatchGlobal");
- if(this.watch)
+ if(watch)
message.setValue("Enabled", "true");
else
message.setValue("Enabled", "false");
@@ -25,7 +25,7 @@
return true;
}
- public boolean stop(FCPQueueManager queueManager) {
+ public boolean stop(final FCPQueueManager queueManager) {
return true;
}
Modified: trunk/apps/Thaw/src/thaw/gui/JDragTree.java
===================================================================
--- trunk/apps/Thaw/src/thaw/gui/JDragTree.java 2006-12-06 18:18:48 UTC (rev
11272)
+++ trunk/apps/Thaw/src/thaw/gui/JDragTree.java 2006-12-06 18:21:00 UTC (rev
11273)
@@ -18,17 +18,49 @@
*/
package thaw.gui;
-import java.awt.*;
-import java.awt.datatransfer.*;
-import java.awt.dnd.*;
-import java.awt.event.*;
-import java.awt.geom.*;
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.SystemColor;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragGestureRecognizer;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DragSourceDragEvent;
+import java.awt.dnd.DragSourceDropEvent;
+import java.awt.dnd.DragSourceEvent;
+import java.awt.dnd.DragSourceListener;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetDragEvent;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.dnd.DropTargetEvent;
+import java.awt.dnd.DropTargetListener;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.InputEvent;
+import java.awt.event.MouseEvent;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
-import java.util.logging.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
-import javax.swing.*;
-import javax.swing.tree.*;
+import javax.swing.Icon;
+import javax.swing.JLabel;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreeNode;
+import javax.swing.tree.TreePath;
public class JDragTree extends JTree implements DragGestureListener,
DragSourceListener {
@@ -40,18 +72,17 @@
// Fields...
private TreePath _pathLast = null;
- private Rectangle2D _raCueLine = new
Rectangle2D.Float();
+ private final Rectangle2D _raCueLine = new
Rectangle2D.Float();
private Rectangle2D _raGhost = new
Rectangle2D.Float();
private Color _colorCueLine;
private Point _ptLast = new Point();
private javax.swing.Timer _timerHover;
private int _nLeftRight = 0; // Cumulative
left/right mouse movement
- private int _nShift = 0;
// Constructor...
public CDropTargetListener()
{
- this._colorCueLine = new Color(
+ _colorCueLine = new Color(
SystemColor.controlShadow.getRed(),
SystemColor.controlShadow.getGreen(),
SystemColor.controlShadow.getBlue(),
@@ -60,118 +91,113 @@
// Set up a hover timer, so that a node will be
automatically expanded or collapsed
// if the user lingers on it for more than a short time
- this._timerHover = new javax.swing.Timer(1000, new
ActionListener()
+ _timerHover = new javax.swing.Timer(1000, new
ActionListener()
{
- public void actionPerformed(ActionEvent e)
+ public void actionPerformed(final ActionEvent
e)
{
- CDropTargetListener.this._nLeftRight =
0; // Reset left/right movement trend
- if
(JDragTree.this.isRootPath(CDropTargetListener.this._pathLast))
+ _nLeftRight = 0; // Reset
left/right movement trend
+ if (isRootPath(_pathLast))
return; // Do nothing if we
are hovering over the root node
- if
(JDragTree.this.isExpanded(CDropTargetListener.this._pathLast))
-
JDragTree.this.collapsePath(CDropTargetListener.this._pathLast);
+ if
(JDragTree.this.isExpanded(_pathLast))
+ collapsePath(_pathLast);
else
-
JDragTree.this.expandPath(CDropTargetListener.this._pathLast);
+ expandPath(_pathLast);
}
});
- this._timerHover.setRepeats(false); // Set timer to
one-shot mode
+ _timerHover.setRepeats(false); // Set timer to
one-shot mode
}
// DropTargetListener interface
- public void dragEnter(DropTargetDragEvent e)
+ public void dragEnter(final DropTargetDragEvent e)
{
- if (!this.isDragAcceptable(e))
+ if (!isDragAcceptable(e))
e.rejectDrag();
else
e.acceptDrag(e.getDropAction());
}
- public void dragExit(DropTargetEvent e)
+ public void dragExit(final DropTargetEvent e)
{
if (!DragSource.isDragImageSupported())
{
-
JDragTree.this.repaint(this._raGhost.getBounds());
+ JDragTree.this.repaint(_raGhost.getBounds());
}
}
/**
* This is where the ghost image is drawn
*/
- public void dragOver(DropTargetDragEvent e)
+ public void dragOver(final DropTargetDragEvent e)
{
- if( e==null || this._raGhost == null || this._ptLast == null ||
- JDragTree.this._ptOffset == null || JDragTree.this._imgGhost
== null || this._raCueLine == null ) {
- return;
- }
+ if( (e==null) || (_raGhost == null) || (_ptLast == null) ||
+ (_ptOffset == null) || (_imgGhost == null) || (_raCueLine ==
null) )
+ return;
// Even if the mouse is not moving, this method is
still invoked 10 times per second
- Point pt = e.getLocation();
- if(pt==null) {
- return;
- }
- if (pt.equals(this._ptLast))
+ final Point pt = e.getLocation();
+ if(pt==null)
+ return;
+ if (pt.equals(_ptLast))
return;
// Try to determine whether the user is flicking the
cursor right or left
- int nDeltaLeftRight = pt.x - this._ptLast.x;
- if ( (this._nLeftRight > 0 && nDeltaLeftRight < 0) ||
(this._nLeftRight < 0 && nDeltaLeftRight > 0) )
- this._nLeftRight = 0;
- this._nLeftRight += nDeltaLeftRight;
- this._ptLast = pt;
- Graphics2D g2 = (Graphics2D)
JDragTree.this.getGraphics();
- if( g2 == null ) {
- return;
- }
+ final int nDeltaLeftRight = pt.x - _ptLast.x;
+ if ( ((_nLeftRight > 0) && (nDeltaLeftRight < 0)) ||
((_nLeftRight < 0) && (nDeltaLeftRight > 0)) )
+ _nLeftRight = 0;
+ _nLeftRight += nDeltaLeftRight;
+ _ptLast = pt;
+ final Graphics2D g2 = (Graphics2D) getGraphics();
+ if( g2 == null )
+ return;
// If a drag image is not supported by the platform,
then draw my own drag image
if (!DragSource.isDragImageSupported())
{
-
JDragTree.this.paintImmediately(this._raGhost.getBounds()); // Rub out the last
ghost image and cue line
+
JDragTree.this.paintImmediately(_raGhost.getBounds()); // Rub out the last
ghost image and cue line
// And remember where we are about to draw the
new ghost image
- this._raGhost.setRect(pt.x -
JDragTree.this._ptOffset.x, pt.y - JDragTree.this._ptOffset.y,
JDragTree.this._imgGhost.getWidth(), JDragTree.this._imgGhost.getHeight());
- g2.drawImage(JDragTree.this._imgGhost,
AffineTransform.getTranslateInstance(this._raGhost.getX(),
this._raGhost.getY()), null);
+ _raGhost.setRect(pt.x - _ptOffset.x, pt.y -
_ptOffset.y, _imgGhost.getWidth(), _imgGhost.getHeight());
+ g2.drawImage(_imgGhost,
AffineTransform.getTranslateInstance(_raGhost.getX(), _raGhost.getY()), null);
}
else // Just rub out the last cue line
-
JDragTree.this.paintImmediately(this._raCueLine.getBounds());
+
JDragTree.this.paintImmediately(_raCueLine.getBounds());
- TreePath path =
JDragTree.this.getClosestPathForLocation(pt.x, pt.y);
- if (!(path == this._pathLast))
+ final TreePath path = getClosestPathForLocation(pt.x,
pt.y);
+ if (!(path == _pathLast))
{
- this._nLeftRight = 0; // We've moved up or
down, so reset left/right movement trend
- this._pathLast = path;
- this._timerHover.restart();
+ _nLeftRight = 0; // We've moved up or down,
so reset left/right movement trend
+ _pathLast = path;
+ _timerHover.restart();
}
// In any case draw (over the ghost image if
necessary) a cue line indicating where a drop will occur
- Rectangle raPath = JDragTree.this.getPathBounds(path);
- this._raCueLine.setRect(0,
raPath.y+(int)raPath.getHeight(), JDragTree.this.getWidth(), 2);
+ final Rectangle raPath = getPathBounds(path);
+ _raCueLine.setRect(0,
raPath.y+(int)raPath.getHeight(), getWidth(), 2);
- g2.setColor(this._colorCueLine);
- g2.fill(this._raCueLine);
+ g2.setColor(_colorCueLine);
+ g2.fill(_raCueLine);
- this._nShift = 0;
-
// And include the cue line in the area to be rubbed
out next time
- this._raGhost =
this._raGhost.createUnion(this._raCueLine);
+ _raGhost = _raGhost.createUnion(_raCueLine);
// Do this if you want to prohibit dropping onto the
drag source
- if (path.equals(JDragTree.this._pathSource))
+ if (path.equals(_pathSource))
e.rejectDrag();
else
e.acceptDrag(e.getDropAction());
}
- public void dropActionChanged(DropTargetDragEvent e)
+ public void dropActionChanged(final DropTargetDragEvent e)
{
- if (!this.isDragAcceptable(e))
+ if (!isDragAcceptable(e))
e.rejectDrag();
else
e.acceptDrag(e.getDropAction());
}
- public void drop(DropTargetDropEvent e)
+ public void drop(final DropTargetDropEvent e)
{
- this._timerHover.stop(); // Prevent hover timer from
doing an unwanted expandPath or collapsePath
+ _timerHover.stop(); // Prevent hover timer from doing
an unwanted expandPath or collapsePath
- if (!this.isDropAcceptable(e))
+ if (!isDropAcceptable(e))
{
e.rejectDrop();
return;
@@ -179,42 +205,42 @@
e.acceptDrop(e.getDropAction());
- Transferable transferable = e.getTransferable();
+ final Transferable transferable = e.getTransferable();
- DataFlavor[] flavors =
transferable.getTransferDataFlavors();
+ final DataFlavor[] flavors =
transferable.getTransferDataFlavors();
for (int i = 0; i < flavors.length; i++ )
{
- DataFlavor flavor = flavors[i];
+ final DataFlavor flavor = flavors[i];
if
(flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType))
{
try
{
- Point pt = e.getLocation();
- TreePath pathTarget =
JDragTree.this.getClosestPathForLocation(pt.x, pt.y);
- TreePath pathSource =
(TreePath) transferable.getTransferData(flavor);
+ final Point pt =
e.getLocation();
+ final TreePath pathTarget =
getClosestPathForLocation(pt.x, pt.y);
+ final TreePath pathSource =
(TreePath) transferable.getTransferData(flavor);
- if( pathTarget == null ||
pathSource == null )
+ if( (pathTarget == null) ||
(pathSource == null) )
{
e.dropComplete(false);
return;
}
- DefaultMutableTreeNode
sourceNode = (DefaultMutableTreeNode)pathSource.getLastPathComponent();
- DefaultMutableTreeNode
oldParent = (DefaultMutableTreeNode)sourceNode.getParent();
+ final DefaultMutableTreeNode
sourceNode = (DefaultMutableTreeNode)pathSource.getLastPathComponent();
+ final DefaultMutableTreeNode
oldParent = (DefaultMutableTreeNode)sourceNode.getParent();
- DefaultMutableTreeNode
targetNode = (DefaultMutableTreeNode)pathTarget.getLastPathComponent();
- DefaultMutableTreeNode
newParent = (DefaultMutableTreeNode)targetNode.getParent();
+ final DefaultMutableTreeNode
targetNode = (DefaultMutableTreeNode)pathTarget.getLastPathComponent();
+ final DefaultMutableTreeNode
newParent = (DefaultMutableTreeNode)targetNode.getParent();
- if( !sourceNode.isLeaf() &&
targetNode.getParent() == sourceNode )
+ if( !sourceNode.isLeaf() &&
(targetNode.getParent() == sourceNode) )
{
// trying to drag a
folder into its own childs
e.dropComplete(false);
return;
}
- DefaultTreeModel model =
(DefaultTreeModel)JDragTree.this.getModel();
- TreePath pathNewChild = null;
+ final DefaultTreeModel model =
(DefaultTreeModel)getModel();
+ final TreePath pathNewChild =
null;
if( targetNode.isLeaf() ||
JDragTree.this.isCollapsed(pathTarget) )
{
@@ -223,7 +249,7 @@
int idx =
newParent.getIndex(targetNode);
if( idx < 0 )
{
-
logger.warning("child not found in parent!!!");
+
JDragTree.logger.warning("child not found in parent!!!");
e.dropComplete(false);
return;
}
@@ -232,8 +258,8 @@
idx++; //
insert AFTER targetNode
// remove node
from oldParent ...
- Object[]
removedChilds = { sourceNode };
- int[]
childIndices = { oldParent.getIndex(sourceNode) };
+ final Object[]
removedChilds = { sourceNode };
+ final int[]
childIndices = { oldParent.getIndex(sourceNode) };
sourceNode.removeFromParent();
model.nodesWereRemoved( oldParent, childIndices, removedChilds );
@@ -241,13 +267,13 @@
if( idx >=
newParent.getChildCount() )
{
newParent.add( sourceNode );
- int
insertedIndex[] = { newParent.getChildCount()-1 };
+ final
int insertedIndex[] = { newParent.getChildCount()-1 };
model.nodesWereInserted( newParent, insertedIndex );
}
else
{
newParent.insert(sourceNode, idx);
- int
insertedIndex[] = { idx };
+ final
int insertedIndex[] = { idx };
model.nodesWereInserted( newParent, insertedIndex );
}
}
@@ -256,29 +282,29 @@
{
// expanded node,
insert UNDER the node (before first child)
// remove node from
oldParent ...
- Object[] removedChilds
= { sourceNode };
- int[] childIndices = {
oldParent.getIndex(sourceNode) };
+ final Object[]
removedChilds = { sourceNode };
+ final int[]
childIndices = { oldParent.getIndex(sourceNode) };
sourceNode.removeFromParent();
model.nodesWereRemoved( oldParent, childIndices, removedChilds );
// ... and add to
newParent
targetNode.insert(
sourceNode, 0 );
- int insertedIndex[] =
{ 0 };
+ final int
insertedIndex[] = { 0 };
model.nodesWereInserted( targetNode, insertedIndex );
}
if (pathNewChild != null)
-
JDragTree.this.setSelectionPath(pathNewChild); // Mark this as the selected
path in the tree
+
setSelectionPath(pathNewChild); // Mark this as the selected path in the tree
break; // No need to check
remaining flavors
}
- catch (UnsupportedFlavorException ufe)
+ catch (final
UnsupportedFlavorException ufe)
{
- logger.log(Level.SEVERE,
"Exception thrown in drop(DropTargetDropEvent e)", ufe);
+
JDragTree.logger.log(Level.SEVERE, "Exception thrown in
drop(DropTargetDropEvent e)", ufe);
e.dropComplete(false);
return;
}
- catch (IOException ioe)
+ catch (final IOException ioe)
{
- logger.log(Level.SEVERE,
"Exception thrown in drop(DropTargetDropEvent e)", ioe);
+
JDragTree.logger.log(Level.SEVERE, "Exception thrown in
drop(DropTargetDropEvent e)", ioe);
e.dropComplete(false);
return;
}
@@ -288,39 +314,39 @@
}
// Helpers...
- public boolean isDragAcceptable(DropTargetDragEvent e)
+ public boolean isDragAcceptable(final DropTargetDragEvent e)
{
// Only accept COPY or MOVE gestures (ie LINK is not
supported)
if ((e.getDropAction() & DnDConstants.ACTION_MOVE) ==
0)
return false;
// Only accept this particular flavor
- if (!e.isDataFlavorSupported(TREEPATH_FLAVOR))
+ if
(!e.isDataFlavorSupported(JDragTree.TREEPATH_FLAVOR))
return false;
// Do this if you want to prohibit dropping onto the
drag source...
- Point pt = e.getLocation();
- TreePath path =
JDragTree.this.getClosestPathForLocation(pt.x, pt.y);
- if(path == null ||
path.equals(JDragTree.this._pathSource))
+ final Point pt = e.getLocation();
+ final TreePath path = getClosestPathForLocation(pt.x,
pt.y);
+ if((path == null) || path.equals(_pathSource))
return false;
return true;
}
- public boolean isDropAcceptable(DropTargetDropEvent e)
+ public boolean isDropAcceptable(final DropTargetDropEvent e)
{
// Only accept COPY or MOVE gestures (ie LINK is not
supported)
if ((e.getDropAction() & DnDConstants.ACTION_MOVE) ==
0)
return false;
// Only accept this particular flavor
- if (!e.isDataFlavorSupported(TREEPATH_FLAVOR))
+ if
(!e.isDataFlavorSupported(JDragTree.TREEPATH_FLAVOR))
return false;
// Do this if you want to prohibit dropping onto the
drag source...
- Point pt = e.getLocation();
- TreePath path =
JDragTree.this.getClosestPathForLocation(pt.x, pt.y);
- if( path == null ||
path.equals(JDragTree.this._pathSource))
+ final Point pt = e.getLocation();
+ final TreePath path = getClosestPathForLocation(pt.x,
pt.y);
+ if( (path == null) || path.equals(_pathSource))
return false;
return true;
@@ -336,40 +362,40 @@
/**
* Constructs a transferrable tree path object for the specified
path.
*/
- public CTransferableTreePath(TreePath path)
+ public CTransferableTreePath(final TreePath path)
{
- this._path = path;
+ _path = path;
}
// Transferable interface methods...
public DataFlavor[] getTransferDataFlavors()
{
- return JDragTree.this._flavors;
+ return _flavors;
}
- public boolean isDataFlavorSupported(DataFlavor flavor)
+ public boolean isDataFlavorSupported(final DataFlavor flavor)
{
- return
java.util.Arrays.asList(JDragTree.this._flavors).contains(flavor);
+ return
java.util.Arrays.asList(_flavors).contains(flavor);
}
- public synchronized Object getTransferData(DataFlavor flavor)
throws UnsupportedFlavorException
+ public synchronized Object getTransferData(final DataFlavor
flavor) throws UnsupportedFlavorException
{
- if
(flavor.isMimeTypeEqual(TREEPATH_FLAVOR.getMimeType()))
- return this._path;
+ if
(flavor.isMimeTypeEqual(JDragTree.TREEPATH_FLAVOR.getMimeType()))
+ return _path;
else
throw new UnsupportedFlavorException(flavor);
}
}
- private static Logger logger =
Logger.getLogger(JDragTree.class.getName());
+ private static final Logger logger =
Logger.getLogger(JDragTree.class.getName());
private TreePath _pathSource; // The path being
dragged
private BufferedImage _imgGhost; // The 'drag image'
- private Point _ptOffset = new Point(); // Where, in the
drag image, the mouse was clicked
+ private final Point _ptOffset = new Point(); // Where, in
the drag image, the mouse was clicked
// The type of DnD object being dragged...
public final static DataFlavor TREEPATH_FLAVOR = new
DataFlavor(DataFlavor.javaJVMLocalObjectMimeType, "TreePath");
- private DataFlavor[] _flavors = { TREEPATH_FLAVOR };
+ private final DataFlavor[] _flavors = { JDragTree.TREEPATH_FLAVOR };
private DragSource dragSource = null;
private DragGestureRecognizer dgRecognizer = null;
@@ -378,92 +404,90 @@
/**
* @param root
*/
- public JDragTree(TreeNode root) {
+ public JDragTree(final TreeNode root) {
super(root);
- this.initialize();
+ initialize();
}
/**
* @param root
*/
- public JDragTree(TreeModel model) {
+ public JDragTree(final TreeModel model) {
super(model);
- this.initialize();
+ initialize();
}
private void initialize() {
// install drag n drop support
- this.dragSource = DragSource.getDefaultDragSource();
- this.dgRecognizer =
this.dragSource.createDefaultDragGestureRecognizer(this,
+ dragSource = DragSource.getDefaultDragSource();
+ dgRecognizer =
dragSource.createDefaultDragGestureRecognizer(this,
DnDConstants.ACTION_MOVE,
this);
// don't act on right mouse button
-
this.dgRecognizer.setSourceActions(this.dgRecognizer.getSourceActions() &
~InputEvent.BUTTON3_MASK & ~InputEvent.BUTTON2_MASK);
- this.dropTarget = new DropTarget(this, new
CDropTargetListener());
+ dgRecognizer.setSourceActions(dgRecognizer.getSourceActions() &
~InputEvent.BUTTON3_MASK & ~InputEvent.BUTTON2_MASK);
+ dropTarget = new DropTarget(this, new CDropTargetListener());
}
/**
* @param path
* @return
*/
- private boolean isRootPath(TreePath path)
+ private boolean isRootPath(final TreePath path)
{
- return this.isRootVisible() && this.getRowForPath(path) == 0;
+ return isRootVisible() && (getRowForPath(path) == 0);
}
// DragSourceListener interface methods
- public void dragDropEnd(DragSourceDropEvent e)
+ public void dragDropEnd(final DragSourceDropEvent e)
{
this.repaint();
}
- public void dragEnter(DragSourceDragEvent e) {}
+ public void dragEnter(final DragSourceDragEvent e) {}
- public void dragExit(DragSourceEvent e) {}
+ public void dragExit(final DragSourceEvent e) {}
// DragGestureListener interface method
- public void dragGestureRecognized(DragGestureEvent e)
+ public void dragGestureRecognized(final DragGestureEvent e)
{
//we should make sure we aren't in edit mode
- InputEvent ievent=e.getTriggerEvent();
+ final InputEvent ievent=e.getTriggerEvent();
if( ievent instanceof MouseEvent )
{
//even though I tell dgRecognizer to ignore the the
right mouse button,
// it thinks the RMB starts a drag event...argh
if( (((MouseEvent)ievent).getModifiers() &
InputEvent.BUTTON3_MASK) != 0 )
- {
return;
- }
}
// begin dnd
- Point ptDragOrigin = e.getDragOrigin();
- TreePath path = this.getPathForLocation(ptDragOrigin.x,
ptDragOrigin.y);
+ final Point ptDragOrigin = e.getDragOrigin();
+ final TreePath path = getPathForLocation(ptDragOrigin.x,
ptDragOrigin.y);
if (path == null)
return;
- if (this.isRootPath(path))
+ if (isRootPath(path))
return; // Ignore user trying to drag the root node
// Work out the offset of the drag point from the TreePath
bounding rectangle origin
- Rectangle raPath = this.getPathBounds(path);
- this._ptOffset.setLocation(ptDragOrigin.x-raPath.x,
ptDragOrigin.y-raPath.y);
+ final Rectangle raPath = getPathBounds(path);
+ _ptOffset.setLocation(ptDragOrigin.x-raPath.x,
ptDragOrigin.y-raPath.y);
// Get the cell renderer (which is a JLabel) for the path being
dragged
- JLabel lbl = (JLabel)
this.getCellRenderer().getTreeCellRendererComponent
+ final JLabel lbl = (JLabel)
getCellRenderer().getTreeCellRendererComponent
(
this,
// tree
path.getLastPathComponent(), // value
false,
// isSelected (dont want a colored
background)
this.isExpanded(path), // isExpanded
-
this.getModel().isLeaf(path.getLastPathComponent()), // isLeaf
+
getModel().isLeaf(path.getLastPathComponent()), // isLeaf
0,
// row (not important for
rendering)
false
// hasFocus (dont want a focus
rectangle)
);
lbl.setSize((int)raPath.getWidth(), (int)raPath.getHeight());
// <-- The layout manager would normally do this
// Get a buffered image of the selection for dragging a ghost
image
- this._imgGhost = new BufferedImage((int)raPath.getWidth(),
(int)raPath.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE);
- Graphics2D g2 = this._imgGhost.createGraphics();
+ _imgGhost = new BufferedImage((int)raPath.getWidth(),
(int)raPath.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE);
+ final Graphics2D g2 = _imgGhost.createGraphics();
// Ask the cell renderer to paint itself into the BufferedImage
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC,
0.5f)); // Make the image ghostlike
@@ -471,28 +495,28 @@
// Now paint a gradient UNDER the ghosted JLabel text (but not
under the icon if any)
// Note: this will need tweaking if your icon is not positioned
to the left of the text
- Icon icon = lbl.getIcon();
- int nStartOfText = (icon == null) ? 0 :
icon.getIconWidth()+lbl.getIconTextGap();
+ final Icon icon = lbl.getIcon();
+ final int nStartOfText = (icon == null) ? 0 :
icon.getIconWidth()+lbl.getIconTextGap();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_OVER, 0.5f)); //
Make the gradient ghostlike
g2.setPaint(new GradientPaint(nStartOfText, 0,
SystemColor.controlShadow,
-
this.getWidth(), 0, new Color(255,255,255,0)));
- g2.fillRect(nStartOfText, 0, this.getWidth(),
this._imgGhost.getHeight());
+
getWidth(), 0, new Color(255,255,255,0)));
+ g2.fillRect(nStartOfText, 0, getWidth(), _imgGhost.getHeight());
g2.dispose();
- this.setSelectionPath(path); // Select this path in the tree
+ setSelectionPath(path); // Select this path in the tree
// Wrap the path being transferred into a Transferable object
- Transferable transferable = new CTransferableTreePath(path);
+ final Transferable transferable = new
CTransferableTreePath(path);
// Remember the path being dragged (because if it is being
moved, we will have to delete it later)
- this._pathSource = path;
+ _pathSource = path;
// We pass our drag image just in case it IS supported by the
platform
- e.startDrag(null, this._imgGhost, new Point(5,5), transferable,
this);
+ e.startDrag(null, _imgGhost, new Point(5,5), transferable,
this);
}
- public void dragOver(DragSourceDragEvent e) {}
+ public void dragOver(final DragSourceDragEvent e) {}
- public void dropActionChanged(DragSourceDragEvent e) {}
+ public void dropActionChanged(final DragSourceDragEvent e) {}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/Console.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/Console.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/Console.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,22 +1,26 @@
package thaw.plugins;
-import javax.swing.JPanel;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JScrollPane;
import java.awt.BorderLayout;
import java.awt.GridLayout;
-import javax.swing.JFileChooser;
-
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileOutputStream;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
+import javax.swing.JButton;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
-import thaw.core.*;
+import thaw.core.Core;
+import thaw.core.FileChooser;
+import thaw.core.I18n;
+import thaw.core.LogListener;
+import thaw.core.Logger;
+import thaw.core.Plugin;
/**
@@ -39,44 +43,44 @@
}
- public boolean run(Core core) {
+ public boolean run(final Core core) {
this.core = core;
- this.consolePanel = new JPanel();
- this.consolePanel.setLayout(new BorderLayout());
+ consolePanel = new JPanel();
+ consolePanel.setLayout(new BorderLayout());
- this.logArea = new JTextArea();
- this.logArea.setEditable(false);
- this.saveToFile = new
JButton(I18n.getMessage("thaw.plugin.console.saveToFile"));
+ logArea = new JTextArea();
+ logArea.setEditable(false);
+ saveToFile = new
JButton(I18n.getMessage("thaw.plugin.console.saveToFile"));
- this.saveToFile.addActionListener(this);
+ saveToFile.addActionListener(this);
- this.consolePanel.add(new JScrollPane(this.logArea),
BorderLayout.CENTER);
- this.consolePanel.add(this.saveToFile, BorderLayout.SOUTH);
+ consolePanel.add(new JScrollPane(logArea), BorderLayout.CENTER);
+ consolePanel.add(saveToFile, BorderLayout.SOUTH);
-
core.getMainWindow().addTab(I18n.getMessage("thaw.plugin.console.console"),
this.consolePanel);
+
core.getMainWindow().addTab(I18n.getMessage("thaw.plugin.console.console"),
consolePanel);
if(core.getConfig().getValue("consoleMaxLogSize") == null)
- core.getConfig().setValue("consoleMaxLogSize", ((new
Long(this.maxLogSize)).toString()) );
+ core.getConfig().setValue("consoleMaxLogSize", ((new
Long(maxLogSize)).toString()) );
else {
try {
- this.maxLogSize = (new
Long(core.getConfig().getValue("consoleMaxLogSize"))).longValue();
- } catch(Exception e) {
+ maxLogSize = (new
Long(core.getConfig().getValue("consoleMaxLogSize"))).longValue();
+ } catch(final Exception e) {
Logger.notice(this, "Invalide size given in
configuration ! Using default one.");
- core.getConfig().setValue("consoleMaxLogSize",
(new Long(this.maxLogSize)).toString());
+ core.getConfig().setValue("consoleMaxLogSize",
(new Long(maxLogSize)).toString());
}
}
- this.configPanel = new JPanel();
- this.configPanel.setLayout(new GridLayout(15, 1));
+ configPanel = new JPanel();
+ configPanel.setLayout(new GridLayout(15, 1));
- this.sizeLabel = new
JLabel(I18n.getMessage("thaw.plugin.console.maxSize"));
- this.sizeField = new
JTextField(core.getConfig().getValue("consoleMaxLogSize"));
+ sizeLabel = new
JLabel(I18n.getMessage("thaw.plugin.console.maxSize"));
+ sizeField = new
JTextField(core.getConfig().getValue("consoleMaxLogSize"));
- this.configPanel.add(this.sizeLabel);
- this.configPanel.add(this.sizeField);
+ configPanel.add(sizeLabel);
+ configPanel.add(sizeField);
-
core.getConfigWindow().addTab(I18n.getMessage("thaw.plugin.console.console"),
this.configPanel);
+
core.getConfigWindow().addTab(I18n.getMessage("thaw.plugin.console.console"),
configPanel);
Logger.addLogListener(this);
@@ -86,30 +90,30 @@
public boolean stop() {
- this.core.getConfig().setValue("consoleMaxLogSize",
this.sizeField.getText() );
+ core.getConfig().setValue("consoleMaxLogSize",
sizeField.getText() );
Logger.removeLogListener(this);
- this.core.getConfigWindow().removeTab(this.configPanel);
- this.core.getMainWindow().removeTab(this.consolePanel);
+ core.getConfigWindow().removeTab(configPanel);
+ core.getMainWindow().removeTab(consolePanel);
return true;
}
- public void actionPerformed(ActionEvent e) {
- if(e.getSource() == this.saveToFile) {
- FileChooser fileChooser = new FileChooser();
+ public void actionPerformed(final ActionEvent e) {
+ if(e.getSource() == saveToFile) {
+ final FileChooser fileChooser = new FileChooser();
fileChooser.setTitle(I18n.getMessage("thaw.plugin.console.console"));
fileChooser.setDirectoryOnly(false);
fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
- File file = fileChooser.askOneFile();
+ final File file = fileChooser.askOneFile();
if(file != null) {
Logger.info(this, "Saving logs ...");
- this.writeLogsToFile(file);
+ writeLogsToFile(file);
Logger.info(this, "Saving done.");
}
@@ -117,41 +121,41 @@
}
- public void writeLogsToFile(File file) {
+ public void writeLogsToFile(final File file) {
/* A la bourrin */
FileOutputStream output;
try {
output = new FileOutputStream(file);
- } catch(java.io.FileNotFoundException e) {
+ } catch(final java.io.FileNotFoundException e) {
Logger.error(this, "FileNotFoundException ? wtf ?");
return;
}
try {
- output.write(this.logArea.getText().getBytes("UTF-8"));
- } catch(java.io.IOException e) {
+ output.write(logArea.getText().getBytes("UTF-8"));
+ } catch(final java.io.IOException e) {
Logger.error(this, "IOException while writing logs ...
out of space ?");
return;
}
try {
output.close();
- } catch(java.io.IOException e) {
+ } catch(final java.io.IOException e) {
Logger.error(this, "IOException while closing log file
?!");
return;
}
}
- public void newLogLine(String line) {
- String text = this.logArea.getText() + "\n" + line;
+ public void newLogLine(final String line) {
+ String text = logArea.getText() + "\n" + line;
- if(text.length() > this.maxLogSize) {
- text = text.substring((int)(text.length() -
this.maxLogSize));
+ if(text.length() > maxLogSize) {
+ text = text.substring((int)(text.length() -
maxLogSize));
}
- this.logArea.setText(text);
+ logArea.setText(text);
}
Modified: trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,19 +1,21 @@
package thaw.plugins;
+import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
+import javax.swing.JButton;
import javax.swing.JFrame;
-import javax.swing.JButton;
+import javax.swing.JMenuItem;
import javax.swing.WindowConstants;
-import javax.swing.JMenuItem;
+import thaw.core.Core;
+import thaw.core.FreenetURIHelper;
+import thaw.core.I18n;
+import thaw.core.IconBox;
+import thaw.core.Logger;
+import thaw.fcp.FCPClientGet;
+import thaw.plugins.fetchPlugin.FetchPanel;
-import thaw.core.*;
-import thaw.plugins.fetchPlugin.*;
-
-import thaw.fcp.*;
-
public class FetchPlugin implements thaw.core.Plugin, ActionListener {
private Core core;
@@ -30,12 +32,12 @@
}
- public boolean run(Core core) {
+ public boolean run(final Core core) {
this.core = core;
Logger.info(this, "Starting plugin \"FetchPlugin\" ...");
- this.fetchPanel = new FetchPanel(core, this);
+ fetchPanel = new FetchPanel(core, this);
//core.getMainWindow().addTab(I18n.getMessage("thaw.common.download"),
// IconBox.minDownloads,
@@ -93,24 +95,24 @@
return I18n.getMessage("thaw.common.download");
}
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(final ActionEvent e) {
fetchFrame.setVisible(true);
}
- public void fetchFiles(String[] keys, int priority,
- int persistence, boolean globalQueue,
- String destination) {
+ public void fetchFiles(final String[] keys, final int priority,
+ final int persistence, final boolean globalQueue,
+ final String destination) {
for(int i = 0 ; i < keys.length ; i++) {
if(keys[i].length() < 10)
continue;
- String[] subKey = keys[i].split("\\?"); /* Because of
VolodyA :p */
+ final String[] subKey = keys[i].split("\\?"); /*
Because of VolodyA :p */
- String key = FreenetURIHelper.cleanURI(subKey[0]);
+ final String key = FreenetURIHelper.cleanURI(subKey[0]);
if (key != null)
-
this.core.getQueueManager().addQueryToThePendingQueue(new FCPClientGet(key,
+
core.getQueueManager().addQueryToThePendingQueue(new FCPClientGet(key,
priority,
persistence,
globalQueue, -1,
Modified: trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -2,29 +2,26 @@
import java.sql.Connection;
import java.sql.DriverManager;
-
import java.sql.ResultSet;
import java.sql.Statement;
-import thaw.core.*;
+import thaw.core.Core;
+import thaw.core.I18n;
+import thaw.core.LibraryPlugin;
+import thaw.core.Logger;
public class Hsqldb extends LibraryPlugin {
private Core core;
+ public volatile String dbLock;
private Connection connection;
- private int writeLock;
-
- public Hsqldb() {
- writeLock = 0;
- }
-
- public boolean run(Core core) {
+ public boolean run(final Core core) {
this.core = core;
try {
Class.forName("org.hsqldb.jdbcDriver");
- } catch (Exception e) {
+ } catch (final Exception e) {
Logger.error(this, "ERROR: failed to load HSQLDB JDBC
driver.");
e.printStackTrace();
System.exit(1);
@@ -35,47 +32,39 @@
}
- public synchronized void lockWriting() {
- }
-
- public synchronized void unlockWriting() {
-
- }
-
public void realStart() {
Logger.info(this, "Connecting to the database ...");
- if(this.core.getConfig().getValue("hsqldb.url") == null)
- this.core.getConfig().setValue("hsqldb.url",
"jdbc:hsqldb:file:thaw.db;shutdown=true");
+ if(core.getConfig().getValue("hsqldb.url") == null)
+ core.getConfig().setValue("hsqldb.url",
"jdbc:hsqldb:file:thaw.db;shutdown=true");
try {
- this.connect();
- } catch (java.sql.SQLException e) {
- Logger.error(this, "SQLException while connecting to
the database '"+this.core.getConfig().getValue("hsqldb.url")+"'");
+ connect();
+ } catch (final java.sql.SQLException e) {
+ Logger.error(this, "SQLException while connecting to
the database '"+core.getConfig().getValue("hsqldb.url")+"'");
e.printStackTrace();
}
}
public void connect() throws java.sql.SQLException {
- if(this.core.getConfig().getValue("hsqldb.url") == null)
- this.core.getConfig().setValue("hsqldb.url",
"jdbc:hsqldb:file:thaw.db");
+ if(core.getConfig().getValue("hsqldb.url") == null)
+ core.getConfig().setValue("hsqldb.url",
"jdbc:hsqldb:file:thaw.db");
- if(this.connection != null)
- this.disconnect();
+ if(connection != null)
+ disconnect();
- this.connection =
DriverManager.getConnection(this.core.getConfig().getValue("hsqldb.url"),
+ connection =
DriverManager.getConnection(core.getConfig().getValue("hsqldb.url"),
"sa", "");
}
public void disconnect() throws java.sql.SQLException {
- this.connection.close();
+ connection.close();
}
public boolean stop() {
-
return true;
}
@@ -83,11 +72,11 @@
Logger.info(this, "Disconnecting from the database ...");
try {
- this.connection.commit();
- this.executeQuery("SHUTDOWN");
+ connection.commit();
+ executeQuery("SHUTDOWN");
- this.connection.close();
- } catch(java.sql.SQLException e) {
+ connection.close();
+ } catch(final java.sql.SQLException e) {
Logger.error(this, "SQLException while closing
connection !");
e.printStackTrace();
}
@@ -100,14 +89,14 @@
public Connection getConnection() {
- return this.connection;
+ return connection;
}
- public ResultSet executeQuery(String query) throws
java.sql.SQLException {
+ public ResultSet executeQuery(final String query) throws
java.sql.SQLException {
ResultSet results;
- Statement stmt = this.connection.createStatement();
+ final Statement stmt = connection.createStatement();
results = stmt.executeQuery(query);
Modified: trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,16 +1,22 @@
package thaw.plugins;
+import java.util.Iterator;
+import java.util.Vector;
+
import javax.swing.JButton;
+import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
-import javax.swing.event.ChangeEvent;
-import java.util.Vector;
-import java.util.Iterator;
+import thaw.core.Core;
+import thaw.core.I18n;
+import thaw.core.IconBox;
+import thaw.core.Logger;
+import thaw.core.Plugin;
+import thaw.plugins.index.IndexBrowserPanel;
+import thaw.plugins.index.IndexManagementHelper;
+import thaw.plugins.index.IndexTreeNode;
+import thaw.plugins.index.TableCreator;
-import thaw.core.*;
-
-import thaw.plugins.index.*;
-
public class IndexBrowser extends ToolbarModifier implements Plugin,
ChangeListener, java.util.Observer {
public static final String DEFAULT_INDEX = "USK at
G-ofLp2KlhHBNPezx~GDWDKThJ-QUxJK8c2xiF~-jwE,-55vLnqo3U1H5qmKA1LLADoYGQdk-Y3hSLxyKeUyHNc,AQABAAE/Thaw/2/Thaw.xml";
@@ -25,7 +31,7 @@
}
- public boolean run(Core core) {
+ public boolean run(final Core core) {
this.core = core;
if(core.getPluginManager().getPlugin("thaw.plugins.Hsqldb") ==
null) {
@@ -91,7 +97,7 @@
if (newDb) {
IndexManagementHelper.addIndex(hsqldb,
core.getQueueManager(), browserPanel.getUnknownIndexList(),
browserPanel.getIndexTree(),
-
browserPanel.getIndexTree().getRoot(), DEFAULT_INDEX);
+
browserPanel.getIndexTree().getRoot(), IndexBrowser.DEFAULT_INDEX);
}
stateChanged(null);
@@ -119,7 +125,7 @@
* Called when the JTabbedPane changed (ie change in the selected tab,
etc)
* @param e can be null.
*/
- public void stateChanged(ChangeEvent e) {
+ public void stateChanged(final ChangeEvent e) {
int tabId;
tabId =
core.getMainWindow().getTabbedPane().indexOfTab(I18n.getMessage("thaw.plugin.index.indexes"));
@@ -136,13 +142,13 @@
}
}
- public void update (java.util.Observable o, Object arg) {
- if (o == browserPanel.getIndexTree()
- && arg instanceof IndexTreeNode) {
+ public void update (final java.util.Observable o, final Object arg) {
+ if ((o == browserPanel.getIndexTree())
+ && (arg instanceof IndexTreeNode)) {
- for (Iterator it = toolbarActions.iterator();
+ for (final Iterator it = toolbarActions.iterator();
it.hasNext(); ) {
- IndexManagementHelper.IndexAction action =
(IndexManagementHelper.IndexAction)it.next();
+ final IndexManagementHelper.IndexAction action
= (IndexManagementHelper.IndexAction)it.next();
action.setTarget((IndexTreeNode)arg);
}
Modified: trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,21 +1,23 @@
package thaw.plugins;
-import javax.swing.JScrollPane;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.io.File;
+import javax.swing.JButton;
import javax.swing.JFrame;
-import javax.swing.JButton;
+import javax.swing.JMenuItem;
+import javax.swing.JScrollPane;
import javax.swing.WindowConstants;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
+import thaw.core.Core;
+import thaw.core.I18n;
+import thaw.core.IconBox;
+import thaw.core.Logger;
+import thaw.core.WarningWindow;
+import thaw.fcp.FCPClientPut;
+import thaw.plugins.insertPlugin.InsertPanel;
-import javax.swing.JMenuItem;
-
-import thaw.core.*;
-import thaw.plugins.insertPlugin.*;
-import thaw.fcp.*;
-
public class InsertPlugin implements thaw.core.Plugin, ActionListener {
private Core core;
@@ -35,15 +37,15 @@
}
- public boolean run(Core core) {
+ public boolean run(final Core core) {
this.core = core;
Logger.info(this, "Starting plugin \"InsertPlugin\" ...");
- this.insertPanel = new InsertPanel(this,
+ insertPanel = new InsertPanel(this,
Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue());
- this.scrollPane = new JScrollPane(this.insertPanel.getPanel());
+ scrollPane = new JScrollPane(insertPanel.getPanel());
//core.getMainWindow().addTab(I18n.getMessage("thaw.common.insertion"),
// IconBox.minInsertions,
@@ -54,7 +56,7 @@
insertionFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
insertionFrame.setContentPane(scrollPane);
- if (core.getConfig().getValue("advancedMode") == null
+ if ((core.getConfig().getValue("advancedMode") == null)
||
Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue()) {
insertionFrame.setSize(750, 450);
} else {
@@ -105,7 +107,7 @@
}
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(final ActionEvent e) {
insertionFrame.setVisible(true);
}
@@ -120,23 +122,23 @@
* @param persistence 0 = Forever ; 1 = Until node reboot ; 2 = Until
the app disconnect
* @param mimeType null = autodetect
*/
- public boolean insertFile(String fileList, int keyType,
- int rev, String name,
- String privateKey,
- int priority, boolean global,
- int persistence, String mimeType) {
+ public boolean insertFile(final String fileList, final int keyType,
+ final int rev, final String name,
+ final String privateKey,
+ final int priority, final boolean global,
+ final int persistence, final String mimeType)
{
FCPClientPut clientPut = null;
- String[] files = fileList.split(";");
+ final String[] files = fileList.split(";");
- if(keyType > 0 && files.length > 1) {
- new WarningWindow(this.core, "Can't insert multiple
SSH@ / KSK@ files at the same time. Use jSite.");
+ if((keyType > 0) && (files.length > 1)) {
+ new WarningWindow(core, "Can't insert multiple SSH@ /
KSK@ files at the same time. Use jSite.");
return false;
}
for(int i = 0 ; i < files.length ; i++) {
- if(privateKey != null && !"".equals( privateKey )) {
+ if((privateKey != null) && !"".equals( privateKey )) {
clientPut = new FCPClientPut(new
File(files[i]), keyType, rev, name,
"USK@"+privateKey+"/", priority,
global,
persistence);
@@ -151,10 +153,10 @@
clientPut.setMetadata("ContentType", mimeType);
}
- this.insertPanel.setLastInserted(clientPut);
- clientPut.addObserver(this.insertPanel);
+ insertPanel.setLastInserted(clientPut);
+ clientPut.addObserver(insertPanel);
-
this.core.getQueueManager().addQueryToThePendingQueue(clientPut);
+
core.getQueueManager().addQueryToThePendingQueue(clientPut);
}
Modified: trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,23 +1,25 @@
package thaw.plugins;
-import javax.swing.JPanel;
-import javax.swing.JSplitPane;
-import java.awt.GridLayout;
import java.awt.event.ActionListener;
-import java.util.Vector;
-import java.util.Iterator;
-import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
-import javax.swing.event.ChangeListener;
+import java.beans.PropertyChangeListener;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.swing.JSplitPane;
import javax.swing.event.ChangeEvent;
-import javax.swing.JButton;
+import javax.swing.event.ChangeListener;
+import thaw.core.Core;
+import thaw.core.I18n;
+import thaw.core.IconBox;
+import thaw.core.Logger;
+import thaw.core.MainWindow;
+import thaw.fcp.FCPTransferQuery;
+import thaw.plugins.queueWatcher.DetailPanel;
+import thaw.plugins.queueWatcher.DragAndDropManager;
+import thaw.plugins.queueWatcher.QueuePanel;
-import thaw.core.*;
-import thaw.plugins.queueWatcher.*;
-
-import thaw.fcp.*;
-
public class QueueWatcher extends ToolbarModifier implements thaw.core.Plugin,
PropertyChangeListener, ChangeListener {
private Core core;
@@ -26,7 +28,7 @@
public final static int DOWNLOAD_PANEL = 0;
public final static int INSERTION_PANEL = 1;
- private QueuePanel[] queuePanels = new QueuePanel[2];
+ private final QueuePanel[] queuePanels = new QueuePanel[2];
private DetailPanel detailPanel;
private DragAndDropManager dnd;
@@ -41,40 +43,35 @@
private java.awt.Container panelAdded;
- public QueueWatcher() {
-
- }
-
-
- public boolean run(Core core) {
+ public boolean run(final Core core) {
this.core = core;
Logger.info(this, "Starting plugin \"QueueWatcher\" ...");
- this.detailPanel = new DetailPanel(core);
+ detailPanel = new DetailPanel();
- queuePanels[DOWNLOAD_PANEL] = new QueuePanel(core, detailPanel,
false); /* download */
- queuePanels[INSERTION_PANEL] = new QueuePanel(core,
detailPanel, true); /* upload */
+ queuePanels[QueueWatcher.DOWNLOAD_PANEL] = new QueuePanel(core,
detailPanel, false); /* download */
+ queuePanels[QueueWatcher.INSERTION_PANEL] = new
QueuePanel(core, detailPanel, true); /* upload */
split = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
queuePanels[0].getPanel(),
queuePanels[1].getPanel());
- this.advancedMode =
Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue();
+ advancedMode =
Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue();
if(advancedMode) {
mainPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
detailPanel.getPanel(), split);
- if(core.getConfig().getValue("detailPanelFolded") ==
null
- || ((new
Boolean(core.getConfig().getValue("detailPanelFolded"))).booleanValue()) ==
true) {
+ if((core.getConfig().getValue("detailPanelFolded") ==
null)
+ || (((new
Boolean(core.getConfig().getValue("detailPanelFolded"))).booleanValue()) ==
true)) {
folded = true;
detailPanel.getPanel().setVisible(false);
mainPanel.setDividerLocation(1);
} else {
folded = false;
detailPanel.getPanel().setVisible(true);
- mainPanel.setDividerLocation(DIVIDER_LOCATION);
+
mainPanel.setDividerLocation(QueueWatcher.DIVIDER_LOCATION);
}
mainPanel.addPropertyChangeListener(this);
@@ -97,7 +94,7 @@
split.setResizeWeight(0.5);
if (core.getConfig().getValue("queuePanelSplitLocation") ==
null) {
- split.setDividerLocation(((double)0.5));
+ split.setDividerLocation((0.5));
} else {
split.setDividerLocation(Double.parseDouble(core.getConfig().getValue("queuePanelSplitLocation")));
}
@@ -114,7 +111,7 @@
/**
* @param panel see DOWNLOAD_PANEL and INSERTION_PANEL
*/
- public void addButtonListener(int panel, ActionListener listener) {
+ public void addButtonListener(final int panel, final ActionListener
listener) {
queuePanels[panel].getButton().addActionListener(listener);
}
@@ -129,18 +126,18 @@
core.getConfig().setValue("queuePanelSplitLocation",
Double.toString(splitLocation));
- this.core.getConfig().setValue("detailPanelFolded", ((new
Boolean(this.folded)).toString()));
- this.core.getMainWindow().removeTab(this.panelAdded);
+ core.getConfig().setValue("detailPanelFolded", ((new
Boolean(folded)).toString()));
+ core.getMainWindow().removeTab(panelAdded);
return true;
}
- public void addMenuItemToTheDownloadTable(javax.swing.JMenuItem item) {
+ public void addMenuItemToTheDownloadTable(final javax.swing.JMenuItem
item) {
queuePanels[0].addMenuItem(item);
}
- public void addMenuItemToTheInsertionTable(javax.swing.JMenuItem item) {
+ public void addMenuItemToTheInsertionTable(final javax.swing.JMenuItem
item) {
queuePanels[1].addMenuItem(item);
}
@@ -149,18 +146,18 @@
}
- protected void addToPanels(Vector queries) {
+ protected void addToPanels(final Vector queries) {
- for(Iterator it = queries.iterator();
+ for(final Iterator it = queries.iterator();
it.hasNext();) {
- FCPTransferQuery query = (FCPTransferQuery)it.next();
+ final FCPTransferQuery query =
(FCPTransferQuery)it.next();
if(query.getQueryType() == 1)
- this.queuePanels[0].addToTable(query);
+ queuePanels[0].addToTable(query);
if(query.getQueryType() == 2)
- this.queuePanels[1].addToTable(query);
+ queuePanels[1].addToTable(query);
}
@@ -169,25 +166,25 @@
/**
* Called when the split bar position changes.
*/
- public void propertyChange(PropertyChangeEvent evt) {
+ public void propertyChange(final PropertyChangeEvent evt) {
if("dividerLocation".equals( evt.getPropertyName() )) {
- if(System.currentTimeMillis() - this.lastChange < 500) {
- this.lastChange = System.currentTimeMillis();
+ if(System.currentTimeMillis() - lastChange < 500) {
+ lastChange = System.currentTimeMillis();
return;
}
- this.lastChange = System.currentTimeMillis();
+ lastChange = System.currentTimeMillis();
- this.folded = !this.folded;
+ folded = !folded;
- if(this.folded) {
- this.detailPanel.getPanel().setVisible(false);
- this.mainPanel.setDividerLocation(1);
+ if(folded) {
+ detailPanel.getPanel().setVisible(false);
+ mainPanel.setDividerLocation(1);
} else {
- this.detailPanel.getPanel().setVisible(true);
-
this.mainPanel.setDividerLocation(DIVIDER_LOCATION);
+ detailPanel.getPanel().setVisible(true);
+
mainPanel.setDividerLocation(QueueWatcher.DIVIDER_LOCATION);
}
}
@@ -198,7 +195,7 @@
* Called when the JTabbedPane changed (ie change in the selected tab,
etc)
* @param e can be null.
*/
- public void stateChanged(ChangeEvent e) {
+ public void stateChanged(final ChangeEvent e) {
int tabId;
tabId =
core.getMainWindow().getTabbedPane().indexOfTab(I18n.getMessage("thaw.common.status"));
Modified: trunk/apps/Thaw/src/thaw/plugins/Restarter.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/Restarter.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/Restarter.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,20 +1,23 @@
package thaw.plugins;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import javax.swing.JLabel;
-import javax.swing.JCheckBox;
import java.awt.GridLayout;
-
-import java.util.Vector;
import java.util.Iterator;
+import java.util.Observable;
import java.util.Observer;
-import java.util.Observable;
import java.util.Random;
+import java.util.Vector;
-import thaw.core.*;
-import thaw.fcp.*;
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import thaw.core.Core;
+import thaw.core.I18n;
+import thaw.core.Logger;
+import thaw.core.Plugin;
+import thaw.fcp.FCPTransferQuery;
+
/**
* This plugin, after a given time, restart all/some the failed downloads (if
maxDownloads >= 0, downloads to restart are choosen randomly).
* A not too bad example to show how to make plugins.
@@ -40,83 +43,83 @@
private JCheckBox restartFatalsBox;
- public boolean run(Core core) {
+ public boolean run(final Core core) {
this.core = core;
/* Reloading value from the configuration */
try {
- if(core.getConfig().getValue("restartInterval") != null
- && core.getConfig().getValue("restartFatals") !=
null) {
- this.interval =
Integer.parseInt(core.getConfig().getValue("restartInterval"));
- this.restartFatals =
Boolean.valueOf(core.getConfig().getValue("restartFatals")).booleanValue();
+ if((core.getConfig().getValue("restartInterval") !=
null)
+ && (core.getConfig().getValue("restartFatals") !=
null)) {
+ interval =
Integer.parseInt(core.getConfig().getValue("restartInterval"));
+ restartFatals =
Boolean.valueOf(core.getConfig().getValue("restartFatals")).booleanValue();
}
- } catch(Exception e) { /* probably conversion errors */ /* Yes
I know, it's dirty */
+ } catch(final Exception e) { /* probably conversion errors */
/* Yes I know, it's dirty */
Logger.notice(this, "Unable to read / understand value
from the config. Using default values");
}
/* Adding restart config tab to the config window */
- this.configPanel = new JPanel();
- this.configPanel.setLayout(new GridLayout(15, 1));
+ configPanel = new JPanel();
+ configPanel.setLayout(new GridLayout(15, 1));
- this.restartIntervalLabel = new
JLabel(I18n.getMessage("thaw.plugin.restarter.interval"));
- this.restartIntervalField = new
JTextField(Integer.toString(this.interval));
+ restartIntervalLabel = new
JLabel(I18n.getMessage("thaw.plugin.restarter.interval"));
+ restartIntervalField = new
JTextField(Integer.toString(interval));
- this.restartFatalsBox = new
JCheckBox(I18n.getMessage("thaw.plugin.restarter.restartFatals"),
this.restartFatals);
+ restartFatalsBox = new
JCheckBox(I18n.getMessage("thaw.plugin.restarter.restartFatals"),
restartFatals);
- this.configPanel.add(this.restartIntervalLabel);
- this.configPanel.add(this.restartIntervalField);
- this.configPanel.add(this.restartFatalsBox);
+ configPanel.add(restartIntervalLabel);
+ configPanel.add(restartIntervalField);
+ configPanel.add(restartFatalsBox);
-
core.getConfigWindow().addTab(I18n.getMessage("thaw.plugin.restarter.configTabName"),
this.configPanel);
+
core.getConfigWindow().addTab(I18n.getMessage("thaw.plugin.restarter.configTabName"),
configPanel);
core.getConfigWindow().addObserver(this);
- this.running = true;
- this.restarter = new Thread(this);
- this.restarter.start();
+ running = true;
+ restarter = new Thread(this);
+ restarter.start();
return true;
}
public boolean stop() {
- this.core.getConfigWindow().removeTab(this.configPanel);
- this.core.getConfigWindow().deleteObserver(this);
- this.running = false;
+ core.getConfigWindow().removeTab(configPanel);
+ core.getConfigWindow().deleteObserver(this);
+ running = false;
return true;
}
public void run() {
- while(this.running) {
+ while(running) {
try {
- for(this.timeElapsed = 0 ; this.timeElapsed <
this.interval && this.running; this.timeElapsed++) {
+ for(timeElapsed = 0 ; (timeElapsed < interval)
&& running; timeElapsed++) {
Thread.sleep(1000);
}
- } catch(java.lang.InterruptedException e) {
+ } catch(final java.lang.InterruptedException e) {
// We really really really don't care.
}
Logger.notice(this, "Restarting [some] failed
downloads");
try {
- if(!this.running)
+ if(!running)
break;
- int maxDownloads =
this.core.getQueueManager().getMaxDownloads();
+ final int maxDownloads =
core.getQueueManager().getMaxDownloads();
int alreadyRunning = 0;
int failed = 0;
- Vector runningQueue =
this.core.getQueueManager().getRunningQueue();
+ final Vector runningQueue =
core.getQueueManager().getRunningQueue();
if(maxDownloads >= 0) {
/* We count how many are really running
and we write down those which are
failed */
- for(Iterator it =
runningQueue.iterator();
+ for(final Iterator it =
runningQueue.iterator();
it.hasNext();) {
- FCPTransferQuery query =
(FCPTransferQuery)it.next();
+ final FCPTransferQuery query =
(FCPTransferQuery)it.next();
if(query.getQueryType() != 1)
continue;
@@ -126,28 +129,28 @@
}
if(query.isFinished() &&
!query.isSuccessful()
- && (this.restartFatals ||
!query.isFatallyFailed()) ) {
+ && (restartFatals ||
!query.isFatallyFailed()) ) {
failed++;
}
}
/* We choose randomly the ones to
restart */
- while(alreadyRunning < maxDownloads &&
failed > 0) {
- int toRestart = (new
Random()).nextInt(failed);
+ while((alreadyRunning < maxDownloads)
&& (failed > 0)) {
+ final int toRestart = (new
Random()).nextInt(failed);
- Iterator it =
runningQueue.iterator();
+ final Iterator it =
runningQueue.iterator();
int i = 0;
while(it.hasNext()) {
- FCPTransferQuery query
= (FCPTransferQuery)it.next();
+ final FCPTransferQuery
query = (FCPTransferQuery)it.next();
if(query.getQueryType()
!= 1)
continue;
if(query.isFinished()
&& !query.isSuccessful()
- &&
(this.restartFatals || !query.isFatallyFailed())) {
+ && (restartFatals ||
!query.isFatallyFailed())) {
if(i ==
toRestart) {
-
this.restartQuery(query);
+
restartQuery(query);
break;
}
@@ -163,20 +166,20 @@
} else { /* => if maxDownloads < 0 */
/* We restart them all */
- for(Iterator it =
runningQueue.iterator();
+ for(final Iterator it =
runningQueue.iterator();
it.hasNext();) {
- FCPTransferQuery query =
(FCPTransferQuery)it.next();
+ final FCPTransferQuery query =
(FCPTransferQuery)it.next();
- if(query.getQueryType() == 1 &&
query.isFinished()
+ if((query.getQueryType() == 1)
&& query.isFinished()
&& !query.isSuccessful()
- && (this.restartFatals ||
!query.isFatallyFailed()))
-
this.restartQuery(query);
+ && (restartFatals ||
!query.isFatallyFailed()))
+ restartQuery(query);
}
}
- } catch(java.util.ConcurrentModificationException e) {
+ } catch(final java.util.ConcurrentModificationException
e) {
Logger.notice(this, "Collision ! Sorry I will
restart failed downloads later ...");
- } catch(Exception e) {
+ } catch(final Exception e) {
Logger.error(this, "Exception : "+e);
}
@@ -184,31 +187,31 @@
}
- public void restartQuery(FCPTransferQuery query) {
- query.stop(this.core.getQueueManager());
+ public void restartQuery(final FCPTransferQuery query) {
+ query.stop(core.getQueueManager());
if(query.getMaxAttempt() >= 0)
query.setAttempt(0);
- query.start(this.core.getQueueManager());
+ query.start(core.getQueueManager());
}
- public void update(Observable o, Object arg) {
- if(o == this.core.getConfigWindow()) {
+ public void update(final Observable o, final Object arg) {
+ if(o == core.getConfigWindow()) {
- if(arg == this.core.getConfigWindow().getOkButton()){
-
this.core.getConfig().setValue("restartInterval",
this.restartIntervalField.getText());
- this.core.getConfig().setValue("restartFatals",
-
Boolean.toString(this.restartFatalsBox.isSelected()));
+ if(arg == core.getConfigWindow().getOkButton()){
+ core.getConfig().setValue("restartInterval",
restartIntervalField.getText());
+ core.getConfig().setValue("restartFatals",
+
Boolean.toString(restartFatalsBox.isSelected()));
/* Plugin will be stop() and start(), so no
need to reload config */
return;
}
- if(arg ==
this.core.getConfigWindow().getCancelButton()) {
-
this.restartIntervalField.setText(Integer.toString(this.interval));
-
this.restartFatalsBox.setSelected(this.restartFatals);
+ if(arg == core.getConfigWindow().getCancelButton()) {
+
restartIntervalField.setText(Integer.toString(interval));
+ restartFatalsBox.setSelected(restartFatals);
return;
}
Modified: trunk/apps/Thaw/src/thaw/plugins/SqlConsole.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/SqlConsole.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/SqlConsole.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,22 +1,22 @@
package thaw.plugins;
-import javax.swing.JPanel;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
-import javax.swing.JScrollPane;
-import javax.swing.JButton;
-
import java.awt.BorderLayout;
-
+import java.awt.Font;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
-import java.awt.Font;
+import javax.swing.JButton;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import thaw.core.Core;
+import thaw.core.I18n;
+import thaw.core.Logger;
+import thaw.core.Plugin;
import thaw.plugins.index.TableCreator;
-import thaw.core.*;
-
public class SqlConsole implements Plugin, java.awt.event.ActionListener {
public final static int BUFFER_SIZE = 51200;
@@ -33,7 +33,7 @@
}
- public boolean run(Core core) {
+ public boolean run(final Core core) {
this.core = core;
if(core.getPluginManager().getPlugin("thaw.plugins.Hsqldb") ==
null) {
@@ -46,23 +46,23 @@
}
}
- this.hsqldb =
(Hsqldb)core.getPluginManager().getPlugin("thaw.plugins.Hsqldb");
+ hsqldb =
(Hsqldb)core.getPluginManager().getPlugin("thaw.plugins.Hsqldb");
- this.hsqldb.registerChild(this);
+ hsqldb.registerChild(this);
- this.panel = this.getPanel();
+ panel = getPanel();
core.getMainWindow().addTab(I18n.getMessage("thaw.plugin.hsqldb.console"),
- this.panel);
+ panel);
return true;
}
public boolean stop() {
- this.core.getMainWindow().removeTab(this.panel);
+ core.getMainWindow().removeTab(panel);
- this.hsqldb.unregisterChild(this);
+ hsqldb.unregisterChild(this);
return true;
}
@@ -81,40 +81,40 @@
subPanel = new JPanel();
subPanel.setLayout(new BorderLayout());
- this.sqlArea = new JTextArea("");
- this.sqlArea.setEditable(false);
- this.sqlArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
+ sqlArea = new JTextArea("");
+ sqlArea.setEditable(false);
+ sqlArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
- this.commandField = new JTextField("");
- this.commandField.addActionListener(this);
+ commandField = new JTextField("");
+ commandField.addActionListener(this);
- this.sendButton = new JButton(" Ok ");
- this.sendButton.addActionListener(this);
+ sendButton = new JButton(" Ok ");
+ sendButton.addActionListener(this);
- subPanel.add(this.commandField, BorderLayout.CENTER);
- subPanel.add(this.sendButton, BorderLayout.EAST);
+ subPanel.add(commandField, BorderLayout.CENTER);
+ subPanel.add(sendButton, BorderLayout.EAST);
- panel.add(new JScrollPane(this.sqlArea), BorderLayout.CENTER);
+ panel.add(new JScrollPane(sqlArea), BorderLayout.CENTER);
panel.add(subPanel, BorderLayout.SOUTH);
return panel;
}
- public void addToConsole(String txt) {
- String text = this.sqlArea.getText() + txt;
+ public void addToConsole(final String txt) {
+ String text = sqlArea.getText() + txt;
- if(text.length() > BUFFER_SIZE) {
- text = text.substring((text.length() - BUFFER_SIZE));
+ if(text.length() > SqlConsole.BUFFER_SIZE) {
+ text = text.substring((text.length() -
SqlConsole.BUFFER_SIZE));
}
- this.sqlArea.setText(text);
+ sqlArea.setText(text);
}
- public void actionPerformed(java.awt.event.ActionEvent e) {
+ public void actionPerformed(final java.awt.event.ActionEvent e) {
- this.sendCommand(this.commandField.getText());
+ sendCommand(commandField.getText());
- this.commandField.setText("");
+ commandField.setText("");
}
@@ -122,7 +122,7 @@
if(txt == null)
txt = "(null)";
- int txtLength = txt.length();
+ final int txtLength = txt.length();
String fTxt = txt;
@@ -133,7 +133,7 @@
fTxt = fTxt + " ";
}
- this.addToConsole(fTxt);
+ addToConsole(fTxt);
}
public void sendCommand(String cmd) {
@@ -142,17 +142,17 @@
if("list_tables".equals( cmd.toLowerCase() ))
cmd = "SELECT * FROM INFORMATION_SCHEMA.SYSTEM_TABLES";
- this.addToConsole("\n> "+cmd+"\n\n");
+ addToConsole("\n> "+cmd+"\n\n");
try {
if("reconnect".equals( cmd.toLowerCase() )) {
- this.hsqldb.connect();
- this.addToConsole("Ok\n");
+ hsqldb.connect();
+ addToConsole("Ok\n");
return;
}
- java.sql.Statement st =
this.hsqldb.getConnection().createStatement();
+ final java.sql.Statement st =
hsqldb.getConnection().createStatement();
ResultSet result;
@@ -160,60 +160,60 @@
if(st.execute(cmd))
result = st.getResultSet();
else {
- this.addToConsole("Ok\n");
+ addToConsole("Ok\n");
return;
}
} else {
- TableCreator.dropTables(this.hsqldb);
- this.addToConsole("Ok\n");
+ TableCreator.dropTables(hsqldb);
+ addToConsole("Ok\n");
return;
}
if(result == null) {
- this.addToConsole("(null)\n");
+ addToConsole("(null)\n");
return;
}
if(result.getFetchSize() == 0) {
- this.addToConsole("(done)\n");
+ addToConsole("(done)\n");
return;
}
java.sql.SQLWarning warning = result.getWarnings();
while(warning != null) {
- this.addToConsole("Warning:
"+warning.toString());
+ addToConsole("Warning: "+warning.toString());
warning = warning.getNextWarning();
}
- ResultSetMetaData metadatas = result.getMetaData();
+ final ResultSetMetaData metadatas =
result.getMetaData();
- int nmbCol = metadatas.getColumnCount();
+ final int nmbCol = metadatas.getColumnCount();
- this.addToConsole(" ");
+ addToConsole(" ");
for(int i = 1; i <= nmbCol ; i++) {
- this.display(metadatas.getColumnLabel(i),
metadatas.getColumnDisplaySize(i));
- this.addToConsole(" ");
+ display(metadatas.getColumnLabel(i),
metadatas.getColumnDisplaySize(i));
+ addToConsole(" ");
}
- this.addToConsole("\n");
+ addToConsole("\n");
- this.addToConsole(" ");
+ addToConsole(" ");
for(int i = 1; i <= nmbCol ; i++) {
- this.display(metadatas.getColumnTypeName(i),
metadatas.getColumnDisplaySize(i));
- this.addToConsole(" ");
+ display(metadatas.getColumnTypeName(i),
metadatas.getColumnDisplaySize(i));
+ addToConsole(" ");
}
- this.addToConsole("\n");
+ addToConsole("\n");
- this.addToConsole(" ");
+ addToConsole(" ");
for(int i = 1; i <= nmbCol ; i++) {
- this.display("----",
metadatas.getColumnDisplaySize(i));
- this.addToConsole(" ");
+ display("----",
metadatas.getColumnDisplaySize(i));
+ addToConsole(" ");
}
- this.addToConsole("\n");
+ addToConsole("\n");
boolean ret = true;
@@ -223,18 +223,18 @@
if(!ret)
break;
- this.display(Integer.toString(result.getRow()),
4);
- this.addToConsole(" ");
+ display(Integer.toString(result.getRow()), 4);
+ addToConsole(" ");
for(int i =1; i <= nmbCol ; i++) {
- this.display(result.getString(i),
metadatas.getColumnDisplaySize(i));
- this.addToConsole(" ");
+ display(result.getString(i),
metadatas.getColumnDisplaySize(i));
+ addToConsole(" ");
}
- this.addToConsole("\n");
+ addToConsole("\n");
}
- } catch(java.sql.SQLException e) {
- this.addToConsole("SQLException : "+e.toString()+" :
"+e.getCause()+"\n");
+ } catch(final java.sql.SQLException e) {
+ addToConsole("SQLException : "+e.toString()+" :
"+e.getCause()+"\n");
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/StatusBar.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/StatusBar.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/StatusBar.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,10 +1,14 @@
package thaw.plugins;
+import java.util.Iterator;
import java.util.Vector;
-import java.util.Iterator;
-import thaw.core.*;
-import thaw.fcp.*;
+import thaw.core.Core;
+import thaw.core.I18n;
+import thaw.core.Logger;
+import thaw.core.Main;
+import thaw.core.Plugin;
+import thaw.fcp.FCPTransferQuery;
public class StatusBar implements Runnable, Plugin {
public final static int INTERVAL = 3000; /* in ms */
@@ -16,29 +20,29 @@
private boolean advancedMode = false;
- public boolean run(Core core) {
+ public boolean run(final Core core) {
this.core = core;
- this.advancedMode =
Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue();
+ advancedMode =
Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue();
- this.running = true;
- this.refresher = new Thread(this);
+ running = true;
+ refresher = new Thread(this);
- this.refresher.start();
+ refresher.start();
return true;
}
public void run() {
- while(this.running) {
+ while(running) {
try {
- Thread.sleep(INTERVAL);
- } catch(java.lang.InterruptedException e) {
+ Thread.sleep(StatusBar.INTERVAL);
+ } catch(final java.lang.InterruptedException e) {
// pfff :P
}
- this.updateStatusBar();
+ updateStatusBar();
}
@@ -55,11 +59,11 @@
int total = 0;
try {
- Vector runningQueue =
this.core.getQueueManager().getRunningQueue();
+ final Vector runningQueue =
core.getQueueManager().getRunningQueue();
- for(Iterator it = runningQueue.iterator();
+ for(final Iterator it = runningQueue.iterator();
it.hasNext(); ) {
- FCPTransferQuery query =
(FCPTransferQuery)it.next();
+ final FCPTransferQuery query =
(FCPTransferQuery)it.next();
if(query.isRunning() && !query.isFinished()) {
running++;
@@ -78,7 +82,7 @@
}
}
- Vector[] pendingQueues =
this.core.getQueueManager().getPendingQueues();
+ final Vector[] pendingQueues =
core.getQueueManager().getPendingQueues();
for(int i =0 ; i < pendingQueues.length; i++) {
@@ -87,9 +91,9 @@
}
- } catch(java.util.ConcurrentModificationException e) {
+ } catch(final java.util.ConcurrentModificationException e) {
Logger.notice(this, "Collision !");
-
this.core.getMainWindow().setStatus(this.core.getMainWindow().getStatus()+"*");
+
core.getMainWindow().setStatus(core.getMainWindow().getStatus()+"*");
return;
}
@@ -97,31 +101,31 @@
String status = "Thaw "+Main.VERSION;
- if(this.advancedMode) {
+ if(advancedMode) {
status = status
- + SEPARATOR +
I18n.getMessage("thaw.plugin.statistics.globalProgression") + " "
+ + StatusBar.SEPARATOR +
I18n.getMessage("thaw.plugin.statistics.globalProgression") + " "
+ Integer.toString(progressDone) + "/" +
Integer.toString(progressTotal);
}
status = status
- + SEPARATOR +
I18n.getMessage("thaw.plugin.statistics.finished")+ " "
+ + StatusBar.SEPARATOR +
I18n.getMessage("thaw.plugin.statistics.finished")+ " "
+ Integer.toString(finished) + "/" +
Integer.toString(total)
- + SEPARATOR +
I18n.getMessage("thaw.plugin.statistics.failed") + " "
+ + StatusBar.SEPARATOR +
I18n.getMessage("thaw.plugin.statistics.failed") + " "
+ Integer.toString(failed) + "/" +
Integer.toString(total)
- + SEPARATOR +
I18n.getMessage("thaw.plugin.statistics.running") + " "
+ + StatusBar.SEPARATOR +
I18n.getMessage("thaw.plugin.statistics.running") + " "
+ Integer.toString(running) + "/" +
Integer.toString(total)
- + SEPARATOR +
I18n.getMessage("thaw.plugin.statistics.pending") + " "
+ + StatusBar.SEPARATOR +
I18n.getMessage("thaw.plugin.statistics.pending") + " "
+ Integer.toString(pending) + "/" +
Integer.toString(total);
- this.core.getMainWindow().setStatus(status);
+ core.getMainWindow().setStatus(status);
}
public boolean stop() {
- this.running = false;
+ running = false;
- this.core.getMainWindow().setStatus("Thaw "+Main.VERSION);
+ core.getMainWindow().setStatus("Thaw "+Main.VERSION);
return true;
}
Modified: trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java 2006-12-06
18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java 2006-12-06
18:21:00 UTC (rev 11273)
@@ -1,6 +1,7 @@
package thaw.plugins;
import java.util.Vector;
+
import javax.swing.JButton;
import thaw.core.Logger;
@@ -21,25 +22,25 @@
areDisplayed = false;
}
- public ToolbarModifier(MainWindow toolbarTarget) {
+ public ToolbarModifier(final MainWindow toolbarTarget) {
this();
setMainWindow(toolbarTarget);
}
- public void setMainWindow(MainWindow target) {
- this.mainWindow = target;
- this.mainWindow.resetLastKnowToolBarModifier();
+ public void setMainWindow(final MainWindow target) {
+ mainWindow = target;
+ mainWindow.resetLastKnowToolBarModifier();
}
- public void addButtonToTheToolbar(JButton button) {
+ public void addButtonToTheToolbar(final JButton button) {
buttons.add(button);
if (areDisplayed)
displayButtonsInTheToolbar();
}
- public void removeButtonFromTheToolbar(JButton button) {
+ public void removeButtonFromTheToolbar(final JButton button) {
buttons.remove(button);
if (areDisplayed)
Modified: trunk/apps/Thaw/src/thaw/plugins/fetchPlugin/FetchPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/fetchPlugin/FetchPanel.java
2006-12-06 18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/fetchPlugin/FetchPanel.java
2006-12-06 18:21:00 UTC (rev 11273)
@@ -1,131 +1,129 @@
package thaw.plugins.fetchPlugin;
-import java.awt.GridLayout;
import java.awt.BorderLayout;
-import javax.swing.JComboBox;
-import javax.swing.JPanel;
-import javax.swing.JLabel;
-import javax.swing.JButton;
-import javax.swing.JTextField;
-import javax.swing.JTextArea;
-import javax.swing.JScrollPane;
import java.awt.Dimension;
-import javax.swing.JFileChooser;
-
-import java.awt.Toolkit;
-import java.awt.datatransfer.Clipboard;
-import java.awt.datatransfer.DataFlavor;
-import java.awt.datatransfer.Transferable;
-
-import javax.swing.JPopupMenu;
-import javax.swing.JMenuItem;
-
-import java.awt.event.MouseListener;
+import java.awt.GridLayout;
import java.awt.event.MouseEvent;
-
+import java.awt.event.MouseListener;
import java.io.File;
-import java.util.Vector;
import java.util.Iterator;
+import java.util.Vector;
-import thaw.core.*;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import thaw.core.Core;
+import thaw.core.FileChooser;
+import thaw.core.GUIHelper;
+import thaw.core.I18n;
+import thaw.core.Logger;
+import thaw.core.WarningWindow;
import thaw.plugins.FetchPlugin;
public class FetchPanel implements java.awt.event.ActionListener,
MouseListener {
- private JPanel mainPanel = null;
- private JPanel centeredPart = null; /* (below is the validation button)
*/
- private JButton validationButton = null;
+ private JPanel mainPanel;
+ private JPanel centeredPart; /* (below is the validation button) */
+ private JButton validationButton;
- private JPanel filePanel = null;
- private JLabel fileLabel = null;
- private JTextArea fileList = null;
- private JButton pasteButton = null;
- private JButton loadListButton = null;
+ private JPanel filePanel;
+ private JLabel fileLabel;
+ private JTextArea fileList;
+ private JButton pasteButton;
+ private JButton loadListButton;
- private JPanel belowPanel = null; /* 1 x 2 */
+ private JPanel belowPanel; /* 1 x 2 */
- private JPanel priorityPanel = null; /* 2 x 1 */
- private JLabel priorityLabel = null;
- private String[] priorities = null;
- private JComboBox prioritySelecter = null;
+ private JPanel priorityPanel; /* 2 x 1 */
+ private JLabel priorityLabel;
+ private String[] priorities;
+ private JComboBox prioritySelecter;
- private JLabel destinationLabel = null;
- private JPanel dstChoosePanel = null; /* 3 x 1 */
- private JTextField destinationField = null;
- private JButton destinationButton = null;
+ private JLabel destinationLabel;
+ private JPanel dstChoosePanel; /* 3 x 1 */
+ private JTextField destinationField;
+ private JButton destinationButton;
- private JPanel queuePanel = null;
- private JLabel queueLabel = null;
- private String[] queues = null;
- private JComboBox queueSelecter = null;
+ private JPanel queuePanel;
+ private JLabel queueLabel;
+ private String[] queues;
+ private JComboBox queueSelecter;
private JPopupMenu rightClickMenu;
- private Core core;
- private FetchPlugin fetchPlugin;
+ private final Core core;
+ private final FetchPlugin fetchPlugin;
private boolean advancedMode;
- public FetchPanel(Core core, FetchPlugin fetchPlugin) {
+ public FetchPanel(final Core core, final FetchPlugin fetchPlugin) {
this.core = core;
this.fetchPlugin = fetchPlugin;
- this.advancedMode =
Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue();
+ advancedMode =
Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue();
- this.mainPanel = new JPanel();
- this.mainPanel.setLayout(new BorderLayout(20, 20));
+ mainPanel = new JPanel();
+ mainPanel.setLayout(new BorderLayout(20, 20));
- this.centeredPart = new JPanel();
- this.centeredPart.setLayout(new BorderLayout(10, 10));
+ centeredPart = new JPanel();
+ centeredPart.setLayout(new BorderLayout(10, 10));
- this.validationButton = new
JButton(I18n.getMessage("thaw.common.fetch"));
- this.validationButton.setPreferredSize(new Dimension(300, 40));
+ validationButton = new
JButton(I18n.getMessage("thaw.common.fetch"));
+ validationButton.setPreferredSize(new Dimension(300, 40));
- this.validationButton.addActionListener(this);
+ validationButton.addActionListener(this);
- this.filePanel = new JPanel();
- this.filePanel.setLayout(new BorderLayout());
+ filePanel = new JPanel();
+ filePanel.setLayout(new BorderLayout());
/* FILE LIST */
- this.fileList = new JTextArea();
- this.fileLabel = new
JLabel(I18n.getMessage("thaw.plugin.fetch.keyList"));
+ fileList = new JTextArea();
+ fileLabel = new
JLabel(I18n.getMessage("thaw.plugin.fetch.keyList"));
- this.loadListButton = new
JButton(I18n.getMessage("thaw.plugin.fetch.loadKeyListFromFile"));
- this.loadListButton.addActionListener(this);
+ loadListButton = new
JButton(I18n.getMessage("thaw.plugin.fetch.loadKeyListFromFile"));
+ loadListButton.addActionListener(this);
- this.pasteButton = new
JButton(I18n.getMessage("thaw.plugin.fetch.pasteFromClipboard"));
+ pasteButton = new
JButton(I18n.getMessage("thaw.plugin.fetch.pasteFromClipboard"));
new GUIHelper.PasteHelper(pasteButton, fileList);
fileList.addMouseListener(this);
- JPanel buttonPanel = new JPanel();
+ final JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new GridLayout(1,2));
- buttonPanel.add(this.pasteButton);
- buttonPanel.add(this.loadListButton);
+ buttonPanel.add(pasteButton);
+ buttonPanel.add(loadListButton);
- this.filePanel.add(this.fileLabel, BorderLayout.NORTH);
- this.filePanel.add(new JScrollPane(this.fileList),
BorderLayout.CENTER);
- this.filePanel.add(buttonPanel, BorderLayout.SOUTH);
+ filePanel.add(fileLabel, BorderLayout.NORTH);
+ filePanel.add(new JScrollPane(fileList), BorderLayout.CENTER);
+ filePanel.add(buttonPanel, BorderLayout.SOUTH);
/* below panel */
- this.belowPanel = new JPanel();
- if(this.advancedMode)
- this.belowPanel.setLayout(new GridLayout(2, 2, 10, 10));
+ belowPanel = new JPanel();
+ if(advancedMode)
+ belowPanel.setLayout(new GridLayout(2, 2, 10, 10));
else
- this.belowPanel.setLayout(new GridLayout(1, 2, 10, 10));
+ belowPanel.setLayout(new GridLayout(1, 2, 10, 10));
/* PRIORITY */
- this.priorityPanel = new JPanel();
- this.priorityPanel.setLayout(new GridLayout(2, 1, 5, 5));
+ priorityPanel = new JPanel();
+ priorityPanel.setLayout(new GridLayout(2, 1, 5, 5));
- this.priorityLabel = new
JLabel(I18n.getMessage("thaw.common.priority"));
- this.priorities = new String[] {
+ priorityLabel = new
JLabel(I18n.getMessage("thaw.common.priority"));
+ priorities = new String[] {
I18n.getMessage("thaw.plugin.priority.p0"),
I18n.getMessage("thaw.plugin.priority.p1"),
I18n.getMessage("thaw.plugin.priority.p2"),
@@ -134,109 +132,109 @@
I18n.getMessage("thaw.plugin.priority.p5"),
I18n.getMessage("thaw.plugin.priority.p6")
};
- this.prioritySelecter = new JComboBox(this.priorities);
-
this.prioritySelecter.setSelectedItem(I18n.getMessage("thaw.plugin.priority.p4"));
+ prioritySelecter = new JComboBox(priorities);
+
prioritySelecter.setSelectedItem(I18n.getMessage("thaw.plugin.priority.p4"));
- this.priorityPanel.add(this.priorityLabel);
- this.priorityPanel.add(this.prioritySelecter);
+ priorityPanel.add(priorityLabel);
+ priorityPanel.add(prioritySelecter);
/* QUEUE */
- this.queuePanel = new JPanel();
- this.queuePanel.setLayout(new GridLayout(2, 1, 5, 5));
+ queuePanel = new JPanel();
+ queuePanel.setLayout(new GridLayout(2, 1, 5, 5));
- this.queueLabel = new
JLabel(I18n.getMessage("thaw.common.globalQueue"));
- this.queues = new String [] {
+ queueLabel = new
JLabel(I18n.getMessage("thaw.common.globalQueue"));
+ queues = new String [] {
I18n.getMessage("thaw.common.true"),
I18n.getMessage("thaw.common.false"),
};
- this.queueSelecter = new JComboBox(this.queues);
+ queueSelecter = new JComboBox(queues);
- this.queuePanel.add(this.queueLabel);
- this.queuePanel.add(this.queueSelecter);
+ queuePanel.add(queueLabel);
+ queuePanel.add(queueSelecter);
/* DESTINATION */
- this.destinationLabel = new
JLabel(I18n.getMessage("thaw.plugin.fetch.destinationDirectory"));
+ destinationLabel = new
JLabel(I18n.getMessage("thaw.plugin.fetch.destinationDirectory"));
- this.dstChoosePanel = new JPanel();
- this.dstChoosePanel.setLayout(new GridLayout(3,1, 5, 5));
+ dstChoosePanel = new JPanel();
+ dstChoosePanel.setLayout(new GridLayout(3,1, 5, 5));
- this.destinationField = new JTextField("");
+ destinationField = new JTextField("");
if(core.getConfig().getValue("lastDestinationDirectory") !=
null)
-
this.destinationField.setText(core.getConfig().getValue("lastDestinationDirectory"));
- this.destinationField.setEditable(true);
+
destinationField.setText(core.getConfig().getValue("lastDestinationDirectory"));
+ destinationField.setEditable(true);
- this.destinationButton = new
JButton(I18n.getMessage("thaw.plugin.fetch.chooseDestination"));
- this.destinationButton.addActionListener(this);
+ destinationButton = new
JButton(I18n.getMessage("thaw.plugin.fetch.chooseDestination"));
+ destinationButton.addActionListener(this);
rightClickMenu = new JPopupMenu();
- JMenuItem item = new
JMenuItem(I18n.getMessage("thaw.common.paste"));
+ final JMenuItem item = new
JMenuItem(I18n.getMessage("thaw.common.paste"));
new GUIHelper.PasteHelper(item, fileList);
rightClickMenu.add(item);
/*** Putting things together ***/
- this.dstChoosePanel.add(this.destinationLabel);
- this.dstChoosePanel.add(this.destinationField);
- this.dstChoosePanel.add(this.destinationButton);
+ dstChoosePanel.add(destinationLabel);
+ dstChoosePanel.add(destinationField);
+ dstChoosePanel.add(destinationButton);
- if(this.advancedMode) {
- this.belowPanel.add(this.priorityPanel);
+ if(advancedMode) {
+ belowPanel.add(priorityPanel);
//belowPanel.add(persistencePanel);
- this.belowPanel.add(this.queuePanel);
+ belowPanel.add(queuePanel);
}
- this.belowPanel.add(this.dstChoosePanel);
+ belowPanel.add(dstChoosePanel);
- if(!this.advancedMode) {
- this.belowPanel.add(new JPanel());
+ if(!advancedMode) {
+ belowPanel.add(new JPanel());
}
- this.centeredPart.add(this.filePanel, BorderLayout.CENTER);
- this.centeredPart.add(this.belowPanel, BorderLayout.SOUTH);
+ centeredPart.add(filePanel, BorderLayout.CENTER);
+ centeredPart.add(belowPanel, BorderLayout.SOUTH);
- this.mainPanel.add(this.centeredPart, BorderLayout.CENTER);
- this.mainPanel.add(this.validationButton, BorderLayout.SOUTH);
+ mainPanel.add(centeredPart, BorderLayout.CENTER);
+ mainPanel.add(validationButton, BorderLayout.SOUTH);
}
public JPanel getPanel() {
- return this.mainPanel;
+ return mainPanel;
}
- public void actionPerformed(java.awt.event.ActionEvent e) {
- if(e.getSource() == this.validationButton) {
+ public void actionPerformed(final java.awt.event.ActionEvent e) {
+ if(e.getSource() == validationButton) {
int priority = 6;
boolean globalQueue = true;
-
if(((String)this.queueSelecter.getSelectedItem()).equals(I18n.getMessage("thaw.common.false")))
+
if(((String)queueSelecter.getSelectedItem()).equals(I18n.getMessage("thaw.common.false")))
globalQueue = false;
- for(int i = 0; i < this.priorities.length ; i++) {
-
if(((String)this.prioritySelecter.getSelectedItem()).equals(I18n.getMessage("thaw.plugin.priority.p"+i)))
+ for(int i = 0; i < priorities.length ; i++) {
+
if(((String)prioritySelecter.getSelectedItem()).equals(I18n.getMessage("thaw.plugin.priority.p"+i)))
priority = i;
}
- if(this.destinationField.getText() == null ||
"".equals( this.destinationField.getText() )) {
- new thaw.core.WarningWindow(this.core,
I18n.getMessage("thaw.plugin.fetch.chooseADestination"));
+ if((destinationField.getText() == null) || "".equals(
destinationField.getText() )) {
+ new thaw.core.WarningWindow(core,
I18n.getMessage("thaw.plugin.fetch.chooseADestination"));
return;
}
-
this.fetchPlugin.fetchFiles(this.fileList.getText().split("\n"),
+ fetchPlugin.fetchFiles(fileList.getText().split("\n"),
priority, 0, globalQueue,
- this.destinationField.getText());
+ destinationField.getText());
- this.fileList.setText("");
+ fileList.setText("");
}
- if(e.getSource() == this.destinationButton) {
+ if(e.getSource() == destinationButton) {
FileChooser fileChooser;
- if(this.destinationField.getText() != null &&
!"".equals( this.destinationField.getText() )) {
- fileChooser = new
FileChooser(this.destinationField.getText());
+ if((destinationField.getText() != null) && !"".equals(
destinationField.getText() )) {
+ fileChooser = new
FileChooser(destinationField.getText());
} else {
fileChooser = new FileChooser();
}
@@ -254,13 +252,13 @@
return;
}
- this.destinationField.setText(dir.getPath());
-
this.core.getConfig().setValue("lastDestinationDirectory",
this.destinationField.getText());
+ destinationField.setText(dir.getPath());
+ core.getConfig().setValue("lastDestinationDirectory",
destinationField.getText());
}
- if(e.getSource() == this.loadListButton) {
- FileChooser fileChooser = new FileChooser();
+ if(e.getSource() == loadListButton) {
+ final FileChooser fileChooser = new FileChooser();
File toParse = null;
fileChooser.setTitle(I18n.getMessage("thaw.plugin.fetch.loadKeyListFromFile"));
@@ -274,40 +272,40 @@
return;
}
- Vector keys = KeyFileFilter.extractKeys(toParse);
+ final Vector keys = KeyFileFilter.extractKeys(toParse);
- if(keys == null || keys.size() <= 0) {
- new WarningWindow(this.core, "No key found !");
+ if((keys == null) || (keys.size() <= 0)) {
+ new WarningWindow(core, "No key found !");
return;
}
- String result = this.fileList.getText();
+ String result = fileList.getText();
- for(Iterator i = keys.iterator(); i.hasNext() ;) {
- String key = (String)i.next();
+ for(final Iterator i = keys.iterator(); i.hasNext() ;) {
+ final String key = (String)i.next();
result = result + key + "\n";
}
- this.fileList.setText(result);
+ fileList.setText(result);
}
}
- public void mouseClicked(MouseEvent e) { }
- public void mouseEntered(MouseEvent e) { }
- public void mouseExited(MouseEvent e) { }
- public void mousePressed(MouseEvent e) {
- this.showPopupMenu(e);
+ public void mouseClicked(final MouseEvent e) { }
+ public void mouseEntered(final MouseEvent e) { }
+ public void mouseExited(final MouseEvent e) { }
+ public void mousePressed(final MouseEvent e) {
+ showPopupMenu(e);
}
- public void mouseReleased(MouseEvent e) {
- this.showPopupMenu(e);
+ public void mouseReleased(final MouseEvent e) {
+ showPopupMenu(e);
}
- protected void showPopupMenu(MouseEvent e) {
+ protected void showPopupMenu(final MouseEvent e) {
if(e.isPopupTrigger()) {
rightClickMenu.show(e.getComponent(), e.getX(),
e.getY());
}
Modified: trunk/apps/Thaw/src/thaw/plugins/fetchPlugin/KeyFileFilter.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/fetchPlugin/KeyFileFilter.java
2006-12-06 18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/fetchPlugin/KeyFileFilter.java
2006-12-06 18:21:00 UTC (rev 11273)
@@ -1,12 +1,12 @@
package thaw.plugins.fetchPlugin;
-import java.util.Vector;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
-import java.io.BufferedReader;
import java.io.InputStreamReader;
+import java.util.Vector;
-import thaw.core.*;
+import thaw.core.Logger;
public class KeyFileFilter {
@@ -21,27 +21,27 @@
/**
* @return Vector of Strings
*/
- public static Vector extractKeys(File file) {
- Vector result = new Vector();
+ public static Vector extractKeys(final File file) {
+ final Vector result = new Vector();
FileInputStream fstream = null;
try {
fstream = new FileInputStream(file);
- } catch(java.io.FileNotFoundException e) {
+ } catch(final java.io.FileNotFoundException e) {
Logger.warning(new KeyFileFilter(), "File not found
exception for "+file.getPath());
return null;
}
- BufferedReader in = new BufferedReader(new
InputStreamReader(fstream));
+ final BufferedReader in = new BufferedReader(new
InputStreamReader(fstream));
try {
String line = null;
while((line = in.readLine()) != null) {
- String[] pieces = line.split("[^-
\\?.a-zA-Z0-9,~%@/'_]");
+ final String[] pieces = line.split("[^-
\\?.a-zA-Z0-9,~%@/'_]");
for(int i = 0 ; i < pieces.length ; i++) {
if(pieces[i].matches(".{3}@.*,.*"))
@@ -50,7 +50,7 @@
}
- } catch(java.io.IOException e) {
+ } catch(final java.io.IOException e) {
Logger.warning(new KeyFileFilter(), "IOException while
reading '"+file.getPath()+"' !");
return result;
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/File.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/File.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/index/File.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,124 +1,126 @@
package thaw.plugins.index;
-import java.sql.*;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.Iterator;
+import java.util.Vector;
-import org.w3c.dom.Element;
import org.w3c.dom.Document;
+import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import java.util.Vector;
-import java.util.Iterator;
-
-import thaw.core.Logger;
import thaw.core.FreenetURIHelper;
-
-import thaw.fcp.*;
-import thaw.plugins.Hsqldb;
import thaw.core.Logger;
-
+import thaw.fcp.FCPClientGet;
+import thaw.fcp.FCPClientPut;
+import thaw.fcp.FCPQueueManager;
+import thaw.fcp.FCPTransferQuery;
+import thaw.plugins.Hsqldb;
import thaw.plugins.insertPlugin.DefaultMIMETypes;
public class File extends java.util.Observable implements java.util.Observer {
private int id = -1; /* -1 = undefined */
- private String fileName = null;
- private String publicKey = null;
- private String mime = null;
+ private String fileName;
+ private String publicKey;
+ private String mime;
private long size = -1;
- private String category = null;
+ private String category;
- private String localPath = null;
+ private String localPath;
private FCPTransferQuery transfer = null; /* can be null */
private Index parent;
private int parentId;
- private Hsqldb db;
+ private final Hsqldb db;
private FCPQueueManager queueManager = null;
- public File(Hsqldb db, String publicKey, Index parent) {
+ public File(final Hsqldb db, final String publicKey, final Index
parent) {
this.db = db;
- this.id = -1;
+ id = -1;
this.publicKey = publicKey;
deduceFilenameFromKey();
- this.size = 0;
+ size = 0;
}
/**
* @param path Local path
* @param transfer Corresponding tranfer (can be null).
*/
- public File(Hsqldb db, String path, String category, Index parent,
FCPTransferQuery transfer) {
+ public File(final Hsqldb db, final String path, final String category,
final Index parent, final FCPTransferQuery transfer) {
this.db = db;
- this.id = -1;
- this.localPath = path;
+ id = -1;
+ localPath = path;
this.transfer = transfer;
- String[] pathElements =
this.localPath.split(java.io.File.separator.replaceAll("\\\\", "\\\\\\\\"));
- this.fileName = pathElements[pathElements.length-1];
+ final String[] pathElements =
localPath.split(java.io.File.separator.replaceAll("\\\\", "\\\\\\\\"));
+ fileName = pathElements[pathElements.length-1];
- this.size = (new java.io.File(path)).length();
+ size = (new java.io.File(path)).length();
this.category = category;
- this.setParent(parent);
+ setParent(parent);
if(transfer != null)
((java.util.Observable)transfer).addObserver(this);
}
- public File(Hsqldb db, ResultSet resultSet, Index parent) throws
SQLException {
+ public File(final Hsqldb db, final ResultSet resultSet, final Index
parent) throws SQLException {
this.db = db;
- this.id = resultSet.getInt("id");
- this.fileName = resultSet.getString("filename").trim();
- this.publicKey = resultSet.getString("publicKey").trim();
- this.localPath = resultSet.getString("localPath");
- this.size = resultSet.getLong("size");
- this.parentId = resultSet.getInt("indexParent");
+ id = resultSet.getInt("id");
+ fileName = resultSet.getString("filename").trim();
+ publicKey = resultSet.getString("publicKey").trim();
+ localPath = resultSet.getString("localPath");
+ size = resultSet.getLong("size");
+ parentId = resultSet.getInt("indexParent");
//category = resultSet.getString("category");
- this.deduceFilenameFromKey();
+ deduceFilenameFromKey();
this.parent = parent;
}
- public File(Hsqldb db, Element fileElement, Index parent) {
+ public File(final Hsqldb db, final Element fileElement, final Index
parent) {
this.db = db;
- this.id = Integer.parseInt(fileElement.getAttribute("id")); /*
will be changed when inserted in the database */
- this.publicKey = fileElement.getAttribute("key");
+ id = Integer.parseInt(fileElement.getAttribute("id")); /* will
be changed when inserted in the database */
+ publicKey = fileElement.getAttribute("key");
- if (this.publicKey != null)
- this.publicKey = this.publicKey.trim();
+ if (publicKey != null)
+ publicKey = publicKey.trim();
- this.localPath = null;
+ localPath = null;
- this.size = Long.parseLong(fileElement.getAttribute("size"));
+ size = Long.parseLong(fileElement.getAttribute("size"));
- this.setOptions(fileElement.getChildNodes());
+ setOptions(fileElement.getChildNodes());
- this.deduceFilenameFromKey();
+ deduceFilenameFromKey();
this.parent = parent;
}
public void deduceFilenameFromKey() {
- this.fileName =
FreenetURIHelper.getFilenameFromKey(this.publicKey);
+ fileName = FreenetURIHelper.getFilenameFromKey(publicKey);
}
- public void setOptions(NodeList list) {
+ public void setOptions(final NodeList list) {
for(int i = 0 ; i < list.getLength() ; i++) {
if(list.item(i).getNodeType() == Node.ELEMENT_NODE) {
- Element option = (Element)list.item(i);
+ final Element option = (Element)list.item(i);
if("category".equals(
option.getAttribute("name") ))
- this.category =
option.getAttribute("value");
+ category = option.getAttribute("value");
else {
/* TODO */
}
@@ -126,12 +128,12 @@
}
}
- public void setParent(Index parent) {
+ public void setParent(final Index parent) {
this.parent = parent;
if (parent != null)
- this.parentId = parent.getId();
+ parentId = parent.getId();
else
- this.parentId = -1;
+ parentId = -1;
}
public Index getParent() {
@@ -139,41 +141,41 @@
}
public int getParentId() {
- return this.parentId;
+ return parentId;
}
public String getFilename() {
- return this.fileName;
+ return fileName;
}
public long getSize() {
- return this.size;
+ return size;
}
public String getLocalPath() {
- return this.localPath;
+ return localPath;
}
public String getCategory() {
- return this.category;
+ return category;
}
public String getPublicKey() {
return publicKey;
}
- public void setPublicKey(String publicKey) {
+ public void setPublicKey(final String publicKey) {
this.publicKey = publicKey;
- this.setChanged();
+ setChanged();
this.notifyObservers();
}
public FCPTransferQuery getTransfer() {
- return this.transfer;
+ return transfer;
}
- public void setTransfer(FCPTransferQuery query) {
+ public void setTransfer(final FCPTransferQuery query) {
if (transfer != null) {
Logger.notice(this, "A transfer is already running for
this file");
return;
@@ -183,20 +185,20 @@
if (transfer != null) {
if(transfer instanceof FCPClientPut)
- ((FCPClientPut)this.transfer).addObserver(this);
+ ((FCPClientPut)transfer).addObserver(this);
if(transfer instanceof FCPClientGet)
- ((FCPClientGet)this.transfer).addObserver(this);
+ ((FCPClientGet)transfer).addObserver(this);
}
if (transfer != null)
update(((java.util.Observable)transfer), null);
- this.setChanged();
+ setChanged();
this.notifyObservers(query);
}
- public void recalculateCHK(FCPQueueManager queueManager) {
+ public void recalculateCHK(final FCPQueueManager queueManager) {
this.queueManager = queueManager;
if (getLocalPath() == null) {
@@ -204,7 +206,7 @@
return;
}
- FCPClientPut insertion = new FCPClientPut(new
java.io.File(getLocalPath()), 0, 0, null,
+ final FCPClientPut insertion = new FCPClientPut(new
java.io.File(getLocalPath()), 0, 0, null,
null, 4,
true, 2, true); /*
getCHKOnly */
queueManager.addQueryToThePendingQueue(insertion);
@@ -212,8 +214,8 @@
this.setTransfer(insertion);
}
- public void download(String targetPath, FCPQueueManager queueManager) {
- FCPClientGet clientGet = new FCPClientGet(getPublicKey(), 4, 0,
true, -1, targetPath);
+ public void download(final String targetPath, final FCPQueueManager
queueManager) {
+ final FCPClientGet clientGet = new FCPClientGet(getPublicKey(),
4, 0, true, -1, targetPath);
queueManager.addQueryToThePendingQueue(clientGet);
@@ -221,8 +223,8 @@
}
- public void insertOnFreenet(FCPQueueManager queueManager) {
- FCPClientPut clientPut = new FCPClientPut(new
java.io.File(getLocalPath()),
+ public void insertOnFreenet(final FCPQueueManager queueManager) {
+ final FCPClientPut clientPut = new FCPClientPut(new
java.io.File(getLocalPath()),
0, 0, null, null, 4,
true, 0);
queueManager.addQueryToThePendingQueue(clientPut);
@@ -231,8 +233,8 @@
/* Try to find its download automagically */
- public void setTransfer(FCPQueueManager queueManager) {
- if (publicKey != null || fileName != null) {
+ public void setTransfer(final FCPQueueManager queueManager) {
+ if ((publicKey != null) || (fileName != null)) {
FCPTransferQuery trans;
if (getPublicKey() == null)
@@ -251,68 +253,66 @@
notifyObservers();
}
- public synchronized void insert() {
- if (this.parent == null) {
+ public void insert() {
+ if (parent == null) {
Logger.notice(this, "insert(): No parent !");
return;
}
- db.lockWriting();
+ synchronized (db.dbLock) {
+ try {
+ PreparedStatement st;
- try {
- PreparedStatement st;
+ st =
db.getConnection().prepareStatement("SELECT id FROM files ORDER BY id DESC
LIMIT 1");
- st = this.db.getConnection().prepareStatement("SELECT
id FROM files ORDER BY id DESC LIMIT 1");
+ try {
+ if(st.execute()) {
+ final ResultSet result =
st.getResultSet();
+ result.next();
+ id = result.getInt("id")+1;
+ } else
+ id = 1;
+ } catch(final SQLException e) {
+ id = 1;
+ }
- try {
- if(st.execute()) {
- ResultSet result = st.getResultSet();
- result.next();
- this.id = result.getInt("id")+1;
- } else
- this.id = 1;
- } catch(SQLException e) {
- this.id = 1;
- }
+ st =
db.getConnection().prepareStatement("INSERT INTO files (id, filename,
publicKey, "+
+ "localPath, mime, size,
category, indexParent) "+
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
+ st.setInt(1, id);
- st = this.db.getConnection().prepareStatement("INSERT
INTO files (id, filename, publicKey, "+
-
"localPath, mime, size, category, indexParent) "+
- "VALUES
(?, ?, ?, ?, ?, ?, ?, ?)");
- st.setInt(1, this.id);
+ st.setString(2, fileName);
- st.setString(2, this.fileName);
+ if(publicKey != null)
+ st.setString(3, publicKey);
+ else
+ st.setString(3, fileName);
- if(this.publicKey != null)
- st.setString(3, this.publicKey);
- else
- st.setString(3, this.fileName);
+ if(localPath != null)
+ st.setString(4, localPath);
+ else
+ st.setNull(4, Types.VARCHAR);
- if(this.localPath != null)
- st.setString(4, this.localPath);
- else
- st.setNull(4, Types.VARCHAR);
+ if(mime != null)
+ st.setString(5, mime);
+ else
+ st.setNull(5, Types.VARCHAR);
- if(this.mime != null)
- st.setString(5, this.mime);
- else
- st.setNull(5, Types.VARCHAR);
+ st.setLong(6, size);
- st.setLong(6, this.size);
+ if(category != null)
+ st.setString(7, category);
+ else
+ st.setNull(7, Types.VARCHAR);
- if(this.category != null)
- st.setString(7, this.category);
- else
- st.setNull(7, Types.VARCHAR);
+ st.setInt(8, parent.getId());
- st.setInt(8, this.parent.getId());
-
- st.execute();
- } catch(SQLException e) {
- Logger.error(this, "Unable to insert file
'"+this.fileName+"' because: "+e.toString());
+ st.execute();
+ } catch(final SQLException e) {
+ Logger.error(this, "Unable to insert file
'"+fileName+"' because: "+e.toString());
+ }
}
-
- db.unlockWriting();
}
public void delete() {
@@ -320,18 +320,18 @@
try {
PreparedStatement st;
- st = this.db.getConnection().prepareStatement("DELETE
FROM files WHERE id = ?");
- st.setInt(1, this.id);
+ st = db.getConnection().prepareStatement("DELETE FROM
files WHERE id = ?");
+ st.setInt(1, id);
st.execute();
- } catch(SQLException e) {
- Logger.error(this, "Unable to remove file
'"+this.fileName+"' because: "+e.toString());
+ } catch(final SQLException e) {
+ Logger.error(this, "Unable to remove file
'"+fileName+"' because: "+e.toString());
}
}
public void update() {
- if (this.parent == null) {
+ if (parent == null) {
Logger.notice(this, "update(): No parent !");
return;
}
@@ -339,45 +339,45 @@
try {
PreparedStatement st;
- st = this.db.getConnection().prepareStatement("UPDATE
files SET filename = ?, publicKey = ?, localPath = ?, mime= ?, size = ?,
category = ?, indexParent = ? WHERE id = ?");
+ st = db.getConnection().prepareStatement("UPDATE files
SET filename = ?, publicKey = ?, localPath = ?, mime= ?, size = ?, category =
?, indexParent = ? WHERE id = ?");
- st.setString(1, this.fileName);
+ st.setString(1, fileName);
- if(this.publicKey != null)
- st.setString(2, this.publicKey);
+ if(publicKey != null)
+ st.setString(2, publicKey);
else
- st.setString(2, this.fileName);
+ st.setString(2, fileName);
- if(this.localPath != null)
- st.setString(3, this.localPath);
+ if(localPath != null)
+ st.setString(3, localPath);
else
st.setNull(3, Types.VARCHAR);
- if(this.mime != null)
- st.setString(4, this.mime);
+ if(mime != null)
+ st.setString(4, mime);
else
st.setNull(4, Types.VARCHAR);
- st.setLong(5, this.size);
+ st.setLong(5, size);
- if(this.category != null)
- st.setString(6, this.category);
+ if(category != null)
+ st.setString(6, category);
else
st.setNull(6, Types.VARCHAR);
- st.setInt(7, this.getParent().getId());
+ st.setInt(7, getParent().getId());
- st.setInt(8, this.id);
+ st.setInt(8, id);
st.execute();
- } catch(SQLException e) {
- Logger.error(this, "Unable to update file
'"+this.fileName+"' because: "+e.toString());
+ } catch(final SQLException e) {
+ Logger.error(this, "Unable to update file
'"+fileName+"' because: "+e.toString());
}
}
public boolean isInTheDatabase() {
- if (this.parent == null) {
+ if (parent == null) {
Logger.notice(this, "isInTheDatabase(): No parent !");
return false;
}
@@ -385,23 +385,22 @@
try {
PreparedStatement st;
- st = this.db.getConnection().prepareStatement("SELECT
publicKey from files WHERE publicKey = ? AND indexParent = ?");
+ st = db.getConnection().prepareStatement("SELECT
publicKey from files WHERE publicKey = ? AND indexParent = ?");
- if(this.publicKey != null)
- st.setString(1, this.publicKey);
+ if(publicKey != null)
+ st.setString(1, publicKey);
else
- st.setString(1, this.fileName);
+ st.setString(1, fileName);
- st.setInt(2, this.getParent().getId());
+ st.setInt(2, getParent().getId());
if(st.execute()) {
- ResultSet result = st.getResultSet();
- if (result != null && result.next()) {
+ final ResultSet result = st.getResultSet();
+ if ((result != null) && result.next())
return true;
- }
}
- } catch(SQLException e) {
+ } catch(final SQLException e) {
}
@@ -409,14 +408,14 @@
}
- public void update(java.util.Observable o, Object param) {
- if(o == this.transfer) {
+ public void update(final java.util.Observable o, final Object param) {
+ if(o == transfer) {
if (transfer.getFileKey() != null)
setPublicKey(transfer.getFileKey());
- if (transfer.isFinished() && transfer instanceof
FCPClientPut) {
+ if (transfer.isFinished() && (transfer instanceof
FCPClientPut)) {
if (queueManager != null) {
- queueManager.remove(this.transfer);
+ queueManager.remove(transfer);
queueManager = null;
}
@@ -425,41 +424,41 @@
update();
}
- if(this.transfer.isFinished() && this.transfer
instanceof FCPClientGet) {
-
((FCPClientGet)this.transfer).deleteObserver(this);
- this.size = (new
java.io.File(transfer.getPath())).length();
+ if(transfer.isFinished() && (transfer instanceof
FCPClientGet)) {
+ ((FCPClientGet)transfer).deleteObserver(this);
+ size = (new
java.io.File(transfer.getPath())).length();
}
- if(this.transfer.isFinished() &&
this.transfer.isSuccessful()) {
- this.transfer = null;
+ if(transfer.isFinished() && transfer.isSuccessful()) {
+ transfer = null;
}
- this.setChanged();
+ setChanged();
this.notifyObservers();
}
}
public int getId() {
- return this.id;
+ return id;
}
- public Element getXML(Document xmlDoc) {
- if(this.getPublicKey() == null) {
- Logger.notice(this, "No public key for file
'"+this.fileName+"' => not added to the index");
+ public Element getXML(final Document xmlDoc) {
+ if(getPublicKey() == null) {
+ Logger.notice(this, "No public key for file
'"+fileName+"' => not added to the index");
return null;
}
- Element file = xmlDoc.createElement("file");
+ final Element file = xmlDoc.createElement("file");
- file.setAttribute("id", Integer.toString(this.getId()));
- file.setAttribute("key", this.getPublicKey());
- file.setAttribute("size", Long.toString(this.getSize()));
- file.setAttribute("mime",
DefaultMIMETypes.guessMIMEType(this.fileName));
+ file.setAttribute("id", Integer.toString(getId()));
+ file.setAttribute("key", getPublicKey());
+ file.setAttribute("size", Long.toString(getSize()));
+ file.setAttribute("mime",
DefaultMIMETypes.guessMIMEType(fileName));
- for(Iterator it = this.getOptionElements(xmlDoc).iterator();
+ for(final Iterator it = getOptionElements(xmlDoc).iterator();
it.hasNext(); ) {
- Element e = (Element)it.next();
+ final Element e = (Element)it.next();
file.appendChild(e);
}
@@ -469,13 +468,13 @@
/**
* @return Element Vector
*/
- public Vector getOptionElements(Document xmlDoc) {
- Vector options = new Vector();
+ public Vector getOptionElements(final Document xmlDoc) {
+ final Vector options = new Vector();
- if(this.category != null) {
- Element categoryEl = xmlDoc.createElement("option");
+ if(category != null) {
+ final Element categoryEl =
xmlDoc.createElement("option");
categoryEl.setAttribute("name", "category");
- categoryEl.setAttribute("value", this.category);
+ categoryEl.setAttribute("value", category);
options.add(categoryEl);
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/FileDetailsEditor.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/FileDetailsEditor.java
2006-12-06 18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/index/FileDetailsEditor.java
2006-12-06 18:21:00 UTC (rev 11273)
@@ -6,13 +6,13 @@
private JPanel panel;
- public FileDetailsEditor(boolean modifiables) {
- this.panel = new JPanel();
+ public FileDetailsEditor(final boolean modifiables) {
+ panel = new JPanel();
}
public JPanel getPanel() {
- return this.panel;
+ return panel;
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/FileManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/FileManagementHelper.java
2006-12-06 18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/index/FileManagementHelper.java
2006-12-06 18:21:00 UTC (rev 11273)
@@ -1,27 +1,23 @@
package thaw.plugins.index;
-import java.awt.event.ActionListener;
+import java.awt.Toolkit;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
-import javax.swing.AbstractButton;
+import java.awt.event.ActionListener;
+import java.util.Iterator;
+import java.util.Vector;
+import javax.swing.AbstractButton;
import javax.swing.JFileChooser;
-import java.util.Vector;
-import java.util.Iterator;
-
-import thaw.core.FileChooser;
import thaw.core.Config;
+import thaw.core.FileChooser;
import thaw.core.I18n;
-import thaw.plugins.Hsqldb;
import thaw.core.Logger;
+import thaw.fcp.FCPQueueManager;
-import java.awt.Toolkit;
-import java.awt.datatransfer.Clipboard;
-import java.awt.datatransfer.StringSelection;
-import thaw.fcp.*;
-
-
public class FileManagementHelper {
/**
* Class implementing IndexAction will automatically do an
addActionListener if necessary
@@ -44,7 +40,7 @@
private Vector target;
private Config config;
- public FileDownloader(Config config, FCPQueueManager
queueManager, AbstractButton actionSource) {
+ public FileDownloader(final Config config, final
FCPQueueManager queueManager, final AbstractButton actionSource) {
this.queueManager = queueManager;
this.actionSource = actionSource;
this.config = config;
@@ -52,15 +48,15 @@
actionSource.addActionListener(this);
}
- public void setTarget(Vector target) {
+ public void setTarget(final Vector target) {
this.target = target;
- actionSource.setEnabled(target != null && target.size()
!= 0);
+ actionSource.setEnabled((target != null) &&
(target.size() != 0));
}
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(final ActionEvent e) {
FileChooser fileChooser;
- if (this.config.getValue("lastDestinationDirectory") ==
null)
+ if (config.getValue("lastDestinationDirectory") == null)
fileChooser = new FileChooser();
else
fileChooser = new
FileChooser(config.getValue("lastDestinationDirectory"));
@@ -69,14 +65,14 @@
fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
fileChooser.setTitle(I18n.getMessage("thaw.plugin.fetch.destinationDirectory"));
- java.io.File destination = fileChooser.askOneFile();
+ final java.io.File destination =
fileChooser.askOneFile();
if (destination == null)
return;
config.setValue("lastDestinationDirectory",
destination.getPath());
- downloadFiles(queueManager, target,
destination.getPath());
+ FileManagementHelper.downloadFiles(queueManager,
target, destination.getPath());
}
}
@@ -84,11 +80,11 @@
/**
* @param files See thaw.plugins.index.File
*/
- public static void downloadFiles(FCPQueueManager queueManager,
- Vector files, String destinationPath) {
- for (Iterator it = files.iterator();
+ public static void downloadFiles(final FCPQueueManager queueManager,
+ final Vector files, final String
destinationPath) {
+ for (final Iterator it = files.iterator();
it.hasNext();) {
- thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
+ final thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
file.download(destinationPath, queueManager);
}
}
@@ -99,14 +95,14 @@
private AbstractButton actionSource;
private Vector target;
- public FileInserter(FCPQueueManager queueManager,
AbstractButton actionSource) {
+ public FileInserter(final FCPQueueManager queueManager, final
AbstractButton actionSource) {
this.queueManager = queueManager;
this.actionSource = actionSource;
if (actionSource != null)
actionSource.addActionListener(this);
}
- public void setTarget(Vector target) {
+ public void setTarget(final Vector target) {
boolean isOk;
isOk = true;
@@ -114,11 +110,11 @@
this.target = target;
if (target != null) {
- for (Iterator it = target.iterator();
+ for (final Iterator it = target.iterator();
it.hasNext(); ) {
- thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
+ final thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
- if (file.getLocalPath() == null
+ if ((file.getLocalPath() == null)
|| !file.isModifiable()) {
isOk = false;
break;
@@ -126,22 +122,22 @@
}
}
- actionSource.setEnabled(target != null && target.size()
!= 0 && isOk);
+ actionSource.setEnabled((target != null) &&
(target.size() != 0) && isOk);
}
- public void actionPerformed(ActionEvent e) {
- insertFiles(queueManager, target);
+ public void actionPerformed(final ActionEvent e) {
+ FileManagementHelper.insertFiles(queueManager, target);
}
}
/**
* @param files See thaw.plugins.index.File
*/
- public static void insertFiles(FCPQueueManager queueManager,
- Vector files) {
- for (Iterator it = files.iterator();
+ public static void insertFiles(final FCPQueueManager queueManager,
+ final Vector files) {
+ for (final Iterator it = files.iterator();
it.hasNext();) {
- thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
+ final thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
file.insertOnFreenet(queueManager);
}
}
@@ -152,25 +148,25 @@
private AbstractButton actionSource;
private Vector target;
- public FileKeyComputer(FCPQueueManager queueManager,
AbstractButton actionSource) {
+ public FileKeyComputer(final FCPQueueManager queueManager,
final AbstractButton actionSource) {
this.queueManager = queueManager;
this.actionSource = actionSource;
if (actionSource != null)
actionSource.addActionListener(this);
}
- public void setTarget(Vector target) {
+ public void setTarget(final Vector target) {
boolean isOk;
isOk = true;
this.target = target;
if (target != null) {
- for (Iterator it = target.iterator();
+ for (final Iterator it = target.iterator();
it.hasNext(); ) {
- thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
+ final thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
- if (file.getLocalPath() == null
+ if ((file.getLocalPath() == null)
|| !file.isModifiable()) {
isOk = false;
break;
@@ -178,23 +174,23 @@
}
}
- actionSource.setEnabled(target != null && target.size()
!= 0 && isOk);
+ actionSource.setEnabled((target != null) &&
(target.size() != 0) && isOk);
}
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(final ActionEvent e) {
Logger.notice(this, "COMPUTING");
- computeFileKeys(queueManager, target);
+ FileManagementHelper.computeFileKeys(queueManager,
target);
}
}
/**
* @param files See thaw.plugins.index.File
*/
- public static void computeFileKeys(FCPQueueManager queueManager,
- Vector files) {
- for (Iterator it = files.iterator();
+ public static void computeFileKeys(final FCPQueueManager queueManager,
+ final Vector files) {
+ for (final Iterator it = files.iterator();
it.hasNext();) {
- thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
+ final thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
file.recalculateCHK(queueManager);
}
}
@@ -208,14 +204,14 @@
/**
* @param queueManager is used to stop transfers if needed
*/
- public FileRemover(FCPQueueManager queueManager, AbstractButton
actionSource) {
+ public FileRemover(final FCPQueueManager queueManager, final
AbstractButton actionSource) {
this.queueManager = queueManager;
this.actionSource = actionSource;
if (actionSource != null)
actionSource.addActionListener(this);
}
- public void setTarget(Vector target) {
+ public void setTarget(final Vector target) {
boolean isOk;
isOk = true;
@@ -223,9 +219,9 @@
this.target = target;
if (target != null) {
- for (Iterator it = target.iterator();
+ for (final Iterator it = target.iterator();
it.hasNext();) {
- thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
+ final thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
if (!file.isModifiable()) {
isOk = false;
@@ -235,11 +231,11 @@
}
- actionSource.setEnabled(target != null && target.size()
!= 0 && isOk);
+ actionSource.setEnabled((target != null) &&
(target.size() != 0) && isOk);
}
- public void actionPerformed(ActionEvent e) {
- removeFiles(queueManager, target);
+ public void actionPerformed(final ActionEvent e) {
+ FileManagementHelper.removeFiles(queueManager, target);
}
}
@@ -247,12 +243,12 @@
* @param files See thaw.plugins.index.File / files must have their
parent correctly set
* @param queueManager Used to stop the transfer if needed
*/
- public static void removeFiles(FCPQueueManager queueManager,
- Vector files) {
- for (Iterator it = files.iterator();
+ public static void removeFiles(final FCPQueueManager queueManager,
+ final Vector files) {
+ for (final Iterator it = files.iterator();
it.hasNext();) {
- thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
- Index parent = file.getParent();
+ final thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
+ final Index parent = file.getParent();
if (parent == null) {
Logger.warning(new FileManagementHelper(),
"File '"+file.getFilename()+"' has no parent ?!");
@@ -271,39 +267,39 @@
private AbstractButton src;
private Vector t;
- public PublicKeyCopier(AbstractButton actionSource) {
+ public PublicKeyCopier(final AbstractButton actionSource) {
src = actionSource;
if (src != null)
src.addActionListener(this);
}
- public void setTarget(Vector targets) {
+ public void setTarget(final Vector targets) {
t = targets;
- src.setEnabled(targets != null && targets.size() > 0);
+ src.setEnabled((targets != null) && (targets.size() >
0));
}
- public void actionPerformed(ActionEvent e) {
- copyPublicKeyFrom(t);
+ public void actionPerformed(final ActionEvent e) {
+ FileManagementHelper.copyPublicKeyFrom(t);
}
}
- public static void copyPublicKeyFrom(Vector targets) {
+ public static void copyPublicKeyFrom(final Vector targets) {
String keys = "";
if (targets == null)
return;
- Toolkit tk = Toolkit.getDefaultToolkit();
+ final Toolkit tk = Toolkit.getDefaultToolkit();
- for(Iterator it = targets.iterator();
+ for(final Iterator it = targets.iterator();
it.hasNext();) {
- thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
+ final thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
keys = keys + file.getPublicKey() + "\n";
}
- StringSelection st = new StringSelection(keys);
- Clipboard cp = tk.getSystemClipboard();
+ final StringSelection st = new StringSelection(keys);
+ final Clipboard cp = tk.getSystemClipboard();
cp.setContents(st, null);
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java 2006-12-06
18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java 2006-12-06
18:21:00 UTC (rev 11273)
@@ -1,61 +1,52 @@
package thaw.plugins.index;
-import javax.swing.JPanel;
-import javax.swing.JTable;
-import javax.swing.JScrollPane;
-
import java.awt.BorderLayout;
-import javax.swing.event.TableModelEvent;
-
-import java.awt.event.ActionListener;
+import java.awt.Component;
import java.awt.event.ActionEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.KeyListener;
+import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.Iterator;
+import java.util.Observable;
+import java.util.Vector;
-import javax.swing.table.DefaultTableCellRenderer;
-import java.awt.Component;
-
-import javax.swing.JPopupMenu;
+import javax.swing.JLabel;
import javax.swing.JMenuItem;
-import javax.swing.JFileChooser;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
import javax.swing.JProgressBar;
-import javax.swing.JLabel;
-
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.event.TableModelEvent;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.JTableHeader;
import javax.swing.tree.TreePath;
-import java.awt.Toolkit;
-import java.awt.datatransfer.Clipboard;
-import java.awt.datatransfer.StringSelection;
+import thaw.core.Config;
+import thaw.core.I18n;
+import thaw.core.Logger;
+import thaw.fcp.FCPClientGet;
+import thaw.fcp.FCPClientPut;
+import thaw.fcp.FCPQueueManager;
+import thaw.fcp.FCPTransferQuery;
-import java.util.Vector;
-import java.util.Iterator;
-
-import java.util.Observable;
-import javax.swing.table.JTableHeader;
-
-
-import thaw.core.*;
-import thaw.fcp.*;
-
public class FileTable implements MouseListener, KeyListener, ActionListener {
- private JPanel panel;
+ private final JPanel panel;
- private JTable table;
+ private final JTable table;
private FileListModel fileListModel;
- private FileList fileList = null;
+ private FileList fileList;
- private FCPQueueManager queueManager;
+ private String sortColumn;
+ private final boolean ascOrder = false;
- private String sortColumn = null;
- private boolean ascOrder = false;
-
- private JPopupMenu rightClickMenu;
- private Vector rightClickActions;
- private JMenuItem gotoItem;
+ private final JPopupMenu rightClickMenu;
+ private final Vector rightClickActions;
+ private final JMenuItem gotoItem;
// Download
// Insert
// Compute keys
@@ -64,32 +55,29 @@
private int[] selectedRows;
- private Config config;
- private Tables tables;
- private IndexTree tree;
+ private final Tables tables;
+ private final IndexTree tree;
- public FileTable(FCPQueueManager queueManager, IndexTree tree, Config
config, Tables tables) {
- this.queueManager = queueManager;
- this.config = config;
+ public FileTable(final FCPQueueManager queueManager, final IndexTree
tree, final Config config, final Tables tables) {
this.tables = tables;
this.tree = tree;
- this.fileListModel = new FileListModel();
- this.table = new JTable(this.fileListModel);
- this.table.setShowGrid(true);
- this.table.setDefaultRenderer( this.table.getColumnClass(0),
new FileRenderer() );
+ fileListModel = new FileListModel();
+ table = new JTable(fileListModel);
+ table.setShowGrid(true);
+ table.setDefaultRenderer( table.getColumnClass(0), new
FileRenderer() );
- this.table.addMouseListener(this);
+ table.addMouseListener(this);
- JTableHeader header = table.getTableHeader();
+ final JTableHeader header = table.getTableHeader();
header.setUpdateTableInRealTime(true);
header.setReorderingAllowed(true);
- this.panel = new JPanel();
- this.panel.setLayout(new BorderLayout());
+ panel = new JPanel();
+ panel.setLayout(new BorderLayout());
- this.panel.add(new
JLabel(I18n.getMessage("thaw.plugin.index.fileList")), BorderLayout.NORTH);
- this.panel.add(new JScrollPane(this.table));
+ panel.add(new
JLabel(I18n.getMessage("thaw.plugin.index.fileList")), BorderLayout.NORTH);
+ panel.add(new JScrollPane(table));
// Menu
rightClickMenu = new JPopupMenu();
@@ -126,83 +114,83 @@
public JPanel getPanel() {
- return this.panel;
+ return panel;
}
- protected void updateRightClickMenu(Vector selectedFiles) {
+ protected void updateRightClickMenu(final Vector selectedFiles) {
FileManagementHelper.FileAction action;
- for(Iterator it = rightClickActions.iterator();
+ for(final Iterator it = rightClickActions.iterator();
it.hasNext();) {
action = (FileManagementHelper.FileAction)it.next();
action.setTarget(selectedFiles);
}
- gotoItem.setEnabled(fileList != null && !(fileList instanceof
Index));
+ gotoItem.setEnabled((fileList != null) && !(fileList instanceof
Index));
}
- protected Vector getSelectedFiles(int[] selectedRows) {
- Vector srcList = fileList.getFileList();
- Vector files = new Vector();
+ protected Vector getSelectedFiles(final int[] selectedRows) {
+ final Vector srcList = fileList.getFileList();
+ final Vector files = new Vector();
for(int i = 0 ; i < selectedRows.length ; i++) {
- thaw.plugins.index.File file =
(thaw.plugins.index.File)srcList.get(selectedRows[i]);
+ final thaw.plugins.index.File file =
(thaw.plugins.index.File)srcList.get(selectedRows[i]);
files.add(file);
}
return files;
}
- public void setFileList(FileList fileList) {
+ public void setFileList(final FileList fileList) {
if(this.fileList != null) {
this.fileList.unloadFiles();
}
if(fileList != null) {
- fileList.loadFiles(this.sortColumn, this.ascOrder);
+ fileList.loadFiles(sortColumn, ascOrder);
}
this.fileList = fileList;
- this.fileListModel.reloadFileList(fileList);
+ fileListModel.reloadFileList(fileList);
}
- public void mouseClicked(MouseEvent e) {
+ public void mouseClicked(final MouseEvent e) {
if (fileList instanceof Index)
((Index)fileList).setChanged(false);
- if(e.getButton() == MouseEvent.BUTTON3
- && fileList != null) {
+ if((e.getButton() == MouseEvent.BUTTON3)
+ && (fileList != null)) {
selectedRows = table.getSelectedRows();
updateRightClickMenu(getSelectedFiles(selectedRows));
rightClickMenu.show(e.getComponent(), e.getX(),
e.getY());
}
}
- public void mouseEntered(MouseEvent e) { }
+ public void mouseEntered(final MouseEvent e) { }
- public void mouseExited(MouseEvent e) { }
+ public void mouseExited(final MouseEvent e) { }
- public void mousePressed(MouseEvent e) { }
+ public void mousePressed(final MouseEvent e) { }
- public void mouseReleased(MouseEvent e) { }
+ public void mouseReleased(final MouseEvent e) { }
- public void keyPressed(KeyEvent e) { }
+ public void keyPressed(final KeyEvent e) { }
- public void keyReleased(KeyEvent e) { }
+ public void keyReleased(final KeyEvent e) { }
- public void keyTyped(KeyEvent e) { }
+ public void keyTyped(final KeyEvent e) { }
- public void actionPerformed(ActionEvent e) {
- if(this.fileList == null)
+ public void actionPerformed(final ActionEvent e) {
+ if(fileList == null)
return;
if (e.getSource() == gotoItem) {
if (selectedRows.length <= 0)
return;
- thaw.plugins.index.File file =
(thaw.plugins.index.File)fileList.getFileList().get(selectedRows[0]);
+ final thaw.plugins.index.File file =
(thaw.plugins.index.File)fileList.getFileList().get(selectedRows[0]);
if (file.getParentId() == -1) {
Logger.notice(this, "No parent ? abnormal");
@@ -239,8 +227,8 @@
}
- public void setSelectedRows(int min, int max) {
- this.table.setRowSelectionInterval(min, max);
+ public void setSelectedRows(final int min, final int max) {
+ table.setRowSelectionInterval(min, max);
}
@@ -256,64 +244,64 @@
public FileListModel() {
super();
- this.columnNames = new Vector();
+ columnNames = new Vector();
-
this.columnNames.add(I18n.getMessage("thaw.common.file"));
-
this.columnNames.add(I18n.getMessage("thaw.common.size"));
+ columnNames.add(I18n.getMessage("thaw.common.file"));
+ columnNames.add(I18n.getMessage("thaw.common.size"));
//columnNames.add(I18n.getMessage("thaw.plugin.index.category"));
-
this.columnNames.add(I18n.getMessage("thaw.common.key"));
-
this.columnNames.add(I18n.getMessage("thaw.common.status"));
+ columnNames.add(I18n.getMessage("thaw.common.key"));
+ columnNames.add(I18n.getMessage("thaw.common.status"));
}
- public void reloadFileList(FileList newFileList) {
- if(this.fileList != null && (this.fileList instanceof
Observable)) {
-
((Observable)this.fileList).deleteObserver(this);
+ public void reloadFileList(final FileList newFileList) {
+ if((fileList != null) && (fileList instanceof
Observable)) {
+ ((Observable)fileList).deleteObserver(this);
}
- if(newFileList != null && (newFileList instanceof
Observable)) {
+ if((newFileList != null) && (newFileList instanceof
Observable)) {
((Observable)newFileList).addObserver(this);
}
- this.fileList = newFileList;
+ fileList = newFileList;
- if(this.files != null) {
- for(Iterator it = this.files.iterator();
+ if(files != null) {
+ for(final Iterator it = files.iterator();
it.hasNext(); ) {
- thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
+ final thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
file.deleteObserver(this);
}
}
- this.files = null;
+ files = null;
- if(this.fileList != null) {
- this.files = this.fileList.getFileList();
+ if(fileList != null) {
+ files = fileList.getFileList();
}
this.refresh();
}
public int getRowCount() {
- if(this.files == null)
+ if(files == null)
return 0;
- return this.files.size();
+ return files.size();
}
public int getColumnCount() {
- return this.columnNames.size();
+ return columnNames.size();
}
- public String getColumnName(int column) {
- return (String)this.columnNames.get(column);
+ public String getColumnName(final int column) {
+ return (String)columnNames.get(column);
}
- public Object getValueAt(int row, int column) {
- if (row >= this.files.size())
+ public Object getValueAt(final int row, final int column) {
+ if (row >= files.size())
return null;
- thaw.plugins.index.File file =
(thaw.plugins.index.File)this.files.get(row);
+ final thaw.plugins.index.File file =
(thaw.plugins.index.File)files.get(row);
if(column == 0)
return file.getFilename();
@@ -338,24 +326,24 @@
}
public void refresh() {
- if(this.fileList != null) {
- this.files = this.fileList.getFileList();
+ if(fileList != null) {
+ files = fileList.getFileList();
}
- TableModelEvent event = new TableModelEvent(this);
+ final TableModelEvent event = new TableModelEvent(this);
this.refresh(event);
}
- public void refresh(int row) {
- TableModelEvent event = new TableModelEvent(this, row);
+ public void refresh(final int row) {
+ final TableModelEvent event = new TableModelEvent(this,
row);
this.refresh(event);
}
- public void refresh(TableModelEvent e) {
- this.fireTableChanged(e);
+ public void refresh(final TableModelEvent e) {
+ fireTableChanged(e);
}
- public void update(java.util.Observable o, Object param) {
+ public void update(final java.util.Observable o, final Object
param) {
this.refresh(); /* TODO : Do it more nicely ... :) */
}
}
@@ -368,23 +356,23 @@
}
- public Component getTableCellRendererComponent(JTable table,
Object value,
- boolean
isSelected, boolean hasFocus,
- int row, int
column) {
+ public Component getTableCellRendererComponent(final JTable
table, final Object value,
+ final boolean
isSelected, final boolean hasFocus,
+ final int row,
final int column) {
if(value == null)
return
super.getTableCellRendererComponent(table, "",
isSelected, hasFocus, row, column);
if(value instanceof FCPTransferQuery) {
- FCPTransferQuery query =
(FCPTransferQuery)value;
- JProgressBar bar = new JProgressBar(0, 100);
+ final FCPTransferQuery query =
(FCPTransferQuery)value;
+ final JProgressBar bar = new JProgressBar(0,
100);
bar.setStringPainted(true);
bar.setBorderPainted(false);
- if((query instanceof FCPClientPut &&
query.getProgression() > 0)
- || (query instanceof FCPClientGet &&
query.getProgression() < 100) )
+ if(((query instanceof FCPClientPut) &&
(query.getProgression() > 0))
+ || ((query instanceof FCPClientGet) &&
(query.getProgression() < 100)) )
bar.setValue(query.getProgression());
else
bar.setValue(query.getTransferWithTheNodeProgression());
@@ -402,13 +390,12 @@
return bar;
}
- if(value instanceof Long) {
+ if(value instanceof Long)
return
super.getTableCellRendererComponent(table,
thaw.plugins.queueWatcher.QueueTableModel.getPrintableSize(((Long)value).longValue()),
isSelected, hasFocus, row, column);
- }
- Component cell =
super.getTableCellRendererComponent(table, value,
+ final Component cell =
super.getTableCellRendererComponent(table, value,
isSelected, hasFocus,
row, column);
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,39 +1,45 @@
package thaw.plugins.index;
-import javax.swing.tree.DefaultMutableTreeNode;
-
-import java.sql.*;
-
-import java.util.Vector;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
import java.util.Iterator;
+import java.util.Vector;
-import org.w3c.dom.Document;
-import javax.xml.parsers.DocumentBuilderFactory;
+import javax.swing.tree.DefaultMutableTreeNode;
import javax.xml.parsers.DocumentBuilder;
-import org.w3c.dom.DOMImplementation;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.Text;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.OutputKeys;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
-import java.io.OutputStream;
-import java.io.InputStream;
-import java.io.FileOutputStream;
-import java.io.FileInputStream;
-
-import thaw.fcp.*;
+import thaw.core.FreenetURIHelper;
+import thaw.core.Logger;
+import thaw.fcp.FCPClientGet;
+import thaw.fcp.FCPClientPut;
+import thaw.fcp.FCPGenerateSSK;
+import thaw.fcp.FCPQueueManager;
+import thaw.fcp.FCPTransferQuery;
import thaw.plugins.Hsqldb;
-import thaw.core.*;
public class Index extends java.util.Observable implements FileAndLinkList,
IndexTreeNode, java.util.Observer {
- private Hsqldb db;
- private IndexTree tree;
+ private final Hsqldb db;
private int id;
private IndexCategory parent;
@@ -52,40 +58,33 @@
private FCPGenerateSSK sskGenerator;
- private FCPQueueManager queueManager;
+ private final FCPQueueManager queueManager;
private UnknownIndexList uIndexList;
private FCPTransferQuery transfer = null;
- private java.io.File targetFile = null;
+ private File targetFile = null;
- private String author = null;
+ private String author;
private boolean rewriteKey = true;
- private boolean xmlParserReady = false;
private boolean changed = false;
- private FCPClientPut publicKeyRecalculation = null;
-
private boolean updateWhenKeyAreAvailable = false;
/**
* The bigest constructor of the world ...
* @param revision Ignored if the index is not modifiable (=> deduced
from the publicKey)
*/
- public Index(Hsqldb db, FCPQueueManager queueManager, UnknownIndexList
indexList,
- int id, IndexCategory parent,
+ public Index(final Hsqldb db, final FCPQueueManager queueManager, final
UnknownIndexList indexList,
+ final int id, final IndexCategory parent,
String realName, String displayName,
- String publicKey, String privateKey,
- int revision,
- String author) {
- this.uIndexList = indexList;
+ final String publicKey, final String privateKey,
+ final int revision,
+ final String author) {
+ uIndexList = indexList;
this.queueManager = queueManager;
-
- this.treeNode = new DefaultMutableTreeNode(displayName, false);
-
+ treeNode = new DefaultMutableTreeNode(displayName, false);
this.db = db;
- this.tree = this.tree;
-
this.id = id;
this.parent = parent;
this.realName = realName.trim();
@@ -104,28 +103,28 @@
setPrivateKey(privateKey);
setPublicKey(publicKey);
- this.treeNode.setUserObject(this);
+ treeNode.setUserObject(this);
this.setTransfer();
}
- public static boolean isDumbKey(String key) {
- return (key == null || key.equals("") || key.length() < 20);
+ public static boolean isDumbKey(final String key) {
+ return ((key == null) || key.equals("") || (key.length() < 20));
}
- public void setParent(IndexCategory parent) {
+ public void setParent(final IndexCategory parent) {
this.parent = parent;
}
public IndexCategory getParent() {
- return this.parent;
+ return parent;
}
public DefaultMutableTreeNode getTreeNode() {
- return this.treeNode;
+ return treeNode;
}
- public Index getIndex(int id) {
+ public Index getIndex(final int id) {
return (id == getId()) ? this : null;
}
@@ -141,102 +140,97 @@
public boolean create() {
try {
/* Rahh ! Hsqldb doesn't support getGeneratedKeys() !
8/ */
- db.lockWriting();
+ synchronized (db.dbLock) {
+ final Connection c = db.getConnection();
+ PreparedStatement st;
- Connection c = this.db.getConnection();
- PreparedStatement st;
+ st = c.prepareStatement("SELECT id FROM indexes
ORDER BY id DESC LIMIT 1");
- st = c.prepareStatement("SELECT id FROM indexes ORDER
BY id DESC LIMIT 1");
+ st.execute();
- st.execute();
+ try {
+ final ResultSet key = st.getResultSet();
+ key.next();
+ id = key.getInt(1) + 1;
+ } catch(final SQLException e) {
+ id = 1;
+ }
- try {
- ResultSet key = st.getResultSet();
- key.next();
- this.id = key.getInt(1) + 1;
- } catch(SQLException e) {
- this.id = 1;
- }
+ st = c.prepareStatement("INSERT INTO indexes
(id, originalName, displayName, publicKey, privateKey, author, positionInTree,
revision, parent) VALUES (?, ?,?,?,?,?, ?,?, ?)");
+ st.setInt(1, id);
+ st.setString(2, realName);
+ st.setString(3, displayName);
+ st.setString(4, publicKey != null ? publicKey :
"");
+ st.setString(5, privateKey);
+ st.setString(6, author);
+ st.setInt(7, 0);
- st = c.prepareStatement("INSERT INTO indexes (id,
originalName, displayName, publicKey, privateKey, author, positionInTree,
revision, parent) VALUES (?, ?,?,?,?,?, ?,?, ?)");
- st.setInt(1, this.id);
- st.setString(2, this.realName);
- st.setString(3, this.displayName);
- st.setString(4, publicKey != null ? publicKey : "");
- st.setString(5, privateKey);
- st.setString(6, this.author);
- st.setInt(7, 0);
+ st.setInt(8, revision);
- st.setInt(8, this.revision);
+ if((parent != null) && (parent.getId() >= 0))
+ st.setInt(9, parent.getId());
+ else
+ st.setNull(9, Types.INTEGER);
- if(this.parent != null && this.parent.getId() >= 0)
- st.setInt(9, this.parent.getId());
- else
- st.setNull(9, Types.INTEGER);
+ st.execute();
+ }
- st.execute();
-
- db.unlockWriting();
-
return true;
- } catch(SQLException e) {
+ } catch(final SQLException e) {
Logger.error(this, "Unable to insert the new index in
the db, because: "+e.toString());
-
- db.unlockWriting();
-
return false;
}
}
- public void rename(String name) {
+ public void rename(final String name) {
try {
- Connection c = this.db.getConnection();
+ final Connection c = db.getConnection();
PreparedStatement st;
st = c.prepareStatement("UPDATE indexes SET displayName
= ? WHERE id = ?");
st.setString(1, name);
- st.setInt(2, this.id);
+ st.setInt(2, id);
st.execute();
- this.displayName = name;
+ displayName = name;
- } catch(SQLException e) {
- Logger.error(this, "Unable to rename the index
'"+this.displayName+"' in '"+name+"', because: "+e.toString());
+ } catch(final SQLException e) {
+ Logger.error(this, "Unable to rename the index
'"+displayName+"' in '"+name+"', because: "+e.toString());
}
}
public void delete() {
try {
- this.loadFiles(null, true);
+ loadFiles(null, true);
this.loadLinks(null, true);
- for(Iterator fileIt = this.fileList.iterator();
fileIt.hasNext(); ) {
- thaw.plugins.index.File file =
(thaw.plugins.index.File)fileIt.next();
+ for(final Iterator fileIt = fileList.iterator();
fileIt.hasNext(); ) {
+ final thaw.plugins.index.File file =
(thaw.plugins.index.File)fileIt.next();
file.delete();
}
- for (Iterator linkIt = this.linkList.iterator();
linkIt.hasNext() ;) {
- Link link = (Link)linkIt.next();
+ for (final Iterator linkIt = linkList.iterator();
linkIt.hasNext() ;) {
+ final Link link = (Link)linkIt.next();
link.delete();
}
- Connection c = this.db.getConnection();
- PreparedStatement st = c.prepareStatement("DELETE FROM
indexes WHERE id = ?");
- st.setInt(1, this.id);
+ final Connection c = db.getConnection();
+ final PreparedStatement st = c.prepareStatement("DELETE
FROM indexes WHERE id = ?");
+ st.setInt(1, id);
st.execute();
- } catch(SQLException e) {
- Logger.error(this, "Unable to delete the index
'"+this.displayName+"', because: "+e.toString());
+ } catch(final SQLException e) {
+ Logger.error(this, "Unable to delete the index
'"+displayName+"', because: "+e.toString());
}
}
public void update() {
- if (!isDumbKey(publicKey) && isDumbKey(privateKey)) /* non
modifiable */
+ if (!Index.isDumbKey(publicKey) && Index.isDumbKey(privateKey))
/* non modifiable */
return;
- if (isDumbKey(publicKey) && isDumbKey(privateKey)) {
+ if (Index.isDumbKey(publicKey) && Index.isDumbKey(privateKey)) {
generateKeys();
updateWhenKeyAreAvailable = true;
return;
@@ -251,7 +245,7 @@
targetFile = new java.io.File(tmpdir + realName +".xml");
- if (this.transfer != null) {
+ if (transfer != null) {
Logger.notice(this, "A transfer is already running");
return;
}
@@ -265,25 +259,25 @@
try {
outputStream = new FileOutputStream(targetFile);
- } catch(java.io.FileNotFoundException e) {
+ } catch(final java.io.FileNotFoundException e) {
Logger.warning(this, "Unable to create file
'"+targetFile.toString()+"' ! not generated !");
return;
}
- this.generateXML(outputStream);
+ generateXML(outputStream);
- if(this.targetFile.exists()) {
+ if(targetFile.exists()) {
Logger.info(this, "Inserting new version");
- this.revision++;
+ revision++;
- clientPut = new FCPClientPut(this.targetFile,
2, this.revision, realName, this.privateKey, 2, true, 0);
- this.transfer = clientPut;
+ clientPut = new FCPClientPut(targetFile, 2,
revision, realName, privateKey, 2, true, 0);
+ transfer = clientPut;
clientPut.addObserver(this);
-
this.queueManager.addQueryToThePendingQueue(clientPut);
+
queueManager.addQueryToThePendingQueue(clientPut);
- this.save();
+ save();
} else {
Logger.warning(this, "Index not generated !");
@@ -292,12 +286,12 @@
setChanged();
notifyObservers();
} else {
- this.updateFromFreenet(-1);
+ updateFromFreenet(-1);
}
}
- public void updateFromFreenet(int rev) {
+ public void updateFromFreenet(final int rev) {
FCPClientGet clientGet;
if (publicKey == null) {
@@ -331,7 +325,7 @@
clientGet = new FCPClientGet(key, 2, 2, false, -1, null);
- this.transfer = clientGet;
+ transfer = clientGet;
clientGet.addObserver(this);
@@ -348,29 +342,29 @@
}
public boolean isUpdating() {
- return (sskGenerator != null || (transfer != null &&
(!transfer.isFinished())));
+ return ((sskGenerator != null) || ((transfer != null) &&
(!transfer.isFinished())));
}
- protected void setTransfer(FCPTransferQuery query) {
- this.transfer = query;
+ protected void setTransfer(final FCPTransferQuery query) {
+ transfer = query;
- if (this.transfer != null) {
- if (this.transfer instanceof FCPClientGet)
- ((FCPClientGet)this.transfer).addObserver(this);
- if (this.transfer instanceof FCPClientPut)
- ((FCPClientPut)this.transfer).addObserver(this);
- this.update(((java.util.Observable)this.transfer),
null);
+ if (transfer != null) {
+ if (transfer instanceof FCPClientGet)
+ ((FCPClientGet)transfer).addObserver(this);
+ if (transfer instanceof FCPClientPut)
+ ((FCPClientPut)transfer).addObserver(this);
+ this.update(((java.util.Observable)transfer), null);
}
}
protected void setTransfer() {
- if (this.queueManager == null)
+ if (queueManager == null)
return;
- if (this.getPublicKey() != null) {
- if(!this.queueManager.isQueueCompletlyLoaded()) {
- Thread th = new Thread(new WaitCompleteQueue());
+ if (getPublicKey() != null) {
+ if(!queueManager.isQueueCompletlyLoaded()) {
+ final Thread th = new Thread(new
WaitCompleteQueue());
th.start();
return;
}
@@ -378,11 +372,11 @@
String key;
if (privateKey != null)
- key =
FreenetURIHelper.getPublicInsertionSSK(this.getPublicKey());
+ key =
FreenetURIHelper.getPublicInsertionSSK(getPublicKey());
else
- key = this.getPublicKey();
+ key = getPublicKey();
- this.setTransfer(this.queueManager.getTransfer(key));
+ this.setTransfer(queueManager.getTransfer(key));
}
this.setChanged();
@@ -395,10 +389,10 @@
public void run() {
int tryNumber = 0;
- while(!Index.this.queueManager.isQueueCompletlyLoaded()
&& tryNumber < 120 /* 1min */) {
+ while(!queueManager.isQueueCompletlyLoaded() &&
(tryNumber < 120 /* 1min */)) {
try {
Thread.sleep(500);
- } catch(java.lang.InterruptedException e) {
+ } catch(final java.lang.InterruptedException e)
{
/* \_o< */
}
@@ -416,12 +410,12 @@
public void purgeLinkList() {
unloadLinks();
try {
- Connection c = this.db.getConnection();
- PreparedStatement st = c.prepareStatement("DELETE FROM
links WHERE indexParent = ?");
- st.setInt(1, this.getId());
+ final Connection c = db.getConnection();
+ final PreparedStatement st = c.prepareStatement("DELETE
FROM links WHERE indexParent = ?");
+ st.setInt(1, getId());
st.execute();
- this.linkList = new Vector();
- } catch(SQLException e) {
+ linkList = new Vector();
+ } catch(final SQLException e) {
Logger.error(this, "Unable to purge da list !
Exception: "+e.toString());
}
}
@@ -429,57 +423,57 @@
public void purgeFileList() {
unloadFiles();
try {
- Connection c = this.db.getConnection();
- PreparedStatement st = c.prepareStatement("DELETE FROM
files WHERE indexParent = ?");
- st.setInt(1, this.getId());
+ final Connection c = db.getConnection();
+ final PreparedStatement st = c.prepareStatement("DELETE
FROM files WHERE indexParent = ?");
+ st.setInt(1, getId());
st.execute();
- this.fileList = new Vector();
- } catch(SQLException e) {
+ fileList = new Vector();
+ } catch(final SQLException e) {
Logger.error(this, "Unable to purge da list !
Exception: "+e.toString());
}
}
public synchronized void save() {
try {
- Connection c = this.db.getConnection();
- PreparedStatement st = c.prepareStatement("UPDATE
indexes SET originalName = ?, displayName = ?, publicKey = ?, privateKey = ?,
positionInTree = ?, revision = ?, parent = ? , author = ? WHERE id = ?");
+ final Connection c = db.getConnection();
+ final PreparedStatement st = c.prepareStatement("UPDATE
indexes SET originalName = ?, displayName = ?, publicKey = ?, privateKey = ?,
positionInTree = ?, revision = ?, parent = ? , author = ? WHERE id = ?");
- st.setString(1, this.realName);
- st.setString(2, this.displayName);
+ st.setString(1, realName);
+ st.setString(2, displayName);
st.setString(3, publicKey != null ? publicKey : "");
- if(this.privateKey != null)
+ if(privateKey != null)
st.setString(4, privateKey);
else
st.setNull(4, Types.VARCHAR);
- if (treeNode != null && treeNode.getParent() != null)
+ if ((treeNode != null) && (treeNode.getParent() !=
null))
st.setInt(5,
treeNode.getParent().getIndex(treeNode));
else
st.setInt(5, 0);
st.setInt(6, revision);
- if( ((IndexTreeNode)this.treeNode.getParent()).getId()
< 0)
+ if( ((IndexTreeNode)treeNode.getParent()).getId() < 0)
st.setNull(7, Types.INTEGER);
else
- st.setInt(7,
((IndexTreeNode)this.treeNode.getParent()).getId());
+ st.setInt(7,
((IndexTreeNode)treeNode.getParent()).getId());
- st.setString(8, this.author);
+ st.setString(8, author);
- st.setInt(9, this.getId());
+ st.setInt(9, getId());
st.execute();
- } catch(SQLException e) {
+ } catch(final SQLException e) {
Logger.error(this, "Unable to save index state
'"+toString()+"' because : "+e.toString());
}
}
public int getId() {
- return this.id;
+ return id;
}
public String getPublicKey() {
- if (publicKey == null || isDumbKey(publicKey))
+ if ((publicKey == null) || Index.isDumbKey(publicKey))
return null;
if (publicKey.startsWith("SSK@")) { /* as it should when
privateKey is known */
@@ -494,30 +488,30 @@
/**
* Always set the privateKey first
*/
- public void setPublicKey(String key) {
- if (key != null && !isDumbKey(key))
- this.publicKey = key.trim();
+ public void setPublicKey(final String key) {
+ if ((key != null) && !Index.isDumbKey(key))
+ publicKey = key.trim();
else
- this.publicKey = null;
+ publicKey = null;
- if (privateKey != null && publicKey != null &&
publicKey.startsWith("USK@")) {
- String[] split =
FreenetURIHelper.convertUSKtoSSK(publicKey).split("/");
+ if ((privateKey != null) && (publicKey != null) &&
publicKey.startsWith("USK@")) {
+ final String[] split =
FreenetURIHelper.convertUSKtoSSK(publicKey).split("/");
publicKey = split[0];
}
- if (publicKey != null && publicKey.startsWith("USK@"))
- this.revision =
FreenetURIHelper.getUSKRevision(publicKey);
+ if ((publicKey != null) && publicKey.startsWith("USK@"))
+ revision = FreenetURIHelper.getUSKRevision(publicKey);
}
public String getPrivateKey() {
- if (privateKey == null || isDumbKey(privateKey))
+ if ((privateKey == null) || Index.isDumbKey(privateKey))
return null;
return privateKey;
}
- public void setPrivateKey(String key) {
- if (key != null && !isDumbKey(key))
+ public void setPrivateKey(final String key) {
+ if ((key != null) && !Index.isDumbKey(key))
privateKey = key.trim();
else
privateKey = null;
@@ -541,9 +535,9 @@
}
- public void update(java.util.Observable o, Object p) {
+ public void update(final java.util.Observable o, final Object p) {
- if(o == this.sskGenerator) {
+ if(o == sskGenerator) {
sskGenerator.deleteObserver(this);
publicKey = sskGenerator.getPublicKey();
privateKey = sskGenerator.getPrivateKey();
@@ -564,25 +558,25 @@
return;
}
- if(o == this.transfer) {
- if(this.transfer.isFinished() &&
this.transfer.isSuccessful()) {
- if(this.transfer instanceof FCPClientPut) {
- if (this.targetFile != null)
- this.targetFile.delete();
+ if(o == transfer) {
+ if(transfer.isFinished() && transfer.isSuccessful()) {
+ if(transfer instanceof FCPClientPut) {
+ if (targetFile != null)
+ targetFile.delete();
else {
- String path =
((FCPClientPut)this.transfer).getPath();
+ final String path =
((FCPClientPut)transfer).getPath();
if (path != null) {
- java.io.File fl = new
java.io.File(path);
+ final java.io.File fl =
new java.io.File(path);
fl.delete();
}
}
-
((FCPClientPut)this.transfer).deleteObserver(this);
+
((FCPClientPut)transfer).deleteObserver(this);
- if
(this.transfer.stop(this.queueManager))
-
this.queueManager.remove(this.transfer);
+ if (transfer.stop(queueManager))
+ queueManager.remove(transfer);
- this.transfer = null;
+ transfer = null;
this.setChanged();
this.notifyObservers();
@@ -590,10 +584,10 @@
return;
}
- if (this.transfer instanceof FCPClientGet) {
-
((FCPClientGet)this.transfer).deleteObserver(this);
+ if (transfer instanceof FCPClientGet) {
+
((FCPClientGet)transfer).deleteObserver(this);
- int oldRevision = revision;
+ final int oldRevision = revision;
if (rewriteKey)
publicKey =
transfer.getFileKey();
@@ -609,7 +603,7 @@
//if
(this.transfer.stop(this.queueManager))
//
this.queueManager.remove(this.transfer);
- this.queueManager.remove(this.transfer);
+ queueManager.remove(transfer);
if (transfer.getPath() == null) {
Logger.error(this, "No path
?!");
@@ -619,7 +613,7 @@
loadXML(transfer.getPath());
(new
java.io.File(transfer.getPath())).delete();
- this.transfer = null;
+ transfer = null;
save();
@@ -631,9 +625,9 @@
}
- if (this.transfer != null && this.transfer.isFinished()
&& !this.transfer.isSuccessful()) {
+ if ((transfer != null) && transfer.isFinished() &&
!transfer.isSuccessful()) {
Logger.info(this, "Unable to get new version of
the index");
- this.transfer = null;
+ transfer = null;
this.setChanged();
this.notifyObservers();
return;
@@ -641,8 +635,8 @@
}
- if (o instanceof thaw.plugins.index.File
- || o instanceof Link) {
+ if ((o instanceof thaw.plugins.index.File)
+ || (o instanceof Link)) {
this.setChanged();
this.notifyObservers(o);
}
@@ -654,18 +648,18 @@
}
- public void setChanged(boolean val) {
+ public void setChanged(final boolean val) {
changed = val;
}
public boolean isEmpty() {
- if (this.fileList == null)
- this.loadFiles(null, true);
- if (this.linkList == null)
+ if (fileList == null)
+ loadFiles(null, true);
+ if (linkList == null)
this.loadLinks(null, true);
- if (this.fileList.size() == 0 && this.linkList.size() == 0)
+ if ((fileList.size() == 0) && (linkList.size() == 0))
return true;
return false;
@@ -674,9 +668,9 @@
////// FILE LIST ////////
- public void loadFiles(String columnToSort, boolean asc) {
+ public void loadFiles(final String columnToSort, boolean asc) {
- this.fileList = new Vector();
+ fileList = new Vector();
try {
String query = "SELECT id, filename, publicKey, mime,
size, localPath, category, indexParent FROM files WHERE indexParent = ?";
@@ -688,23 +682,23 @@
query = query + " DESC";
}
- PreparedStatement st =
this.db.getConnection().prepareStatement(query);
+ final PreparedStatement st =
db.getConnection().prepareStatement(query);
- st.setInt(1, this.getId());
+ st.setInt(1, getId());
if(st.execute()) {
- ResultSet results = st.getResultSet();
+ final ResultSet results = st.getResultSet();
while(results.next()) {
- thaw.plugins.index.File file = new
thaw.plugins.index.File(this.db, results, this);
- file.setTransfer(this.queueManager);
- this.addFileToList(file);
+ final thaw.plugins.index.File file =
new thaw.plugins.index.File(db, results, this);
+ file.setTransfer(queueManager);
+ addFileToList(file);
}
}
- } catch(java.sql.SQLException e) {
- Logger.error(this, "Unable to get the file list for
index: '"+this.toString()+"' because: "+e.toString());
+ } catch(final java.sql.SQLException e) {
+ Logger.error(this, "Unable to get the file list for
index: '"+toString()+"' because: "+e.toString());
}
setChanged(false); /* java.util.Index */
@@ -716,12 +710,12 @@
* Returns a *copy* of da vector.
*/
public Vector getFileList() {
- Vector newList = new Vector();
+ final Vector newList = new Vector();
if (fileList == null)
return newList;
- for(Iterator it = fileList.iterator();
+ for(final Iterator it = fileList.iterator();
it.hasNext();) {
newList.add(it.next());
}
@@ -729,12 +723,12 @@
return newList;
}
- public thaw.plugins.index.File getFile(int index) {
- return (thaw.plugins.index.File)this.fileList.get(index);
+ public thaw.plugins.index.File getFile(final int index) {
+ return (thaw.plugins.index.File)fileList.get(index);
}
- public int getFilePosition(thaw.plugins.index.File fileA) {
- int pos = this.fileList.indexOf(fileA);
+ public int getFilePosition(final thaw.plugins.index.File fileA) {
+ int pos = fileList.indexOf(fileA);
if (fileA.getPublicKey() == null)
return -1;
@@ -742,11 +736,11 @@
if (pos < 0) {
/* Manual research */
pos = 0;
- for(Iterator it = this.fileList.iterator();
+ for(final Iterator it = fileList.iterator();
it.hasNext();) {
- thaw.plugins.index.File fileB =
(thaw.plugins.index.File)it.next();
+ final thaw.plugins.index.File fileB =
(thaw.plugins.index.File)it.next();
- if (fileB.getPublicKey() != null
+ if ((fileB.getPublicKey() != null)
&&
fileB.getPublicKey().equals(fileA.getPublicKey()))
return pos;
pos++;
@@ -759,29 +753,29 @@
public void unloadFiles() {
- if (this.fileList != null) {
- for (Iterator it = this.fileList.iterator();
+ if (fileList != null) {
+ for (final Iterator it = fileList.iterator();
it.hasNext();)
{
- thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
+ final thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
file.deleteObserver(this);
}
}
- this.fileList = null;
+ fileList = null;
}
/**
* Note for myself: For external use only ! (file will be inserted in
the database etc)
*/
- public void addFile(thaw.plugins.index.File file) {
+ public void addFile(final thaw.plugins.index.File file) {
file.setParent(this);
if (!file.isInTheDatabase()) {
file.insert();
- this.addFileToList(file);
+ addFileToList(file);
this.setChanged();
this.notifyObservers(file);
@@ -794,19 +788,19 @@
/**
* Won't notify
*/
- protected void addFileToList(thaw.plugins.index.File file) {
- if (this.fileList == null)
- this.loadFiles(null, true);
+ protected void addFileToList(final thaw.plugins.index.File file) {
+ if (fileList == null)
+ loadFiles(null, true);
file.addObserver(this);
- this.fileList.add(file);
+ fileList.add(file);
}
- public void removeFile(thaw.plugins.index.File file) {
+ public void removeFile(final thaw.plugins.index.File file) {
file.delete();
- if(this.fileList != null) {
- this.fileList.remove(file);
+ if(fileList != null) {
+ fileList.remove(file);
this.setChanged();
this.notifyObservers(file);
@@ -817,8 +811,8 @@
* Do the update all the files in the database.
*/
public void updateFileList() {
- for(Iterator it = this.fileList.iterator(); it.hasNext();) {
- thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
+ for(final Iterator it = fileList.iterator(); it.hasNext();) {
+ final thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
file.update();
}
}
@@ -826,13 +820,13 @@
//// LINKS ////
- public void addLink(Link link) {
+ public void addLink(final Link link) {
link.setParent(this);
if (!link.isInTheDatabase()) {
link.insert();
- this.addLinkToList(link);
+ addLinkToList(link);
setChanged();
notifyObservers(link);
@@ -842,18 +836,18 @@
}
- protected void addLinkToList(Link link) {
- if (this.linkList == null)
+ protected void addLinkToList(final Link link) {
+ if (linkList == null)
this.loadLinks(null, true);
- this.linkList.add(link);
+ linkList.add(link);
}
- public void removeLink(Link link) {
+ public void removeLink(final Link link) {
link.delete();
- if (this.linkList != null) {
- this.linkList.remove(link);
+ if (linkList != null) {
+ linkList.remove(link);
this.setChanged();
this.notifyObservers(link);
}
@@ -864,15 +858,15 @@
* Update all the links in the database.
*/
public void updateLinkList() {
- for(Iterator it = this.linkList.iterator(); it.hasNext();) {
- Link link = (Link)it.next();
+ for(final Iterator it = linkList.iterator(); it.hasNext();) {
+ final Link link = (Link)it.next();
link.update();
}
}
- public void loadLinks(String columnToSort, boolean asc)
+ public void loadLinks(final String columnToSort, boolean asc)
{
- this.linkList = new Vector();
+ linkList = new Vector();
try {
String query = "SELECT id, publicKey, mark, comment,
indexTarget FROM links WHERE indexParent = ?";
@@ -884,26 +878,26 @@
query = query + " DESC";
}
- PreparedStatement st =
this.db.getConnection().prepareStatement(query);
+ final PreparedStatement st =
db.getConnection().prepareStatement(query);
- st.setInt(1, this.getId());
+ st.setInt(1, getId());
if(st.execute()) {
- ResultSet results = st.getResultSet();
+ final ResultSet results = st.getResultSet();
while(results.next()) {
try {
- Link link = new Link(this.db,
results, this);
- this.addLinkToList(link);
- } catch(Exception e) {
- Logger.warning(this, "Unable to
add index '"+this.publicKey+"' to the list because: "+e.toString());
+ final Link link = new Link(db,
results, this);
+ addLinkToList(link);
+ } catch(final Exception e) {
+ Logger.warning(this, "Unable to
add index '"+publicKey+"' to the list because: "+e.toString());
}
}
}
- } catch(java.sql.SQLException e) {
- Logger.error(this, "Unable to get the link list for
index: '"+this.toString()+"' because: "+e.toString());
+ } catch(final java.sql.SQLException e) {
+ Logger.error(this, "Unable to get the link list for
index: '"+toString()+"' because: "+e.toString());
}
setChanged(false); /* Index */
@@ -915,12 +909,12 @@
/* Returns a copy ! */
public Vector getLinkList()
{
- Vector newList = new Vector();
+ final Vector newList = new Vector();
if (linkList == null)
return newList;
- for(Iterator it = linkList.iterator();
+ for(final Iterator it = linkList.iterator();
it.hasNext();) {
newList.add(it.next());
}
@@ -928,53 +922,53 @@
return newList;
}
- public Link getLink(int index)
+ public Link getLink(final int index)
{
- return (Link)this.linkList.get(index);
+ return (Link)linkList.get(index);
}
public void unloadLinks()
{
- this.linkList = null;
+ linkList = null;
}
//// XML ////
- public void generateXML(OutputStream out) {
- StreamResult streamResult = new StreamResult(out);
+ public void generateXML(final OutputStream out) {
+ final StreamResult streamResult = new StreamResult(out);
Document xmlDoc;
- DocumentBuilderFactory xmlFactory =
DocumentBuilderFactory.newInstance();
+ final DocumentBuilderFactory xmlFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder xmlBuilder;
try {
xmlBuilder = xmlFactory.newDocumentBuilder();
- } catch(javax.xml.parsers.ParserConfigurationException e) {
+ } catch(final javax.xml.parsers.ParserConfigurationException e)
{
Logger.error(this, "Unable to generate the index
because : "+e.toString());
return;
}
- DOMImplementation impl = xmlBuilder.getDOMImplementation();
+ final DOMImplementation impl =
xmlBuilder.getDOMImplementation();
xmlDoc = impl.createDocument(null, "index", null);
- Element rootEl = xmlDoc.getDocumentElement();
+ final Element rootEl = xmlDoc.getDocumentElement();
- rootEl.appendChild(this.getXMLHeader(xmlDoc));
- rootEl.appendChild(this.getXMLLinks(xmlDoc));
- rootEl.appendChild(this.getXMLFileList(xmlDoc));
+ rootEl.appendChild(getXMLHeader(xmlDoc));
+ rootEl.appendChild(getXMLLinks(xmlDoc));
+ rootEl.appendChild(getXMLFileList(xmlDoc));
/* Serialization */
- DOMSource domSource = new DOMSource(xmlDoc);
- TransformerFactory transformFactory =
TransformerFactory.newInstance();
+ final DOMSource domSource = new DOMSource(xmlDoc);
+ final TransformerFactory transformFactory =
TransformerFactory.newInstance();
Transformer serializer;
try {
serializer = transformFactory.newTransformer();
- } catch(javax.xml.transform.TransformerConfigurationException
e) {
+ } catch(final
javax.xml.transform.TransformerConfigurationException e) {
Logger.error(this, "Unable to save index because:
"+e.toString());
return;
}
@@ -985,26 +979,26 @@
/* final step */
try {
serializer.transform(domSource, streamResult);
- } catch(javax.xml.transform.TransformerException e) {
+ } catch(final javax.xml.transform.TransformerException e) {
Logger.error(this, "Unable to save index because:
"+e.toString());
return;
}
}
- public Element getXMLHeader(Document xmlDoc) {
- Element header = xmlDoc.createElement("header");
+ public Element getXMLHeader(final Document xmlDoc) {
+ final Element header = xmlDoc.createElement("header");
- Element title = xmlDoc.createElement("title");
- Text titleText = xmlDoc.createTextNode(displayName);
+ final Element title = xmlDoc.createElement("title");
+ final Text titleText = xmlDoc.createTextNode(displayName);
title.appendChild(titleText);
- Element owner = xmlDoc.createElement("owner");
+ final Element owner = xmlDoc.createElement("owner");
Text ownerText;
- if (this.author == null)
+ if (author == null)
ownerText = xmlDoc.createTextNode("Another anonymous");
else
- ownerText = xmlDoc.createTextNode(this.author);
+ ownerText = xmlDoc.createTextNode(author);
owner.appendChild(ownerText);
@@ -1014,18 +1008,18 @@
return header;
}
- public Element getXMLLinks(Document xmlDoc) {
- Element links = xmlDoc.createElement("indexes");
+ public Element getXMLLinks(final Document xmlDoc) {
+ final Element links = xmlDoc.createElement("indexes");
- if (this.linkList == null) {
+ if (linkList == null) {
this.loadLinks(null, true);
}
- for (Iterator it = this.getLinkList().iterator();
+ for (final Iterator it = getLinkList().iterator();
it.hasNext();) {
- Link link = (Link)it.next();
+ final Link link = (Link)it.next();
- Element xmlLink = link.getXML(xmlDoc);
+ final Element xmlLink = link.getXML(xmlDoc);
if (xmlLink != null)
links.appendChild(xmlLink);
@@ -1036,18 +1030,18 @@
return links;
}
- public Element getXMLFileList(Document xmlDoc) {
- Element files = xmlDoc.createElement("files");
+ public Element getXMLFileList(final Document xmlDoc) {
+ final Element files = xmlDoc.createElement("files");
- if(this.fileList == null) {
- this.loadFiles(null, true);
+ if(fileList == null) {
+ loadFiles(null, true);
}
- for(Iterator it = this.getFileList().iterator();
+ for(final Iterator it = getFileList().iterator();
it.hasNext();) {
- thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
+ final thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
- Element xmlFile = file.getXML(xmlDoc);
+ final Element xmlFile = file.getXML(xmlDoc);
if(xmlFile != null)
files.appendChild(xmlFile);
@@ -1058,21 +1052,21 @@
return files;
}
- public void loadXML(String filePath) {
+ public void loadXML(final String filePath) {
try {
loadXML(new FileInputStream(filePath));
- } catch(java.io.FileNotFoundException e) {
+ } catch(final java.io.FileNotFoundException e) {
Logger.error(this, "Unable to load XML:
FileNotFoundException ('"+filePath+"') ! : "+e.toString());
}
}
- public synchronized void loadXML(java.io.InputStream input) {
- DocumentBuilderFactory xmlFactory =
DocumentBuilderFactory.newInstance();
+ public synchronized void loadXML(final java.io.InputStream input) {
+ final DocumentBuilderFactory xmlFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder xmlBuilder;
try {
xmlBuilder = xmlFactory.newDocumentBuilder();
- } catch(javax.xml.parsers.ParserConfigurationException e) {
+ } catch(final javax.xml.parsers.ParserConfigurationException e)
{
Logger.error(this, "Unable to load index because:
"+e.toString());
return;
}
@@ -1081,81 +1075,80 @@
try {
Logger.info(this, "XML parser ready");
- xmlParserReady = true;
xmlDoc = xmlBuilder.parse(input);
Logger.info(this, "Index parsed");
- } catch(org.xml.sax.SAXException e) {
+ } catch(final org.xml.sax.SAXException e) {
Logger.error(this, "Unable to load index because:
"+e.toString());
return;
- } catch(java.io.IOException e) {
+ } catch(final java.io.IOException e) {
Logger.error(this, "Unable to load index because:
"+e.toString());
return;
}
- Element rootEl = xmlDoc.getDocumentElement();
+ final Element rootEl = xmlDoc.getDocumentElement();
- this.loadHeader(rootEl);
+ loadHeader(rootEl);
this.loadLinks(rootEl);
- this.loadFileList(rootEl);
+ loadFileList(rootEl);
}
- public void loadHeader(Element rootEl) {
- Element header =
(Element)rootEl.getElementsByTagName("header").item(0);
+ public void loadHeader(final Element rootEl) {
+ final Element header =
(Element)rootEl.getElementsByTagName("header").item(0);
if (header == null)
return;
- this.realName = this.getHeaderElement(header, "title");
- this.author = this.getHeaderElement(header, "owner");
+ realName = getHeaderElement(header, "title");
+ author = getHeaderElement(header, "owner");
- if (this.author == null)
- this.author = "Another anonymous";
+ if (author == null)
+ author = "Another anonymous";
}
- public String getHeaderElement(Element header, String name) {
+ public String getHeaderElement(final Element header, final String name)
{
try {
if (header == null)
return null;
- NodeList nl = header.getElementsByTagName(name);
+ final NodeList nl = header.getElementsByTagName(name);
if (nl == null)
return null;
- Element sub = (Element)nl.item(0);
+ final Element sub = (Element)nl.item(0);
if (sub == null)
return null;
- Text txt = (Text)sub.getFirstChild();
+ final Text txt = (Text)sub.getFirstChild();
if (txt == null)
return null;
return txt.getData();
- } catch(Exception e) {
+ } catch(final Exception e) {
Logger.notice(this, "Unable to get header element
'"+name+"', because: "+e.toString());
return null;
}
}
- public void loadLinks(Element rootEl) {
- this.purgeLinkList();
+ public void loadLinks(final Element rootEl) {
+ purgeLinkList();
- Element links =
(Element)rootEl.getElementsByTagName("indexes").item(0);
+ final Element links =
(Element)rootEl.getElementsByTagName("indexes").item(0);
if (links == null)
return;
- NodeList list = links.getChildNodes();
+ final NodeList list = links.getChildNodes();
for(int i = 0; i < list.getLength() ; i++) {
if(list.item(i).getNodeType() == Node.ELEMENT_NODE) {
- Element e = (Element)list.item(i);
+ final Element e = (Element)list.item(i);
- Link link = new Link(this.db, e, this);
- this.addLink(link);
+ final Link link = new Link(db, e, this);
+ addLink(link);
}
}
@@ -1163,22 +1156,22 @@
notifyObservers();
}
- public void loadFileList(Element rootEl) {
- this.purgeFileList();
+ public void loadFileList(final Element rootEl) {
+ purgeFileList();
- Element filesEl =
(Element)rootEl.getElementsByTagName("files").item(0);
+ final Element filesEl =
(Element)rootEl.getElementsByTagName("files").item(0);
if (filesEl == null)
return;
- NodeList list = filesEl.getChildNodes();
+ final NodeList list = filesEl.getChildNodes();
for(int i = 0; i < list.getLength() ; i++) {
if(list.item(i).getNodeType() == Node.ELEMENT_NODE) {
- Element e = (Element)list.item(i);
+ final Element e = (Element)list.item(i);
- thaw.plugins.index.File file = new
thaw.plugins.index.File(this.db, e, this);
- this.addFile(file);
+ final thaw.plugins.index.File file = new
thaw.plugins.index.File(db, e, this);
+ addFile(file);
}
}
@@ -1188,7 +1181,7 @@
}
- static String getNameFromKey(String key) {
+ static String getNameFromKey(final String key) {
String name = null;
name = FreenetURIHelper.getFilenameFromKey(key);
@@ -1203,8 +1196,8 @@
public Vector getIndexIds() {
- Vector ids = new Vector();
- ids.add(new Integer(this.getId()));
+ final Vector ids = new Vector();
+ ids.add(new Integer(getId()));
return ids;
}
@@ -1212,10 +1205,10 @@
return (privateKey != null);
}
- public boolean isInIndex(thaw.plugins.index.File file) {
- if (this.fileList == null)
- this.loadFiles(null, true);
- return this.fileList.contains(file);
+ public boolean isInIndex(final thaw.plugins.index.File file) {
+ if (fileList == null)
+ loadFiles(null, true);
+ return fileList.contains(file);
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
2006-12-06 18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
2006-12-06 18:21:00 UTC (rev 11273)
@@ -1,17 +1,18 @@
package thaw.plugins.index;
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
import javax.swing.JPanel;
import javax.swing.JSplitPane;
-
import javax.swing.tree.DefaultMutableTreeNode;
-import java.awt.BorderLayout;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-
-import thaw.core.*;
-import thaw.fcp.*;
-
+import thaw.core.Config;
+import thaw.core.I18n;
+import thaw.core.Logger;
+import thaw.core.MainWindow;
+import thaw.fcp.FCPQueueManager;
import thaw.plugins.Hsqldb;
@@ -32,7 +33,7 @@
- public IndexBrowserPanel(Hsqldb db, FCPQueueManager queueManager,
Config config, MainWindow mainWindow) {
+ public IndexBrowserPanel(final Hsqldb db, final FCPQueueManager
queueManager, final Config config, final MainWindow mainWindow) {
this.db = db;
this.queueManager = queueManager;
this.config = config;
@@ -45,30 +46,30 @@
indexTree.getPanel(),
unknownList.getPanel());
- this.listAndDetails = new JPanel();
- this.listAndDetails.setLayout(new BorderLayout(10, 10));
+ listAndDetails = new JPanel();
+ listAndDetails.setLayout(new BorderLayout(10, 10));
- this.tables = new Tables(false, db, queueManager, unknownList,
this.indexTree, config);
- this.fileDetails = new FileDetailsEditor(false);
+ tables = new Tables(false, db, queueManager, unknownList,
indexTree, config);
+ fileDetails = new FileDetailsEditor(false);
- this.listAndDetails.add(this.tables.getPanel(),
BorderLayout.CENTER);
- this.listAndDetails.add(this.fileDetails.getPanel(),
BorderLayout.SOUTH);
+ listAndDetails.add(tables.getPanel(), BorderLayout.CENTER);
+ listAndDetails.add(fileDetails.getPanel(), BorderLayout.SOUTH);
- this.split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
+ split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
leftSplit, listAndDetails);
- this.indexTree.addTreeSelectionListener(this);
+ indexTree.addTreeSelectionListener(this);
}
public void restoreState() {
if (config.getValue("indexBrowserPanelSplitPosition") != null)
-
split.setDividerLocation(Integer.parseInt(this.config.getValue("indexBrowserPanelSplitPosition")));
+
split.setDividerLocation(Integer.parseInt(config.getValue("indexBrowserPanelSplitPosition")));
leftSplit.setSize(150, MainWindow.DEFAULT_SIZE_Y - 150);
leftSplit.setResizeWeight(0.5);
if (config.getValue("indexTreeUnknownListSplitLocation") ==
null) {
- leftSplit.setDividerLocation(((double)0.5));
+ leftSplit.setDividerLocation((0.5));
} else {
leftSplit.setDividerLocation(Double.parseDouble(config.getValue("indexTreeUnknownListSplitLocation")));
}
@@ -91,12 +92,12 @@
}
public JSplitPane getPanel() {
- return this.split;
+ return split;
}
public void saveState() {
- this.indexTree.save();
- this.config.setValue("indexBrowserPanelSplitPosition",
Integer.toString(this.split.getDividerLocation()));
+ indexTree.save();
+ config.setValue("indexBrowserPanelSplitPosition",
Integer.toString(split.getDividerLocation()));
double splitLocation;
splitLocation = ((double)leftSplit.getDividerLocation() -
((double)leftSplit.getMinimumDividerLocation())) /
(((double)leftSplit.getMaximumDividerLocation()) -
((double)leftSplit.getMinimumDividerLocation()));
@@ -104,33 +105,33 @@
config.setValue("indexTreeUnknownListSplitLocation",
Double.toString(splitLocation));
- this.tables.saveState();
+ tables.saveState();
}
- protected void setList(FileAndLinkList l) {
- this.tables.setList(l);
+ protected void setList(final FileAndLinkList l) {
+ tables.setList(l);
}
- protected void setFileList(FileList l) {
- this.tables.setFileList(l);
+ protected void setFileList(final FileList l) {
+ tables.setFileList(l);
}
- protected void setLinkList(LinkList l) {
- this.tables.setLinkList(l);
+ protected void setLinkList(final LinkList l) {
+ tables.setLinkList(l);
}
- public void valueChanged(javax.swing.event.TreeSelectionEvent e) {
- javax.swing.tree.TreePath path = e.getPath();
+ public void valueChanged(final javax.swing.event.TreeSelectionEvent e) {
+ final javax.swing.tree.TreePath path = e.getPath();
- this.setList(null);
+ setList(null);
if(path == null) {
Logger.notice(this, "Path null ?");
return;
}
- IndexTreeNode node =
(IndexTreeNode)((DefaultMutableTreeNode)path.getLastPathComponent()).getUserObject();
+ final IndexTreeNode node =
(IndexTreeNode)((DefaultMutableTreeNode)path.getLastPathComponent()).getUserObject();
if(node == null) {
Logger.notice(this, "Node null ?");
@@ -139,18 +140,18 @@
if (node instanceof FileList) {
Logger.info(this, "FileList !");
- this.setFileList((FileList)node);
+ setFileList((FileList)node);
}
if (node instanceof LinkList) {
Logger.info(this, "LinkList !");
- this.setLinkList((LinkList)node);
+ setLinkList((LinkList)node);
}
}
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(final ActionEvent e) {
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java 2006-12-06
18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java 2006-12-06
18:21:00 UTC (rev 11273)
@@ -1,20 +1,22 @@
package thaw.plugins.index;
-import java.sql.*;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Vector;
+import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.MutableTreeNode;
import javax.swing.tree.TreeNode;
-import javax.swing.tree.DefaultMutableTreeNode;
-import java.util.Enumeration;
-import java.util.Vector;
-import java.util.Iterator;
-
-import thaw.fcp.*;
+import thaw.core.Logger;
+import thaw.fcp.FCPQueueManager;
import thaw.plugins.Hsqldb;
-import thaw.core.*;
-
public class IndexCategory extends DefaultMutableTreeNode implements
IndexTreeNode {
private static final long serialVersionUID = 1L;
@@ -26,12 +28,12 @@
private FCPQueueManager queueManager;
private UnknownIndexList uIndexList;
- public IndexCategory(Hsqldb db, FCPQueueManager queueManager,
UnknownIndexList uil,
- int id, IndexCategory parent,
- String name) {
+ public IndexCategory(final Hsqldb db, final FCPQueueManager
queueManager, final UnknownIndexList uil,
+ final int id, final IndexCategory parent,
+ final String name) {
super(name, true);
- this.uIndexList = uil;
+ uIndexList = uil;
this.id = id;
this.name = name;
this.parent = parent;
@@ -39,11 +41,11 @@
this.db = db;
this.queueManager = queueManager;
- this.setUserObject(this);
+ setUserObject(this);
}
- public void setParent(IndexCategory parent) {
+ public void setParent(final IndexCategory parent) {
this.parent = parent;
}
@@ -58,37 +60,37 @@
try {
/* Rahh ! Hsqldb doesn't support getGeneratedKeys() !
8/ */
- Connection c = this.db.getConnection();
+ final Connection c = db.getConnection();
PreparedStatement st;
st = c.prepareStatement("SELECT id FROM indexCategories
ORDER BY id DESC LIMIT 1");
st.execute();
try {
- ResultSet key = st.getResultSet();
+ final ResultSet key = st.getResultSet();
key.next();
- this.id = key.getInt(1) + 1;
- } catch(SQLException e) {
- this.id = 0;
+ id = key.getInt(1) + 1;
+ } catch(final SQLException e) {
+ id = 0;
}
st = c.prepareStatement("INSERT INTO indexCategories
(id, name, positionInTree, parent, modifiableIndexes) "+
"VALUES (?,
?,?,?, true)");
- st.setInt(1, this.id);
- st.setString(2, this.name);
+ st.setInt(1, id);
+ st.setString(2, name);
st.setInt(3, 0);
- if(this.parent.getId() >= 0)
- st.setInt(4, this.parent.getId());
+ if(parent.getId() >= 0)
+ st.setInt(4, parent.getId());
else
st.setNull(4, Types.INTEGER);
st.execute();
return true;
- } catch(SQLException e) {
+ } catch(final SQLException e) {
Logger.error(this, "Unable to insert the new index
category in the db, because: "+e.toString());
return false;
@@ -96,43 +98,43 @@
}
public void delete() {
- if (this.id < 0) /* Operation not allowed */
+ if (id < 0) /* Operation not allowed */
return;
- if(this.children == null)
- this.children = this.loadChildren();
+ if(children == null)
+ children = loadChildren();
- for(Iterator it = this.children.iterator();
+ for(final Iterator it = children.iterator();
it.hasNext();) {
- IndexTreeNode child =
(IndexTreeNode)((DefaultMutableTreeNode)it.next()).getUserObject();
+ final IndexTreeNode child =
(IndexTreeNode)((DefaultMutableTreeNode)it.next()).getUserObject();
child.delete();
}
- this.children = null;
+ children = null;
try {
- Connection c = this.db.getConnection();
- PreparedStatement st = c.prepareStatement("DELETE FROM
indexCategories WHERE id = ?");
- st.setInt(1, this.id);
+ final Connection c = db.getConnection();
+ final PreparedStatement st = c.prepareStatement("DELETE
FROM indexCategories WHERE id = ?");
+ st.setInt(1, id);
st.execute();
- } catch(SQLException e) {
- Logger.error(this, "Unable to delete the index category
'"+this.name+"', because: "+e.toString());
+ } catch(final SQLException e) {
+ Logger.error(this, "Unable to delete the index category
'"+name+"', because: "+e.toString());
}
}
- public void rename(String name) {
+ public void rename(final String name) {
try {
- Connection c = this.db.getConnection();
- PreparedStatement st = c.prepareStatement("UPDATE
indexCategories SET name = ? WHERE id = ?");
+ final Connection c = db.getConnection();
+ final PreparedStatement st = c.prepareStatement("UPDATE
indexCategories SET name = ? WHERE id = ?");
st.setString(1, name);
- st.setInt(2, this.id);
+ st.setInt(2, id);
st.execute();
this.name = name;
- } catch(SQLException e) {
+ } catch(final SQLException e) {
Logger.error(this, "Unable to rename the index category
'"+this.name+"' in '"+name+"', because: "+e.toString());
}
}
@@ -140,9 +142,9 @@
public String getPublicKey() {
String result = "";
- for(Iterator it = this.children.iterator();
+ for(final Iterator it = children.iterator();
it.hasNext();) {
- IndexTreeNode node =
(IndexTreeNode)((DefaultMutableTreeNode)it.next()).getUserObject();
+ final IndexTreeNode node =
(IndexTreeNode)((DefaultMutableTreeNode)it.next()).getUserObject();
result = result + node.getPublicKey();
if (it.hasNext())
@@ -155,9 +157,9 @@
public String getPrivateKey() {
String result = "";
- for(Iterator it = this.children.iterator();
+ for(final Iterator it = children.iterator();
it.hasNext();) {
- IndexTreeNode node =
(IndexTreeNode)((DefaultMutableTreeNode)it.next()).getUserObject();
+ final IndexTreeNode node =
(IndexTreeNode)((DefaultMutableTreeNode)it.next()).getUserObject();
result = result + node.getPrivateKey();
if (it.hasNext())
@@ -167,31 +169,31 @@
return result;
}
- public void addObserver(java.util.Observer o) {
- if(this.children == null)
- this.children = this.loadChildren();
+ public void addObserver(final java.util.Observer o) {
+ if(children == null)
+ children = loadChildren();
- for(Iterator it = this.children.iterator();
+ for(final Iterator it = children.iterator();
it.hasNext();) {
- IndexTreeNode node =
(IndexTreeNode)((DefaultMutableTreeNode)it.next()).getUserObject();
+ final IndexTreeNode node =
(IndexTreeNode)((DefaultMutableTreeNode)it.next()).getUserObject();
node.addObserver(o);
}
}
public void update() {
- for (Enumeration e = this.children() ; e.hasMoreElements() ;) {
+ for (final Enumeration e = children() ; e.hasMoreElements() ;) {
((IndexTreeNode)((DefaultMutableTreeNode)e.nextElement()).getUserObject()).update();
}
}
- public void updateFromFreenet(int rev) {
- for (Enumeration e = this.children() ; e.hasMoreElements() ;) {
+ public void updateFromFreenet(final int rev) {
+ for (final Enumeration e = children() ; e.hasMoreElements() ;) {
((IndexTreeNode)((DefaultMutableTreeNode)e.nextElement()).getUserObject()).updateFromFreenet(rev);
}
}
public boolean isUpdating() {
- for (Enumeration e = this.children() ; e.hasMoreElements() ;) {
+ for (final Enumeration e = children() ; e.hasMoreElements() ;) {
if(((IndexTreeNode)((DefaultMutableTreeNode)e.nextElement())).isUpdating())
return true;
}
@@ -200,40 +202,40 @@
}
public void save() {
- this.saveThis();
+ saveThis();
- for (Enumeration e = this.children() ; e.hasMoreElements() ;) {
+ for (final Enumeration e = children() ; e.hasMoreElements() ;) {
((IndexTreeNode)((DefaultMutableTreeNode)e.nextElement()).getUserObject()).save();
}
}
public void saveThis() {
- if(this.getId() < 0)
+ if(getId() < 0)
return;
try {
- Connection c = this.db.getConnection();
- PreparedStatement st = c.prepareStatement("UPDATE
indexCategories SET name = ?, positionInTree = ?, parent = ? WHERE id = ?");
+ final Connection c = db.getConnection();
+ final PreparedStatement st = c.prepareStatement("UPDATE
indexCategories SET name = ?, positionInTree = ?, parent = ? WHERE id = ?");
- st.setString(1, this.name);
- st.setInt(2, this.getParent().getIndex(this));
+ st.setString(1, name);
+ st.setInt(2, getParent().getIndex(this));
- if( ((IndexTreeNode)this.getParent()).getId() < 0)
+ if( ((IndexTreeNode)getParent()).getId() < 0)
st.setNull(3, Types.INTEGER);
else
- st.setInt(3,
((IndexTreeNode)this.getParent()).getId());
+ st.setInt(3,
((IndexTreeNode)getParent()).getId());
- st.setInt(4, this.getId());
+ st.setInt(4, getId());
st.execute();
- } catch(SQLException e) {
- Logger.error(this, "Unable to save index category state
'"+this.toString()+"' because : "+e.toString());
+ } catch(final SQLException e) {
+ Logger.error(this, "Unable to save index category state
'"+toString()+"' because : "+e.toString());
}
}
public int getId() {
- return this.id;
+ return id;
}
public int getChildNumber() {
@@ -247,27 +249,27 @@
}
public Vector loadChildren() {
- Vector children = new Vector();
+ final Vector children = new Vector();
Logger.debug(this, "loadChildren()");
- this.loadChildCategories(children);
- this.loadChildIndexes(children);
+ loadChildCategories(children);
+ loadChildIndexes(children);
- this.cleanChildList(children);
+ cleanChildList(children);
Logger.debug(this, "Children: "+children.size());
- for(Iterator it = children.iterator();
+ for(final Iterator it = children.iterator();
it.hasNext(); ) {
- this.add((MutableTreeNode)it.next());
+ add((MutableTreeNode)it.next());
}
return children;
}
- public void loadChildIndexes(Vector children) {
+ public void loadChildIndexes(final Vector children) {
ResultSet result;
@@ -275,51 +277,51 @@
query = "SELECT id, originalName, displayName, publicKey,
privateKey, author, positionInTree, revision FROM indexes";
- if(this.id < 0)
+ if(id < 0)
query = query + " WHERE parent IS NULL";
else
- query = query + " WHERE parent =
"+Integer.toString(this.id);
+ query = query + " WHERE parent = "+Integer.toString(id);
query = query + " ORDER BY positionInTree DESC";
try {
- result = this.db.executeQuery(query);
+ result = db.executeQuery(query);
if(result == null) {
- Logger.warning(this, "Unable to get child
indexes for '"+this.toString()+"'");
+ Logger.warning(this, "Unable to get child
indexes for '"+toString()+"'");
return;
}
while(result.next()) {
- int id = result.getInt("id");
- int position = result.getInt("positionInTree");
+ final int id = result.getInt("id");
+ final int position =
result.getInt("positionInTree");
- String realName =
result.getString("originalName");
- String displayName =
result.getString("displayName");
+ final String realName =
result.getString("originalName");
+ final String displayName =
result.getString("displayName");
- String publicKey =
result.getString("publicKey");
- String privateKey =
result.getString("privateKey");
+ final String publicKey =
result.getString("publicKey");
+ final String privateKey =
result.getString("privateKey");
- int revision = result.getInt("revision");
+ final int revision = result.getInt("revision");
- String author = result.getString("author");
+ final String author =
result.getString("author");
- Index index = new Index(db, queueManager,
uIndexList,
+ final Index index = new Index(db, queueManager,
uIndexList,
id, this,
realName, displayName,
publicKey, privateKey,
revision,
author);
- this.set(children, position,
index.getTreeNode());
+ set(children, position, index.getTreeNode());
}
- } catch (java.sql.SQLException e) {
- Logger.warning(this, "SQLException while getting child
of index category '"+this.name+"': "+e.toString());
+ } catch (final java.sql.SQLException e) {
+ Logger.warning(this, "SQLException while getting child
of index category '"+name+"': "+e.toString());
}
}
- public void loadChildCategories(Vector children) {
+ public void loadChildCategories(final Vector children) {
ResultSet result;
@@ -327,44 +329,44 @@
query = "SELECT id, name, positionInTree FROM indexCategories";
- if(this.id < 0)
+ if(id < 0)
query = query + " WHERE parent IS NULL";
else
- query = query + " WHERE parent =
"+Integer.toString(this.id);
+ query = query + " WHERE parent = "+Integer.toString(id);
query = query + " ORDER BY positionInTree DESC";
try {
- result = this.db.executeQuery(query);
+ result = db.executeQuery(query);
if(result == null) {
- Logger.error(this, "Unable to get child
categories for '"+this.toString()+"'");
+ Logger.error(this, "Unable to get child
categories for '"+toString()+"'");
return;
}
while(result.next()) {
- int id = result.getInt("id");
- int position = result.getInt("positionInTree");
- String name = result.getString("name");
+ final int id = result.getInt("id");
+ final int position =
result.getInt("positionInTree");
+ final String name = result.getString("name");
- IndexCategory cat = new IndexCategory(this.db,
this.queueManager, uIndexList, id, this, name);
+ final IndexCategory cat = new IndexCategory(db,
queueManager, uIndexList, id, this, name);
cat.loadChildren();
- this.set(children, position, cat);
+ set(children, position, cat);
}
- } catch (java.sql.SQLException e) {
- Logger.error(this, "SQLException while getting child of
index category '"+this.name+"': "+e.toString());
+ } catch (final java.sql.SQLException e) {
+ Logger.error(this, "SQLException while getting child of
index category '"+name+"': "+e.toString());
}
}
- protected void cleanChildList(Vector children) {
+ protected void cleanChildList(final Vector children) {
while(children.remove(null)) {
Logger.warning(this, "cleanChildList() : null removed
!");
}
}
- public void set(Vector children, int position, TreeNode node) {
- if(node == this || node == null)
+ public void set(final Vector children, final int position, final
TreeNode node) {
+ if((node == this) || (node == null))
return;
if(children.size() <= position) {
@@ -384,19 +386,19 @@
}
public String toString() {
- return this.name;
+ return name;
}
public Vector getIndexIds()
{
- if(this.children == null)
- this.children = this.loadChildren();
+ if(children == null)
+ children = loadChildren();
- Vector result = new Vector();
+ final Vector result = new Vector();
- for(Iterator it = this.children.iterator();
+ for(final Iterator it = children.iterator();
it.hasNext();) {
- IndexTreeNode node =
(IndexTreeNode)((DefaultMutableTreeNode)it.next()).getUserObject();
+ final IndexTreeNode node =
(IndexTreeNode)((DefaultMutableTreeNode)it.next()).getUserObject();
result.addAll(node.getIndexIds());
}
@@ -404,15 +406,15 @@
}
- public Index getIndex(int id)
+ public Index getIndex(final int id)
{
- if(this.children == null)
- this.children = this.loadChildren();
+ if(children == null)
+ children = loadChildren();
- for(Iterator it = this.children.iterator();
+ for(final Iterator it = children.iterator();
it.hasNext();) {
- IndexTreeNode node =
(IndexTreeNode)((DefaultMutableTreeNode)it.next()).getUserObject();
- Index result = node.getIndex(id);
+ final IndexTreeNode node =
(IndexTreeNode)((DefaultMutableTreeNode)it.next()).getUserObject();
+ final Index result = node.getIndex(id);
if (result != null)
return result;
}
@@ -427,9 +429,9 @@
if(children == null)
children = loadChildren();
- for(Iterator it = children.iterator();
+ for(final Iterator it = children.iterator();
it.hasNext();) {
- IndexTreeNode node =
(IndexTreeNode)((DefaultMutableTreeNode)it.next()).getUserObject();
+ final IndexTreeNode node =
(IndexTreeNode)((DefaultMutableTreeNode)it.next()).getUserObject();
if (!node.isModifiable())
return false;
}
@@ -442,9 +444,9 @@
if(children == null)
children = loadChildren();
- for(Iterator it = children.iterator();
+ for(final Iterator it = children.iterator();
it.hasNext();) {
- IndexTreeNode node =
(IndexTreeNode)((DefaultMutableTreeNode)it.next()).getUserObject();
+ final IndexTreeNode node =
(IndexTreeNode)((DefaultMutableTreeNode)it.next()).getUserObject();
if (node.hasChanged())
return true;
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2006-12-06 18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2006-12-06 18:21:00 UTC (rev 11273)
@@ -2,55 +2,46 @@
import java.awt.BorderLayout;
import java.awt.GridLayout;
-
-import java.awt.event.ActionListener;
+import java.awt.Toolkit;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
-import javax.swing.AbstractButton;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.io.FileOutputStream;
+import java.util.Iterator;
+import java.util.Vector;
-import javax.swing.tree.MutableTreeNode;
-import javax.swing.tree.DefaultMutableTreeNode;
-
-import javax.swing.JFrame;
+import javax.swing.AbstractButton;
+import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
-import javax.swing.JButton;
import javax.swing.JPanel;
-import javax.swing.JTextField;
-import javax.swing.JTextArea;
-import javax.swing.JLabel;
import javax.swing.JPopupMenu;
-import javax.swing.JMenuItem;
-import javax.swing.JFileChooser;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.tree.DefaultMutableTreeNode;
-import java.io.FileOutputStream;
-
-import java.util.Vector;
-import java.util.Iterator;
-
-import java.awt.Toolkit;
-import java.awt.datatransfer.Clipboard;
-import java.awt.datatransfer.StringSelection;
-
-import java.awt.event.MouseListener;
-import java.awt.event.MouseEvent;
-
-import thaw.core.Config;
-import thaw.core.I18n;
+import thaw.core.FileChooser;
import thaw.core.FreenetURIHelper;
-import thaw.plugins.Hsqldb;
-
-import thaw.fcp.*;
+import thaw.core.I18n;
import thaw.core.Logger;
import thaw.core.MainWindow;
-import thaw.core.FileChooser;
+import thaw.fcp.FCPClientPut;
+import thaw.fcp.FCPQueueManager;
+import thaw.fcp.FCPTransferQuery;
+import thaw.plugins.Hsqldb;
/**
* Index.java, IndexCategory.java and IndexTree.java must NEVER use this
helper (to avoid loops).
*/
public class IndexManagementHelper {
- private static String askAName(String prompt, String defVal) {
+ private static String askAName(final String prompt, final String
defVal) {
return JOptionPane.showInputDialog(prompt, defVal);
}
@@ -75,11 +66,11 @@
private AbstractButton actionSource;
private IndexTreeNode target;
- public BasicIndexAction(Hsqldb db, FCPQueueManager
queueManager, UnknownIndexList uIndexList, IndexTree tree, AbstractButton
actionSource) {
+ public BasicIndexAction(final Hsqldb db, final FCPQueueManager
queueManager, final UnknownIndexList uIndexList, final IndexTree tree, final
AbstractButton actionSource) {
this.db = db;
this.tree = tree;
this.actionSource = actionSource;
- this.target = null;
+ target = null;
this.queueManager = queueManager;
this.uIndexList = uIndexList;
actionSource.addActionListener(this);
@@ -89,7 +80,7 @@
return actionSource;
}
- public void setTarget(IndexTreeNode node) {
+ public void setTarget(final IndexTreeNode node) {
target = node;
}
@@ -120,36 +111,36 @@
public static class IndexCreator extends BasicIndexAction {
- public IndexCreator(Hsqldb db, FCPQueueManager queueManager,
UnknownIndexList uIndexList, IndexTree tree, AbstractButton actionSource) {
+ public IndexCreator(final Hsqldb db, final FCPQueueManager
queueManager, final UnknownIndexList uIndexList, final IndexTree tree, final
AbstractButton actionSource) {
super(db, queueManager, uIndexList, tree, actionSource);
}
- public void setTarget(IndexTreeNode node) {
+ public void setTarget(final IndexTreeNode node) {
super.setTarget(node);
- getActionSource().setEnabled(node == null || node
instanceof IndexCategory);
+ getActionSource().setEnabled((node == null) || (node
instanceof IndexCategory));
}
- public void actionPerformed(ActionEvent e) {
- String name =
askAName(I18n.getMessage("thaw.plugin.index.indexName"),
+ public void actionPerformed(final ActionEvent e) {
+ final String name =
IndexManagementHelper.askAName(I18n.getMessage("thaw.plugin.index.indexName"),
I18n.getMessage("thaw.plugin.index.newIndex"));
if (name == null)
return;
- createIndex(getDb(), getQueueManager(),
getUnknownIndexList(), getTree(), (IndexCategory)getTarget(), name);
+ IndexManagementHelper.createIndex(getDb(),
getQueueManager(), getUnknownIndexList(), getTree(),
(IndexCategory)getTarget(), name);
}
}
- public static void createIndex(Hsqldb db, FCPQueueManager queueManager,
UnknownIndexList uIndexList, IndexTree tree, IndexCategory target, String name)
{
+ public static void createIndex(final Hsqldb db, final FCPQueueManager
queueManager, final UnknownIndexList uIndexList, final IndexTree tree,
IndexCategory target, final String name) {
if (target == null)
target = tree.getRoot();
- if (name == null || name.indexOf("/") >= 0) {
+ if ((name == null) || (name.indexOf("/") >= 0)) {
Logger.error(new IndexManagementHelper(), "invalid
name");
return;
}
- Index index = new Index(db, queueManager, uIndexList, -1,
target, name, name, null, null, 0, null);
+ final Index index = new Index(db, queueManager, uIndexList, -1,
target, name, name, null, null, 0, null);
index.generateKeys();
index.create();
@@ -177,17 +168,17 @@
/**
* @return String[0] == publicKey ; String[1] == privateKey ;
public or private are null if unchanged
*/
- public static String[] askKeys(boolean askPrivateKey,
- String defaultPublicKey,
- String defaultPrivateKey,
- MainWindow mainWindow) {
+ public static String[] askKeys(final boolean askPrivateKey,
+ final String defaultPublicKey,
+ final String defaultPrivateKey,
+ final MainWindow mainWindow) {
return ((new KeyAsker()).askKeysBis(askPrivateKey,
defaultPublicKey, defaultPrivateKey, mainWindow));
}
- public synchronized String[] askKeysBis(boolean askPrivateKey,
+ public synchronized String[] askKeysBis(final boolean
askPrivateKey,
String defaultPublicKey,
String defaultPrivateKey,
- MainWindow mainWindow) {
+ final MainWindow mainWindow) {
formState = 0;
if (defaultPublicKey == null)
@@ -196,15 +187,15 @@
if (defaultPrivateKey == null)
defaultPrivateKey = "SSK@";
- JDialog frame = new JDialog(mainWindow.getMainFrame(),
I18n.getMessage("thaw.plugin.index.indexKey"));
+ final JDialog frame = new
JDialog(mainWindow.getMainFrame(),
I18n.getMessage("thaw.plugin.index.indexKey"));
frame.getContentPane().setLayout(new BorderLayout());
publicKeyField = new JTextField(defaultPublicKey);
privateKeyField = new JTextField(defaultPrivateKey);
- JPanel subPanelA = new JPanel(); /* left => labels */
- JPanel subPanelB = new JPanel(); /* right => textfield
*/
+ final JPanel subPanelA = new JPanel(); /* left =>
labels */
+ final JPanel subPanelB = new JPanel(); /* right =>
textfield */
subPanelA.setLayout(new GridLayout(askPrivateKey ? 2 :
1, 1));
subPanelB.setLayout(new GridLayout(askPrivateKey ? 2 :
1, 1));
@@ -231,7 +222,7 @@
frame.getContentPane().add(subPanelA,
BorderLayout.WEST);
frame.getContentPane().add(subPanelB,
BorderLayout.CENTER);
- JPanel subPanelC = new JPanel();
+ final JPanel subPanelC = new JPanel();
subPanelC.setLayout(new GridLayout(1, 2));
cancelButton = new
JButton(I18n.getMessage("thaw.common.cancel"));
@@ -252,7 +243,7 @@
/* VVVVVVVVVVV */
try {
wait();
- } catch(java.lang.InterruptedException e) {
+ } catch(final java.lang.InterruptedException e) {
/* \_o< */
}
/*
@@ -269,7 +260,7 @@
if (formState == 2)
return null;
- String[] keys = new String[2];
+ final String[] keys = new String[2];
keys[0] = publicKeyField.getText();
if (askPrivateKey)
@@ -279,17 +270,17 @@
frame.dispose();
- if (keys[0] == null || keys[0].length() < 20)
+ if ((keys[0] == null) || (keys[0].length() < 20))
return null;
- if (keys[1] == null || keys[1].length() < 20)
+ if ((keys[1] == null) || (keys[1].length() < 20))
keys[1] = null;
return keys;
}
- public synchronized void actionPerformed(ActionEvent e) {
+ public synchronized void actionPerformed(final ActionEvent e) {
if (e.getSource() == okButton) {
formState = 1;
}
@@ -301,19 +292,19 @@
notify();
}
- public void mouseClicked(MouseEvent e) { }
- public void mouseEntered(MouseEvent e) { }
- public void mouseExited(MouseEvent e) { }
+ public void mouseClicked(final MouseEvent e) { }
+ public void mouseEntered(final MouseEvent e) { }
+ public void mouseExited(final MouseEvent e) { }
- public void mousePressed(MouseEvent e) {
- this.showPopupMenu(e);
+ public void mousePressed(final MouseEvent e) {
+ showPopupMenu(e);
}
- public void mouseReleased(MouseEvent e) {
- this.showPopupMenu(e);
+ public void mouseReleased(final MouseEvent e) {
+ showPopupMenu(e);
}
- protected void showPopupMenu(MouseEvent e) {
+ protected void showPopupMenu(final MouseEvent e) {
if(e.isPopupTrigger()) {
if (e.getComponent() == publicKeyField)
popupMenuA.show(e.getComponent(),
e.getX(), e.getY());
@@ -327,20 +318,20 @@
public static class IndexKeyModifier extends BasicIndexAction
implements Runnable {
private MainWindow mainWindow;
- public IndexKeyModifier(MainWindow mainWindow, AbstractButton
actionSource) {
+ public IndexKeyModifier(final MainWindow mainWindow, final
AbstractButton actionSource) {
super(null, null, null, null, actionSource);
this.mainWindow = mainWindow;
}
- public void setTarget(IndexTreeNode node) {
+ public void setTarget(final IndexTreeNode node) {
super.setTarget(node);
- getActionSource().setEnabled(node != null || node
instanceof Index);
+ getActionSource().setEnabled((node != null) || (node
instanceof Index));
}
public void run() {
- Index index = ((Index)getTarget());
+ final Index index = ((Index)getTarget());
- String[] keys = KeyAsker.askKeys(true,
index.getPublicKey(), index.getPrivateKey(), mainWindow);
+ final String[] keys = KeyAsker.askKeys(true,
index.getPublicKey(), index.getPrivateKey(), mainWindow);
if (keys == null)
return;
@@ -349,9 +340,9 @@
index.setPublicKey(keys[0]);
}
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(final ActionEvent e) {
if (e.getSource() == getActionSource()) {
- Thread th = new Thread(this);
+ final Thread th = new Thread(this);
th.start();
}
}
@@ -361,14 +352,14 @@
public static class IndexReuser extends BasicIndexAction implements
Runnable {
private MainWindow mainWindow;
- public IndexReuser(Hsqldb db, FCPQueueManager queueManager,
UnknownIndexList uIndexList, IndexTree tree, MainWindow mainWindow,
AbstractButton actionSource) {
+ public IndexReuser(final Hsqldb db, final FCPQueueManager
queueManager, final UnknownIndexList uIndexList, final IndexTree tree, final
MainWindow mainWindow, final AbstractButton actionSource) {
super(db, queueManager, uIndexList, tree, actionSource);
this.mainWindow = mainWindow;
}
- public void setTarget(IndexTreeNode node) {
+ public void setTarget(final IndexTreeNode node) {
super.setTarget(node);
- getActionSource().setEnabled(node == null || node
instanceof IndexCategory);
+ getActionSource().setEnabled((node == null) || (node
instanceof IndexCategory));
}
public void run() {
@@ -384,20 +375,20 @@
publicKey = keys[0];
privateKey = keys[1];
- reuseIndex(getDb(), getQueueManager(),
getUnknownIndexList(), getTree(), (IndexCategory)getTarget(), publicKey,
privateKey);
+ IndexManagementHelper.reuseIndex(getDb(),
getQueueManager(), getUnknownIndexList(), getTree(),
(IndexCategory)getTarget(), publicKey, privateKey);
}
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(final ActionEvent e) {
if (e.getSource() == getActionSource()) {
- Thread newThread = new Thread(this);
+ final Thread newThread = new Thread(this);
newThread.start();
}
}
}
- public static void addIndex(Hsqldb db, FCPQueueManager queueManager,
UnknownIndexList uIndexList, IndexTree tree, IndexCategory target, String
publicKey) {
- reuseIndex(db, queueManager, uIndexList, tree, target,
publicKey, null);
+ public static void addIndex(final Hsqldb db, final FCPQueueManager
queueManager, final UnknownIndexList uIndexList, final IndexTree tree, final
IndexCategory target, final String publicKey) {
+ IndexManagementHelper.reuseIndex(db, queueManager, uIndexList,
tree, target, publicKey, null);
}
@@ -405,7 +396,7 @@
* Can be use directly
* @param privateKey Can be null
*/
- public static void reuseIndex(Hsqldb db, FCPQueueManager queueManager,
UnknownIndexList uIndexList, IndexTree tree, IndexCategory target,
+ public static void reuseIndex(final Hsqldb db, final FCPQueueManager
queueManager, final UnknownIndexList uIndexList, final IndexTree tree, final
IndexCategory target,
String publicKey, String privateKey) {
publicKey = FreenetURIHelper.cleanURI(publicKey);
@@ -414,16 +405,16 @@
if (publicKey == null)
return;
- String name = Index.getNameFromKey(publicKey);
+ final String name = Index.getNameFromKey(publicKey);
IndexCategory parent;
- if (target != null && target instanceof IndexCategory)
- parent = (IndexCategory)target;
+ if ((target != null) && (target instanceof IndexCategory))
+ parent = target;
else
parent = tree.getRoot();
- Index index = new Index(db, queueManager, uIndexList, -2,
parent, name, name, publicKey, privateKey, 0, null);
+ final Index index = new Index(db, queueManager, uIndexList, -2,
parent, name, name, publicKey, privateKey, 0, null);
uIndexList.removeLink(index);
index.create();
@@ -439,28 +430,28 @@
public static class IndexCategoryAdder extends BasicIndexAction {
- public IndexCategoryAdder(Hsqldb db, FCPQueueManager
queueManager, UnknownIndexList uil, IndexTree tree, AbstractButton
actionSource) {
+ public IndexCategoryAdder(final Hsqldb db, final
FCPQueueManager queueManager, final UnknownIndexList uil, final IndexTree tree,
final AbstractButton actionSource) {
super(db, queueManager, uil, tree, actionSource);
}
- public void setTarget(IndexTreeNode node) {
+ public void setTarget(final IndexTreeNode node) {
super.setTarget(node);
- getActionSource().setEnabled(node == null || node
instanceof IndexCategory);
+ getActionSource().setEnabled((node == null) || (node
instanceof IndexCategory));
}
- public void actionPerformed(ActionEvent e) {
- String name =
askAName(I18n.getMessage("thaw.plugin.index.categoryName"),
+ public void actionPerformed(final ActionEvent e) {
+ final String name =
IndexManagementHelper.askAName(I18n.getMessage("thaw.plugin.index.categoryName"),
I18n.getMessage("thaw.plugin.index.newCategory"));
- addIndexCategory(getDb(), getQueueManager(),
getUnknownIndexList(), getTree(), (IndexCategory)getTarget(), name);
+ IndexManagementHelper.addIndexCategory(getDb(),
getQueueManager(), getUnknownIndexList(), getTree(),
(IndexCategory)getTarget(), name);
}
}
- public static void addIndexCategory(Hsqldb db, FCPQueueManager
queueManager, UnknownIndexList uIndexList, IndexTree tree, IndexCategory
target, String name) {
+ public static void addIndexCategory(final Hsqldb db, final
FCPQueueManager queueManager, final UnknownIndexList uIndexList, final
IndexTree tree, IndexCategory target, final String name) {
if (target == null)
target = tree.getRoot();
- IndexCategory newCat = new IndexCategory(db, queueManager,
uIndexList, -2, target, name);
+ final IndexCategory newCat = new IndexCategory(db,
queueManager, uIndexList, -2, target, name);
newCat.create();
@@ -469,16 +460,16 @@
public static class IndexDownloader extends BasicIndexAction implements
Runnable {
- public IndexDownloader(AbstractButton actionSource) {
+ public IndexDownloader(final AbstractButton actionSource) {
super(null, null, null, null, actionSource);
}
- public void setTarget(IndexTreeNode node) {
+ public void setTarget(final IndexTreeNode node) {
super.setTarget(node);
}
- public void actionPerformed(ActionEvent e) {
- Thread newTh = new Thread(this);
+ public void actionPerformed(final ActionEvent e) {
+ final Thread newTh = new Thread(this);
newTh.run();
}
@@ -491,17 +482,17 @@
}
public static class IndexUploader extends BasicIndexAction implements
Runnable {
- public IndexUploader(AbstractButton actionSource) {
+ public IndexUploader(final AbstractButton actionSource) {
super(null, null, null, null, actionSource);
}
- public void setTarget(IndexTreeNode node) {
+ public void setTarget(final IndexTreeNode node) {
super.setTarget(node);
- getActionSource().setEnabled(node != null &&
node.isModifiable());
+ getActionSource().setEnabled((node != null) &&
node.isModifiable());
}
- public void actionPerformed(ActionEvent e) {
- Thread newTh = new Thread(this);
+ public void actionPerformed(final ActionEvent e) {
+ final Thread newTh = new Thread(this);
newTh.run();
}
@@ -513,55 +504,55 @@
public static class PublicKeyCopier extends BasicIndexAction {
- public PublicKeyCopier(AbstractButton actionSource) {
+ public PublicKeyCopier(final AbstractButton actionSource) {
super(null, null, null, null, actionSource);
}
- public void setTarget(IndexTreeNode node) {
+ public void setTarget(final IndexTreeNode node) {
super.setTarget(node);
getActionSource().setEnabled(node != null);
}
- public void actionPerformed(ActionEvent e) {
- copyPublicKeyFrom(getTarget());
+ public void actionPerformed(final ActionEvent e) {
+ IndexManagementHelper.copyPublicKeyFrom(getTarget());
}
}
- public static void copyPublicKeyFrom(IndexTreeNode node) {
+ public static void copyPublicKeyFrom(final IndexTreeNode node) {
if (node == null)
return;
- Toolkit tk = Toolkit.getDefaultToolkit();
- StringSelection st = new StringSelection(node.getPublicKey());
- Clipboard cp = tk.getSystemClipboard();
+ final Toolkit tk = Toolkit.getDefaultToolkit();
+ final StringSelection st = new
StringSelection(node.getPublicKey());
+ final Clipboard cp = tk.getSystemClipboard();
cp.setContents(st, null);
}
public static class PrivateKeyCopier extends BasicIndexAction {
- public PrivateKeyCopier(AbstractButton actionSource) {
+ public PrivateKeyCopier(final AbstractButton actionSource) {
super(null, null, null, null, actionSource);
}
- public void setTarget(IndexTreeNode node) {
+ public void setTarget(final IndexTreeNode node) {
super.setTarget(node);
- getActionSource().setEnabled(node != null && node
instanceof Index && node.isModifiable());
+ getActionSource().setEnabled((node != null) && (node
instanceof Index) && node.isModifiable());
}
- public void actionPerformed(ActionEvent e) {
- copyPrivateKeyFrom(getTarget());
+ public void actionPerformed(final ActionEvent e) {
+ IndexManagementHelper.copyPrivateKeyFrom(getTarget());
}
}
- public static void copyPrivateKeyFrom(IndexTreeNode node) {
+ public static void copyPrivateKeyFrom(final IndexTreeNode node) {
if (node == null)
return;
- Toolkit tk = Toolkit.getDefaultToolkit();
- StringSelection st = new StringSelection(node.getPrivateKey());
- Clipboard cp = tk.getSystemClipboard();
+ final Toolkit tk = Toolkit.getDefaultToolkit();
+ final StringSelection st = new
StringSelection(node.getPrivateKey());
+ final Clipboard cp = tk.getSystemClipboard();
cp.setContents(st, null);
}
@@ -569,36 +560,36 @@
* Can rename indexes or index categories.
*/
public static class IndexRenamer extends BasicIndexAction {
- public IndexRenamer(IndexTree tree, AbstractButton
actionSource) {
+ public IndexRenamer(final IndexTree tree, final AbstractButton
actionSource) {
super(null, null, null, tree, actionSource);
}
- public void setTarget(IndexTreeNode node) {
+ public void setTarget(final IndexTreeNode node) {
super.setTarget(node);
getActionSource().setEnabled(node != null);
}
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(final ActionEvent e) {
String newName;
if (getTarget() instanceof Index) {
- newName =
askAName(I18n.getMessage("thaw.plugin.index.indexName"),
+ newName =
IndexManagementHelper.askAName(I18n.getMessage("thaw.plugin.index.indexName"),
getTarget().toString());
} else {
- newName =
askAName(I18n.getMessage("thaw.plugin.index.categoryName"),
+ newName =
IndexManagementHelper.askAName(I18n.getMessage("thaw.plugin.index.categoryName"),
getTarget().toString());
}
if (newName == null)
return;
- renameNode(getTree(), getTarget(), newName);
+ IndexManagementHelper.renameNode(getTree(),
getTarget(), newName);
}
}
- public static void renameNode(IndexTree tree, IndexTreeNode node,
String newName) {
- if (node == null || newName == null)
+ public static void renameNode(final IndexTree tree, final IndexTreeNode
node, final String newName) {
+ if ((node == null) || (newName == null))
return;
node.rename(newName);
@@ -609,19 +600,19 @@
public static class IndexExporter extends BasicIndexAction {
- public IndexExporter(AbstractButton actionSource) {
+ public IndexExporter(final AbstractButton actionSource) {
super(null, null, null, null, actionSource);
}
- public void setTarget(IndexTreeNode node) {
+ public void setTarget(final IndexTreeNode node) {
super.setTarget(node);
- getActionSource().setEnabled(node != null && node
instanceof Index);
+ getActionSource().setEnabled((node != null) && (node
instanceof Index));
}
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(final ActionEvent e) {
java.io.File newFile;
- FileChooser fileChooser = new FileChooser();
+ final FileChooser fileChooser = new FileChooser();
fileChooser.setTitle(I18n.getMessage("thaw.plugin.index.exportIndex"));
fileChooser.setDirectoryOnly(false);
fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
@@ -634,7 +625,7 @@
try {
out = new FileOutputStream(newFile);
- } catch(java.io.FileNotFoundException excep) {
+ } catch(final java.io.FileNotFoundException excep) {
Logger.warning(this, "Unable to create file
'"+newFile.toString()+"' ! not generated because : "+excep.toString());
return;
}
@@ -645,19 +636,19 @@
public static class IndexImporter extends BasicIndexAction {
- public IndexImporter(AbstractButton actionSource) {
+ public IndexImporter(final AbstractButton actionSource) {
super(null, null, null, null, actionSource);
}
- public void setTarget(IndexTreeNode node) {
+ public void setTarget(final IndexTreeNode node) {
super.setTarget(node);
- getActionSource().setEnabled(node != null && node
instanceof Index);
+ getActionSource().setEnabled((node != null) && (node
instanceof Index));
}
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(final ActionEvent e) {
java.io.File newFile;
- FileChooser fileChooser = new FileChooser();
+ final FileChooser fileChooser = new FileChooser();
fileChooser.setTitle(I18n.getMessage("thaw.plugin.index.importIndex"));
fileChooser.setDirectoryOnly(false);
fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
@@ -676,26 +667,26 @@
* Can be used on indexes or index categories.
*/
public static class IndexDeleter extends BasicIndexAction {
- public IndexDeleter(IndexTree tree, AbstractButton
actionSource) {
+ public IndexDeleter(final IndexTree tree, final AbstractButton
actionSource) {
super(null, null, null, tree, actionSource);
}
- public void setTarget(IndexTreeNode node) {
+ public void setTarget(final IndexTreeNode node) {
super.setTarget(node);
getActionSource().setEnabled(node != null);
}
- public void actionPerformed(ActionEvent e) {
- deleteNode(getTree(), getTarget());
+ public void actionPerformed(final ActionEvent e) {
+ IndexManagementHelper.deleteNode(getTree(),
getTarget());
}
}
- public static void deleteNode(IndexTree tree, IndexTreeNode node) {
+ public static void deleteNode(final IndexTree tree, final IndexTreeNode
node) {
if (node == null)
return;
- DefaultMutableTreeNode parent =
(DefaultMutableTreeNode)node.getTreeNode().getParent();
+ final DefaultMutableTreeNode parent =
(DefaultMutableTreeNode)node.getTreeNode().getParent();
if (parent != null)
parent.remove(node.getTreeNode());
@@ -711,74 +702,74 @@
public static class FileInserterAndAdder extends BasicIndexAction {
- public FileInserterAndAdder(Hsqldb db, FCPQueueManager
queueManager, AbstractButton actionSource) {
+ public FileInserterAndAdder(final Hsqldb db, final
FCPQueueManager queueManager, final AbstractButton actionSource) {
super(db, queueManager, null, null, actionSource);
}
- public void setTarget(IndexTreeNode node) {
+ public void setTarget(final IndexTreeNode node) {
super.setTarget(node);
- getActionSource().setEnabled(node != null && node
instanceof Index && ((Index)node).isModifiable());
+ getActionSource().setEnabled((node != null) && (node
instanceof Index) && ((Index)node).isModifiable());
}
- public void actionPerformed(ActionEvent e) {
- FileChooser fileChooser = new FileChooser();
+ public void actionPerformed(final ActionEvent e) {
+ final FileChooser fileChooser = new FileChooser();
fileChooser.setDirectoryOnly(false);
fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
fileChooser.setTitle(I18n.getMessage("thaw.plugin.index.addFilesWithInserting"));
- Vector files = fileChooser.askManyFiles();
+ final Vector files = fileChooser.askManyFiles();
if(files == null)
return;
- String category = FileCategory.promptForACategory();
+ final String category =
FileCategory.promptForACategory();
- addFiles(getDb(), getQueueManager(),
(Index)getTarget(), files, category, true);
+ IndexManagementHelper.addFiles(getDb(),
getQueueManager(), (Index)getTarget(), files, category, true);
}
}
public static class FileAdder extends BasicIndexAction {
- public FileAdder(Hsqldb db, FCPQueueManager queueManager,
AbstractButton actionSource) {
+ public FileAdder(final Hsqldb db, final FCPQueueManager
queueManager, final AbstractButton actionSource) {
super(db, queueManager, null, null, actionSource);
}
- public void setTarget(IndexTreeNode node) {
+ public void setTarget(final IndexTreeNode node) {
super.setTarget(node);
- getActionSource().setEnabled(node != null && node
instanceof Index && ((Index)node).isModifiable());
+ getActionSource().setEnabled((node != null) && (node
instanceof Index) && ((Index)node).isModifiable());
}
- public void actionPerformed(ActionEvent e) {
- FileChooser fileChooser = new FileChooser();
+ public void actionPerformed(final ActionEvent e) {
+ final FileChooser fileChooser = new FileChooser();
fileChooser.setDirectoryOnly(false);
fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
fileChooser.setTitle(I18n.getMessage("thaw.plugin.index.addFilesWithoutInserting"));
- Vector files = fileChooser.askManyFiles();
+ final Vector files = fileChooser.askManyFiles();
if(files == null)
return;
- String category = FileCategory.promptForACategory();
+ final String category =
FileCategory.promptForACategory();
- addFiles(getDb(), getQueueManager(),
(Index)getTarget(), files, category, false);
+ IndexManagementHelper.addFiles(getDb(),
getQueueManager(), (Index)getTarget(), files, category, false);
}
}
/**
* @param files See thaw.plugins.index.File
*/
- public static void addFiles(Hsqldb db, FCPQueueManager queueManager,
- Index target, Vector files, String
category, boolean insert) {
- if (target == null || files == null)
+ public static void addFiles(final Hsqldb db, final FCPQueueManager
queueManager,
+ final Index target, final Vector files,
final String category, final boolean insert) {
+ if ((target == null) || (files == null))
return;
- for(Iterator it = files.iterator();
+ for(final Iterator it = files.iterator();
it.hasNext();) {
- java.io.File ioFile = (java.io.File)it.next();
+ final java.io.File ioFile = (java.io.File)it.next();
FCPTransferQuery insertion = null;
@@ -794,7 +785,7 @@
insertion.start(queueManager);
}
- thaw.plugins.index.File file = new
thaw.plugins.index.File(db, ioFile.getPath(),
+ final thaw.plugins.index.File file = new
thaw.plugins.index.File(db, ioFile.getPath(),
category, target,
insertion);
@@ -816,14 +807,14 @@
private JPopupMenu popupMenu = null;
private MainWindow mainWindow;
- public KeyAdder(Hsqldb db, MainWindow win, AbstractButton
actionSource) {
+ public KeyAdder(final Hsqldb db, final MainWindow win, final
AbstractButton actionSource) {
super(db, null, null, null, actionSource);
- this.mainWindow = win;
+ mainWindow = win;
}
- public void setTarget(IndexTreeNode node) {
+ public void setTarget(final IndexTreeNode node) {
super.setTarget(node);
- getActionSource().setEnabled(node != null && node
instanceof Index && ((Index)node).isModifiable());
+ getActionSource().setEnabled((node != null) && (node
instanceof Index) && ((Index)node).isModifiable());
}
public void run() {
@@ -840,7 +831,7 @@
okButton = new
JButton(I18n.getMessage("thaw.common.ok"));
popupMenu = new JPopupMenu();
- JMenuItem item = new
JMenuItem(I18n.getMessage("thaw.common.paste"));
+ final JMenuItem item = new
JMenuItem(I18n.getMessage("thaw.common.paste"));
popupMenu.add(item);
textArea.addMouseListener(this);
new thaw.core.GUIHelper.PasteHelper(item, textArea);
@@ -863,30 +854,30 @@
frame.setVisible(true);
}
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(final ActionEvent e) {
if (e.getSource() == getActionSource()) {
- Thread newThread = new Thread(this);
+ final Thread newThread = new Thread(this);
newThread.start();
}
if (e.getSource() == okButton) {
- Vector keyVec = new Vector();
+ final Vector keyVec = new Vector();
frame.setVisible(false);
- String category =
FileCategory.promptForACategory();
+ final String category =
FileCategory.promptForACategory();
- String[] keys = textArea.getText().split("\n");
+ final String[] keys =
textArea.getText().split("\n");
for (int i = 0 ; i < keys.length ; i++) {
- String key =
FreenetURIHelper.cleanURI(keys[i]);
+ final String key =
FreenetURIHelper.cleanURI(keys[i]);
if (key != null) {
keyVec.add(key);
}
}
- addKeys(getDb(), (Index)getTarget(), keyVec,
category);
+ IndexManagementHelper.addKeys(getDb(),
(Index)getTarget(), keyVec, category);
}
if (e.getSource() == cancelButton) {
@@ -894,19 +885,19 @@
}
}
- public void mouseClicked(MouseEvent e) { }
- public void mouseEntered(MouseEvent e) { }
- public void mouseExited(MouseEvent e) { }
+ public void mouseClicked(final MouseEvent e) { }
+ public void mouseEntered(final MouseEvent e) { }
+ public void mouseExited(final MouseEvent e) { }
- public void mousePressed(MouseEvent e) {
- this.showPopupMenu(e);
+ public void mousePressed(final MouseEvent e) {
+ showPopupMenu(e);
}
- public void mouseReleased(MouseEvent e) {
- this.showPopupMenu(e);
+ public void mouseReleased(final MouseEvent e) {
+ showPopupMenu(e);
}
- protected void showPopupMenu(MouseEvent e) {
+ protected void showPopupMenu(final MouseEvent e) {
if(e.isPopupTrigger()) {
popupMenu.show(e.getComponent(), e.getX(),
e.getY());
}
@@ -917,16 +908,16 @@
/**
* @param keys => String
*/
- public static void addKeys(Hsqldb db, Index target, Vector keys, String
category) {
- if (target == null || keys == null)
+ public static void addKeys(final Hsqldb db, final Index target, final
Vector keys, final String category) {
+ if ((target == null) || (keys == null))
return;
- for(Iterator it = keys.iterator();
+ for(final Iterator it = keys.iterator();
it.hasNext();) {
- String key = (String)it.next();
+ final String key = (String)it.next();
- thaw.plugins.index.File file = new
thaw.plugins.index.File(db, key, target);
+ final thaw.plugins.index.File file = new
thaw.plugins.index.File(db, key, target);
target.addFile(file);
}
}
@@ -934,31 +925,26 @@
public static class LinkAdder extends BasicIndexAction implements
Runnable {
- private JButton cancelButton = null;
- private JButton okButton = null;
- private JTextArea textArea = null;
- private JFrame frame = null;
-
- public LinkAdder(Hsqldb db, AbstractButton actionSource) {
+ public LinkAdder(final Hsqldb db, final AbstractButton
actionSource) {
super(db, null, null, null, actionSource);
}
- public void setTarget(IndexTreeNode node) {
+ public void setTarget(final IndexTreeNode node) {
super.setTarget(node);
- getActionSource().setEnabled(node != null && node
instanceof Index && ((Index)node).isModifiable());
+ getActionSource().setEnabled((node != null) && (node
instanceof Index) && ((Index)node).isModifiable());
}
public void run() {
- IndexSelecter indexSelecter = new IndexSelecter();
- String indexKey =
indexSelecter.askForAnIndexURI(getDb());
+ final IndexSelecter indexSelecter = new IndexSelecter();
+ final String indexKey =
indexSelecter.askForAnIndexURI(getDb());
if (indexKey != null) {
- addLink(getDb(), (Index)getTarget(), indexKey);
+ IndexManagementHelper.addLink(getDb(),
(Index)getTarget(), indexKey);
}
}
- public void actionPerformed(ActionEvent e) {
- Thread newThread = new Thread(this);
+ public void actionPerformed(final ActionEvent e) {
+ final Thread newThread = new Thread(this);
newThread.start();
}
}
@@ -966,11 +952,11 @@
/**
* @param keys => String
*/
- public static void addLink(Hsqldb db, Index target, String linkKey) {
- if (target == null || linkKey == null)
+ public static void addLink(final Hsqldb db, final Index target, final
String linkKey) {
+ if ((target == null) || (linkKey == null))
return;
- Link newLink = new Link(db, linkKey, target);
+ final Link newLink = new Link(db, linkKey, target);
target.addLink(newLink);
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexSelecter.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexSelecter.java 2006-12-06
18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexSelecter.java 2006-12-06
18:21:00 UTC (rev 11273)
@@ -1,19 +1,19 @@
package thaw.plugins.index;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.GridLayout;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
import javax.swing.JTextField;
-import javax.swing.JButton;
-import javax.swing.JScrollPane;
-
-import thaw.plugins.Hsqldb;
import thaw.core.I18n;
import thaw.core.Logger;
+import thaw.plugins.Hsqldb;
/**
* Class helping to display a dialog allowing the user to choose an index.
(For example, it's used when you want
@@ -61,7 +61,7 @@
/**
* Returned null if canceled. Is blocking !
*/
- public String askForAnIndexURI(Hsqldb db) {
+ public String askForAnIndexURI(final Hsqldb db) {
frame = new
JFrame(I18n.getMessage("thaw.plugin.index.selectIndex"));
frame.setVisible(false);
@@ -106,56 +106,56 @@
okButton.addActionListener(this);
indexTree.addObserver(this);
- this.frame.setVisible(true);
+ frame.setVisible(true);
- for (this.closeWin = false ; !this.closeWin ; ) {
+ for (closeWin = false ; !closeWin ; ) {
try {
Thread.sleep(500);
- } catch(java.lang.InterruptedException e) {
+ } catch(final java.lang.InterruptedException e) {
/* \_o< \_o< \_o< */
}
}
- this.frame.setVisible(false);
+ frame.setVisible(false);
- this.frame = null;
+ frame = null;
upPanel = null;
indexTree = null;
- this.fieldPanel = null;
- this.keyField = null;
+ fieldPanel = null;
+ keyField = null;
- this.downPanel = null;
- this.cancelButton = null;
- this.okButton = null;
+ downPanel = null;
+ cancelButton = null;
+ okButton = null;
- return this.selectedIndexKey;
+ return selectedIndexKey;
}
- public void update(java.util.Observable o, Object param) {
+ public void update(final java.util.Observable o, final Object param) {
if (param instanceof Index) {
- Index index = (Index)param;
+ final Index index = (Index)param;
selectedIndexKey = index.getPublicKey();
- Logger.info(this, "Selected index key:
"+this.selectedIndexKey);
- keyField.setText(this.selectedIndexKey);
+ Logger.info(this, "Selected index key:
"+selectedIndexKey);
+ keyField.setText(selectedIndexKey);
}
}
- public void actionPerformed(java.awt.event.ActionEvent e) {
- if (e.getSource() == this.okButton) {
- if (this.keyField.getText() == null || "".equals(
this.keyField.getText() ))
- this.selectedIndexKey = null;
+ public void actionPerformed(final java.awt.event.ActionEvent e) {
+ if (e.getSource() == okButton) {
+ if ((keyField.getText() == null) || "".equals(
keyField.getText() ))
+ selectedIndexKey = null;
else
- this.selectedIndexKey = this.keyField.getText();
- this.closeWin = true;
+ selectedIndexKey = keyField.getText();
+ closeWin = true;
}
- if (e.getSource() == this.cancelButton) {
- this.selectedIndexKey = null;
- this.closeWin = true;
+ if (e.getSource() == cancelButton) {
+ selectedIndexKey = null;
+ closeWin = true;
}
indexTree.deleteObserver(this);
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2006-12-06
18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2006-12-06
18:21:00 UTC (rev 11273)
@@ -1,57 +1,38 @@
package thaw.plugins.index;
-import javax.swing.JPanel;
import java.awt.BorderLayout;
-import java.awt.GridLayout;
-import javax.swing.JTree;
-import javax.swing.JMenu;
-import javax.swing.tree.TreeSelectionModel;
-import javax.swing.tree.MutableTreeNode;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.TreePath;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.DefaultTreeCellRenderer;
-
+import java.awt.Color;
import java.awt.Font;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.Iterator;
+import java.util.Vector;
-import javax.swing.JPopupMenu;
+import javax.swing.JMenu;
import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreePath;
+import javax.swing.tree.TreeSelectionModel;
-import java.awt.event.MouseListener;
-import java.awt.event.MouseEvent;
-
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-
-import java.awt.Toolkit;
-import java.awt.datatransfer.Clipboard;
-import java.awt.datatransfer.StringSelection;
-
-import java.awt.Color;
-
-import javax.swing.JFrame;
-
-import javax.swing.JToolBar;
-import javax.swing.JButton;
-
-import javax.swing.JTextField;
-import javax.swing.JLabel;
-
-import java.util.Vector;
-import java.util.Iterator;
-
-import java.sql.*;
-
-
+import thaw.core.I18n;
+import thaw.core.IconBox;
+import thaw.core.Logger;
+import thaw.core.MainWindow;
+import thaw.fcp.FCPQueueManager;
+import thaw.gui.JDragTree;
import thaw.plugins.Hsqldb;
-import thaw.core.*;
-import thaw.fcp.*;
-import thaw.gui.JDragTree;
-
/**
* Manages the index tree and its menu (right-click).
*/
@@ -110,12 +91,12 @@
/**
* @param queueManager Not used if selectionOnly is set to true
*/
- public IndexTree(String rootName,
+ public IndexTree(final String rootName,
boolean selectionOnly,
- FCPQueueManager queueManager,
- UnknownIndexList uIndexList,
- MainWindow mainWindow,
- Hsqldb db) {
+ final FCPQueueManager queueManager,
+ final UnknownIndexList uIndexList,
+ final MainWindow mainWindow,
+ final Hsqldb db) {
this.uIndexList = uIndexList;
this.queueManager = queueManager;
@@ -141,7 +122,7 @@
//tree.addMouseListener(this);
}
- IndexTreeRenderer treeRenderer = new IndexTreeRenderer();
+ final IndexTreeRenderer treeRenderer = new IndexTreeRenderer();
treeRenderer.setLeafIcon(IconBox.minIndex);
tree.setCellRenderer(treeRenderer);
@@ -265,15 +246,15 @@
public javax.swing.JComponent getPanel() {
- return this.panel;
+ return panel;
}
- public void
addTreeSelectionListener(javax.swing.event.TreeSelectionListener tsl) {
+ public void addTreeSelectionListener(final
javax.swing.event.TreeSelectionListener tsl) {
tree.addTreeSelectionListener(tsl);
}
- public void valueChanged(javax.swing.event.TreeSelectionEvent e) {
- TreePath path = e.getPath();
+ public void valueChanged(final javax.swing.event.TreeSelectionEvent e) {
+ final TreePath path = e.getPath();
if(path == null)
return;
@@ -285,16 +266,16 @@
}
- public void updateMenuState(IndexTreeNode node) {
+ public void updateMenuState(final IndexTreeNode node) {
IndexManagementHelper.IndexAction action;
- for(Iterator it = indexCategoryActions.iterator();
+ for(final Iterator it = indexCategoryActions.iterator();
it.hasNext();) {
action = (IndexManagementHelper.IndexAction)it.next();
action.setTarget(node);
}
- for(Iterator it = indexAndFileActions.iterator();
+ for(final Iterator it = indexAndFileActions.iterator();
it.hasNext();) {
action = (IndexManagementHelper.IndexAction)it.next();
action.setTarget(node);
@@ -307,27 +288,27 @@
}
public IndexCategory getRoot() {
- return this.root;
+ return root;
}
- public void mouseClicked(MouseEvent e) {
- this.notifySelection(e);
+ public void mouseClicked(final MouseEvent e) {
+ notifySelection(e);
}
- public void mouseEntered(MouseEvent e) { }
- public void mouseExited(MouseEvent e) { }
+ public void mouseEntered(final MouseEvent e) { }
+ public void mouseExited(final MouseEvent e) { }
- public void mousePressed(MouseEvent e) {
- if (!this.selectionOnly)
- this.showPopupMenu(e);
+ public void mousePressed(final MouseEvent e) {
+ if (!selectionOnly)
+ showPopupMenu(e);
}
- public void mouseReleased(MouseEvent e) {
- if (!this.selectionOnly)
- this.showPopupMenu(e);
+ public void mouseReleased(final MouseEvent e) {
+ if (!selectionOnly)
+ showPopupMenu(e);
}
- protected void showPopupMenu(MouseEvent e) {
+ protected void showPopupMenu(final MouseEvent e) {
if(e.isPopupTrigger()) {
if(selectedNode == null)
return;
@@ -344,24 +325,24 @@
}
}
- public void notifySelection(MouseEvent e) {
- TreePath path = this.tree.getPathForLocation(e.getX(),
e.getY());
+ public void notifySelection(final MouseEvent e) {
+ final TreePath path = tree.getPathForLocation(e.getX(),
e.getY());
if(path == null)
return;
selectedNode =
(IndexTreeNode)((DefaultMutableTreeNode)path.getLastPathComponent()).getUserObject();
- if (uIndexList != null && selectedNode instanceof Index) {
+ if ((uIndexList != null) && (selectedNode instanceof Index)) {
uIndexList.addLinks(((Index)selectedNode));
}
setChanged();
- notifyObservers(this.selectedNode);
+ notifyObservers(selectedNode);
}
public IndexTreeNode getSelectedNode() {
- Object obj = this.tree.getLastSelectedPathComponent();
+ final Object obj = tree.getLastSelectedPathComponent();
if (obj == null)
return null;
@@ -378,7 +359,7 @@
}
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(final ActionEvent e) {
if(selectedNode == null)
selectedNode = root;
}
@@ -388,10 +369,10 @@
}
- public void update(java.util.Observable o, Object param) {
+ public void update(final java.util.Observable o, final Object param) {
if( (o instanceof Index)
&& (param == null) ) {
- Index index = (Index)o;
+ final Index index = (Index)o;
if (treeModel != null) {
treeModel.nodeChanged(index.getTreeNode());
@@ -411,26 +392,26 @@
super();
}
- public java.awt.Component getTreeCellRendererComponent(JTree
tree,
- Object
value,
- boolean
selected,
- boolean
expanded,
- boolean
leaf,
- int row,
- boolean
hasFocus) {
+ public java.awt.Component getTreeCellRendererComponent(final
JTree tree,
+ final
Object value,
+ final
boolean selected,
+ final
boolean expanded,
+ final
boolean leaf,
+ final
int row,
+ final
boolean hasFocus) {
setBackgroundNonSelectionColor(Color.WHITE);
- setBackgroundSelectionColor(SELECTION_COLOR);
+ setBackgroundSelectionColor(IndexTree.SELECTION_COLOR);
setFont(new Font("Dialog", Font.PLAIN, 12));
if(value instanceof DefaultMutableTreeNode) {
- Object o =
((DefaultMutableTreeNode)value).getUserObject();
+ final Object o =
((DefaultMutableTreeNode)value).getUserObject();
if(o instanceof Index) {
- Index index = (Index)o;
+ final Index index = (Index)o;
if (index.isUpdating()) {
-
setBackgroundNonSelectionColor(LOADING_COLOR);
-
setBackgroundSelectionColor(LOADING_SELECTION_COLOR);
+
setBackgroundNonSelectionColor(IndexTree.LOADING_COLOR);
+
setBackgroundSelectionColor(IndexTree.LOADING_SELECTION_COLOR);
}
}
@@ -451,11 +432,11 @@
}
- public boolean addToRoot(IndexTreeNode node) {
+ public boolean addToRoot(final IndexTreeNode node) {
return addToIndexCategory(root, node);
}
- public boolean addToIndexCategory(IndexCategory target, IndexTreeNode
node) {
+ public boolean addToIndexCategory(final IndexCategory target, final
IndexTreeNode node) {
if ((node instanceof Index) &&
alreadyExistingIndex(node.getPublicKey())) {
Logger.notice(this, "Index already added");
return false;
@@ -469,10 +450,10 @@
}
- public boolean alreadyExistingIndex(String key) {
+ public boolean alreadyExistingIndex(final String key) {
int maxLength = 0;
- if (key == null || key.length() <= 10)
+ if ((key == null) || (key.length() <= 10))
return false;
if (key.length() <= 60)
@@ -480,10 +461,10 @@
else
maxLength = 60;
- String realKey = key.substring(0, maxLength).toLowerCase();
+ final String realKey = key.substring(0,
maxLength).toLowerCase();
try {
- Connection c = this.db.getConnection();
+ final Connection c = db.getConnection();
PreparedStatement st;
String query;
@@ -498,15 +479,14 @@
st.setString(1, realKey+"%");
if (st.execute()) {
- ResultSet results = st.getResultSet();
+ final ResultSet results = st.getResultSet();
- if (results.next()) {
+ if (results.next())
return true;
- }
}
- } catch(java.sql.SQLException e) {
+ } catch(final java.sql.SQLException e) {
Logger.warning(this, "Exception while trying to check
if '"+key+"' is already know: '"+e.toString()+"'");
}
@@ -518,12 +498,12 @@
/**
* @param node can be null
*/
- public void reloadModel(DefaultMutableTreeNode node) {
- this.treeModel.reload(node);
+ public void reloadModel(final DefaultMutableTreeNode node) {
+ treeModel.reload(node);
}
public void reloadModel() {
- this.treeModel.reload();
+ treeModel.reload();
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Link.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Link.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Link.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,60 +1,64 @@
package thaw.plugins.index;
-import java.sql.*;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
-import org.w3c.dom.Element;
import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
import thaw.core.Logger;
import thaw.plugins.Hsqldb;
public class Link extends java.util.Observable {
private int id;
- private String indexName = null;
- private String key = null;
+ private String indexName;
+ private String key;
private Index parent = null;
private int parentId;
- private Hsqldb db;
+ private final Hsqldb db;
- public Link(Hsqldb hsqldb, String indexName, String key, Index parent) {
+ public Link(final Hsqldb hsqldb, final String indexName, final String
key, final Index parent) {
this.indexName = indexName;
if (key != null)
this.key = key.trim();
else
this.key = null;
this.parent = parent;
- this.db = hsqldb;
+ db = hsqldb;
}
- public Link(Hsqldb hsqldb, String key, Index parent) {
+ public Link(final Hsqldb hsqldb, final String key, final Index parent) {
this(hsqldb, Index.getNameFromKey(key), key, parent);
}
- public Link(Hsqldb hsqldb, ResultSet resultSet, Index parent) throws
SQLException {
- this.db = hsqldb;
- this.id = resultSet.getInt("id");
- this.key = resultSet.getString("publicKey").trim();
+ public Link(final Hsqldb hsqldb, final ResultSet resultSet, final Index
parent) throws SQLException {
+ db = hsqldb;
+ id = resultSet.getInt("id");
+ key = resultSet.getString("publicKey").trim();
- this.indexName = Index.getNameFromKey(this.key);
+ indexName = Index.getNameFromKey(key);
this.parent = parent;
if (parent != null)
- this.parentId = parent.getId();
+ parentId = parent.getId();
else
- this.parentId = resultSet.getInt("indexParent");
+ parentId = resultSet.getInt("indexParent");
}
- public Link(Hsqldb hsqldb, Element linkElement, Index parent) {
- this.db = hsqldb;
- this.key = linkElement.getAttribute("key");
+ public Link(final Hsqldb hsqldb, final Element linkElement, final Index
parent) {
+ db = hsqldb;
+ key = linkElement.getAttribute("key");
- if (this.key != null)
- this.key = this.key.trim();
+ if (key != null)
+ key = key.trim();
- this.indexName = Index.getNameFromKey(this.key);
+ indexName = Index.getNameFromKey(key);
this.parent = parent;
@@ -68,29 +72,29 @@
return key;
}
- public boolean compare(Link l) {
- if (l == null
- || getPublicKey() == null
- || l.getPublicKey() == null
- || getPublicKey().length() < 40
- || l.getPublicKey().length() < 40)
+ public boolean compare(final Link l) {
+ if ((l == null)
+ || (getPublicKey() == null)
+ || (l.getPublicKey() == null)
+ || (getPublicKey().length() < 40)
+ || (l.getPublicKey().length() < 40))
return false;
return (l.getPublicKey().substring(4,
40).equals(getPublicKey().substring(4, 40)));
}
- public boolean compare(Index l) {
- if (l == null
- || getPublicKey() == null
- || l.getPublicKey() == null
- || getPublicKey().length() < 40
- || l.getPublicKey().length() < 40)
+ public boolean compare(final Index l) {
+ if ((l == null)
+ || (getPublicKey() == null)
+ || (l.getPublicKey() == null)
+ || (getPublicKey().length() < 40)
+ || (l.getPublicKey().length() < 40))
return false;
return (l.getPublicKey().substring(4,
40).equals(getPublicKey().substring(4, 40)));
}
- public void setParent(Index index) {
+ public void setParent(final Index index) {
parent = index;
}
@@ -113,13 +117,13 @@
return getIndexName();
}
- public void setIndexKey(String key) {
+ public void setIndexKey(final String key) {
this.key = key;
if (this.key != null)
this.key = this.key.trim();
- this.setChanged();
+ setChanged();
this.notifyObservers();
}
@@ -127,43 +131,40 @@
try {
PreparedStatement st;
- db.lockWriting();
+ synchronized (db.dbLock) {
+ st =
db.getConnection().prepareStatement("SELECT id FROM links ORDER BY id DESC
LIMIT 1");
- st = this.db.getConnection().prepareStatement("SELECT
id FROM links ORDER BY id DESC LIMIT 1");
+ try {
+ if(st.execute()) {
+ final ResultSet result =
st.getResultSet();
+ result.next();
+ id = result.getInt("id")+1;
+ } else
+ id = 1;
+ } catch(final SQLException e) {
+ id = 1;
+ }
- try {
- if(st.execute()) {
- ResultSet result = st.getResultSet();
- result.next();
- this.id = result.getInt("id")+1;
- } else
- this.id = 1;
- } catch(SQLException e) {
- this.id = 1;
- }
+ st =
db.getConnection().prepareStatement("INSERT INTO links (id, publicKey, "+
+ "mark, comment, indexParent,
indexTarget) "+
+ "VALUES (?, ?, ?, ?, ?, ?)");
+ st.setInt(1, id);
- st = this.db.getConnection().prepareStatement("INSERT
INTO links (id, publicKey, "+
- "mark,
comment, indexParent, indexTarget) "+
- "VALUES (?, ?,
?, ?, ?, ?)");
- st.setInt(1, this.id);
+ if(key != null)
+ st.setString(2, key);
+ else
+ st.setString(2, indexName);
- if(this.key != null)
- st.setString(2, this.key);
- else
- st.setString(2, this.indexName);
+ st.setInt(3, 0);
+ st.setString(4, "No comment");
+ st.setInt(5, parent.getId());
+ st.setNull(6, Types.INTEGER);
- st.setInt(3, 0);
- st.setString(4, "No comment");
- st.setInt(5, this.parent.getId());
- st.setNull(6, Types.INTEGER);
-
- st.execute();
- } catch(SQLException e) {
- Logger.error(this, "Unable to insert link to
'"+this.indexName+"' because: "+e.toString());
+ st.execute();
+ }
+ } catch(final SQLException e) {
+ Logger.error(this, "Unable to insert link to
'"+indexName+"' because: "+e.toString());
}
-
- db.unlockWriting();
-
}
public boolean isIndexAlreadyKnown() {
@@ -180,13 +181,12 @@
st.setString(1, "%"+key.substring(3, 40)+"%");
if(st.execute()) {
- ResultSet result = st.getResultSet();
- if (result != null && result.next()) {
+ final ResultSet result = st.getResultSet();
+ if ((result != null) && result.next())
return true;
- }
}
- } catch(SQLException e) {
+ } catch(final SQLException e) {
Logger.error(this, "Unable to check if link '"+key+"'
point to a know index because: "+e.toString());
}
@@ -194,7 +194,7 @@
}
public boolean isInTheDatabase() {
- if (this.parent == null) {
+ if (parent == null) {
Logger.notice(this, "isInTheDatabase(): No parent !");
return false;
}
@@ -202,21 +202,20 @@
try {
PreparedStatement st;
- st = this.db.getConnection().prepareStatement("SELECT
publicKey from links WHERE publicKey = ? AND indexParent = ?");
+ st = db.getConnection().prepareStatement("SELECT
publicKey from links WHERE publicKey = ? AND indexParent = ?");
- st.setString(1, this.key);
+ st.setString(1, key);
- st.setInt(2, this.getParent().getId());
+ st.setInt(2, getParent().getId());
if(st.execute()) {
- ResultSet result = st.getResultSet();
- if (result != null && result.next()) {
+ final ResultSet result = st.getResultSet();
+ if ((result != null) && result.next())
return true;
- }
}
- } catch(SQLException e) {
- Logger.error(this, "Unable to check if link
'"+this.key+"' exists because: "+e.toString());
+ } catch(final SQLException e) {
+ Logger.error(this, "Unable to check if link '"+key+"'
exists because: "+e.toString());
}
return false;
@@ -227,13 +226,13 @@
try {
PreparedStatement st;
- st = this.db.getConnection().prepareStatement("DELETE
FROM links WHERE id = ?");
- st.setInt(1, this.id);
+ st = db.getConnection().prepareStatement("DELETE FROM
links WHERE id = ?");
+ st.setInt(1, id);
st.execute();
- } catch(SQLException e) {
- Logger.error(this, "Unable to remove link to
'"+this.indexName+"' because: "+e.toString());
+ } catch(final SQLException e) {
+ Logger.error(this, "Unable to remove link to
'"+indexName+"' because: "+e.toString());
}
}
@@ -241,28 +240,28 @@
try {
PreparedStatement st;
- st = this.db.getConnection().prepareStatement("UPDATE
links SET publicKey = ?, indexParent = ? WHERE id = ?");
+ st = db.getConnection().prepareStatement("UPDATE links
SET publicKey = ?, indexParent = ? WHERE id = ?");
- if(this.key != null)
- st.setString(1, this.key);
+ if(key != null)
+ st.setString(1, key);
else
- st.setString(1, this.indexName);
+ st.setString(1, indexName);
- st.setInt(2, this.getParent().getId());
+ st.setInt(2, getParent().getId());
- st.setInt(3, this.id);
+ st.setInt(3, id);
st.execute();
- } catch(SQLException e) {
- Logger.error(this, "Unable to update link to
'"+this.indexName+"' because: "+e.toString());
+ } catch(final SQLException e) {
+ Logger.error(this, "Unable to update link to
'"+indexName+"' because: "+e.toString());
}
}
- public Element getXML(Document xmlDoc) {
- Element link = xmlDoc.createElement("index");
+ public Element getXML(final Document xmlDoc) {
+ final Element link = xmlDoc.createElement("index");
- link.setAttribute("key", this.key);
+ link.setAttribute("key", key);
return link;
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/LinkManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/LinkManagementHelper.java
2006-12-06 18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/index/LinkManagementHelper.java
2006-12-06 18:21:00 UTC (rev 11273)
@@ -1,19 +1,16 @@
package thaw.plugins.index;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-import javax.swing.AbstractButton;
-
-import java.util.Vector;
-import java.util.Iterator;
-
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Iterator;
+import java.util.Vector;
-import thaw.core.Logger;
-import thaw.fcp.*;
+import javax.swing.AbstractButton;
+import thaw.fcp.FCPQueueManager;
import thaw.plugins.Hsqldb;
public class LinkManagementHelper {
@@ -34,13 +31,13 @@
/**
* @param queueManager is used to stop transfers if needed
*/
- public LinkRemover(AbstractButton actionSource) {
+ public LinkRemover(final AbstractButton actionSource) {
this.actionSource = actionSource;
if (actionSource != null)
actionSource.addActionListener(this);
}
- public void setTarget(Vector target) {
+ public void setTarget(final Vector target) {
boolean isOk;
isOk = true;
@@ -48,9 +45,9 @@
this.target = target;
if (target != null) {
- for (Iterator it = target.iterator();
+ for (final Iterator it = target.iterator();
it.hasNext();) {
- Link link = (Link)it.next();
+ final Link link = (Link)it.next();
if (!link.isModifiable()) {
isOk = false;
@@ -60,22 +57,22 @@
}
- actionSource.setEnabled(target != null && target.size()
!= 0 && isOk);
+ actionSource.setEnabled((target != null) &&
(target.size() != 0) && isOk);
}
- public void actionPerformed(ActionEvent e) {
- removeLinks(target);
+ public void actionPerformed(final ActionEvent e) {
+ LinkManagementHelper.removeLinks(target);
}
}
- public static void removeLinks(Vector links) {
+ public static void removeLinks(final Vector links) {
if (links == null)
return;
- for (Iterator it = links.iterator();
+ for (final Iterator it = links.iterator();
it.hasNext() ; ) {
- Link link = (Link)it.next();
+ final Link link = (Link)it.next();
link.getParent().removeLink(link);
}
}
@@ -90,10 +87,10 @@
private AbstractButton src;
private Vector t;
- public IndexAdder(AbstractButton actionSource,
- Hsqldb db, FCPQueueManager queueManager,
- UnknownIndexList uil,
- IndexTree tree) {
+ public IndexAdder(final AbstractButton actionSource,
+ final Hsqldb db, final FCPQueueManager
queueManager,
+ final UnknownIndexList uil,
+ final IndexTree tree) {
src = actionSource;
if (actionSource != null)
actionSource.addActionListener(this);
@@ -103,15 +100,15 @@
this.uil = uil;
}
- public void setTarget(Vector targets) {
+ public void setTarget(final Vector targets) {
t = targets;
- src.setEnabled(targets != null && targets.size() > 0);
+ src.setEnabled((targets != null) && (targets.size() >
0));
}
- public void actionPerformed(ActionEvent e) {
- for (Iterator it = t.iterator();
+ public void actionPerformed(final ActionEvent e) {
+ for (final Iterator it = t.iterator();
it.hasNext(); ) {
- Link link = (Link)it.next();
+ final Link link = (Link)it.next();
IndexManagementHelper.addIndex(db,
queueManager, uil, tree, null,
link.getPublicKey());
}
@@ -123,39 +120,39 @@
private AbstractButton src;
private Vector t;
- public PublicKeyCopier(AbstractButton actionSource) {
+ public PublicKeyCopier(final AbstractButton actionSource) {
src = actionSource;
if (actionSource != null)
actionSource.addActionListener(this);
}
- public void setTarget(Vector targets) {
+ public void setTarget(final Vector targets) {
t = targets;
- src.setEnabled(targets != null && targets.size() > 0);
+ src.setEnabled((targets != null) && (targets.size() >
0));
}
- public void actionPerformed(ActionEvent e) {
- copyPublicKeyFrom(t);
+ public void actionPerformed(final ActionEvent e) {
+ LinkManagementHelper.copyPublicKeyFrom(t);
}
}
- public static void copyPublicKeyFrom(Vector targets) {
+ public static void copyPublicKeyFrom(final Vector targets) {
String keys = "";
if (targets == null)
return;
- Toolkit tk = Toolkit.getDefaultToolkit();
+ final Toolkit tk = Toolkit.getDefaultToolkit();
- for(Iterator it = targets.iterator();
+ for(final Iterator it = targets.iterator();
it.hasNext();) {
- Link link = (Link)it.next();
+ final Link link = (Link)it.next();
keys = keys + link.getPublicKey() + "\n";
}
- StringSelection st = new StringSelection(keys);
- Clipboard cp = tk.getSystemClipboard();
+ final StringSelection st = new StringSelection(keys);
+ final Clipboard cp = tk.getSystemClipboard();
cp.setContents(st, null);
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java 2006-12-06
18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java 2006-12-06
18:21:00 UTC (rev 11273)
@@ -1,36 +1,28 @@
package thaw.plugins.index;
-import javax.swing.JPanel;
-import javax.swing.JTable;
-import javax.swing.JScrollPane;
-
import java.awt.BorderLayout;
-import javax.swing.event.TableModelEvent;
-
-import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.KeyListener;
+import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.Iterator;
+import java.util.Observable;
+import java.util.Vector;
-import javax.swing.JPopupMenu;
-import javax.swing.JMenuItem;
import javax.swing.JLabel;
-
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.event.TableModelEvent;
import javax.swing.tree.TreePath;
-import java.awt.Toolkit;
-import java.awt.datatransfer.Clipboard;
-import java.awt.datatransfer.StringSelection;
-
-import java.util.Vector;
-import java.util.Iterator;
-
-import java.util.Observable;
-import thaw.core.*;
-import thaw.fcp.*;
-
+import thaw.core.I18n;
+import thaw.core.Logger;
+import thaw.fcp.FCPQueueManager;
import thaw.plugins.Hsqldb;
@@ -54,23 +46,23 @@
private int[] selectedRows;
- public LinkTable (Hsqldb db, FCPQueueManager queueManager,
UnknownIndexList uil, IndexTree tree, Tables tables) {
+ public LinkTable (final Hsqldb db, final FCPQueueManager queueManager,
final UnknownIndexList uil, final IndexTree tree, final Tables tables) {
this.queueManager = queueManager;
this.db = db;
- this.linkListModel = new LinkListModel();
- this.table = new JTable(this.linkListModel);
- this.table.setShowGrid(true);
+ linkListModel = new LinkListModel();
+ table = new JTable(linkListModel);
+ table.setShowGrid(true);
- this.panel = new JPanel();
- this.panel.setLayout(new BorderLayout());
+ panel = new JPanel();
+ panel.setLayout(new BorderLayout());
- this.panel.add(new
JLabel(I18n.getMessage("thaw.plugin.index.linkList")), BorderLayout.NORTH);
- this.panel.add(new JScrollPane(this.table));
+ panel.add(new
JLabel(I18n.getMessage("thaw.plugin.index.linkList")), BorderLayout.NORTH);
+ panel.add(new JScrollPane(table));
- this.table.addMouseListener(this);
+ table.addMouseListener(this);
- this.indexTree = tree;
+ indexTree = tree;
this.tables = tables;
rightClickMenu = new JPopupMenu();
@@ -98,34 +90,34 @@
}
public JPanel getPanel() {
- return this.panel;
+ return panel;
}
- protected void updateRightClickMenu(Vector selectedLinks) {
+ protected void updateRightClickMenu(final Vector selectedLinks) {
LinkManagementHelper.LinkAction action;
- for (Iterator it = rightClickActions.iterator();
+ for (final Iterator it = rightClickActions.iterator();
it.hasNext(); ) {
action = (LinkManagementHelper.LinkAction)it.next();
action.setTarget(selectedLinks);
}
- gotoItem.setEnabled(linkList != null && !(linkList instanceof
Index));
+ gotoItem.setEnabled((linkList != null) && !(linkList instanceof
Index));
}
- protected Vector getSelectedLinks(int[] selectedRows) {
- Vector srcList = linkList.getLinkList();
- Vector links = new Vector();
+ protected Vector getSelectedLinks(final int[] selectedRows) {
+ final Vector srcList = linkList.getLinkList();
+ final Vector links = new Vector();
for(int i = 0 ; i < selectedRows.length ; i++) {
- Link link = (Link)srcList.get(selectedRows[i]);
+ final Link link = (Link)srcList.get(selectedRows[i]);
links.add(link);
}
return links;
}
- public void setLinkList(LinkList linkList) {
+ public void setLinkList(final LinkList linkList) {
if(this.linkList != null) {
this.linkList.unloadLinks();
}
@@ -136,38 +128,38 @@
this.linkList = linkList;
- this.linkListModel.reloadLinkList(linkList);
+ linkListModel.reloadLinkList(linkList);
}
- public void mouseClicked(MouseEvent e) {
+ public void mouseClicked(final MouseEvent e) {
if (linkList instanceof Index)
((Index)linkList).setChanged(false);
- if(e.getButton() == MouseEvent.BUTTON3
- && this.linkList != null) {
+ if((e.getButton() == MouseEvent.BUTTON3)
+ && (linkList != null)) {
selectedRows = table.getSelectedRows();
updateRightClickMenu(getSelectedLinks(selectedRows));
rightClickMenu.show(e.getComponent(), e.getX(),
e.getY());
}
}
- public void mouseEntered(MouseEvent e) { }
+ public void mouseEntered(final MouseEvent e) { }
- public void mouseExited(MouseEvent e) { }
+ public void mouseExited(final MouseEvent e) { }
- public void mousePressed(MouseEvent e) { }
+ public void mousePressed(final MouseEvent e) { }
- public void mouseReleased(MouseEvent e) { }
+ public void mouseReleased(final MouseEvent e) { }
- public void keyPressed(KeyEvent e) { }
+ public void keyPressed(final KeyEvent e) { }
- public void keyReleased(KeyEvent e) { }
+ public void keyReleased(final KeyEvent e) { }
- public void keyTyped(KeyEvent e) { }
+ public void keyTyped(final KeyEvent e) { }
- public void actionPerformed(ActionEvent e) {
- Vector links;
- String keyList = "";
+ public void actionPerformed(final ActionEvent e) {
+ final Vector links;
+ final String keyList = "";
if (linkList == null) // don't forget that linkList == Index
most of the time
return;
@@ -176,7 +168,7 @@
if (selectedRows.length <= 0)
return;
- Link link =
(Link)linkList.getLinkList().get(selectedRows[0]);
+ final Link link =
(Link)linkList.getLinkList().get(selectedRows[0]);
if (link.getParentId() == -1) {
Logger.notice(this, "No parent ? Abnormal !");
@@ -216,36 +208,36 @@
public LinkListModel() {
super();
- this.columnNames = new Vector();
+ columnNames = new Vector();
-
this.columnNames.add(I18n.getMessage("thaw.plugin.index.index"));
-
this.columnNames.add(I18n.getMessage("thaw.common.key"));
+
columnNames.add(I18n.getMessage("thaw.plugin.index.index"));
+ columnNames.add(I18n.getMessage("thaw.common.key"));
}
- public void reloadLinkList(LinkList newLinkList) {
- if (this.linkList != null && (this.linkList instanceof
Observable)) {
-
((Observable)this.linkList).deleteObserver(this);
+ public void reloadLinkList(final LinkList newLinkList) {
+ if ((linkList != null) && (linkList instanceof
Observable)) {
+ ((Observable)linkList).deleteObserver(this);
}
- if (newLinkList != null && (newLinkList instanceof
Observable)) {
+ if ((newLinkList != null) && (newLinkList instanceof
Observable)) {
((Observable)newLinkList).addObserver(this);
}
- this.linkList = newLinkList;
+ linkList = newLinkList;
- if(this.links != null) {
- for(Iterator it = this.links.iterator();
+ if(links != null) {
+ for(final Iterator it = links.iterator();
it.hasNext(); ) {
- thaw.plugins.index.Link link =
(thaw.plugins.index.Link)it.next();
+ final thaw.plugins.index.Link link =
(thaw.plugins.index.Link)it.next();
link.deleteObserver(this);
}
}
- this.links = null;
+ links = null;
- if(this.linkList != null) {
- this.links = this.linkList.getLinkList();
+ if(linkList != null) {
+ links = linkList.getLinkList();
}
this.refresh();
@@ -253,22 +245,22 @@
}
public int getRowCount() {
- if (this.links == null)
+ if (links == null)
return 0;
- return this.links.size();
+ return links.size();
}
public int getColumnCount() {
- return this.columnNames.size();
+ return columnNames.size();
}
- public String getColumnName(int column) {
- return (String)this.columnNames.get(column);
+ public String getColumnName(final int column) {
+ return (String)columnNames.get(column);
}
- public Object getValueAt(int row, int column) {
- thaw.plugins.index.Link link =
(thaw.plugins.index.Link)this.links.get(row);
+ public Object getValueAt(final int row, final int column) {
+ final thaw.plugins.index.Link link =
(thaw.plugins.index.Link)links.get(row);
switch(column) {
case(0): return link.getIndexName();
@@ -278,24 +270,24 @@
}
public void refresh() {
- if(this.linkList != null) {
- this.links = this.linkList.getLinkList();
+ if(linkList != null) {
+ links = linkList.getLinkList();
}
- TableModelEvent event = new TableModelEvent(this);
+ final TableModelEvent event = new TableModelEvent(this);
this.refresh(event);
}
- public void refresh(int row) {
- TableModelEvent event = new TableModelEvent(this, row);
+ public void refresh(final int row) {
+ final TableModelEvent event = new TableModelEvent(this,
row);
this.refresh(event);
}
- public void refresh(TableModelEvent e) {
- this.fireTableChanged(e);
+ public void refresh(final TableModelEvent e) {
+ fireTableChanged(e);
}
- public void update(java.util.Observable o, Object param) {
+ public void update(final java.util.Observable o, final Object
param) {
if(param instanceof thaw.plugins.index.Link) {
//link.deleteObserver(this);
Modified: trunk/apps/Thaw/src/thaw/plugins/index/SearchBar.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/SearchBar.java 2006-12-06
18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/index/SearchBar.java 2006-12-06
18:21:00 UTC (rev 11273)
@@ -1,19 +1,16 @@
package thaw.plugins.index;
-import javax.swing.JTextField;
-import javax.swing.JButton;
-import javax.swing.JPanel;
-import javax.swing.JLabel;
-
import java.awt.BorderLayout;
-
-import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
-import thaw.core.I18n;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import thaw.core.I18n;
import thaw.fcp.FCPQueueManager;
-
import thaw.plugins.Hsqldb;
public class SearchBar implements ActionListener {
@@ -29,41 +26,41 @@
private FCPQueueManager queueManager;
- public SearchBar(Hsqldb db, IndexTree indexTree, FCPQueueManager
queueManager, Tables tables) {
+ public SearchBar(final Hsqldb db, final IndexTree indexTree, final
FCPQueueManager queueManager, final Tables tables) {
this.db = db;
- this.tree = indexTree;
+ tree = indexTree;
this.tables = tables;
this.queueManager = queueManager;
- this.panel = new JPanel();
- this.panel.setLayout(new BorderLayout(0, 0));
+ panel = new JPanel();
+ panel.setLayout(new BorderLayout(0, 0));
- this.userText = new JTextField("");
- this.validationButton = new JButton("
"+I18n.getMessage("thaw.common.search")+" ");
+ userText = new JTextField("");
+ validationButton = new JButton("
"+I18n.getMessage("thaw.common.search")+" ");
- JLabel label = new
JLabel(I18n.getMessage("thaw.plugin.index.search.label"));
+ final JLabel label = new
JLabel(I18n.getMessage("thaw.plugin.index.search.label"));
panel.add(label, BorderLayout.NORTH);
panel.add(userText, BorderLayout.CENTER);
panel.add(validationButton, BorderLayout.EAST);
- this.userText.addActionListener(this);
- this.validationButton.addActionListener(this);
+ userText.addActionListener(this);
+ validationButton.addActionListener(this);
}
public JPanel getPanel() {
- return this.panel;
+ return panel;
}
- public void actionPerformed(ActionEvent e) {
- if (this.userText.getText() == null)
+ public void actionPerformed(final ActionEvent e) {
+ if (userText.getText() == null)
return;
- this.userText.setSelectionStart(0);
- this.userText.setSelectionEnd(this.userText.getText().length());
+ userText.setSelectionStart(0);
+ userText.setSelectionEnd(userText.getText().length());
- SearchResult sr = new SearchResult(this.db,
this.userText.getText(), this.tree.getSelectedNode(), this.queueManager);
- this.tables.setList(sr);
+ final SearchResult sr = new SearchResult(db,
userText.getText(), tree.getSelectedNode(), queueManager);
+ tables.setList(sr);
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java 2006-12-06
18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/index/SearchResult.java 2006-12-06
18:21:00 UTC (rev 11273)
@@ -1,18 +1,18 @@
package thaw.plugins.index;
-import java.util.Vector;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
import java.util.Iterator;
-
import java.util.Observable;
import java.util.Observer;
+import java.util.Vector;
-import java.sql.*;
-
+import thaw.core.Logger;
+import thaw.fcp.FCPQueueManager;
import thaw.plugins.Hsqldb;
-import thaw.fcp.FCPQueueManager;
-import thaw.core.Logger;
-
public class SearchResult extends Observable implements Observer,
FileAndLinkList {
private Vector fileList = null;
@@ -24,18 +24,18 @@
private Hsqldb db;
private FCPQueueManager queueManager;
- public SearchResult(Hsqldb hsqldb, String search, IndexTreeNode node,
FCPQueueManager queueManager) {
+ public SearchResult(final Hsqldb hsqldb, final String search, final
IndexTreeNode node, final FCPQueueManager queueManager) {
this.queueManager = queueManager;
this.search = search.split(" ");
if (node == null)
- this.indexIds = null;
+ indexIds = null;
else
- this.indexIds = node.getIndexIds();
- this.db = hsqldb;
+ indexIds = node.getIndexIds();
+ db = hsqldb;
}
- protected PreparedStatement makeSearchQuery(String fields, String
searchField, String table, Vector indexIds, String[] searchPatterns,
- String columnToSort, boolean asc)
throws SQLException {
+ protected PreparedStatement makeSearchQuery(final String fields, final
String searchField, final String table, final Vector indexIds, final String[]
searchPatterns,
+ final String columnToSort, boolean
asc) throws SQLException {
String query = "";
PreparedStatement st;
@@ -44,7 +44,7 @@
if (indexIds != null) {
query = query +"(FALSE";
- for (Iterator it = indexIds.iterator();
+ for (final Iterator it = indexIds.iterator();
it.hasNext();) {
it.next();
query = query + " OR indexParent = ?";
@@ -68,7 +68,7 @@
query = query + " DESC";
}
- Connection c = this.db.getConnection();
+ final Connection c = db.getConnection();
st = c.prepareStatement(query);
int i;
@@ -76,7 +76,7 @@
i = 1;
if (indexIds != null) {
- for (Iterator it = indexIds.iterator();
+ for (final Iterator it = indexIds.iterator();
it.hasNext(); i++) {
st.setInt(i, ((Integer)it.next()).intValue());
}
@@ -89,100 +89,100 @@
return st;
}
- public void loadFiles(String columnToSort, boolean asc) {
- if (this.fileList != null) {
+ public void loadFiles(final String columnToSort, final boolean asc) {
+ if (fileList != null) {
Logger.notice(this, "Files already loaded, won't reload
them");
return;
}
- this.fileList = new Vector();
+ fileList = new Vector();
try {
- PreparedStatement st = this.makeSearchQuery("id,
filename, publicKey, localPath, mime, size, category, indexParent", "filename",
- "files",
this.indexIds, this.search, columnToSort, asc);
+ final PreparedStatement st = makeSearchQuery("id,
filename, publicKey, localPath, mime, size, category, indexParent", "filename",
+ "files",
indexIds, search, columnToSort, asc);
if (st.execute()) {
- ResultSet results = st.getResultSet();
+ final ResultSet results = st.getResultSet();
while(results.next()) {
- thaw.plugins.index.File file = new
thaw.plugins.index.File(this.db, results, null);
- file.setTransfer(this.queueManager);
+ final thaw.plugins.index.File file =
new thaw.plugins.index.File(db, results, null);
+ file.setTransfer(queueManager);
file.addObserver(this);
- this.fileList.add(file);
+ fileList.add(file);
}
}
- } catch(SQLException e) {
+ } catch(final SQLException e) {
Logger.error(this, "Exception while searching:
"+e.toString());
}
- this.setChanged();
+ setChanged();
this.notifyObservers();
}
- public void loadLinks(String columnToSort, boolean asc) {
- if (this.linkList != null) {
+ public void loadLinks(final String columnToSort, final boolean asc) {
+ if (linkList != null) {
Logger.notice(this, "Links already loaded, won't reload
them");
return;
}
- this.linkList = new Vector();
+ linkList = new Vector();
try {
- PreparedStatement st = this.makeSearchQuery("id,
publicKey, mark, comment, indexTarget, indexParent", "publicKey",
- "links",
this.indexIds, this.search, columnToSort, asc);
+ final PreparedStatement st = makeSearchQuery("id,
publicKey, mark, comment, indexTarget, indexParent", "publicKey",
+ "links",
indexIds, search, columnToSort, asc);
if (st.execute()) {
- ResultSet results = st.getResultSet();
+ final ResultSet results = st.getResultSet();
while(results.next()) {
- Link link = new Link(this.db, results,
null);
- this.linkList.add(link);
+ final Link link = new Link(db, results,
null);
+ linkList.add(link);
}
}
- } catch(SQLException e) {
+ } catch(final SQLException e) {
Logger.error(this, "Exception while searching:
"+e.toString());
}
- this.setChanged();
+ setChanged();
this.notifyObservers();
}
- public void update(Observable o, Object param) {
- this.setChanged();
+ public void update(final Observable o, final Object param) {
+ setChanged();
this.notifyObservers(o);
}
public Vector getFileList() {
- return this.fileList;
+ return fileList;
}
public Vector getLinkList() {
- return this.linkList;
+ return linkList;
}
- public thaw.plugins.index.File getFile(int index) {
- return (thaw.plugins.index.File)this.fileList.get(index);
+ public thaw.plugins.index.File getFile(final int index) {
+ return (thaw.plugins.index.File)fileList.get(index);
}
- public Link getLink(int index) {
- return (Link)this.linkList.get(index);
+ public Link getLink(final int index) {
+ return (Link)linkList.get(index);
}
public void unloadFiles() {
- for (Iterator it = this.fileList.iterator();
+ for (final Iterator it = fileList.iterator();
it.hasNext();) {
- thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
+ final thaw.plugins.index.File file =
(thaw.plugins.index.File)it.next();
file.deleteObserver(this);
}
- this.fileList = null;
+ fileList = null;
}
public void unloadLinks() {
- this.fileList = null;
+ fileList = null;
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/TableCreator.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/TableCreator.java 2006-12-06
18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/index/TableCreator.java 2006-12-06
18:21:00 UTC (rev 11273)
@@ -1,8 +1,8 @@
package thaw.plugins.index;
-import java.sql.*;
+import java.sql.SQLException;
-import thaw.core.*;
+import thaw.core.Logger;
import thaw.plugins.Hsqldb;
/**
@@ -32,10 +32,10 @@
/**
* Can be safely called, even if the tables already exist.
*/
- public static void createTables(Hsqldb db) {
+ public static void createTables(final Hsqldb db) {
//sendQuery(db,
// "SET IGNORECASE TRUE");
- sendQuery(db,
+ TableCreator.sendQuery(db,
"CREATE CACHED TABLE indexCategories ("
+ "id INTEGER IDENTITY NOT NULL,"
+ "name VARCHAR(255) NOT NULL,"
@@ -45,7 +45,7 @@
+ "PRIMARY KEY (id),"
+ "FOREIGN KEY (parent) REFERENCES indexCategories
(id))");
- sendQuery(db,
+ TableCreator.sendQuery(db,
"CREATE CACHED TABLE indexes ("
+ "id INTEGER IDENTITY NOT NULL, "
+ "originalName VARCHAR(255) NOT NULL, "
@@ -59,12 +59,12 @@
+ "PRIMARY KEY (id), "
+ "FOREIGN KEY (parent) REFERENCES indexCategories
(id))");
- sendQuery(db,
+ TableCreator.sendQuery(db,
"CREATE CACHED TABLE categories ("
+ "id INTEGER IDENTITY NOT NULL,"
+ "name VARCHAR(255) NOT NULL)");
- sendQuery(db,
+ TableCreator.sendQuery(db,
"CREATE CACHED TABLE files ("
+ "id INTEGER IDENTITY NOT NULL,"
+ "filename VARCHAR(255) NOT NULL,"
@@ -78,7 +78,7 @@
+ "FOREIGN KEY (indexParent) REFERENCES indexes (id),"
+ "FOREIGN KEY (category) REFERENCES categories
(id))");
- sendQuery(db,
+ TableCreator.sendQuery(db,
"CREATE CACHED TABLE links ("
+ "id INTEGER IDENTITY NOT NULL,"
+ "publicKey VARCHAR(350) NOT NULL," // key ~= 100 +
filename == 255 max
@@ -90,13 +90,13 @@
+ "FOREIGN KEY (indexParent) REFERENCES indexes (id),"
+ "FOREIGN KEY (indexTarget) REFERENCES indexes
(id))");
- sendQuery(db,
+ TableCreator.sendQuery(db,
"CREATE CACHED TABLE metadataNames ("
+ "id INTEGER IDENTITY NOT NULL,"
+ "name VARCHAR(255) NOT NULL,"
+ "PRIMARY KEY (id))");
- sendQuery(db,
+ TableCreator.sendQuery(db,
"CREATE CACHED TABLE metadatas ("
+ "id INTEGER IDENTITY NOT NULL,"
+ "nameId INTEGER NOT NULL,"
@@ -108,25 +108,25 @@
}
- public static void dropTables(Hsqldb db) {
- sendQuery(db, "DROP TABLE metadatas");
- sendQuery(db, "DROP TABLE metadataNames");
+ public static void dropTables(final Hsqldb db) {
+ TableCreator.sendQuery(db, "DROP TABLE metadatas");
+ TableCreator.sendQuery(db, "DROP TABLE metadataNames");
- sendQuery(db, "DROP TABLE files");
- sendQuery(db, "DROP TABLE links");
+ TableCreator.sendQuery(db, "DROP TABLE files");
+ TableCreator.sendQuery(db, "DROP TABLE links");
- sendQuery(db, "DROP TABLE indexes");
- sendQuery(db, "DROP TABLE indexCategories");
+ TableCreator.sendQuery(db, "DROP TABLE indexes");
+ TableCreator.sendQuery(db, "DROP TABLE indexCategories");
}
/**
* Returns no error / Throws no exception.
*/
- protected static void sendQuery(Hsqldb db, String query) {
+ protected static void sendQuery(final Hsqldb db, final String query) {
try {
db.executeQuery(query);
- } catch(SQLException e) {
+ } catch(final SQLException e) {
Logger.notice(new TableCreator(), "While (re)creating
sql tables: "+e.toString());
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Tables.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Tables.java 2006-12-06 18:18:48 UTC
(rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Tables.java 2006-12-06 18:21:00 UTC
(rev 11273)
@@ -1,12 +1,12 @@
package thaw.plugins.index;
+import java.awt.BorderLayout;
+
import javax.swing.JPanel;
import javax.swing.JSplitPane;
-import java.awt.BorderLayout;
+import thaw.core.Config;
import thaw.fcp.FCPQueueManager;
-
-import thaw.core.Config;
import thaw.plugins.Hsqldb;
/**
@@ -22,59 +22,59 @@
private JSplitPane split;
private Config config;
- public Tables(boolean modifiables, Hsqldb db, FCPQueueManager
queueManager, UnknownIndexList uil, IndexTree tree, Config config) {
+ public Tables(final boolean modifiables, final Hsqldb db, final
FCPQueueManager queueManager, final UnknownIndexList uil, final IndexTree tree,
final Config config) {
this.config = config;
- this.panel = new JPanel();
- this.panel.setLayout(new BorderLayout(10, 10));
+ panel = new JPanel();
+ panel.setLayout(new BorderLayout(10, 10));
- this.fileTable = new FileTable(queueManager, tree, config,
this);
- this.linkTable = new LinkTable(db, queueManager, uil, tree,
this);
+ fileTable = new FileTable(queueManager, tree, config, this);
+ linkTable = new LinkTable(db, queueManager, uil, tree, this);
- this.searchBar = new SearchBar(db, tree, queueManager, this);
+ searchBar = new SearchBar(db, tree, queueManager, this);
- this.split = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
- this.linkTable.getPanel(),
- this.fileTable.getPanel());
+ split = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
+ linkTable.getPanel(),
+ fileTable.getPanel());
- this.panel.add(this.searchBar.getPanel(), BorderLayout.NORTH);
- this.panel.add(this.split, BorderLayout.CENTER);
+ panel.add(searchBar.getPanel(), BorderLayout.NORTH);
+ panel.add(split, BorderLayout.CENTER);
}
public JPanel getPanel() {
- return this.panel;
+ return panel;
}
public void restoreState() {
if (config.getValue("indexFileLinkSplit") != null)
-
split.setDividerLocation(Integer.parseInt(this.config.getValue("indexFileLinkSplit")));
+
split.setDividerLocation(Integer.parseInt(config.getValue("indexFileLinkSplit")));
else
split.setDividerLocation(100);
}
public void saveState() {
- this.config.setValue("indexFileLinkSplit",
Integer.toString(this.split.getDividerLocation()));
+ config.setValue("indexFileLinkSplit",
Integer.toString(split.getDividerLocation()));
}
protected FileTable getFileTable() {
- return this.fileTable;
+ return fileTable;
}
protected LinkTable getLinkTable() {
- return this.linkTable;
+ return linkTable;
}
- public void setLinkList(LinkList linkList) {
- this.getLinkTable().setLinkList(linkList);
+ public void setLinkList(final LinkList linkList) {
+ getLinkTable().setLinkList(linkList);
}
- public void setFileList(FileList fileList) {
- this.getFileTable().setFileList(fileList);
+ public void setFileList(final FileList fileList) {
+ getFileTable().setFileList(fileList);
}
- public void setList(FileAndLinkList l) {
- this.setFileList(l);
- this.setLinkList(l);
+ public void setList(final FileAndLinkList l) {
+ setFileList(l);
+ setLinkList(l);
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java
2006-12-06 18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java
2006-12-06 18:21:00 UTC (rev 11273)
@@ -1,23 +1,21 @@
package thaw.plugins.index;
-import javax.swing.JPanel;
-import javax.swing.JList;
-import javax.swing.JLabel;
-import javax.swing.JScrollPane;
import java.awt.BorderLayout;
-
-import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.Iterator;
+import java.util.Vector;
-import javax.swing.JPopupMenu;
+import javax.swing.JLabel;
+import javax.swing.JList;
import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
-import java.util.Vector;
-import java.util.Iterator;
-
-import thaw.core.*;
-import thaw.plugins.Hsqldb;
+import thaw.core.I18n;
import thaw.fcp.FCPQueueManager;
+import thaw.plugins.Hsqldb;
public class UnknownIndexList implements MouseListener {
public final static int MAX_INDEXES = 50;
@@ -40,14 +38,14 @@
private FCPQueueManager queueManager;
private IndexTree indexTree;
- public UnknownIndexList(Hsqldb db, FCPQueueManager queueManager) {
+ public UnknownIndexList(final Hsqldb db, final FCPQueueManager
queueManager) {
this.db = db;
this.queueManager = queueManager;
offset = 0;
full = false;
vList = new Vector();
- linkList = new Link[MAX_INDEXES];
+ linkList = new Link[UnknownIndexList.MAX_INDEXES];
for(int i = 0 ; i < linkList.length ; i++)
linkList[i] = null;
@@ -65,15 +63,15 @@
list.addMouseListener(this);
}
- public void setIndexTree(IndexTree tree) {
- this.indexTree = tree;
+ public void setIndexTree(final IndexTree tree) {
+ indexTree = tree;
}
public JPanel getPanel() {
return panel;
}
- public boolean isInList(Link l) {
+ public boolean isInList(final Link l) {
if (l == null)
return false;
@@ -88,11 +86,11 @@
return false;
}
- public boolean removeLink(Index index) {
+ 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 ((linkList[i] != null) &&
linkList[i].compare(index)) {
if (!full)
vList.remove(linkList[i]);
linkList[i] = null;
@@ -106,8 +104,8 @@
/**
* will check that the link link to an unknown index before adding
*/
- public boolean addLink(Link link) {
- if (link == null || link.isIndexAlreadyKnown() ||
isInList(link))
+ public boolean addLink(final Link link) {
+ if ((link == null) || link.isIndexAlreadyKnown() ||
isInList(link))
return false;
linkList[linkList.length - 1 - offset] = link;
@@ -121,7 +119,7 @@
offset++;
- if (offset >= MAX_INDEXES) {
+ if (offset >= UnknownIndexList.MAX_INDEXES) {
offset = 0;
full = true;
}
@@ -132,15 +130,15 @@
/**
* will add the link from that index (if links link to unknown indexes)
*/
- public boolean addLinks(Index index) {
+ public boolean addLinks(final Index index) {
boolean ret = false;
- Vector ll = index.getLinkList();
+ final Vector ll = index.getLinkList();
- if (ll == null || ll.size() == 0)
+ if ((ll == null) || (ll.size() == 0))
return false;
- for (Iterator it = ll.iterator();
+ for (final Iterator it = ll.iterator();
it.hasNext();) {
if (addLink(((Link)it.next())))
ret = true;
@@ -165,15 +163,15 @@
rightClickActions.add(new
LinkManagementHelper.PublicKeyCopier(item));
}
- Object[] sLink = list.getSelectedValues();
- Vector vLink = new Vector();
+ final Object[] sLink = list.getSelectedValues();
+ final Vector vLink = new Vector();
for (int i = 0; i < sLink.length ; i++)
vLink.add(sLink[i]);
LinkManagementHelper.LinkAction action;
- for(Iterator it = rightClickActions.iterator();
+ for(final Iterator it = rightClickActions.iterator();
it.hasNext(); ) {
action = (LinkManagementHelper.LinkAction)it.next();
action.setTarget(vLink);
@@ -181,19 +179,19 @@
}
- public void mouseClicked(MouseEvent e) {
- if(e.getButton() == MouseEvent.BUTTON3
- && this.linkList != null) {
+ public void mouseClicked(final MouseEvent e) {
+ if((e.getButton() == MouseEvent.BUTTON3)
+ && (linkList != null)) {
updateRightClickMenu();
rightClickMenu.show(e.getComponent(), e.getX(),
e.getY());
}
}
- public void mouseEntered(MouseEvent e) { }
+ public void mouseEntered(final MouseEvent e) { }
- public void mouseExited(MouseEvent e) { }
+ public void mouseExited(final MouseEvent e) { }
- public void mousePressed(MouseEvent e) { }
+ public void mousePressed(final MouseEvent e) { }
- public void mouseReleased(MouseEvent e) { }
+ public void mouseReleased(final MouseEvent e) { }
}
Modified: trunk/apps/Thaw/src/thaw/plugins/insertPlugin/DefaultMIMETypes.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/insertPlugin/DefaultMIMETypes.java
2006-12-06 18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/insertPlugin/DefaultMIMETypes.java
2006-12-06 18:21:00 UTC (rev 11273)
@@ -14,17 +14,17 @@
public static final String DEFAULT_MIME_TYPE =
"application/octet-stream";
/** MIME types: number -> name */
- private static Vector mimeTypesByNumber = new Vector();
+ private static final Vector mimeTypesByNumber = new Vector();
/** MIME types: name -> number */
- private static HashMap mimeTypesByName = new HashMap();
+ private static final HashMap mimeTypesByName = new HashMap();
/** MIME types by extension. One extension maps to one MIME type, but
not necessarily
* the other way around. */
- private static HashMap mimeTypesByExtension = new HashMap();
+ private static final HashMap mimeTypesByExtension = new HashMap();
/** Primary extension by MIME type number. */
- private static HashMap primaryExtensionByMimeNumber = new HashMap();
+ private static final HashMap primaryExtensionByMimeNumber = new
HashMap();
/**
* Just to be able to use thaw.core.Logger.
@@ -41,15 +41,15 @@
* @param type The actual MIME type string. Do not include ;charset=
etc; these are
* parameters and there is a separate mechanism for them.
*/
- protected static synchronized void addMIMEType(short number, String
type) {
- if(mimeTypesByNumber.size() > number) {
- String s = (String) mimeTypesByNumber.get(number);
+ protected static synchronized void addMIMEType(final short number,
final String type) {
+ if(DefaultMIMETypes.mimeTypesByNumber.size() > number) {
+ final String s = (String)
DefaultMIMETypes.mimeTypesByNumber.get(number);
if(s != null) throw new
IllegalArgumentException("Already used: "+number);
} else {
- mimeTypesByNumber.add(number, null);
+ DefaultMIMETypes.mimeTypesByNumber.add(number, null);
}
- mimeTypesByNumber.set(number, type);
- mimeTypesByName.put(type, new Short(number));
+ DefaultMIMETypes.mimeTypesByNumber.set(number, type);
+ DefaultMIMETypes.mimeTypesByName.put(type, new Short(number));
}
/**
@@ -61,26 +61,26 @@
* @param extensions An array of common extensions for files of this
type. Must be
* unique for the type.
*/
- protected static synchronized void addMIMEType(short number, String
type, String[] extensions, String outExtension) {
- addMIMEType(number, type);
- Short t = new Short(number);
+ protected static synchronized void addMIMEType(final short number,
final String type, final String[] extensions, final String outExtension) {
+ DefaultMIMETypes.addMIMEType(number, type);
+ final Short t = new Short(number);
if(extensions != null) {
for(int i=0;i<extensions.length;i++) {
- String ext = extensions[i].toLowerCase();
- if(mimeTypesByExtension.containsKey(ext)) {
+ final String ext = extensions[i].toLowerCase();
+
if(DefaultMIMETypes.mimeTypesByExtension.containsKey(ext)) {
// No big deal
- Short s = (Short)
mimeTypesByExtension.get(ext);
- Logger.notice(new DefaultMIMETypes(),
"Extension "+ext+" assigned to "+byNumber(s.shortValue())+" in preference to
"+number+":"+type);
+ final Short s = (Short)
DefaultMIMETypes.mimeTypesByExtension.get(ext);
+ Logger.notice(new DefaultMIMETypes(),
"Extension "+ext+" assigned to "+DefaultMIMETypes.byNumber(s.shortValue())+" in
preference to "+number+":"+type);
} else {
// If only one, make it primary
if((outExtension == null) &&
(extensions.length == 1))
-
primaryExtensionByMimeNumber.put(t, ext);
- mimeTypesByExtension.put(ext, t);
+
DefaultMIMETypes.primaryExtensionByMimeNumber.put(t, ext);
+
DefaultMIMETypes.mimeTypesByExtension.put(ext, t);
}
}
}
if(outExtension != null)
- primaryExtensionByMimeNumber.put(t, outExtension);
+ DefaultMIMETypes.primaryExtensionByMimeNumber.put(t,
outExtension);
}
@@ -88,33 +88,33 @@
* Add a MIME type, with extensions separated by spaces. This is more
or less
* the format in /etc/mime-types.
*/
- protected static synchronized void addMIMEType(short number, String
type, String extensions) {
- addMIMEType(number, type, extensions.split(" "), null);
+ protected static synchronized void addMIMEType(final short number,
final String type, final String extensions) {
+ DefaultMIMETypes.addMIMEType(number, type, extensions.split("
"), null);
}
/**
* Add a MIME type, with extensions separated by spaces. This is more
or less
* the format in /etc/mime-types.
*/
- protected static synchronized void addMIMEType(short number, String
type, String extensions, String outExtension) {
- addMIMEType(number, type, extensions.split(" "), outExtension);
+ protected static synchronized void addMIMEType(final short number,
final String type, final String extensions, final String outExtension) {
+ DefaultMIMETypes.addMIMEType(number, type, extensions.split("
"), outExtension);
}
/**
* Get a known MIME type by number.
*/
- public synchronized static String byNumber(short x) {
- if((x > mimeTypesByNumber.size()) || (x < 0))
+ public synchronized static String byNumber(final short x) {
+ if((x > DefaultMIMETypes.mimeTypesByNumber.size()) || (x < 0))
return null;
- return (String) mimeTypesByNumber.get(x);
+ return (String) DefaultMIMETypes.mimeTypesByNumber.get(x);
}
/**
* Get the number of a MIME type, or -1 if it is not in the table of
known MIME
* types, in which case it will have to be sent uncompressed.
*/
- public synchronized static short byName(String s) {
- Short x = (Short) mimeTypesByName.get(s);
+ public synchronized static short byName(final String s) {
+ final Short x = (Short) DefaultMIMETypes.mimeTypesByName.get(s);
if(x != null) return x.shortValue();
else return -1;
}
@@ -128,647 +128,647 @@
// FIXME should we support aliases?
static {
- addMIMEType((short)0, "application/activemessage");
- addMIMEType((short)1, "application/andrew-inset", "ez");
- addMIMEType((short)2, "application/applefile");
- addMIMEType((short)3, "application/atomicmail");
- addMIMEType((short)4, "application/batch-SMTP");
- addMIMEType((short)5, "application/beep+xml");
- addMIMEType((short)6, "application/cals-1840");
- addMIMEType((short)7, "application/commonground");
- addMIMEType((short)8, "application/cu-seeme", "csm cu");
- addMIMEType((short)9, "application/cybercash");
- addMIMEType((short)10, "application/dca-rft");
- addMIMEType((short)11, "application/dec-dx");
- addMIMEType((short)12, "application/docbook+xml");
- addMIMEType((short)13, "application/dsptype", "tsp");
- addMIMEType((short)14, "application/dvcs");
- addMIMEType((short)15, "application/edi-consent");
- addMIMEType((short)16, "application/edifact");
- addMIMEType((short)17, "application/edi-x12");
- addMIMEType((short)18, "application/eshop");
- addMIMEType((short)19, "application/font-tdpfr");
- addMIMEType((short)20, "application/futuresplash", "spl");
- addMIMEType((short)21, "application/ghostview");
- addMIMEType((short)22, "application/hta", "hta");
- addMIMEType((short)23, "application/http");
- addMIMEType((short)24, "application/hyperstudio");
- addMIMEType((short)25, "application/iges");
- addMIMEType((short)26, "application/index");
- addMIMEType((short)27, "application/index.cmd");
- addMIMEType((short)28, "application/index.obj");
- addMIMEType((short)29, "application/index.response");
- addMIMEType((short)30, "application/index.vnd");
- addMIMEType((short)31, "application/iotp");
- addMIMEType((short)32, "application/ipp");
- addMIMEType((short)33, "application/isup");
- addMIMEType((short)34, "application/mac-compactpro", "cpt");
- addMIMEType((short)35, "application/marc");
- addMIMEType((short)36, "application/mac-binhex40", "hqx");
- addMIMEType((short)37, "application/macwriteii");
- addMIMEType((short)38, "application/mathematica", "nb");
- addMIMEType((short)39, "application/mathematica-old");
- addMIMEType((short)40, "application/msaccess", "mdb");
- addMIMEType((short)41, "application/msword", "doc dot", "doc");
- addMIMEType((short)42, "application/news-message-id");
- addMIMEType((short)43, "application/news-transmission");
- addMIMEType((short)44, "application/octet-stream", "bin");
- addMIMEType((short)45, "application/ocsp-request");
- addMIMEType((short)46, "application/ocsp-response");
- addMIMEType((short)47, "application/oda", "oda");
- addMIMEType((short)48, "application/ogg", "ogg");
- addMIMEType((short)49, "application/parityfec");
- addMIMEType((short)50, "application/pics-rules", "prf");
- addMIMEType((short)51, "application/pgp-encrypted");
- addMIMEType((short)52, "application/pgp-keys", "key");
- addMIMEType((short)53, "application/pdf", "pdf");
- addMIMEType((short)54, "application/pgp-signature", "pgp");
- addMIMEType((short)55, "application/pkcs10");
- addMIMEType((short)56, "application/pkcs7-mime");
- addMIMEType((short)57, "application/pkcs7-signature");
- addMIMEType((short)58, "application/pkix-cert");
- addMIMEType((short)59, "application/pkixcmp");
- addMIMEType((short)60, "application/pkix-crl");
- addMIMEType((short)61, "application/postscript", "ps ai eps",
"ps");
- addMIMEType((short)62,
"application/prs.alvestrand.titrax-sheet");
- addMIMEType((short)63, "application/prs.cww");
- addMIMEType((short)64, "application/prs.nprend");
- addMIMEType((short)65, "application/qsig");
- addMIMEType((short)66, "application/rar", "rar");
- addMIMEType((short)67, "application/rdf+xml", "rdf");
- addMIMEType((short)68, "application/remote-printing");
- addMIMEType((short)69, "application/riscos");
- addMIMEType((short)70, "application/rss+xml", "rss");
- addMIMEType((short)71, "application/rtf", "rtf");
- addMIMEType((short)72, "application/sdp");
- addMIMEType((short)73, "application/set-payment");
- addMIMEType((short)74, "application/set-payment-initiation");
- addMIMEType((short)75, "application/set-registration");
- addMIMEType((short)76,
"application/set-registration-initiation");
- addMIMEType((short)77, "application/sgml");
- addMIMEType((short)78, "application/sgml-open-catalog");
- addMIMEType((short)79, "application/sieve");
- addMIMEType((short)80, "application/slate");
- addMIMEType((short)81, "application/smil", "smi smil", "smil");
- addMIMEType((short)82, "application/timestamp-query");
- addMIMEType((short)83, "application/timestamp-reply");
- addMIMEType((short)84, "application/vemmi");
- addMIMEType((short)85, "application/whoispp-query");
- addMIMEType((short)86, "application/whoispp-response");
- addMIMEType((short)87, "application/wita");
- addMIMEType((short)88, "application/wordperfect5.1", "wp5");
- addMIMEType((short)89, "application/x400-bp");
- addMIMEType((short)90, "application/xhtml+xml", "xht xhtml",
"xhtml");
- addMIMEType((short)91, "application/xml", "xml xsl", "xml");
- addMIMEType((short)92, "application/xml-dtd");
- addMIMEType((short)93,
"application/xml-external-parsed-entity");
- addMIMEType((short)94, "application/zip", "zip");
- addMIMEType((short)95, "application/vnd.3M.Post-it-Notes");
- addMIMEType((short)96, "application/vnd.accpac.simply.aso");
- addMIMEType((short)97, "application/vnd.accpac.simply.imp");
- addMIMEType((short)98, "application/vnd.acucobol");
- addMIMEType((short)99, "application/vnd.aether.imp");
- addMIMEType((short)100,
"application/vnd.anser-web-certificate-issue-initiation");
- addMIMEType((short)101,
"application/vnd.anser-web-funds-transfer-initiation");
- addMIMEType((short)102, "application/vnd.audiograph");
- addMIMEType((short)103, "application/vnd.bmi");
- addMIMEType((short)104, "application/vnd.businessobjects");
- addMIMEType((short)105, "application/vnd.canon-cpdl");
- addMIMEType((short)106, "application/vnd.canon-lips");
- addMIMEType((short)107, "application/vnd.cinderella", "cdy");
- addMIMEType((short)108, "application/vnd.claymore");
- addMIMEType((short)109, "application/vnd.commerce-battelle");
- addMIMEType((short)110, "application/vnd.commonspace");
- addMIMEType((short)111, "application/vnd.comsocaller");
- addMIMEType((short)112, "application/vnd.contact.cmsg");
- addMIMEType((short)113, "application/vnd.cosmocaller");
- addMIMEType((short)114, "application/vnd.ctc-posml");
- addMIMEType((short)115, "application/vnd.cups-postscript");
- addMIMEType((short)116, "application/vnd.cups-raster");
- addMIMEType((short)117, "application/vnd.cups-raw");
- addMIMEType((short)118, "application/vnd.cybank");
- addMIMEType((short)119, "application/vnd.dna");
- addMIMEType((short)120, "application/vnd.dpgraph");
- addMIMEType((short)121, "application/vnd.dxr");
- addMIMEType((short)122, "application/vnd.ecdis-update");
- addMIMEType((short)123, "application/vnd.ecowin.chart");
- addMIMEType((short)124, "application/vnd.ecowin.filerequest");
- addMIMEType((short)125, "application/vnd.ecowin.fileupdate");
- addMIMEType((short)126, "application/vnd.ecowin.series");
- addMIMEType((short)127, "application/vnd.ecowin.seriesrequest");
- addMIMEType((short)128, "application/vnd.ecowin.seriesupdate");
- addMIMEType((short)129, "application/vnd.enliven");
- addMIMEType((short)130, "application/vnd.epson.esf");
- addMIMEType((short)131, "application/vnd.epson.msf");
- addMIMEType((short)132, "application/vnd.epson.quickanime");
- addMIMEType((short)133, "application/vnd.epson.salt");
- addMIMEType((short)134, "application/vnd.epson.ssf");
- addMIMEType((short)135, "application/vnd.ericsson.quickcall");
- addMIMEType((short)136, "application/vnd.eudora.data");
- addMIMEType((short)137, "application/vnd.fdf");
- addMIMEType((short)138, "application/vnd.ffsns");
- addMIMEType((short)139, "application/vnd.flographit");
- addMIMEType((short)140, "application/vnd.framemaker");
- addMIMEType((short)141, "application/vnd.fsc.weblaunch");
- addMIMEType((short)142, "application/vnd.fujitsu.oasys");
- addMIMEType((short)143, "application/vnd.fujitsu.oasys2");
- addMIMEType((short)144, "application/vnd.fujitsu.oasys3");
- addMIMEType((short)145, "application/vnd.fujitsu.oasysgp");
- addMIMEType((short)146, "application/vnd.fujitsu.oasysprs");
- addMIMEType((short)147, "application/vnd.fujixerox.ddd");
- addMIMEType((short)148, "application/vnd.fujixerox.docuworks");
- addMIMEType((short)149,
"application/vnd.fujixerox.docuworks.binder");
- addMIMEType((short)150, "application/vnd.fut-misnet");
- addMIMEType((short)151, "application/vnd.grafeq");
- addMIMEType((short)152, "application/vnd.groove-account");
- addMIMEType((short)153,
"application/vnd.groove-identity-message");
- addMIMEType((short)154, "application/vnd.groove-injector");
- addMIMEType((short)155, "application/vnd.groove-tool-message");
- addMIMEType((short)156, "application/vnd.groove-tool-template");
- addMIMEType((short)157, "application/vnd.groove-vcard");
- addMIMEType((short)158, "application/vnd.hhe.lesson-player");
- addMIMEType((short)159, "application/vnd.hp-HPGL");
- addMIMEType((short)160, "application/vnd.hp-PCL");
- addMIMEType((short)161, "application/vnd.hp-PCLXL");
- addMIMEType((short)162, "application/vnd.hp-hpid");
- addMIMEType((short)163, "application/vnd.hp-hps");
- addMIMEType((short)164, "application/vnd.httphone");
- addMIMEType((short)165, "application/vnd.hzn-3d-crossword");
- addMIMEType((short)166, "application/vnd.ibm.MiniPay");
- addMIMEType((short)167, "application/vnd.ibm.afplinedata");
- addMIMEType((short)168, "application/vnd.ibm.modcap");
- addMIMEType((short)169, "application/vnd.informix-visionary");
- addMIMEType((short)170, "application/vnd.intercon.formnet");
- addMIMEType((short)171, "application/vnd.intertrust.digibox");
- addMIMEType((short)172, "application/vnd.intertrust.nncp");
- addMIMEType((short)173, "application/vnd.intu.qbo");
- addMIMEType((short)174, "application/vnd.intu.qfx");
- addMIMEType((short)175,
"application/vnd.irepository.package+xml");
- addMIMEType((short)176, "application/vnd.is-xpr");
- addMIMEType((short)177,
"application/vnd.japannet-directory-service");
- addMIMEType((short)178,
"application/vnd.japannet-jpnstore-wakeup");
- addMIMEType((short)179,
"application/vnd.japannet-payment-wakeup");
- addMIMEType((short)180,
"application/vnd.japannet-registration");
- addMIMEType((short)181,
"application/vnd.japannet-registration-wakeup");
- addMIMEType((short)182,
"application/vnd.japannet-setstore-wakeup");
- addMIMEType((short)183,
"application/vnd.japannet-verification");
- addMIMEType((short)184,
"application/vnd.japannet-verification-wakeup");
- addMIMEType((short)185, "application/vnd.koan");
- addMIMEType((short)186, "application/vnd.lotus-1-2-3");
- addMIMEType((short)187, "application/vnd.lotus-approach");
- addMIMEType((short)188, "application/vnd.lotus-freelance");
- addMIMEType((short)189, "application/vnd.lotus-notes");
- addMIMEType((short)190, "application/vnd.lotus-organizer");
- addMIMEType((short)191, "application/vnd.lotus-screencam");
- addMIMEType((short)192, "application/vnd.lotus-wordpro");
- addMIMEType((short)193, "application/vnd.mcd");
- addMIMEType((short)194, "application/vnd.mediastation.cdkey");
- addMIMEType((short)195, "application/vnd.meridian-slingshot");
- addMIMEType((short)196, "application/vnd.mif", "mif");
- addMIMEType((short)197, "application/vnd.minisoft-hp3000-save");
- addMIMEType((short)198,
"application/vnd.mitsubishi.misty-guard.trustweb");
- addMIMEType((short)199, "application/vnd.mobius.daf");
- addMIMEType((short)200, "application/vnd.mobius.dis");
- addMIMEType((short)201, "application/vnd.mobius.msl");
- addMIMEType((short)202, "application/vnd.mobius.plc");
- addMIMEType((short)203, "application/vnd.mobius.txf");
- addMIMEType((short)204, "application/vnd.motorola.flexsuite");
- addMIMEType((short)205,
"application/vnd.motorola.flexsuite.adsi");
- addMIMEType((short)206,
"application/vnd.motorola.flexsuite.fis");
- addMIMEType((short)207,
"application/vnd.motorola.flexsuite.gotap");
- addMIMEType((short)208,
"application/vnd.motorola.flexsuite.kmr");
- addMIMEType((short)209,
"application/vnd.motorola.flexsuite.ttc");
- addMIMEType((short)210,
"application/vnd.motorola.flexsuite.wem");
- addMIMEType((short)211, "application/vnd.mozilla.xul+xml",
"xul");
- addMIMEType((short)212, "application/vnd.ms-artgalry");
- addMIMEType((short)213, "application/vnd.ms-asf");
- addMIMEType((short)214, "application/vnd.ms-excel", "xls xlb
xlt", "xls");
- addMIMEType((short)215, "application/vnd.ms-lrm");
- addMIMEType((short)216, "application/vnd.ms-pki.seccat", "cat");
- addMIMEType((short)217, "application/vnd.ms-pki.stl", "stl");
- addMIMEType((short)218, "application/vnd.ms-powerpoint", "ppt
pps", "pps");
- addMIMEType((short)219, "application/vnd.ms-project");
- addMIMEType((short)220, "application/vnd.ms-tnef");
- addMIMEType((short)221, "application/vnd.ms-works");
- addMIMEType((short)222, "application/vnd.mseq");
- addMIMEType((short)223, "application/vnd.msign");
- addMIMEType((short)224, "application/vnd.music-niff");
- addMIMEType((short)225, "application/vnd.musician");
- addMIMEType((short)226, "application/vnd.netfpx");
- addMIMEType((short)227, "application/vnd.noblenet-directory");
- addMIMEType((short)228, "application/vnd.noblenet-sealer");
- addMIMEType((short)229, "application/vnd.noblenet-web");
- addMIMEType((short)230, "application/vnd.novadigm.EDM");
- addMIMEType((short)231, "application/vnd.novadigm.EDX");
- addMIMEType((short)232, "application/vnd.novadigm.EXT");
- addMIMEType((short)233, "application/vnd.osa.netdeploy");
- addMIMEType((short)234, "application/vnd.palm");
- addMIMEType((short)235, "application/vnd.pg.format");
- addMIMEType((short)236, "application/vnd.pg.osasli");
- addMIMEType((short)237, "application/vnd.powerbuilder6");
- addMIMEType((short)238, "application/vnd.powerbuilder6-s");
- addMIMEType((short)239, "application/vnd.powerbuilder7");
- addMIMEType((short)240, "application/vnd.powerbuilder7-s");
- addMIMEType((short)241, "application/vnd.powerbuilder75");
- addMIMEType((short)242, "application/vnd.powerbuilder75-s");
- addMIMEType((short)243, "application/vnd.previewsystems.box");
- addMIMEType((short)244,
"application/vnd.publishare-delta-tree");
- addMIMEType((short)245, "application/vnd.pvi.ptid1");
- addMIMEType((short)246, "application/vnd.pwg-xhtml-print+xml");
- addMIMEType((short)247, "application/vnd.rapid");
- addMIMEType((short)248, "application/vnd.s3sms");
- addMIMEType((short)249, "application/vnd.seemail");
- addMIMEType((short)250,
"application/vnd.shana.informed.formdata");
- addMIMEType((short)251,
"application/vnd.shana.informed.formtemplate");
- addMIMEType((short)252,
"application/vnd.shana.informed.interchange");
- addMIMEType((short)253,
"application/vnd.shana.informed.package");
- addMIMEType((short)254, "application/vnd.smaf", "mmf");
- addMIMEType((short)255, "application/vnd.sss-cod");
- addMIMEType((short)256, "application/vnd.sss-dtf");
- addMIMEType((short)257, "application/vnd.sss-ntf");
- addMIMEType((short)258, "application/vnd.stardivision.calc",
"sdc");
- addMIMEType((short)259, "application/vnd.stardivision.draw",
"sda");
- addMIMEType((short)260, "application/vnd.stardivision.impress",
"sdd sdp");
- addMIMEType((short)261, "application/vnd.stardivision.math",
"smf");
- addMIMEType((short)262, "application/vnd.stardivision.writer",
"sdw vor");
- addMIMEType((short)263,
"application/vnd.stardivision.writer-global", "sgl");
- addMIMEType((short)264, "application/vnd.street-stream");
- addMIMEType((short)265, "application/vnd.sun.xml.calc", "sxc");
- addMIMEType((short)266,
"application/vnd.sun.xml.calc.template", "stc");
- addMIMEType((short)267, "application/vnd.sun.xml.draw", "sxd");
- addMIMEType((short)268,
"application/vnd.sun.xml.draw.template", "std");
- addMIMEType((short)269, "application/vnd.sun.xml.impress",
"sxi");
- addMIMEType((short)270,
"application/vnd.sun.xml.impress.template", "sti");
- addMIMEType((short)271, "application/vnd.sun.xml.math", "sxm");
- addMIMEType((short)272, "application/vnd.sun.xml.writer",
"sxw");
- addMIMEType((short)273,
"application/vnd.sun.xml.writer.global", "sxg");
- addMIMEType((short)274,
"application/vnd.sun.xml.writer.template", "stw");
- addMIMEType((short)275, "application/vnd.svd");
- addMIMEType((short)276, "application/vnd.swiftview-ics");
- addMIMEType((short)277, "application/vnd.symbian.install",
"sis");
- addMIMEType((short)278, "application/vnd.triscape.mxs");
- addMIMEType((short)279, "application/vnd.trueapp");
- addMIMEType((short)280, "application/vnd.truedoc");
- addMIMEType((short)281, "application/vnd.tve-trigger");
- addMIMEType((short)282, "application/vnd.ufdl");
- addMIMEType((short)283, "application/vnd.uplanet.alert");
- addMIMEType((short)284, "application/vnd.uplanet.alert-wbxml");
- addMIMEType((short)285,
"application/vnd.uplanet.bearer-choice");
- addMIMEType((short)286,
"application/vnd.uplanet.bearer-choice-wbxml");
- addMIMEType((short)287, "application/vnd.uplanet.cacheop");
- addMIMEType((short)288,
"application/vnd.uplanet.cacheop-wbxml");
- addMIMEType((short)289, "application/vnd.uplanet.channel");
- addMIMEType((short)290,
"application/vnd.uplanet.channel-wbxml");
- addMIMEType((short)291, "application/vnd.uplanet.list");
- addMIMEType((short)292, "application/vnd.uplanet.list-wbxml");
- addMIMEType((short)293, "application/vnd.uplanet.listcmd");
- addMIMEType((short)294,
"application/vnd.uplanet.listcmd-wbxml");
- addMIMEType((short)295, "application/vnd.uplanet.signal");
- addMIMEType((short)296, "application/vnd.vcx");
- addMIMEType((short)297, "application/vnd.vectorworks");
- addMIMEType((short)298,
"application/vnd.vidsoft.vidconference");
- addMIMEType((short)299, "application/vnd.visio", "vsd");
- addMIMEType((short)300, "application/vnd.vividence.scriptfile");
- addMIMEType((short)301, "application/vnd.wap.sic");
- addMIMEType((short)302, "application/vnd.wap.slc");
- addMIMEType((short)303, "application/vnd.wap.wbxml", "wbxml");
- addMIMEType((short)304, "application/vnd.wap.wmlc", "wmlc");
- addMIMEType((short)305, "application/vnd.wap.wmlscriptc",
"wmlsc");
- addMIMEType((short)306, "application/vnd.webturbo");
- addMIMEType((short)307, "application/vnd.wrq-hp3000-labelled");
- addMIMEType((short)308, "application/vnd.wt.stf");
- addMIMEType((short)309, "application/vnd.xara");
- addMIMEType((short)310, "application/vnd.xfdl");
- addMIMEType((short)311,
"application/vnd.yellowriver-custom-menu");
- addMIMEType((short)312, "application/x-123", "wk");
- addMIMEType((short)313, "application/x-apple-diskimage", "dmg");
- addMIMEType((short)314, "application/x-bcpio", "bcpio");
- addMIMEType((short)315, "application/x-bittorrent", "torrent");
- addMIMEType((short)316, "application/x-cdf", "cdf");
- addMIMEType((short)317, "application/x-cdlink", "vcd");
- addMIMEType((short)318, "application/x-chess-pgn", "pgn");
- addMIMEType((short)319, "application/x-chm", "chm");
- addMIMEType((short)320, "application/x-core");
- addMIMEType((short)321, "application/x-cpio", "cpio");
- addMIMEType((short)322, "application/x-csh", "csh");
- addMIMEType((short)323, "application/x-debian-package", "deb");
- addMIMEType((short)324, "application/x-director", "dcr dir
dxr");
- addMIMEType((short)325, "application/x-doom", "wad");
- addMIMEType((short)326, "application/x-dms", "dms");
- addMIMEType((short)327, "application/x-dvi", "dvi");
- addMIMEType((short)328, "application/x-executable");
- addMIMEType((short)329, "application/x-flac", "flac");
- addMIMEType((short)330, "application/x-font", "pfa pfb gsf pcf
pcf.Z", "unknown-font-type");
- addMIMEType((short)331, "application/x-futuresplash", "spl");
- addMIMEType((short)332, "application/x-gnumeric", "gnumeric");
- addMIMEType((short)333, "application/x-go-sgf", "sgf");
- addMIMEType((short)334, "application/x-graphing-calculator",
"gcf");
- addMIMEType((short)335, "application/x-gtar", "gtar tgz taz",
"tgz");
- addMIMEType((short)336, "application/x-hdf", "hdf");
- addMIMEType((short)337, "application/x-httpd-php", "phtml pht
php", "php");
- addMIMEType((short)338, "application/x-httpd-php-source",
"phps");
- addMIMEType((short)339, "application/x-httpd-php3", "php3");
- addMIMEType((short)340,
"application/x-httpd-php3-preprocessed", "php3p");
- addMIMEType((short)341, "application/x-httpd-php4", "php4");
- addMIMEType((short)342, "application/x-ica", "ica");
- addMIMEType((short)343, "application/x-internet-signup", "ins
isp");
- addMIMEType((short)344, "application/x-iphone", "iii");
- addMIMEType((short)345, "application/x-java-applet");
- addMIMEType((short)346, "application/x-java-archive", "jar");
- addMIMEType((short)347, "application/x-java-bean");
- addMIMEType((short)348, "application/x-java-jnlp-file", "jnlp");
- addMIMEType((short)349, "application/x-java-serialized-object",
"ser");
- addMIMEType((short)350, "application/x-java-vm", "class");
- addMIMEType((short)351, "application/x-javascript", "js");
- addMIMEType((short)352, "application/x-kdelnk");
- addMIMEType((short)353, "application/x-kchart", "chrt");
- addMIMEType((short)354, "application/x-killustrator", "kil");
- addMIMEType((short)355, "application/x-kpresenter", "kpr kpt");
- addMIMEType((short)356, "application/x-koan", "skp skd skt
skm");
- addMIMEType((short)357, "application/x-kspread", "ksp");
- addMIMEType((short)358, "application/x-kword", "kwd kwt",
"kwd");
- addMIMEType((short)359, "application/x-latex", "latex");
- addMIMEType((short)360, "application/x-lha", "lha");
- addMIMEType((short)361, "application/x-lzh", "lzh");
- addMIMEType((short)362, "application/x-lzx", "lzx");
- addMIMEType((short)363, "application/x-maker", "frm maker frame
fm fb book fbdoc");
- addMIMEType((short)364, "application/x-mif", "mif");
- addMIMEType((short)365, "application/x-ms-wmz", "wmz");
- addMIMEType((short)366, "application/x-ms-wmd", "wmd");
- addMIMEType((short)367, "application/x-msdos-program", "com exe
bat dll", "exe");
- addMIMEType((short)368, "application/x-msi", "msi");
- addMIMEType((short)369, "application/x-netcdf", "nc");
- addMIMEType((short)370, "application/x-ns-proxy-autoconfig",
"pac");
- addMIMEType((short)371, "application/x-nwc", "nwc");
- addMIMEType((short)372, "application/x-object", "o");
- addMIMEType((short)373, "application/x-oz-application", "oza");
- addMIMEType((short)374, "application/x-pkcs7-certreqresp",
"p7r");
- addMIMEType((short)375, "application/x-pkcs7-crl", "crl");
- addMIMEType((short)376, "application/x-python-code", "pyc pyo",
"unknown-pyc-pyo");
- addMIMEType((short)377, "application/x-quicktimeplayer", "qtl");
- addMIMEType((short)378, "application/x-redhat-package-manager",
"rpm");
- addMIMEType((short)379, "application/x-rx");
- addMIMEType((short)380, "application/x-sh");
- addMIMEType((short)381, "application/x-shar", "shar");
- addMIMEType((short)382, "application/x-shellscript");
- addMIMEType((short)383, "application/x-shockwave-flash", "swf
swfl", "swf");
- addMIMEType((short)384, "application/x-sh", "sh");
- addMIMEType((short)385, "application/x-stuffit", "sit");
- addMIMEType((short)386, "application/x-sv4cpio", "sv4cpio");
- addMIMEType((short)387, "application/x-sv4crc", "sv4crc");
- addMIMEType((short)388, "application/x-tar", "tar");
- addMIMEType((short)389, "application/x-tcl", "tcl");
- addMIMEType((short)390, "application/x-tex-gf", "gf");
- addMIMEType((short)391, "application/x-tex-pk", "pk");
- addMIMEType((short)392, "application/x-texinfo", "texinfo
texi", "texi");
- addMIMEType((short)393, "application/x-trash", "~ % bak old
sik");
- addMIMEType((short)394, "application/x-troff", "t tr roff");
- addMIMEType((short)395, "application/x-troff-man", "man");
- addMIMEType((short)396, "application/x-troff-me", "me");
- addMIMEType((short)397, "application/x-troff-ms", "ms");
- addMIMEType((short)398, "application/x-ustar", "ustar");
- addMIMEType((short)399, "application/x-videolan");
- addMIMEType((short)400, "application/x-wais-source", "src");
- addMIMEType((short)401, "application/x-wingz", "wz");
- addMIMEType((short)402, "application/x-x509-ca-cert", "crt");
- addMIMEType((short)403, "application/x-xcf", "xcf");
- addMIMEType((short)404, "application/x-xfig", "fig");
- addMIMEType((short)405, "audio/32kadpcm");
- addMIMEType((short)406, "audio/basic", "au snd", "au");
- addMIMEType((short)407, "audio/g.722.1");
- addMIMEType((short)408, "audio/l16");
- addMIMEType((short)409, "audio/midi", "mid midi kar", "mid");
- addMIMEType((short)410, "audio/mp4a-latm");
- addMIMEType((short)411, "audio/mpa-robust");
- addMIMEType((short)412, "audio/mpeg", "mpga mpega mp2 mp3 m4a",
"mp3");
- addMIMEType((short)413, "audio/mpegurl", "m3u");
- addMIMEType((short)414, "audio/parityfec");
- addMIMEType((short)415, "audio/prs.sid", "sid");
- addMIMEType((short)416, "audio/telephone-event");
- addMIMEType((short)417, "audio/tone");
- addMIMEType((short)418, "audio/vnd.cisco.nse");
- addMIMEType((short)419, "audio/vnd.cns.anp1");
- addMIMEType((short)420, "audio/vnd.cns.inf1");
- addMIMEType((short)421, "audio/vnd.digital-winds");
- addMIMEType((short)422, "audio/vnd.everad.plj");
- addMIMEType((short)423, "audio/vnd.lucent.voice");
- addMIMEType((short)424, "audio/vnd.nortel.vbk");
- addMIMEType((short)425, "audio/vnd.nuera.ecelp4800");
- addMIMEType((short)426, "audio/vnd.nuera.ecelp7470");
- addMIMEType((short)427, "audio/vnd.nuera.ecelp9600");
- addMIMEType((short)428, "audio/vnd.octel.sbc");
- addMIMEType((short)429, "audio/vnd.qcelp");
- addMIMEType((short)430, "audio/vnd.rhetorex.32kadpcm");
- addMIMEType((short)431, "audio/vnd.vmx.cvsd");
- addMIMEType((short)432, "audio/x-aiff", "aif aiff aifc",
"aiff");
- addMIMEType((short)433, "audio/x-gsm", "gsm");
- addMIMEType((short)434, "audio/x-mpegurl", "m3u");
- addMIMEType((short)435, "audio/x-ms-wma", "wma");
- addMIMEType((short)436, "audio/x-ms-wax", "wax");
- addMIMEType((short)437, "audio/x-pn-realaudio-plugin");
- addMIMEType((short)438, "audio/x-pn-realaudio", "ra rm ram",
"ra");
- addMIMEType((short)439, "audio/x-realaudio", "ra");
- addMIMEType((short)440, "audio/x-scpls", "pls");
- addMIMEType((short)441, "audio/x-sd2", "sd2");
- addMIMEType((short)442, "audio/x-wav", "wav");
- addMIMEType((short)443, "chemical/x-pdb", "pdb");
- addMIMEType((short)444, "chemical/x-xyz", "xyz");
- addMIMEType((short)445, "image/cgm");
- addMIMEType((short)446, "image/g3fax");
- addMIMEType((short)447, "image/gif", "gif");
- addMIMEType((short)448, "image/ief", "ief");
- addMIMEType((short)449, "image/jpeg", "jpeg jpg jpe", "jpeg");
- addMIMEType((short)450, "image/naplps");
- addMIMEType((short)451, "image/pcx", "pcx");
- addMIMEType((short)452, "image/png", "png");
- addMIMEType((short)453, "image/prs.btif");
- addMIMEType((short)454, "image/prs.pti");
- addMIMEType((short)455, "image/svg+xml", "svg svgz", "svg");
- addMIMEType((short)456, "image/tiff", "tiff tif", "tiff");
- addMIMEType((short)457, "image/vnd.cns.inf2");
- addMIMEType((short)458, "image/vnd.djvu", "djvu djv");
- addMIMEType((short)459, "image/vnd.dwg");
- addMIMEType((short)460, "image/vnd.dxf");
- addMIMEType((short)461, "image/vnd.fastbidsheet");
- addMIMEType((short)462, "image/vnd.fpx");
- addMIMEType((short)463, "image/vnd.fst");
- addMIMEType((short)464, "image/vnd.fujixerox.edmics-mmr");
- addMIMEType((short)465, "image/vnd.fujixerox.edmics-rlc");
- addMIMEType((short)466, "image/vnd.mix");
- addMIMEType((short)467, "image/vnd.net-fpx");
- addMIMEType((short)468, "image/vnd.svf");
- addMIMEType((short)469, "image/vnd.wap.wbmp", "wbmp");
- addMIMEType((short)470, "image/vnd.xiff");
- addMIMEType((short)471, "image/x-cmu-raster", "ras");
- addMIMEType((short)472, "image/x-coreldraw", "cdr");
- addMIMEType((short)473, "image/x-coreldrawpattern", "pat");
- addMIMEType((short)474, "image/x-coreldrawtemplate", "cdt");
- addMIMEType((short)475, "image/x-corelphotopaint", "cpt");
- addMIMEType((short)476, "image/x-icon", "ico");
- addMIMEType((short)477, "image/x-jg", "art");
- addMIMEType((short)478, "image/x-jng", "jng");
- addMIMEType((short)479, "image/x-ms-bmp", "bmp");
- addMIMEType((short)480, "image/x-photoshop", "psd");
- addMIMEType((short)481, "image/x-portable-anymap", "pnm");
- addMIMEType((short)482, "image/x-portable-bitmap", "pbm");
- addMIMEType((short)483, "image/x-portable-graymap", "pgm");
- addMIMEType((short)484, "image/x-portable-pixmap", "ppm");
- addMIMEType((short)485, "image/x-rgb", "rgb");
- addMIMEType((short)486, "image/x-xbitmap", "xbm");
- addMIMEType((short)487, "image/x-xpixmap", "xpm");
- addMIMEType((short)488, "image/x-xwindowdump", "xwd");
- addMIMEType((short)489, "inode/chardevice");
- addMIMEType((short)490, "inode/blockdevice");
- addMIMEType((short)491, "inode/directory-locked");
- addMIMEType((short)492, "inode/directory");
- addMIMEType((short)493, "inode/fifo");
- addMIMEType((short)494, "inode/socket");
- addMIMEType((short)495, "message/delivery-status");
- addMIMEType((short)496, "message/disposition-notification");
- addMIMEType((short)497, "message/external-body");
- addMIMEType((short)498, "message/http");
- addMIMEType((short)499, "message/s-http");
- addMIMEType((short)500, "message/news");
- addMIMEType((short)501, "message/partial");
- addMIMEType((short)502, "message/rfc822");
- addMIMEType((short)503, "model/iges", "igs iges");
- addMIMEType((short)504, "model/mesh", "msh mesh silo");
- addMIMEType((short)505, "model/vnd.dwf");
- addMIMEType((short)506, "model/vnd.flatland.3dml");
- addMIMEType((short)507, "model/vnd.gdl");
- addMIMEType((short)508, "model/vnd.gs-gdl");
- addMIMEType((short)509, "model/vnd.gtw");
- addMIMEType((short)510, "model/vnd.mts");
- addMIMEType((short)511, "model/vnd.vtu");
- addMIMEType((short)512, "model/vrml", "wrl vrml", "vrml");
- addMIMEType((short)513, "multipart/alternative");
- addMIMEType((short)514, "multipart/appledouble");
- addMIMEType((short)515, "multipart/byteranges");
- addMIMEType((short)516, "multipart/digest");
- addMIMEType((short)517, "multipart/encrypted");
- addMIMEType((short)518, "multipart/form-data");
- addMIMEType((short)519, "multipart/header-set");
- addMIMEType((short)520, "multipart/mixed");
- addMIMEType((short)521, "multipart/parallel");
- addMIMEType((short)522, "multipart/related");
- addMIMEType((short)523, "multipart/report");
- addMIMEType((short)524, "multipart/signed");
- addMIMEType((short)525, "multipart/voice-message");
- addMIMEType((short)526, "text/calendar", "ics icz", "ics");
- addMIMEType((short)527, "text/comma-separated-values", "csv");
- addMIMEType((short)528, "text/css", "css");
- addMIMEType((short)529, "text/directory");
- addMIMEType((short)530, "text/english");
- addMIMEType((short)531, "text/enriched");
- addMIMEType((short)532, "text/h323", "323");
- addMIMEType((short)533, "text/html", "htm html shtml", "html");
- addMIMEType((short)534, "text/iuls", "uls");
- addMIMEType((short)535, "text/mathml", "mml");
- addMIMEType((short)536, "text/parityfec");
- addMIMEType((short)537, "text/plain", "asc txt text diff pot",
"txt");
- addMIMEType((short)538, "text/prs.lines.tag");
- addMIMEType((short)539, "text/rfc822-headers");
- addMIMEType((short)540, "text/richtext", "rtx");
- addMIMEType((short)541, "text/rtf", "rtf");
- addMIMEType((short)542, "text/scriptlet", "sct wsc");
- addMIMEType((short)543, "text/t140");
- addMIMEType((short)544, "text/texmacs", "tm ts");
- addMIMEType((short)545, "text/tab-separated-values", "tsv");
- addMIMEType((short)546, "text/uri-list");
- addMIMEType((short)547, "text/vnd.abc");
- addMIMEType((short)548, "text/vnd.curl");
- addMIMEType((short)549, "text/vnd.DMClientScript");
- addMIMEType((short)550, "text/vnd.flatland.3dml");
- addMIMEType((short)551, "text/vnd.fly");
- addMIMEType((short)552, "text/vnd.fmi.flexstor");
- addMIMEType((short)553, "text/vnd.in3d.3dml");
- addMIMEType((short)554, "text/vnd.in3d.spot");
- addMIMEType((short)555, "text/vnd.IPTC.NewsML");
- addMIMEType((short)556, "text/vnd.IPTC.NITF");
- addMIMEType((short)557, "text/vnd.latex-z");
- addMIMEType((short)558, "text/vnd.motorola.reflex");
- addMIMEType((short)559, "text/vnd.ms-mediapackage");
- addMIMEType((short)560, "text/vnd.sun.j2me.app-descriptor",
"jad");
- addMIMEType((short)561, "text/vnd.wap.si");
- addMIMEType((short)562, "text/vnd.wap.sl");
- addMIMEType((short)563, "text/vnd.wap.wml", "wml");
- addMIMEType((short)564, "text/vnd.wap.wmlscript", "wmls");
- addMIMEType((short)565, "text/x-c++hdr", "h++ hpp hxx hh",
"hh");
- addMIMEType((short)566, "text/x-c++src", "c++ cpp cxx cc",
"cc");
- addMIMEType((short)567, "text/x-chdr", "h");
- addMIMEType((short)568, "text/x-crontab");
- addMIMEType((short)569, "text/x-csh", "csh");
- addMIMEType((short)570, "text/x-csrc", "c");
- addMIMEType((short)571, "text/x-java", "java");
- addMIMEType((short)572, "text/x-makefile");
- addMIMEType((short)573, "text/x-moc", "moc");
- addMIMEType((short)574, "text/x-pascal", "p pas", "pas");
- addMIMEType((short)575, "text/x-pcs-gcd", "gcd");
- addMIMEType((short)576, "text/x-perl", "pl pm", "pl");
- addMIMEType((short)577, "text/x-python", "py");
- addMIMEType((short)578, "text/x-server-parsed-html", "shmtl",
"shtml");
- addMIMEType((short)579, "text/x-setext", "etx");
- addMIMEType((short)580, "text/x-sh", "sh");
- addMIMEType((short)581, "text/x-tcl", "tcl tk", "tcl");
- addMIMEType((short)582, "text/x-tex", "tex ltx sty cls", "tex");
- addMIMEType((short)583, "text/x-vcalendar", "vcs");
- addMIMEType((short)584, "text/x-vcard", "vcf");
- addMIMEType((short)585, "video/dl", "dl");
- addMIMEType((short)586, "video/fli", "fli");
- addMIMEType((short)587, "video/gl", "gl");
- addMIMEType((short)588, "video/mpeg", "mpeg mpg mpe", "mpeg");
- addMIMEType((short)589, "video/mp4", "mp4");
- addMIMEType((short)590, "video/quicktime", "qt mov", "mov");
- addMIMEType((short)591, "video/mp4v-es");
- addMIMEType((short)592, "video/parityfec");
- addMIMEType((short)593, "video/pointer");
- addMIMEType((short)594, "video/vnd.fvt");
- addMIMEType((short)595, "video/vnd.motorola.video");
- addMIMEType((short)596, "video/vnd.motorola.videop");
- addMIMEType((short)597, "video/vnd.mpegurl", "mxu");
- addMIMEType((short)598, "video/vnd.mts");
- addMIMEType((short)599,
"video/vnd.nokia.interleaved-multimedia");
- addMIMEType((short)600, "video/vnd.vivo");
- addMIMEType((short)601, "video/x-dv", "dif dv");
- addMIMEType((short)602, "video/x-la-asf", "lsf lsx", "lsf");
- addMIMEType((short)603, "video/x-mng", "mng");
- addMIMEType((short)604, "video/x-ms-asf", "asf asx", "asf");
- addMIMEType((short)605, "video/x-ms-wm", "wm");
- addMIMEType((short)606, "video/x-ms-wmv", "wmv");
- addMIMEType((short)607, "video/x-ms-wmx", "wmx");
- addMIMEType((short)608, "video/x-ms-wvx", "wvx");
- addMIMEType((short)609, "video/x-msvideo", "avi");
- addMIMEType((short)610, "video/x-sgi-movie", "movie");
- addMIMEType((short)611, "x-conference/x-cooltalk", "ice");
- addMIMEType((short)612, "x-world/x-vrml", "vrm vrml wrl",
"vrml");
+ DefaultMIMETypes.addMIMEType((short)0,
"application/activemessage");
+ DefaultMIMETypes.addMIMEType((short)1,
"application/andrew-inset", "ez");
+ DefaultMIMETypes.addMIMEType((short)2, "application/applefile");
+ DefaultMIMETypes.addMIMEType((short)3,
"application/atomicmail");
+ DefaultMIMETypes.addMIMEType((short)4,
"application/batch-SMTP");
+ DefaultMIMETypes.addMIMEType((short)5, "application/beep+xml");
+ DefaultMIMETypes.addMIMEType((short)6, "application/cals-1840");
+ DefaultMIMETypes.addMIMEType((short)7,
"application/commonground");
+ DefaultMIMETypes.addMIMEType((short)8, "application/cu-seeme",
"csm cu");
+ DefaultMIMETypes.addMIMEType((short)9, "application/cybercash");
+ DefaultMIMETypes.addMIMEType((short)10, "application/dca-rft");
+ DefaultMIMETypes.addMIMEType((short)11, "application/dec-dx");
+ DefaultMIMETypes.addMIMEType((short)12,
"application/docbook+xml");
+ DefaultMIMETypes.addMIMEType((short)13, "application/dsptype",
"tsp");
+ DefaultMIMETypes.addMIMEType((short)14, "application/dvcs");
+ DefaultMIMETypes.addMIMEType((short)15,
"application/edi-consent");
+ DefaultMIMETypes.addMIMEType((short)16, "application/edifact");
+ DefaultMIMETypes.addMIMEType((short)17, "application/edi-x12");
+ DefaultMIMETypes.addMIMEType((short)18, "application/eshop");
+ DefaultMIMETypes.addMIMEType((short)19,
"application/font-tdpfr");
+ DefaultMIMETypes.addMIMEType((short)20,
"application/futuresplash", "spl");
+ DefaultMIMETypes.addMIMEType((short)21,
"application/ghostview");
+ DefaultMIMETypes.addMIMEType((short)22, "application/hta",
"hta");
+ DefaultMIMETypes.addMIMEType((short)23, "application/http");
+ DefaultMIMETypes.addMIMEType((short)24,
"application/hyperstudio");
+ DefaultMIMETypes.addMIMEType((short)25, "application/iges");
+ DefaultMIMETypes.addMIMEType((short)26, "application/index");
+ DefaultMIMETypes.addMIMEType((short)27,
"application/index.cmd");
+ DefaultMIMETypes.addMIMEType((short)28,
"application/index.obj");
+ DefaultMIMETypes.addMIMEType((short)29,
"application/index.response");
+ DefaultMIMETypes.addMIMEType((short)30,
"application/index.vnd");
+ DefaultMIMETypes.addMIMEType((short)31, "application/iotp");
+ DefaultMIMETypes.addMIMEType((short)32, "application/ipp");
+ DefaultMIMETypes.addMIMEType((short)33, "application/isup");
+ DefaultMIMETypes.addMIMEType((short)34,
"application/mac-compactpro", "cpt");
+ DefaultMIMETypes.addMIMEType((short)35, "application/marc");
+ DefaultMIMETypes.addMIMEType((short)36,
"application/mac-binhex40", "hqx");
+ DefaultMIMETypes.addMIMEType((short)37,
"application/macwriteii");
+ DefaultMIMETypes.addMIMEType((short)38,
"application/mathematica", "nb");
+ DefaultMIMETypes.addMIMEType((short)39,
"application/mathematica-old");
+ DefaultMIMETypes.addMIMEType((short)40, "application/msaccess",
"mdb");
+ DefaultMIMETypes.addMIMEType((short)41, "application/msword",
"doc dot", "doc");
+ DefaultMIMETypes.addMIMEType((short)42,
"application/news-message-id");
+ DefaultMIMETypes.addMIMEType((short)43,
"application/news-transmission");
+ DefaultMIMETypes.addMIMEType((short)44,
"application/octet-stream", "bin");
+ DefaultMIMETypes.addMIMEType((short)45,
"application/ocsp-request");
+ DefaultMIMETypes.addMIMEType((short)46,
"application/ocsp-response");
+ DefaultMIMETypes.addMIMEType((short)47, "application/oda",
"oda");
+ DefaultMIMETypes.addMIMEType((short)48, "application/ogg",
"ogg");
+ DefaultMIMETypes.addMIMEType((short)49,
"application/parityfec");
+ DefaultMIMETypes.addMIMEType((short)50,
"application/pics-rules", "prf");
+ DefaultMIMETypes.addMIMEType((short)51,
"application/pgp-encrypted");
+ DefaultMIMETypes.addMIMEType((short)52, "application/pgp-keys",
"key");
+ DefaultMIMETypes.addMIMEType((short)53, "application/pdf",
"pdf");
+ DefaultMIMETypes.addMIMEType((short)54,
"application/pgp-signature", "pgp");
+ DefaultMIMETypes.addMIMEType((short)55, "application/pkcs10");
+ DefaultMIMETypes.addMIMEType((short)56,
"application/pkcs7-mime");
+ DefaultMIMETypes.addMIMEType((short)57,
"application/pkcs7-signature");
+ DefaultMIMETypes.addMIMEType((short)58,
"application/pkix-cert");
+ DefaultMIMETypes.addMIMEType((short)59, "application/pkixcmp");
+ DefaultMIMETypes.addMIMEType((short)60, "application/pkix-crl");
+ DefaultMIMETypes.addMIMEType((short)61,
"application/postscript", "ps ai eps", "ps");
+ DefaultMIMETypes.addMIMEType((short)62,
"application/prs.alvestrand.titrax-sheet");
+ DefaultMIMETypes.addMIMEType((short)63, "application/prs.cww");
+ DefaultMIMETypes.addMIMEType((short)64,
"application/prs.nprend");
+ DefaultMIMETypes.addMIMEType((short)65, "application/qsig");
+ DefaultMIMETypes.addMIMEType((short)66, "application/rar",
"rar");
+ DefaultMIMETypes.addMIMEType((short)67, "application/rdf+xml",
"rdf");
+ DefaultMIMETypes.addMIMEType((short)68,
"application/remote-printing");
+ DefaultMIMETypes.addMIMEType((short)69, "application/riscos");
+ DefaultMIMETypes.addMIMEType((short)70, "application/rss+xml",
"rss");
+ DefaultMIMETypes.addMIMEType((short)71, "application/rtf",
"rtf");
+ DefaultMIMETypes.addMIMEType((short)72, "application/sdp");
+ DefaultMIMETypes.addMIMEType((short)73,
"application/set-payment");
+ DefaultMIMETypes.addMIMEType((short)74,
"application/set-payment-initiation");
+ DefaultMIMETypes.addMIMEType((short)75,
"application/set-registration");
+ DefaultMIMETypes.addMIMEType((short)76,
"application/set-registration-initiation");
+ DefaultMIMETypes.addMIMEType((short)77, "application/sgml");
+ DefaultMIMETypes.addMIMEType((short)78,
"application/sgml-open-catalog");
+ DefaultMIMETypes.addMIMEType((short)79, "application/sieve");
+ DefaultMIMETypes.addMIMEType((short)80, "application/slate");
+ DefaultMIMETypes.addMIMEType((short)81, "application/smil",
"smi smil", "smil");
+ DefaultMIMETypes.addMIMEType((short)82,
"application/timestamp-query");
+ DefaultMIMETypes.addMIMEType((short)83,
"application/timestamp-reply");
+ DefaultMIMETypes.addMIMEType((short)84, "application/vemmi");
+ DefaultMIMETypes.addMIMEType((short)85,
"application/whoispp-query");
+ DefaultMIMETypes.addMIMEType((short)86,
"application/whoispp-response");
+ DefaultMIMETypes.addMIMEType((short)87, "application/wita");
+ DefaultMIMETypes.addMIMEType((short)88,
"application/wordperfect5.1", "wp5");
+ DefaultMIMETypes.addMIMEType((short)89, "application/x400-bp");
+ DefaultMIMETypes.addMIMEType((short)90,
"application/xhtml+xml", "xht xhtml", "xhtml");
+ DefaultMIMETypes.addMIMEType((short)91, "application/xml", "xml
xsl", "xml");
+ DefaultMIMETypes.addMIMEType((short)92, "application/xml-dtd");
+ DefaultMIMETypes.addMIMEType((short)93,
"application/xml-external-parsed-entity");
+ DefaultMIMETypes.addMIMEType((short)94, "application/zip",
"zip");
+ DefaultMIMETypes.addMIMEType((short)95,
"application/vnd.3M.Post-it-Notes");
+ DefaultMIMETypes.addMIMEType((short)96,
"application/vnd.accpac.simply.aso");
+ DefaultMIMETypes.addMIMEType((short)97,
"application/vnd.accpac.simply.imp");
+ DefaultMIMETypes.addMIMEType((short)98,
"application/vnd.acucobol");
+ DefaultMIMETypes.addMIMEType((short)99,
"application/vnd.aether.imp");
+ DefaultMIMETypes.addMIMEType((short)100,
"application/vnd.anser-web-certificate-issue-initiation");
+ DefaultMIMETypes.addMIMEType((short)101,
"application/vnd.anser-web-funds-transfer-initiation");
+ DefaultMIMETypes.addMIMEType((short)102,
"application/vnd.audiograph");
+ DefaultMIMETypes.addMIMEType((short)103, "application/vnd.bmi");
+ DefaultMIMETypes.addMIMEType((short)104,
"application/vnd.businessobjects");
+ DefaultMIMETypes.addMIMEType((short)105,
"application/vnd.canon-cpdl");
+ DefaultMIMETypes.addMIMEType((short)106,
"application/vnd.canon-lips");
+ DefaultMIMETypes.addMIMEType((short)107,
"application/vnd.cinderella", "cdy");
+ DefaultMIMETypes.addMIMEType((short)108,
"application/vnd.claymore");
+ DefaultMIMETypes.addMIMEType((short)109,
"application/vnd.commerce-battelle");
+ DefaultMIMETypes.addMIMEType((short)110,
"application/vnd.commonspace");
+ DefaultMIMETypes.addMIMEType((short)111,
"application/vnd.comsocaller");
+ DefaultMIMETypes.addMIMEType((short)112,
"application/vnd.contact.cmsg");
+ DefaultMIMETypes.addMIMEType((short)113,
"application/vnd.cosmocaller");
+ DefaultMIMETypes.addMIMEType((short)114,
"application/vnd.ctc-posml");
+ DefaultMIMETypes.addMIMEType((short)115,
"application/vnd.cups-postscript");
+ DefaultMIMETypes.addMIMEType((short)116,
"application/vnd.cups-raster");
+ DefaultMIMETypes.addMIMEType((short)117,
"application/vnd.cups-raw");
+ DefaultMIMETypes.addMIMEType((short)118,
"application/vnd.cybank");
+ DefaultMIMETypes.addMIMEType((short)119, "application/vnd.dna");
+ DefaultMIMETypes.addMIMEType((short)120,
"application/vnd.dpgraph");
+ DefaultMIMETypes.addMIMEType((short)121, "application/vnd.dxr");
+ DefaultMIMETypes.addMIMEType((short)122,
"application/vnd.ecdis-update");
+ DefaultMIMETypes.addMIMEType((short)123,
"application/vnd.ecowin.chart");
+ DefaultMIMETypes.addMIMEType((short)124,
"application/vnd.ecowin.filerequest");
+ DefaultMIMETypes.addMIMEType((short)125,
"application/vnd.ecowin.fileupdate");
+ DefaultMIMETypes.addMIMEType((short)126,
"application/vnd.ecowin.series");
+ DefaultMIMETypes.addMIMEType((short)127,
"application/vnd.ecowin.seriesrequest");
+ DefaultMIMETypes.addMIMEType((short)128,
"application/vnd.ecowin.seriesupdate");
+ DefaultMIMETypes.addMIMEType((short)129,
"application/vnd.enliven");
+ DefaultMIMETypes.addMIMEType((short)130,
"application/vnd.epson.esf");
+ DefaultMIMETypes.addMIMEType((short)131,
"application/vnd.epson.msf");
+ DefaultMIMETypes.addMIMEType((short)132,
"application/vnd.epson.quickanime");
+ DefaultMIMETypes.addMIMEType((short)133,
"application/vnd.epson.salt");
+ DefaultMIMETypes.addMIMEType((short)134,
"application/vnd.epson.ssf");
+ DefaultMIMETypes.addMIMEType((short)135,
"application/vnd.ericsson.quickcall");
+ DefaultMIMETypes.addMIMEType((short)136,
"application/vnd.eudora.data");
+ DefaultMIMETypes.addMIMEType((short)137, "application/vnd.fdf");
+ DefaultMIMETypes.addMIMEType((short)138,
"application/vnd.ffsns");
+ DefaultMIMETypes.addMIMEType((short)139,
"application/vnd.flographit");
+ DefaultMIMETypes.addMIMEType((short)140,
"application/vnd.framemaker");
+ DefaultMIMETypes.addMIMEType((short)141,
"application/vnd.fsc.weblaunch");
+ DefaultMIMETypes.addMIMEType((short)142,
"application/vnd.fujitsu.oasys");
+ DefaultMIMETypes.addMIMEType((short)143,
"application/vnd.fujitsu.oasys2");
+ DefaultMIMETypes.addMIMEType((short)144,
"application/vnd.fujitsu.oasys3");
+ DefaultMIMETypes.addMIMEType((short)145,
"application/vnd.fujitsu.oasysgp");
+ DefaultMIMETypes.addMIMEType((short)146,
"application/vnd.fujitsu.oasysprs");
+ DefaultMIMETypes.addMIMEType((short)147,
"application/vnd.fujixerox.ddd");
+ DefaultMIMETypes.addMIMEType((short)148,
"application/vnd.fujixerox.docuworks");
+ DefaultMIMETypes.addMIMEType((short)149,
"application/vnd.fujixerox.docuworks.binder");
+ DefaultMIMETypes.addMIMEType((short)150,
"application/vnd.fut-misnet");
+ DefaultMIMETypes.addMIMEType((short)151,
"application/vnd.grafeq");
+ DefaultMIMETypes.addMIMEType((short)152,
"application/vnd.groove-account");
+ DefaultMIMETypes.addMIMEType((short)153,
"application/vnd.groove-identity-message");
+ DefaultMIMETypes.addMIMEType((short)154,
"application/vnd.groove-injector");
+ DefaultMIMETypes.addMIMEType((short)155,
"application/vnd.groove-tool-message");
+ DefaultMIMETypes.addMIMEType((short)156,
"application/vnd.groove-tool-template");
+ DefaultMIMETypes.addMIMEType((short)157,
"application/vnd.groove-vcard");
+ DefaultMIMETypes.addMIMEType((short)158,
"application/vnd.hhe.lesson-player");
+ DefaultMIMETypes.addMIMEType((short)159,
"application/vnd.hp-HPGL");
+ DefaultMIMETypes.addMIMEType((short)160,
"application/vnd.hp-PCL");
+ DefaultMIMETypes.addMIMEType((short)161,
"application/vnd.hp-PCLXL");
+ DefaultMIMETypes.addMIMEType((short)162,
"application/vnd.hp-hpid");
+ DefaultMIMETypes.addMIMEType((short)163,
"application/vnd.hp-hps");
+ DefaultMIMETypes.addMIMEType((short)164,
"application/vnd.httphone");
+ DefaultMIMETypes.addMIMEType((short)165,
"application/vnd.hzn-3d-crossword");
+ DefaultMIMETypes.addMIMEType((short)166,
"application/vnd.ibm.MiniPay");
+ DefaultMIMETypes.addMIMEType((short)167,
"application/vnd.ibm.afplinedata");
+ DefaultMIMETypes.addMIMEType((short)168,
"application/vnd.ibm.modcap");
+ DefaultMIMETypes.addMIMEType((short)169,
"application/vnd.informix-visionary");
+ DefaultMIMETypes.addMIMEType((short)170,
"application/vnd.intercon.formnet");
+ DefaultMIMETypes.addMIMEType((short)171,
"application/vnd.intertrust.digibox");
+ DefaultMIMETypes.addMIMEType((short)172,
"application/vnd.intertrust.nncp");
+ DefaultMIMETypes.addMIMEType((short)173,
"application/vnd.intu.qbo");
+ DefaultMIMETypes.addMIMEType((short)174,
"application/vnd.intu.qfx");
+ DefaultMIMETypes.addMIMEType((short)175,
"application/vnd.irepository.package+xml");
+ DefaultMIMETypes.addMIMEType((short)176,
"application/vnd.is-xpr");
+ DefaultMIMETypes.addMIMEType((short)177,
"application/vnd.japannet-directory-service");
+ DefaultMIMETypes.addMIMEType((short)178,
"application/vnd.japannet-jpnstore-wakeup");
+ DefaultMIMETypes.addMIMEType((short)179,
"application/vnd.japannet-payment-wakeup");
+ DefaultMIMETypes.addMIMEType((short)180,
"application/vnd.japannet-registration");
+ DefaultMIMETypes.addMIMEType((short)181,
"application/vnd.japannet-registration-wakeup");
+ DefaultMIMETypes.addMIMEType((short)182,
"application/vnd.japannet-setstore-wakeup");
+ DefaultMIMETypes.addMIMEType((short)183,
"application/vnd.japannet-verification");
+ DefaultMIMETypes.addMIMEType((short)184,
"application/vnd.japannet-verification-wakeup");
+ DefaultMIMETypes.addMIMEType((short)185,
"application/vnd.koan");
+ DefaultMIMETypes.addMIMEType((short)186,
"application/vnd.lotus-1-2-3");
+ DefaultMIMETypes.addMIMEType((short)187,
"application/vnd.lotus-approach");
+ DefaultMIMETypes.addMIMEType((short)188,
"application/vnd.lotus-freelance");
+ DefaultMIMETypes.addMIMEType((short)189,
"application/vnd.lotus-notes");
+ DefaultMIMETypes.addMIMEType((short)190,
"application/vnd.lotus-organizer");
+ DefaultMIMETypes.addMIMEType((short)191,
"application/vnd.lotus-screencam");
+ DefaultMIMETypes.addMIMEType((short)192,
"application/vnd.lotus-wordpro");
+ DefaultMIMETypes.addMIMEType((short)193, "application/vnd.mcd");
+ DefaultMIMETypes.addMIMEType((short)194,
"application/vnd.mediastation.cdkey");
+ DefaultMIMETypes.addMIMEType((short)195,
"application/vnd.meridian-slingshot");
+ DefaultMIMETypes.addMIMEType((short)196, "application/vnd.mif",
"mif");
+ DefaultMIMETypes.addMIMEType((short)197,
"application/vnd.minisoft-hp3000-save");
+ DefaultMIMETypes.addMIMEType((short)198,
"application/vnd.mitsubishi.misty-guard.trustweb");
+ DefaultMIMETypes.addMIMEType((short)199,
"application/vnd.mobius.daf");
+ DefaultMIMETypes.addMIMEType((short)200,
"application/vnd.mobius.dis");
+ DefaultMIMETypes.addMIMEType((short)201,
"application/vnd.mobius.msl");
+ DefaultMIMETypes.addMIMEType((short)202,
"application/vnd.mobius.plc");
+ DefaultMIMETypes.addMIMEType((short)203,
"application/vnd.mobius.txf");
+ DefaultMIMETypes.addMIMEType((short)204,
"application/vnd.motorola.flexsuite");
+ DefaultMIMETypes.addMIMEType((short)205,
"application/vnd.motorola.flexsuite.adsi");
+ DefaultMIMETypes.addMIMEType((short)206,
"application/vnd.motorola.flexsuite.fis");
+ DefaultMIMETypes.addMIMEType((short)207,
"application/vnd.motorola.flexsuite.gotap");
+ DefaultMIMETypes.addMIMEType((short)208,
"application/vnd.motorola.flexsuite.kmr");
+ DefaultMIMETypes.addMIMEType((short)209,
"application/vnd.motorola.flexsuite.ttc");
+ DefaultMIMETypes.addMIMEType((short)210,
"application/vnd.motorola.flexsuite.wem");
+ DefaultMIMETypes.addMIMEType((short)211,
"application/vnd.mozilla.xul+xml", "xul");
+ DefaultMIMETypes.addMIMEType((short)212,
"application/vnd.ms-artgalry");
+ DefaultMIMETypes.addMIMEType((short)213,
"application/vnd.ms-asf");
+ DefaultMIMETypes.addMIMEType((short)214,
"application/vnd.ms-excel", "xls xlb xlt", "xls");
+ DefaultMIMETypes.addMIMEType((short)215,
"application/vnd.ms-lrm");
+ DefaultMIMETypes.addMIMEType((short)216,
"application/vnd.ms-pki.seccat", "cat");
+ DefaultMIMETypes.addMIMEType((short)217,
"application/vnd.ms-pki.stl", "stl");
+ DefaultMIMETypes.addMIMEType((short)218,
"application/vnd.ms-powerpoint", "ppt pps", "pps");
+ DefaultMIMETypes.addMIMEType((short)219,
"application/vnd.ms-project");
+ DefaultMIMETypes.addMIMEType((short)220,
"application/vnd.ms-tnef");
+ DefaultMIMETypes.addMIMEType((short)221,
"application/vnd.ms-works");
+ DefaultMIMETypes.addMIMEType((short)222,
"application/vnd.mseq");
+ DefaultMIMETypes.addMIMEType((short)223,
"application/vnd.msign");
+ DefaultMIMETypes.addMIMEType((short)224,
"application/vnd.music-niff");
+ DefaultMIMETypes.addMIMEType((short)225,
"application/vnd.musician");
+ DefaultMIMETypes.addMIMEType((short)226,
"application/vnd.netfpx");
+ DefaultMIMETypes.addMIMEType((short)227,
"application/vnd.noblenet-directory");
+ DefaultMIMETypes.addMIMEType((short)228,
"application/vnd.noblenet-sealer");
+ DefaultMIMETypes.addMIMEType((short)229,
"application/vnd.noblenet-web");
+ DefaultMIMETypes.addMIMEType((short)230,
"application/vnd.novadigm.EDM");
+ DefaultMIMETypes.addMIMEType((short)231,
"application/vnd.novadigm.EDX");
+ DefaultMIMETypes.addMIMEType((short)232,
"application/vnd.novadigm.EXT");
+ DefaultMIMETypes.addMIMEType((short)233,
"application/vnd.osa.netdeploy");
+ DefaultMIMETypes.addMIMEType((short)234,
"application/vnd.palm");
+ DefaultMIMETypes.addMIMEType((short)235,
"application/vnd.pg.format");
+ DefaultMIMETypes.addMIMEType((short)236,
"application/vnd.pg.osasli");
+ DefaultMIMETypes.addMIMEType((short)237,
"application/vnd.powerbuilder6");
+ DefaultMIMETypes.addMIMEType((short)238,
"application/vnd.powerbuilder6-s");
+ DefaultMIMETypes.addMIMEType((short)239,
"application/vnd.powerbuilder7");
+ DefaultMIMETypes.addMIMEType((short)240,
"application/vnd.powerbuilder7-s");
+ DefaultMIMETypes.addMIMEType((short)241,
"application/vnd.powerbuilder75");
+ DefaultMIMETypes.addMIMEType((short)242,
"application/vnd.powerbuilder75-s");
+ DefaultMIMETypes.addMIMEType((short)243,
"application/vnd.previewsystems.box");
+ DefaultMIMETypes.addMIMEType((short)244,
"application/vnd.publishare-delta-tree");
+ DefaultMIMETypes.addMIMEType((short)245,
"application/vnd.pvi.ptid1");
+ DefaultMIMETypes.addMIMEType((short)246,
"application/vnd.pwg-xhtml-print+xml");
+ DefaultMIMETypes.addMIMEType((short)247,
"application/vnd.rapid");
+ DefaultMIMETypes.addMIMEType((short)248,
"application/vnd.s3sms");
+ DefaultMIMETypes.addMIMEType((short)249,
"application/vnd.seemail");
+ DefaultMIMETypes.addMIMEType((short)250,
"application/vnd.shana.informed.formdata");
+ DefaultMIMETypes.addMIMEType((short)251,
"application/vnd.shana.informed.formtemplate");
+ DefaultMIMETypes.addMIMEType((short)252,
"application/vnd.shana.informed.interchange");
+ DefaultMIMETypes.addMIMEType((short)253,
"application/vnd.shana.informed.package");
+ DefaultMIMETypes.addMIMEType((short)254,
"application/vnd.smaf", "mmf");
+ DefaultMIMETypes.addMIMEType((short)255,
"application/vnd.sss-cod");
+ DefaultMIMETypes.addMIMEType((short)256,
"application/vnd.sss-dtf");
+ DefaultMIMETypes.addMIMEType((short)257,
"application/vnd.sss-ntf");
+ DefaultMIMETypes.addMIMEType((short)258,
"application/vnd.stardivision.calc", "sdc");
+ DefaultMIMETypes.addMIMEType((short)259,
"application/vnd.stardivision.draw", "sda");
+ DefaultMIMETypes.addMIMEType((short)260,
"application/vnd.stardivision.impress", "sdd sdp");
+ DefaultMIMETypes.addMIMEType((short)261,
"application/vnd.stardivision.math", "smf");
+ DefaultMIMETypes.addMIMEType((short)262,
"application/vnd.stardivision.writer", "sdw vor");
+ DefaultMIMETypes.addMIMEType((short)263,
"application/vnd.stardivision.writer-global", "sgl");
+ DefaultMIMETypes.addMIMEType((short)264,
"application/vnd.street-stream");
+ DefaultMIMETypes.addMIMEType((short)265,
"application/vnd.sun.xml.calc", "sxc");
+ DefaultMIMETypes.addMIMEType((short)266,
"application/vnd.sun.xml.calc.template", "stc");
+ DefaultMIMETypes.addMIMEType((short)267,
"application/vnd.sun.xml.draw", "sxd");
+ DefaultMIMETypes.addMIMEType((short)268,
"application/vnd.sun.xml.draw.template", "std");
+ DefaultMIMETypes.addMIMEType((short)269,
"application/vnd.sun.xml.impress", "sxi");
+ DefaultMIMETypes.addMIMEType((short)270,
"application/vnd.sun.xml.impress.template", "sti");
+ DefaultMIMETypes.addMIMEType((short)271,
"application/vnd.sun.xml.math", "sxm");
+ DefaultMIMETypes.addMIMEType((short)272,
"application/vnd.sun.xml.writer", "sxw");
+ DefaultMIMETypes.addMIMEType((short)273,
"application/vnd.sun.xml.writer.global", "sxg");
+ DefaultMIMETypes.addMIMEType((short)274,
"application/vnd.sun.xml.writer.template", "stw");
+ DefaultMIMETypes.addMIMEType((short)275, "application/vnd.svd");
+ DefaultMIMETypes.addMIMEType((short)276,
"application/vnd.swiftview-ics");
+ DefaultMIMETypes.addMIMEType((short)277,
"application/vnd.symbian.install", "sis");
+ DefaultMIMETypes.addMIMEType((short)278,
"application/vnd.triscape.mxs");
+ DefaultMIMETypes.addMIMEType((short)279,
"application/vnd.trueapp");
+ DefaultMIMETypes.addMIMEType((short)280,
"application/vnd.truedoc");
+ DefaultMIMETypes.addMIMEType((short)281,
"application/vnd.tve-trigger");
+ DefaultMIMETypes.addMIMEType((short)282,
"application/vnd.ufdl");
+ DefaultMIMETypes.addMIMEType((short)283,
"application/vnd.uplanet.alert");
+ DefaultMIMETypes.addMIMEType((short)284,
"application/vnd.uplanet.alert-wbxml");
+ DefaultMIMETypes.addMIMEType((short)285,
"application/vnd.uplanet.bearer-choice");
+ DefaultMIMETypes.addMIMEType((short)286,
"application/vnd.uplanet.bearer-choice-wbxml");
+ DefaultMIMETypes.addMIMEType((short)287,
"application/vnd.uplanet.cacheop");
+ DefaultMIMETypes.addMIMEType((short)288,
"application/vnd.uplanet.cacheop-wbxml");
+ DefaultMIMETypes.addMIMEType((short)289,
"application/vnd.uplanet.channel");
+ DefaultMIMETypes.addMIMEType((short)290,
"application/vnd.uplanet.channel-wbxml");
+ DefaultMIMETypes.addMIMEType((short)291,
"application/vnd.uplanet.list");
+ DefaultMIMETypes.addMIMEType((short)292,
"application/vnd.uplanet.list-wbxml");
+ DefaultMIMETypes.addMIMEType((short)293,
"application/vnd.uplanet.listcmd");
+ DefaultMIMETypes.addMIMEType((short)294,
"application/vnd.uplanet.listcmd-wbxml");
+ DefaultMIMETypes.addMIMEType((short)295,
"application/vnd.uplanet.signal");
+ DefaultMIMETypes.addMIMEType((short)296, "application/vnd.vcx");
+ DefaultMIMETypes.addMIMEType((short)297,
"application/vnd.vectorworks");
+ DefaultMIMETypes.addMIMEType((short)298,
"application/vnd.vidsoft.vidconference");
+ DefaultMIMETypes.addMIMEType((short)299,
"application/vnd.visio", "vsd");
+ DefaultMIMETypes.addMIMEType((short)300,
"application/vnd.vividence.scriptfile");
+ DefaultMIMETypes.addMIMEType((short)301,
"application/vnd.wap.sic");
+ DefaultMIMETypes.addMIMEType((short)302,
"application/vnd.wap.slc");
+ DefaultMIMETypes.addMIMEType((short)303,
"application/vnd.wap.wbxml", "wbxml");
+ DefaultMIMETypes.addMIMEType((short)304,
"application/vnd.wap.wmlc", "wmlc");
+ DefaultMIMETypes.addMIMEType((short)305,
"application/vnd.wap.wmlscriptc", "wmlsc");
+ DefaultMIMETypes.addMIMEType((short)306,
"application/vnd.webturbo");
+ DefaultMIMETypes.addMIMEType((short)307,
"application/vnd.wrq-hp3000-labelled");
+ DefaultMIMETypes.addMIMEType((short)308,
"application/vnd.wt.stf");
+ DefaultMIMETypes.addMIMEType((short)309,
"application/vnd.xara");
+ DefaultMIMETypes.addMIMEType((short)310,
"application/vnd.xfdl");
+ DefaultMIMETypes.addMIMEType((short)311,
"application/vnd.yellowriver-custom-menu");
+ DefaultMIMETypes.addMIMEType((short)312, "application/x-123",
"wk");
+ DefaultMIMETypes.addMIMEType((short)313,
"application/x-apple-diskimage", "dmg");
+ DefaultMIMETypes.addMIMEType((short)314, "application/x-bcpio",
"bcpio");
+ DefaultMIMETypes.addMIMEType((short)315,
"application/x-bittorrent", "torrent");
+ DefaultMIMETypes.addMIMEType((short)316, "application/x-cdf",
"cdf");
+ DefaultMIMETypes.addMIMEType((short)317,
"application/x-cdlink", "vcd");
+ DefaultMIMETypes.addMIMEType((short)318,
"application/x-chess-pgn", "pgn");
+ DefaultMIMETypes.addMIMEType((short)319, "application/x-chm",
"chm");
+ DefaultMIMETypes.addMIMEType((short)320, "application/x-core");
+ DefaultMIMETypes.addMIMEType((short)321, "application/x-cpio",
"cpio");
+ DefaultMIMETypes.addMIMEType((short)322, "application/x-csh",
"csh");
+ DefaultMIMETypes.addMIMEType((short)323,
"application/x-debian-package", "deb");
+ DefaultMIMETypes.addMIMEType((short)324,
"application/x-director", "dcr dir dxr");
+ DefaultMIMETypes.addMIMEType((short)325, "application/x-doom",
"wad");
+ DefaultMIMETypes.addMIMEType((short)326, "application/x-dms",
"dms");
+ DefaultMIMETypes.addMIMEType((short)327, "application/x-dvi",
"dvi");
+ DefaultMIMETypes.addMIMEType((short)328,
"application/x-executable");
+ DefaultMIMETypes.addMIMEType((short)329, "application/x-flac",
"flac");
+ DefaultMIMETypes.addMIMEType((short)330, "application/x-font",
"pfa pfb gsf pcf pcf.Z", "unknown-font-type");
+ DefaultMIMETypes.addMIMEType((short)331,
"application/x-futuresplash", "spl");
+ DefaultMIMETypes.addMIMEType((short)332,
"application/x-gnumeric", "gnumeric");
+ DefaultMIMETypes.addMIMEType((short)333,
"application/x-go-sgf", "sgf");
+ DefaultMIMETypes.addMIMEType((short)334,
"application/x-graphing-calculator", "gcf");
+ DefaultMIMETypes.addMIMEType((short)335, "application/x-gtar",
"gtar tgz taz", "tgz");
+ DefaultMIMETypes.addMIMEType((short)336, "application/x-hdf",
"hdf");
+ DefaultMIMETypes.addMIMEType((short)337,
"application/x-httpd-php", "phtml pht php", "php");
+ DefaultMIMETypes.addMIMEType((short)338,
"application/x-httpd-php-source", "phps");
+ DefaultMIMETypes.addMIMEType((short)339,
"application/x-httpd-php3", "php3");
+ DefaultMIMETypes.addMIMEType((short)340,
"application/x-httpd-php3-preprocessed", "php3p");
+ DefaultMIMETypes.addMIMEType((short)341,
"application/x-httpd-php4", "php4");
+ DefaultMIMETypes.addMIMEType((short)342, "application/x-ica",
"ica");
+ DefaultMIMETypes.addMIMEType((short)343,
"application/x-internet-signup", "ins isp");
+ DefaultMIMETypes.addMIMEType((short)344,
"application/x-iphone", "iii");
+ DefaultMIMETypes.addMIMEType((short)345,
"application/x-java-applet");
+ DefaultMIMETypes.addMIMEType((short)346,
"application/x-java-archive", "jar");
+ DefaultMIMETypes.addMIMEType((short)347,
"application/x-java-bean");
+ DefaultMIMETypes.addMIMEType((short)348,
"application/x-java-jnlp-file", "jnlp");
+ DefaultMIMETypes.addMIMEType((short)349,
"application/x-java-serialized-object", "ser");
+ DefaultMIMETypes.addMIMEType((short)350,
"application/x-java-vm", "class");
+ DefaultMIMETypes.addMIMEType((short)351,
"application/x-javascript", "js");
+ DefaultMIMETypes.addMIMEType((short)352,
"application/x-kdelnk");
+ DefaultMIMETypes.addMIMEType((short)353,
"application/x-kchart", "chrt");
+ DefaultMIMETypes.addMIMEType((short)354,
"application/x-killustrator", "kil");
+ DefaultMIMETypes.addMIMEType((short)355,
"application/x-kpresenter", "kpr kpt");
+ DefaultMIMETypes.addMIMEType((short)356, "application/x-koan",
"skp skd skt skm");
+ DefaultMIMETypes.addMIMEType((short)357,
"application/x-kspread", "ksp");
+ DefaultMIMETypes.addMIMEType((short)358, "application/x-kword",
"kwd kwt", "kwd");
+ DefaultMIMETypes.addMIMEType((short)359, "application/x-latex",
"latex");
+ DefaultMIMETypes.addMIMEType((short)360, "application/x-lha",
"lha");
+ DefaultMIMETypes.addMIMEType((short)361, "application/x-lzh",
"lzh");
+ DefaultMIMETypes.addMIMEType((short)362, "application/x-lzx",
"lzx");
+ DefaultMIMETypes.addMIMEType((short)363, "application/x-maker",
"frm maker frame fm fb book fbdoc");
+ DefaultMIMETypes.addMIMEType((short)364, "application/x-mif",
"mif");
+ DefaultMIMETypes.addMIMEType((short)365,
"application/x-ms-wmz", "wmz");
+ DefaultMIMETypes.addMIMEType((short)366,
"application/x-ms-wmd", "wmd");
+ DefaultMIMETypes.addMIMEType((short)367,
"application/x-msdos-program", "com exe bat dll", "exe");
+ DefaultMIMETypes.addMIMEType((short)368, "application/x-msi",
"msi");
+ DefaultMIMETypes.addMIMEType((short)369,
"application/x-netcdf", "nc");
+ DefaultMIMETypes.addMIMEType((short)370,
"application/x-ns-proxy-autoconfig", "pac");
+ DefaultMIMETypes.addMIMEType((short)371, "application/x-nwc",
"nwc");
+ DefaultMIMETypes.addMIMEType((short)372,
"application/x-object", "o");
+ DefaultMIMETypes.addMIMEType((short)373,
"application/x-oz-application", "oza");
+ DefaultMIMETypes.addMIMEType((short)374,
"application/x-pkcs7-certreqresp", "p7r");
+ DefaultMIMETypes.addMIMEType((short)375,
"application/x-pkcs7-crl", "crl");
+ DefaultMIMETypes.addMIMEType((short)376,
"application/x-python-code", "pyc pyo", "unknown-pyc-pyo");
+ DefaultMIMETypes.addMIMEType((short)377,
"application/x-quicktimeplayer", "qtl");
+ DefaultMIMETypes.addMIMEType((short)378,
"application/x-redhat-package-manager", "rpm");
+ DefaultMIMETypes.addMIMEType((short)379, "application/x-rx");
+ DefaultMIMETypes.addMIMEType((short)380, "application/x-sh");
+ DefaultMIMETypes.addMIMEType((short)381, "application/x-shar",
"shar");
+ DefaultMIMETypes.addMIMEType((short)382,
"application/x-shellscript");
+ DefaultMIMETypes.addMIMEType((short)383,
"application/x-shockwave-flash", "swf swfl", "swf");
+ DefaultMIMETypes.addMIMEType((short)384, "application/x-sh",
"sh");
+ DefaultMIMETypes.addMIMEType((short)385,
"application/x-stuffit", "sit");
+ DefaultMIMETypes.addMIMEType((short)386,
"application/x-sv4cpio", "sv4cpio");
+ DefaultMIMETypes.addMIMEType((short)387,
"application/x-sv4crc", "sv4crc");
+ DefaultMIMETypes.addMIMEType((short)388, "application/x-tar",
"tar");
+ DefaultMIMETypes.addMIMEType((short)389, "application/x-tcl",
"tcl");
+ DefaultMIMETypes.addMIMEType((short)390,
"application/x-tex-gf", "gf");
+ DefaultMIMETypes.addMIMEType((short)391,
"application/x-tex-pk", "pk");
+ DefaultMIMETypes.addMIMEType((short)392,
"application/x-texinfo", "texinfo texi", "texi");
+ DefaultMIMETypes.addMIMEType((short)393, "application/x-trash",
"~ % bak old sik");
+ DefaultMIMETypes.addMIMEType((short)394, "application/x-troff",
"t tr roff");
+ DefaultMIMETypes.addMIMEType((short)395,
"application/x-troff-man", "man");
+ DefaultMIMETypes.addMIMEType((short)396,
"application/x-troff-me", "me");
+ DefaultMIMETypes.addMIMEType((short)397,
"application/x-troff-ms", "ms");
+ DefaultMIMETypes.addMIMEType((short)398, "application/x-ustar",
"ustar");
+ DefaultMIMETypes.addMIMEType((short)399,
"application/x-videolan");
+ DefaultMIMETypes.addMIMEType((short)400,
"application/x-wais-source", "src");
+ DefaultMIMETypes.addMIMEType((short)401, "application/x-wingz",
"wz");
+ DefaultMIMETypes.addMIMEType((short)402,
"application/x-x509-ca-cert", "crt");
+ DefaultMIMETypes.addMIMEType((short)403, "application/x-xcf",
"xcf");
+ DefaultMIMETypes.addMIMEType((short)404, "application/x-xfig",
"fig");
+ DefaultMIMETypes.addMIMEType((short)405, "audio/32kadpcm");
+ DefaultMIMETypes.addMIMEType((short)406, "audio/basic", "au
snd", "au");
+ DefaultMIMETypes.addMIMEType((short)407, "audio/g.722.1");
+ DefaultMIMETypes.addMIMEType((short)408, "audio/l16");
+ DefaultMIMETypes.addMIMEType((short)409, "audio/midi", "mid
midi kar", "mid");
+ DefaultMIMETypes.addMIMEType((short)410, "audio/mp4a-latm");
+ DefaultMIMETypes.addMIMEType((short)411, "audio/mpa-robust");
+ DefaultMIMETypes.addMIMEType((short)412, "audio/mpeg", "mpga
mpega mp2 mp3 m4a", "mp3");
+ DefaultMIMETypes.addMIMEType((short)413, "audio/mpegurl",
"m3u");
+ DefaultMIMETypes.addMIMEType((short)414, "audio/parityfec");
+ DefaultMIMETypes.addMIMEType((short)415, "audio/prs.sid",
"sid");
+ DefaultMIMETypes.addMIMEType((short)416,
"audio/telephone-event");
+ DefaultMIMETypes.addMIMEType((short)417, "audio/tone");
+ DefaultMIMETypes.addMIMEType((short)418, "audio/vnd.cisco.nse");
+ DefaultMIMETypes.addMIMEType((short)419, "audio/vnd.cns.anp1");
+ DefaultMIMETypes.addMIMEType((short)420, "audio/vnd.cns.inf1");
+ DefaultMIMETypes.addMIMEType((short)421,
"audio/vnd.digital-winds");
+ DefaultMIMETypes.addMIMEType((short)422,
"audio/vnd.everad.plj");
+ DefaultMIMETypes.addMIMEType((short)423,
"audio/vnd.lucent.voice");
+ DefaultMIMETypes.addMIMEType((short)424,
"audio/vnd.nortel.vbk");
+ DefaultMIMETypes.addMIMEType((short)425,
"audio/vnd.nuera.ecelp4800");
+ DefaultMIMETypes.addMIMEType((short)426,
"audio/vnd.nuera.ecelp7470");
+ DefaultMIMETypes.addMIMEType((short)427,
"audio/vnd.nuera.ecelp9600");
+ DefaultMIMETypes.addMIMEType((short)428, "audio/vnd.octel.sbc");
+ DefaultMIMETypes.addMIMEType((short)429, "audio/vnd.qcelp");
+ DefaultMIMETypes.addMIMEType((short)430,
"audio/vnd.rhetorex.32kadpcm");
+ DefaultMIMETypes.addMIMEType((short)431, "audio/vnd.vmx.cvsd");
+ DefaultMIMETypes.addMIMEType((short)432, "audio/x-aiff", "aif
aiff aifc", "aiff");
+ DefaultMIMETypes.addMIMEType((short)433, "audio/x-gsm", "gsm");
+ DefaultMIMETypes.addMIMEType((short)434, "audio/x-mpegurl",
"m3u");
+ DefaultMIMETypes.addMIMEType((short)435, "audio/x-ms-wma",
"wma");
+ DefaultMIMETypes.addMIMEType((short)436, "audio/x-ms-wax",
"wax");
+ DefaultMIMETypes.addMIMEType((short)437,
"audio/x-pn-realaudio-plugin");
+ DefaultMIMETypes.addMIMEType((short)438,
"audio/x-pn-realaudio", "ra rm ram", "ra");
+ DefaultMIMETypes.addMIMEType((short)439, "audio/x-realaudio",
"ra");
+ DefaultMIMETypes.addMIMEType((short)440, "audio/x-scpls",
"pls");
+ DefaultMIMETypes.addMIMEType((short)441, "audio/x-sd2", "sd2");
+ DefaultMIMETypes.addMIMEType((short)442, "audio/x-wav", "wav");
+ DefaultMIMETypes.addMIMEType((short)443, "chemical/x-pdb",
"pdb");
+ DefaultMIMETypes.addMIMEType((short)444, "chemical/x-xyz",
"xyz");
+ DefaultMIMETypes.addMIMEType((short)445, "image/cgm");
+ DefaultMIMETypes.addMIMEType((short)446, "image/g3fax");
+ DefaultMIMETypes.addMIMEType((short)447, "image/gif", "gif");
+ DefaultMIMETypes.addMIMEType((short)448, "image/ief", "ief");
+ DefaultMIMETypes.addMIMEType((short)449, "image/jpeg", "jpeg
jpg jpe", "jpeg");
+ DefaultMIMETypes.addMIMEType((short)450, "image/naplps");
+ DefaultMIMETypes.addMIMEType((short)451, "image/pcx", "pcx");
+ DefaultMIMETypes.addMIMEType((short)452, "image/png", "png");
+ DefaultMIMETypes.addMIMEType((short)453, "image/prs.btif");
+ DefaultMIMETypes.addMIMEType((short)454, "image/prs.pti");
+ DefaultMIMETypes.addMIMEType((short)455, "image/svg+xml", "svg
svgz", "svg");
+ DefaultMIMETypes.addMIMEType((short)456, "image/tiff", "tiff
tif", "tiff");
+ DefaultMIMETypes.addMIMEType((short)457, "image/vnd.cns.inf2");
+ DefaultMIMETypes.addMIMEType((short)458, "image/vnd.djvu",
"djvu djv");
+ DefaultMIMETypes.addMIMEType((short)459, "image/vnd.dwg");
+ DefaultMIMETypes.addMIMEType((short)460, "image/vnd.dxf");
+ DefaultMIMETypes.addMIMEType((short)461,
"image/vnd.fastbidsheet");
+ DefaultMIMETypes.addMIMEType((short)462, "image/vnd.fpx");
+ DefaultMIMETypes.addMIMEType((short)463, "image/vnd.fst");
+ DefaultMIMETypes.addMIMEType((short)464,
"image/vnd.fujixerox.edmics-mmr");
+ DefaultMIMETypes.addMIMEType((short)465,
"image/vnd.fujixerox.edmics-rlc");
+ DefaultMIMETypes.addMIMEType((short)466, "image/vnd.mix");
+ DefaultMIMETypes.addMIMEType((short)467, "image/vnd.net-fpx");
+ DefaultMIMETypes.addMIMEType((short)468, "image/vnd.svf");
+ DefaultMIMETypes.addMIMEType((short)469, "image/vnd.wap.wbmp",
"wbmp");
+ DefaultMIMETypes.addMIMEType((short)470, "image/vnd.xiff");
+ DefaultMIMETypes.addMIMEType((short)471, "image/x-cmu-raster",
"ras");
+ DefaultMIMETypes.addMIMEType((short)472, "image/x-coreldraw",
"cdr");
+ DefaultMIMETypes.addMIMEType((short)473,
"image/x-coreldrawpattern", "pat");
+ DefaultMIMETypes.addMIMEType((short)474,
"image/x-coreldrawtemplate", "cdt");
+ DefaultMIMETypes.addMIMEType((short)475,
"image/x-corelphotopaint", "cpt");
+ DefaultMIMETypes.addMIMEType((short)476, "image/x-icon", "ico");
+ DefaultMIMETypes.addMIMEType((short)477, "image/x-jg", "art");
+ DefaultMIMETypes.addMIMEType((short)478, "image/x-jng", "jng");
+ DefaultMIMETypes.addMIMEType((short)479, "image/x-ms-bmp",
"bmp");
+ DefaultMIMETypes.addMIMEType((short)480, "image/x-photoshop",
"psd");
+ DefaultMIMETypes.addMIMEType((short)481,
"image/x-portable-anymap", "pnm");
+ DefaultMIMETypes.addMIMEType((short)482,
"image/x-portable-bitmap", "pbm");
+ DefaultMIMETypes.addMIMEType((short)483,
"image/x-portable-graymap", "pgm");
+ DefaultMIMETypes.addMIMEType((short)484,
"image/x-portable-pixmap", "ppm");
+ DefaultMIMETypes.addMIMEType((short)485, "image/x-rgb", "rgb");
+ DefaultMIMETypes.addMIMEType((short)486, "image/x-xbitmap",
"xbm");
+ DefaultMIMETypes.addMIMEType((short)487, "image/x-xpixmap",
"xpm");
+ DefaultMIMETypes.addMIMEType((short)488, "image/x-xwindowdump",
"xwd");
+ DefaultMIMETypes.addMIMEType((short)489, "inode/chardevice");
+ DefaultMIMETypes.addMIMEType((short)490, "inode/blockdevice");
+ DefaultMIMETypes.addMIMEType((short)491,
"inode/directory-locked");
+ DefaultMIMETypes.addMIMEType((short)492, "inode/directory");
+ DefaultMIMETypes.addMIMEType((short)493, "inode/fifo");
+ DefaultMIMETypes.addMIMEType((short)494, "inode/socket");
+ DefaultMIMETypes.addMIMEType((short)495,
"message/delivery-status");
+ DefaultMIMETypes.addMIMEType((short)496,
"message/disposition-notification");
+ DefaultMIMETypes.addMIMEType((short)497,
"message/external-body");
+ DefaultMIMETypes.addMIMEType((short)498, "message/http");
+ DefaultMIMETypes.addMIMEType((short)499, "message/s-http");
+ DefaultMIMETypes.addMIMEType((short)500, "message/news");
+ DefaultMIMETypes.addMIMEType((short)501, "message/partial");
+ DefaultMIMETypes.addMIMEType((short)502, "message/rfc822");
+ DefaultMIMETypes.addMIMEType((short)503, "model/iges", "igs
iges");
+ DefaultMIMETypes.addMIMEType((short)504, "model/mesh", "msh
mesh silo");
+ DefaultMIMETypes.addMIMEType((short)505, "model/vnd.dwf");
+ DefaultMIMETypes.addMIMEType((short)506,
"model/vnd.flatland.3dml");
+ DefaultMIMETypes.addMIMEType((short)507, "model/vnd.gdl");
+ DefaultMIMETypes.addMIMEType((short)508, "model/vnd.gs-gdl");
+ DefaultMIMETypes.addMIMEType((short)509, "model/vnd.gtw");
+ DefaultMIMETypes.addMIMEType((short)510, "model/vnd.mts");
+ DefaultMIMETypes.addMIMEType((short)511, "model/vnd.vtu");
+ DefaultMIMETypes.addMIMEType((short)512, "model/vrml", "wrl
vrml", "vrml");
+ DefaultMIMETypes.addMIMEType((short)513,
"multipart/alternative");
+ DefaultMIMETypes.addMIMEType((short)514,
"multipart/appledouble");
+ DefaultMIMETypes.addMIMEType((short)515,
"multipart/byteranges");
+ DefaultMIMETypes.addMIMEType((short)516, "multipart/digest");
+ DefaultMIMETypes.addMIMEType((short)517, "multipart/encrypted");
+ DefaultMIMETypes.addMIMEType((short)518, "multipart/form-data");
+ DefaultMIMETypes.addMIMEType((short)519,
"multipart/header-set");
+ DefaultMIMETypes.addMIMEType((short)520, "multipart/mixed");
+ DefaultMIMETypes.addMIMEType((short)521, "multipart/parallel");
+ DefaultMIMETypes.addMIMEType((short)522, "multipart/related");
+ DefaultMIMETypes.addMIMEType((short)523, "multipart/report");
+ DefaultMIMETypes.addMIMEType((short)524, "multipart/signed");
+ DefaultMIMETypes.addMIMEType((short)525,
"multipart/voice-message");
+ DefaultMIMETypes.addMIMEType((short)526, "text/calendar", "ics
icz", "ics");
+ DefaultMIMETypes.addMIMEType((short)527,
"text/comma-separated-values", "csv");
+ DefaultMIMETypes.addMIMEType((short)528, "text/css", "css");
+ DefaultMIMETypes.addMIMEType((short)529, "text/directory");
+ DefaultMIMETypes.addMIMEType((short)530, "text/english");
+ DefaultMIMETypes.addMIMEType((short)531, "text/enriched");
+ DefaultMIMETypes.addMIMEType((short)532, "text/h323", "323");
+ DefaultMIMETypes.addMIMEType((short)533, "text/html", "htm html
shtml", "html");
+ DefaultMIMETypes.addMIMEType((short)534, "text/iuls", "uls");
+ DefaultMIMETypes.addMIMEType((short)535, "text/mathml", "mml");
+ DefaultMIMETypes.addMIMEType((short)536, "text/parityfec");
+ DefaultMIMETypes.addMIMEType((short)537, "text/plain", "asc txt
text diff pot", "txt");
+ DefaultMIMETypes.addMIMEType((short)538, "text/prs.lines.tag");
+ DefaultMIMETypes.addMIMEType((short)539, "text/rfc822-headers");
+ DefaultMIMETypes.addMIMEType((short)540, "text/richtext",
"rtx");
+ DefaultMIMETypes.addMIMEType((short)541, "text/rtf", "rtf");
+ DefaultMIMETypes.addMIMEType((short)542, "text/scriptlet", "sct
wsc");
+ DefaultMIMETypes.addMIMEType((short)543, "text/t140");
+ DefaultMIMETypes.addMIMEType((short)544, "text/texmacs", "tm
ts");
+ DefaultMIMETypes.addMIMEType((short)545,
"text/tab-separated-values", "tsv");
+ DefaultMIMETypes.addMIMEType((short)546, "text/uri-list");
+ DefaultMIMETypes.addMIMEType((short)547, "text/vnd.abc");
+ DefaultMIMETypes.addMIMEType((short)548, "text/vnd.curl");
+ DefaultMIMETypes.addMIMEType((short)549,
"text/vnd.DMClientScript");
+ DefaultMIMETypes.addMIMEType((short)550,
"text/vnd.flatland.3dml");
+ DefaultMIMETypes.addMIMEType((short)551, "text/vnd.fly");
+ DefaultMIMETypes.addMIMEType((short)552,
"text/vnd.fmi.flexstor");
+ DefaultMIMETypes.addMIMEType((short)553, "text/vnd.in3d.3dml");
+ DefaultMIMETypes.addMIMEType((short)554, "text/vnd.in3d.spot");
+ DefaultMIMETypes.addMIMEType((short)555,
"text/vnd.IPTC.NewsML");
+ DefaultMIMETypes.addMIMEType((short)556, "text/vnd.IPTC.NITF");
+ DefaultMIMETypes.addMIMEType((short)557, "text/vnd.latex-z");
+ DefaultMIMETypes.addMIMEType((short)558,
"text/vnd.motorola.reflex");
+ DefaultMIMETypes.addMIMEType((short)559,
"text/vnd.ms-mediapackage");
+ DefaultMIMETypes.addMIMEType((short)560,
"text/vnd.sun.j2me.app-descriptor", "jad");
+ DefaultMIMETypes.addMIMEType((short)561, "text/vnd.wap.si");
+ DefaultMIMETypes.addMIMEType((short)562, "text/vnd.wap.sl");
+ DefaultMIMETypes.addMIMEType((short)563, "text/vnd.wap.wml",
"wml");
+ DefaultMIMETypes.addMIMEType((short)564,
"text/vnd.wap.wmlscript", "wmls");
+ DefaultMIMETypes.addMIMEType((short)565, "text/x-c++hdr", "h++
hpp hxx hh", "hh");
+ DefaultMIMETypes.addMIMEType((short)566, "text/x-c++src", "c++
cpp cxx cc", "cc");
+ DefaultMIMETypes.addMIMEType((short)567, "text/x-chdr", "h");
+ DefaultMIMETypes.addMIMEType((short)568, "text/x-crontab");
+ DefaultMIMETypes.addMIMEType((short)569, "text/x-csh", "csh");
+ DefaultMIMETypes.addMIMEType((short)570, "text/x-csrc", "c");
+ DefaultMIMETypes.addMIMEType((short)571, "text/x-java", "java");
+ DefaultMIMETypes.addMIMEType((short)572, "text/x-makefile");
+ DefaultMIMETypes.addMIMEType((short)573, "text/x-moc", "moc");
+ DefaultMIMETypes.addMIMEType((short)574, "text/x-pascal", "p
pas", "pas");
+ DefaultMIMETypes.addMIMEType((short)575, "text/x-pcs-gcd",
"gcd");
+ DefaultMIMETypes.addMIMEType((short)576, "text/x-perl", "pl
pm", "pl");
+ DefaultMIMETypes.addMIMEType((short)577, "text/x-python", "py");
+ DefaultMIMETypes.addMIMEType((short)578,
"text/x-server-parsed-html", "shmtl", "shtml");
+ DefaultMIMETypes.addMIMEType((short)579, "text/x-setext",
"etx");
+ DefaultMIMETypes.addMIMEType((short)580, "text/x-sh", "sh");
+ DefaultMIMETypes.addMIMEType((short)581, "text/x-tcl", "tcl
tk", "tcl");
+ DefaultMIMETypes.addMIMEType((short)582, "text/x-tex", "tex ltx
sty cls", "tex");
+ DefaultMIMETypes.addMIMEType((short)583, "text/x-vcalendar",
"vcs");
+ DefaultMIMETypes.addMIMEType((short)584, "text/x-vcard", "vcf");
+ DefaultMIMETypes.addMIMEType((short)585, "video/dl", "dl");
+ DefaultMIMETypes.addMIMEType((short)586, "video/fli", "fli");
+ DefaultMIMETypes.addMIMEType((short)587, "video/gl", "gl");
+ DefaultMIMETypes.addMIMEType((short)588, "video/mpeg", "mpeg
mpg mpe", "mpeg");
+ DefaultMIMETypes.addMIMEType((short)589, "video/mp4", "mp4");
+ DefaultMIMETypes.addMIMEType((short)590, "video/quicktime", "qt
mov", "mov");
+ DefaultMIMETypes.addMIMEType((short)591, "video/mp4v-es");
+ DefaultMIMETypes.addMIMEType((short)592, "video/parityfec");
+ DefaultMIMETypes.addMIMEType((short)593, "video/pointer");
+ DefaultMIMETypes.addMIMEType((short)594, "video/vnd.fvt");
+ DefaultMIMETypes.addMIMEType((short)595,
"video/vnd.motorola.video");
+ DefaultMIMETypes.addMIMEType((short)596,
"video/vnd.motorola.videop");
+ DefaultMIMETypes.addMIMEType((short)597, "video/vnd.mpegurl",
"mxu");
+ DefaultMIMETypes.addMIMEType((short)598, "video/vnd.mts");
+ DefaultMIMETypes.addMIMEType((short)599,
"video/vnd.nokia.interleaved-multimedia");
+ DefaultMIMETypes.addMIMEType((short)600, "video/vnd.vivo");
+ DefaultMIMETypes.addMIMEType((short)601, "video/x-dv", "dif
dv");
+ DefaultMIMETypes.addMIMEType((short)602, "video/x-la-asf", "lsf
lsx", "lsf");
+ DefaultMIMETypes.addMIMEType((short)603, "video/x-mng", "mng");
+ DefaultMIMETypes.addMIMEType((short)604, "video/x-ms-asf", "asf
asx", "asf");
+ DefaultMIMETypes.addMIMEType((short)605, "video/x-ms-wm", "wm");
+ DefaultMIMETypes.addMIMEType((short)606, "video/x-ms-wmv",
"wmv");
+ DefaultMIMETypes.addMIMEType((short)607, "video/x-ms-wmx",
"wmx");
+ DefaultMIMETypes.addMIMEType((short)608, "video/x-ms-wvx",
"wvx");
+ DefaultMIMETypes.addMIMEType((short)609, "video/x-msvideo",
"avi");
+ DefaultMIMETypes.addMIMEType((short)610, "video/x-sgi-movie",
"movie");
+ DefaultMIMETypes.addMIMEType((short)611,
"x-conference/x-cooltalk", "ice");
+ DefaultMIMETypes.addMIMEType((short)612, "x-world/x-vrml", "vrm
vrml wrl", "vrml");
}
/** Guess a MIME type from a filename */
- public synchronized static String guessMIMEType(String arg) {
- int x = arg.lastIndexOf('.');
+ public synchronized static String guessMIMEType(final String arg) {
+ final int x = arg.lastIndexOf('.');
if((x == -1) || (x == arg.length()-1))
- return DEFAULT_MIME_TYPE;
- String ext = arg.substring(x+1).toLowerCase();
- Short mimeIndexOb = (Short) mimeTypesByExtension.get(ext);
- if(mimeIndexOb != null) {
- return (String)
mimeTypesByNumber.get(mimeIndexOb.intValue());
- } else return DEFAULT_MIME_TYPE;
+ return DefaultMIMETypes.DEFAULT_MIME_TYPE;
+ final String ext = arg.substring(x+1).toLowerCase();
+ final Short mimeIndexOb = (Short)
DefaultMIMETypes.mimeTypesByExtension.get(ext);
+ if(mimeIndexOb != null)
+ return (String)
DefaultMIMETypes.mimeTypesByNumber.get(mimeIndexOb.intValue());
+ else return DefaultMIMETypes.DEFAULT_MIME_TYPE;
}
- public synchronized static String getExtension(String type) {
- short typeNumber = byName(type);
+ public synchronized static String getExtension(final String type) {
+ final short typeNumber = DefaultMIMETypes.byName(type);
if(typeNumber < 0) return null;
- return (String) primaryExtensionByMimeNumber.get(new
Short(typeNumber));
+ return (String)
DefaultMIMETypes.primaryExtensionByMimeNumber.get(new Short(typeNumber));
}
- public synchronized static boolean isValidExt(String expectedMimeType,
String oldExt) {
- Short s = (Short) mimeTypesByExtension.get(oldExt);
+ public synchronized static boolean isValidExt(final String
expectedMimeType, final String oldExt) {
+ final Short s = (Short)
DefaultMIMETypes.mimeTypesByExtension.get(oldExt);
if(s == null) return false;
- String type = byNumber(s.shortValue());
+ final String type = DefaultMIMETypes.byNumber(s.shortValue());
return type.equals(expectedMimeType);
}
public synchronized static Vector getAllMIMETypes() {
- return mimeTypesByNumber;
+ return DefaultMIMETypes.mimeTypesByNumber;
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/insertPlugin/InsertPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/insertPlugin/InsertPanel.java
2006-12-06 18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/insertPlugin/InsertPanel.java
2006-12-06 18:21:00 UTC (rev 11273)
@@ -1,31 +1,34 @@
package thaw.plugins.insertPlugin;
-import java.awt.GridLayout;
import java.awt.BorderLayout;
+import java.awt.Dimension;
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 java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-import javax.swing.JFileChooser;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
import java.io.File;
-import java.awt.event.ItemListener;
-import java.awt.event.ItemEvent;
+import java.util.Iterator;
+import java.util.Observable;
import java.util.Observer;
-import java.util.Observable;
import java.util.Vector;
-import java.util.Iterator;
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JTextField;
-import thaw.core.*;
+import thaw.core.FileChooser;
+import thaw.core.I18n;
+import thaw.core.Logger;
+import thaw.core.WarningWindow;
+import thaw.fcp.FCPClientPut;
import thaw.plugins.InsertPlugin;
-import thaw.fcp.*;
@@ -77,19 +80,19 @@
private boolean advancedMode = false;
- public InsertPanel(InsertPlugin insertPlugin, boolean advancedMode) {
+ public InsertPanel(final InsertPlugin insertPlugin, final boolean
advancedMode) {
this.insertPlugin = insertPlugin;
this.advancedMode = advancedMode;
- this.globalPanel = new JPanel();
+ globalPanel = new JPanel();
- this.mainPanel = new JPanel();
- this.mainPanel.setLayout(new BorderLayout(10, 10));
+ mainPanel = new JPanel();
+ mainPanel.setLayout(new BorderLayout(10, 10));
if(advancedMode) {
- this.subPanel = new JPanel();
- this.subPanel.setLayout(new GridLayout(3,2, 20, 20));
+ subPanel = new JPanel();
+ subPanel.setLayout(new GridLayout(3,2, 20, 20));
}
@@ -97,42 +100,42 @@
JPanel subSubPanel = new JPanel();
subSubPanel.setLayout(new GridLayout(3, 1));
- this.browseLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.filesToInsert"));
- subSubPanel.add(this.browseLabel);
- this.selectedFiles = new JTextField(20);
- this.selectedFiles.setEditable(true);
- subSubPanel.add(this.selectedFiles);
- this.browseButton = new
JButton(I18n.getMessage("thaw.common.selectFiles"));
- this.browseButton.addActionListener(this);
- subSubPanel.add(this.browseButton);
+ browseLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.filesToInsert"));
+ subSubPanel.add(browseLabel);
+ selectedFiles = new JTextField(20);
+ selectedFiles.setEditable(true);
+ subSubPanel.add(selectedFiles);
+ browseButton = new
JButton(I18n.getMessage("thaw.common.selectFiles"));
+ browseButton.addActionListener(this);
+ subSubPanel.add(browseButton);
if(advancedMode)
- this.subPanel.add(subSubPanel);
+ subPanel.add(subSubPanel);
else
- this.mainPanel.add(subSubPanel, BorderLayout.CENTER);
+ mainPanel.add(subSubPanel, BorderLayout.CENTER);
// KEY TYPE SELECTION
subSubPanel = new JPanel();
subSubPanel.setLayout(new GridLayout(4, 1));
- this.selectKeyLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.selectKey"));
- subSubPanel.add(this.selectKeyLabel);
- this.keyRadioButtons = new JRadioButton[3];
- this.keyRadioButtons[0] = new
JRadioButton(I18n.getMessage("thaw.plugin.insert.CHK"));
- this.keyRadioButtons[0].setSelected(true);
- this.keyType = 0;
- this.keyRadioButtons[1] = new
JRadioButton(I18n.getMessage("thaw.plugin.insert.KSK"));
- this.keyRadioButtons[2] = new
JRadioButton(I18n.getMessage("thaw.plugin.insert.SSK"));
- this.keyRadioGroup = new ButtonGroup();
- for(int i = 0 ; i < this.keyRadioButtons.length ; i++) {
- this.keyRadioButtons[i].addItemListener(this);
- this.keyRadioGroup.add(this.keyRadioButtons[i]);
- subSubPanel.add(this.keyRadioButtons[i]);
+ 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.CHK"));
+ keyRadioButtons[0].setSelected(true);
+ keyType = 0;
+ keyRadioButtons[1] = new
JRadioButton(I18n.getMessage("thaw.plugin.insert.KSK"));
+ keyRadioButtons[2] = new
JRadioButton(I18n.getMessage("thaw.plugin.insert.SSK"));
+ keyRadioGroup = new ButtonGroup();
+ for(int i = 0 ; i < keyRadioButtons.length ; i++) {
+ keyRadioButtons[i].addItemListener(this);
+ keyRadioGroup.add(keyRadioButtons[i]);
+ subSubPanel.add(keyRadioButtons[i]);
}
if(advancedMode)
- this.subPanel.add(subSubPanel);
+ subPanel.add(subSubPanel);
/* GLOBAL */
@@ -140,24 +143,24 @@
subSubPanel = new JPanel();
subSubPanel.setLayout(new GridLayout(4, 1));
- this.globalStr = new String[] {
+ globalStr = new String[] {
I18n.getMessage("thaw.common.true"),
I18n.getMessage("thaw.common.false"),
};
- this.globalLabel = new
JLabel(I18n.getMessage("thaw.common.globalQueue"));
- subSubPanel.add(this.globalLabel);
- this.globalSelecter = new JComboBox(this.globalStr);
-
this.globalSelecter.setSelectedItem(I18n.getMessage("thaw.common.true"));
- subSubPanel.add(this.globalSelecter);
+ globalLabel = new
JLabel(I18n.getMessage("thaw.common.globalQueue"));
+ subSubPanel.add(globalLabel);
+ globalSelecter = new JComboBox(globalStr);
+
globalSelecter.setSelectedItem(I18n.getMessage("thaw.common.true"));
+ subSubPanel.add(globalSelecter);
if(advancedMode)
- this.subPanel.add(subSubPanel);
+ subPanel.add(subSubPanel);
// PRIORITY SELECTION
- this.priorities = new String[] {
+ priorities = new String[] {
I18n.getMessage("thaw.plugin.priority.p0"),
I18n.getMessage("thaw.plugin.priority.p1"),
I18n.getMessage("thaw.plugin.priority.p2"),
@@ -168,15 +171,15 @@
};
subSubPanel.setLayout(new GridLayout(4, 1));
- this.priorityLabel = new
JLabel(I18n.getMessage("thaw.common.priority"));
- subSubPanel.add(this.priorityLabel);
- this.prioritySelecter = new JComboBox(this.priorities);
-
this.prioritySelecter.setSelectedItem(I18n.getMessage("thaw.plugin.priority.p4"));
- subSubPanel.add(this.prioritySelecter);
+ priorityLabel = new
JLabel(I18n.getMessage("thaw.common.priority"));
+ subSubPanel.add(priorityLabel);
+ prioritySelecter = new JComboBox(priorities);
+
prioritySelecter.setSelectedItem(I18n.getMessage("thaw.plugin.priority.p4"));
+ subSubPanel.add(prioritySelecter);
if(advancedMode) {
- this.subPanel.add(subSubPanel);
- this.subPanel.add(subSubPanel);
+ subPanel.add(subSubPanel);
+ subPanel.add(subSubPanel);
}
// REVISION SELECTION
@@ -184,24 +187,24 @@
subSubPanel = new JPanel();
subSubPanel.setLayout(new GridLayout(4, 1));
- this.selectRevLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.selectRev"));
- subSubPanel.add(this.selectRevLabel);
- this.revField = new JTextField(4);
- this.revField.setEditable(true);
- subSubPanel.add(this.revField);
+ selectRevLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.selectRev"));
+ subSubPanel.add(selectRevLabel);
+ revField = new JTextField(4);
+ revField.setEditable(true);
+ subSubPanel.add(revField);
// NAME
- this.selectNameLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.selectName"));
- subSubPanel.add(this.selectNameLabel);
- this.nameField = new JTextField(10);
- this.nameField.setEditable(true);
- subSubPanel.add(this.nameField);
+ selectNameLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.selectName"));
+ subSubPanel.add(selectNameLabel);
+ nameField = new JTextField(10);
+ nameField.setEditable(true);
+ subSubPanel.add(nameField);
if(advancedMode)
- this.subPanel.add(subSubPanel);
+ subPanel.add(subSubPanel);
- this.setRevAndNameVisible(false);
+ setRevAndNameVisible(false);
// MIME TYPE
@@ -209,20 +212,20 @@
subSubPanel = new JPanel();
subSubPanel.setLayout(new GridLayout(4, 1));
- this.mimeLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.mime"));
+ mimeLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.mime"));
- Vector mimes =
(Vector)DefaultMIMETypes.getAllMIMETypes().clone();
+ final Vector mimes =
(Vector)DefaultMIMETypes.getAllMIMETypes().clone();
mimes.add(0, "");
- this.mimeField = new JComboBox(mimes);
- this.mimeField.setEditable(true);
- this.mimeField.setPreferredSize(new Dimension(75, 20));
+ mimeField = new JComboBox(mimes);
+ mimeField.setEditable(true);
+ mimeField.setPreferredSize(new Dimension(75, 20));
- subSubPanel.add(this.mimeLabel);
- subSubPanel.add(this.mimeField);
+ subSubPanel.add(mimeLabel);
+ subSubPanel.add(mimeField);
if(advancedMode)
- this.subPanel.add(subSubPanel);
+ subPanel.add(subSubPanel);
// PUBLIC / PRIVATE KEY
@@ -230,51 +233,51 @@
subSubPanel = new JPanel();
subSubPanel.setLayout(new GridLayout(4, 1));
- this.publicKeyLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.publicKey"));
- subSubPanel.add(this.publicKeyLabel);
- this.publicKeyField = new JTextField(20);
- this.publicKeyField.setEditable(true);
- subSubPanel.add(this.publicKeyField);
+ publicKeyLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.publicKey"));
+ subSubPanel.add(publicKeyLabel);
+ publicKeyField = new JTextField(20);
+ publicKeyField.setEditable(true);
+ subSubPanel.add(publicKeyField);
- this.privateKeyLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.privateKey"));
- subSubPanel.add(this.privateKeyLabel);
- this.privateKeyField = new JTextField(20);
- this.privateKeyField.setEditable(true);
- subSubPanel.add(this.privateKeyField);
+ privateKeyLabel = new
JLabel(I18n.getMessage("thaw.plugin.insert.privateKey"));
+ subSubPanel.add(privateKeyLabel);
+ privateKeyField = new JTextField(20);
+ privateKeyField.setEditable(true);
+ subSubPanel.add(privateKeyField);
if(advancedMode)
- this.subPanel.add(subSubPanel);
+ subPanel.add(subSubPanel);
- this.setKeysVisible(false);
+ setKeysVisible(false);
if(advancedMode)
- this.mainPanel.add(this.subPanel, BorderLayout.CENTER);
+ mainPanel.add(subPanel, BorderLayout.CENTER);
- this.letsGoButton = new
JButton(I18n.getMessage("thaw.plugin.insert.insertAction"));
- this.letsGoButton.setPreferredSize(new Dimension(200, 40));
+ letsGoButton = new
JButton(I18n.getMessage("thaw.plugin.insert.insertAction"));
+ letsGoButton.setPreferredSize(new Dimension(200, 40));
- this.letsGoButton.addActionListener(this);
+ letsGoButton.addActionListener(this);
- this.mainPanel.add(this.letsGoButton, BorderLayout.SOUTH);
+ mainPanel.add(letsGoButton, BorderLayout.SOUTH);
if(advancedMode)
- this.mainPanel.setSize(400, 400);
+ mainPanel.setSize(400, 400);
else
- this.mainPanel.setSize(150, 250);
+ mainPanel.setSize(150, 250);
- this.globalPanel.setLayout(new FlowLayout(FlowLayout.CENTER,
10, 10));
+ globalPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 10,
10));
- this.globalPanel.add(this.mainPanel);
+ globalPanel.add(mainPanel);
}
public JPanel getPanel() {
- return this.globalPanel;
+ return globalPanel;
}
- public void actionPerformed(ActionEvent e) {
- if(e.getSource() == this.letsGoButton) {
+ public void actionPerformed(final ActionEvent e) {
+ if(e.getSource() == letsGoButton) {
int rev = -1;
String name = null;
String privateKey = null;
@@ -282,35 +285,35 @@
boolean global = true;
//int persistence = 0;
- if(this.selectedFiles.getText() == null
- || "".equals( this.selectedFiles.getText() )) {
+ if((selectedFiles.getText() == null)
+ || "".equals( selectedFiles.getText() )) {
new WarningWindow(null,
I18n.getMessage("thaw.plugin.insert.specifyFile"));
return;
}
- if(this.keyType == 1 || this.keyType == 2) {
- if(this.nameField.getText() == null
- || "".equals( this.nameField.getText() )
- || this.revField.getText() == null
- || this.revField.getText().equals("")) {
+ if((keyType == 1) || (keyType == 2)) {
+ if((nameField.getText() == null)
+ || "".equals( nameField.getText() )
+ || (revField.getText() == null)
+ || revField.getText().equals("")) {
new WarningWindow(null,
I18n.getMessage("thaw.plugin.insert.specifyNameAndRev"));
return;
}
- rev = Integer.parseInt(this.revField.getText());
- name = this.nameField.getText();
+ rev = Integer.parseInt(revField.getText());
+ name = nameField.getText();
}
- if(this.keyType == 2) {
- if(this.privateKeyField.getText() != null
- && !"".equals(
this.privateKeyField.getText() )) {
- privateKey =
this.privateKeyField.getText();
+ if(keyType == 2) {
+ if((privateKeyField.getText() != null)
+ && !"".equals( privateKeyField.getText() )) {
+ privateKey = privateKeyField.getText();
- if(privateKey != null
+ if((privateKey != null)
&& !"".equals( privateKey )) {
privateKey =
privateKey.replaceFirst("SSK@", "");
privateKey =
privateKey.replaceFirst("USK@", "");
- String[] split =
privateKey.split("/");
+ final String[] split =
privateKey.split("/");
privateKey = split[0];
} else {
privateKey = null;
@@ -318,21 +321,21 @@
}
}
- for(int i = 0 ; i <= MIN_PRIORITY ; i++) {
- if(I18n.getMessage("thaw.plugin.priority.p"+
Integer.toString(i)).equals(this.prioritySelecter.getSelectedItem())) {
+ for(int i = 0 ; i <= InsertPanel.MIN_PRIORITY ; i++) {
+ if(I18n.getMessage("thaw.plugin.priority.p"+
Integer.toString(i)).equals(prioritySelecter.getSelectedItem())) {
priority = i;
}
}
-
if(((String)this.globalSelecter.getSelectedItem()).equals(I18n.getMessage("thaw.common.true")))
+
if(((String)globalSelecter.getSelectedItem()).equals(I18n.getMessage("thaw.common.true")))
global = true;
-
if(((String)this.globalSelecter.getSelectedItem()).equals(I18n.getMessage("thaw.common.false")))
+
if(((String)globalSelecter.getSelectedItem()).equals(I18n.getMessage("thaw.common.false")))
global = false;
String mimeType = null;
- if(this.mimeField.getSelectedItem() != null &&
!((String)this.mimeField.getSelectedItem()).equals(""))
- mimeType =
(String)this.mimeField.getSelectedItem();
+ if((mimeField.getSelectedItem() != null) &&
!((String)mimeField.getSelectedItem()).equals(""))
+ mimeType = (String)mimeField.getSelectedItem();
insertPlugin.insertFile(selectedFiles.getText(),
keyType, rev, name, privateKey,
priority,
@@ -341,8 +344,8 @@
selectedFiles.setText("");
}
- if(e.getSource() == this.browseButton) {
- FileChooser fileChooser = new FileChooser();
+ if(e.getSource() == browseButton) {
+ final FileChooser fileChooser = new FileChooser();
Vector files;
fileChooser.setTitle(I18n.getMessage("thaw.common.selectFile"));
@@ -359,9 +362,9 @@
i = 0;
- for(Iterator it = files.iterator();
+ for(final Iterator it = files.iterator();
it.hasNext(); ) {
- File file = (File)it.next();
+ final File file = (File)it.next();
if(i >= 1)
fileList = fileList + ";";
@@ -370,88 +373,88 @@
i++;
}
- this.selectedFiles.setText(fileList);
+ selectedFiles.setText(fileList);
- if(this.keyType != 0)
-
this.nameField.setText(this.getFileNameFromPath());
+ if(keyType != 0)
+ nameField.setText(getFileNameFromPath());
}
}
public String getFileNameFromPath() {
- if(this.selectedFiles.getText() == null || "".equals(
this.selectedFiles.getText() ))
+ if((selectedFiles.getText() == null) || "".equals(
selectedFiles.getText() ))
return "";
- String[] cutcut =
this.selectedFiles.getText().split(File.separator.replaceAll("\\\\",
"\\\\\\\\"));
+ final String[] cutcut =
selectedFiles.getText().split(File.separator.replaceAll("\\\\", "\\\\\\\\"));
return cutcut[cutcut.length - 1];
}
- public void itemStateChanged(ItemEvent e) {
- if(e.getItem() == this.keyRadioButtons[0]
- && e.getStateChange() == ItemEvent.SELECTED) { /* CHK */
- this.setKeysVisible(false);
- this.setRevAndNameVisible(false);
+ public void itemStateChanged(final ItemEvent e) {
+ if((e.getItem() == keyRadioButtons[0])
+ && (e.getStateChange() == ItemEvent.SELECTED)) { /* CHK */
+ setKeysVisible(false);
+ setRevAndNameVisible(false);
- this.resetOptionalFields();
+ resetOptionalFields();
- this.keyType = 0;
+ keyType = 0;
return;
}
- if(e.getItem() == this.keyRadioButtons[1]
- && e.getStateChange() == ItemEvent.SELECTED) { /* KSK */
- this.setKeysVisible(false);
- this.setRevAndNameVisible(true);
+ if((e.getItem() == keyRadioButtons[1])
+ && (e.getStateChange() == ItemEvent.SELECTED)) { /* KSK */
+ setKeysVisible(false);
+ setRevAndNameVisible(true);
- this.resetOptionalFields();
+ resetOptionalFields();
- this.keyType = 1;
+ keyType = 1;
return;
}
- if(e.getItem() == this.keyRadioButtons[2]
- && e.getStateChange() == ItemEvent.SELECTED) { /* SSK */
- this.setRevAndNameVisible(true);
- this.setKeysVisible(true);
+ if((e.getItem() == keyRadioButtons[2])
+ && (e.getStateChange() == ItemEvent.SELECTED)) { /* SSK */
+ setRevAndNameVisible(true);
+ setKeysVisible(true);
- this.resetOptionalFields();
+ resetOptionalFields();
- this.keyType = 2;
+ keyType = 2;
return;
}
}
- public void setLastInserted(FCPClientPut lastInserted) {
- this.lastInsert = lastInserted;
+ public void setLastInserted(final FCPClientPut lastInserted) {
+ lastInsert = lastInserted;
}
- private void setRevAndNameVisible(boolean v) {
- this.selectRevLabel.setVisible(v);
- this.revField.setVisible(v);
- this.selectNameLabel.setVisible(v);
- this.nameField.setVisible(v);
+ private void setRevAndNameVisible(final boolean v) {
+ selectRevLabel.setVisible(v);
+ revField.setVisible(v);
+ selectNameLabel.setVisible(v);
+ nameField.setVisible(v);
}
- private void setKeysVisible(boolean v) {
- this.publicKeyLabel.setVisible(v);
- this.publicKeyField.setVisible(v);
- this.privateKeyLabel.setVisible(v);
- this.privateKeyField.setVisible(v);
+ private void setKeysVisible(final boolean v) {
+ publicKeyLabel.setVisible(v);
+ publicKeyField.setVisible(v);
+ privateKeyLabel.setVisible(v);
+ privateKeyField.setVisible(v);
}
private void resetOptionalFields() {
- this.revField.setText("0");
- this.nameField.setText(this.getFileNameFromPath());
- this.privateKeyField.setText("");
- this.publicKeyField.setText("");
+ revField.setText("0");
+ nameField.setText(getFileNameFromPath());
+ privateKeyField.setText("");
+ publicKeyField.setText("");
}
- public void update(Observable o, Object param) {
- if(o == this.lastInsert) {
- FCPClientPut clientPut = (FCPClientPut)o;
+ public void update(final Observable o, final Object param) {
+ if(o == lastInsert) {
+ final FCPClientPut clientPut = (FCPClientPut)o;
if(clientPut.getKeyType() == 2) {
Logger.info(this, "Updating display");
@@ -460,26 +463,26 @@
String publicKey =
clientPut.getPublicKey();
publicKey =
publicKey.replaceFirst("SSK@", "");
publicKey =
publicKey.replaceFirst("USK@", "");
- String[] split = publicKey.split("/");
- this.publicKeyField.setText(split[0]);
+ final String[] split =
publicKey.split("/");
+ publicKeyField.setText(split[0]);
} else {
- this.publicKeyField.setText("");
+ publicKeyField.setText("");
}
if(clientPut.getPrivateKey() != null) {
String privateKey =
clientPut.getPrivateKey();
privateKey =
privateKey.replaceFirst("SSK@", "");
privateKey =
privateKey.replaceFirst("USK@", "");
- String[] split = privateKey.split("/");
- this.privateKeyField.setText(split[0]);
+ final String[] split =
privateKey.split("/");
+ privateKeyField.setText(split[0]);
} else {
- this.privateKeyField.setText("");
+ privateKeyField.setText("");
}
} else {
- this.publicKeyField.setText("");
- this.privateKeyField.setText("");
+ publicKeyField.setText("");
+ privateKeyField.setText("");
}
} else {
Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java
2006-12-06 18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java
2006-12-06 18:21:00 UTC (rev 11273)
@@ -2,39 +2,38 @@
import java.awt.Dimension;
import java.awt.GridLayout;
-import javax.swing.JPanel;
+import java.util.Observable;
+import java.util.Observer;
+
+import javax.swing.JComponent;
import javax.swing.JLabel;
-import javax.swing.JTextField;
+import javax.swing.JPanel;
import javax.swing.JProgressBar;
-import javax.swing.JComponent;
+import javax.swing.JTextField;
-import java.util.Observer;
-import java.util.Observable;
+import thaw.core.I18n;
+import thaw.core.Logger;
+import thaw.fcp.FCPTransferQuery;
-import thaw.core.*;
-import thaw.fcp.*;
-
/**
* Right panel of queueWatcher plugin. Show details about a transfer.
*/
public class DetailPanel implements Observer {
- private Core core;
-
private JPanel subPanel;
private JPanel panel;
- private JTextField file = new JTextField();
- private JTextField size = new JTextField();
- private JProgressBar progress = new JProgressBar(0, 100);
- private JProgressBar withTheNodeProgress = new JProgressBar(0, 100);
- private JTextField status = new JTextField();
- private JTextField key = new JTextField();
- private JTextField path = new JTextField();
- private JTextField priority = new JTextField();
- private JTextField identifier = new JTextField();
- private JTextField globalQueue= new JTextField();
+ private final JTextField file = new JTextField();
+ private final JTextField size = new JTextField();
+ private final JProgressBar progress = new JProgressBar(0, 100);
+ private final JProgressBar withTheNodeProgress = new JProgressBar(0,
100);
+ private final JTextField status = new JTextField();
+ private final JTextField key = new JTextField();
+ private final JTextField path = new JTextField();
+ private final JTextField priority = new JTextField();
+ private final JTextField identifier = new JTextField();
+ private final JTextField globalQueue= new JTextField();
private FCPTransferQuery query = null;
@@ -42,13 +41,11 @@
private final static Dimension dim = new Dimension(300, 400);
- public DetailPanel(Core core) {
- this.core = core;
+ public DetailPanel() {
+ panel = new JPanel();
+ subPanel = new JPanel();
- this.panel = new JPanel();
- this.subPanel = new JPanel();
-
- String[] fieldNames = { I18n.getMessage("thaw.common.file"),
+ final String[] fieldNames = {
I18n.getMessage("thaw.common.file"),
I18n.getMessage("thaw.common.size"),
I18n.getMessage("thaw.common.progress"),
I18n.getMessage("thaw.common.withTheNodeProgress"),
@@ -60,56 +57,56 @@
I18n.getMessage("thaw.common.globalQueue")
};
- this.subPanel.setLayout(new GridLayout(fieldNames.length*2, 1));
+ 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]);
- this.subPanel.add(newLabel);
+ final JLabel newLabel = new
JLabel(fieldNames[i/2]);
+ subPanel.add(newLabel);
} else {
JComponent field = null;
switch((i/2)) {
- case(0): field = this.file;
this.file.setEditable(false); break;
- case(1): field = this.size;
this.size.setEditable(false); break;
+ case(0): field = file; file.setEditable(false);
break;
+ case(1): field = size; size.setEditable(false);
break;
case(2):
- field = this.progress;
- this.progress.setString("");
- this.progress.setStringPainted(true);
+ field = progress;
+ progress.setString("");
+ progress.setStringPainted(true);
break;
case(3):
- field = this.withTheNodeProgress;
- this.withTheNodeProgress.setString("");
-
this.withTheNodeProgress.setStringPainted(true);
+ field = withTheNodeProgress;
+ withTheNodeProgress.setString("");
+
withTheNodeProgress.setStringPainted(true);
break;
- case(4): field = this.status;
this.status.setEditable(false); break;
- case(5): field = this.key;
this.key.setEditable(false);break;
- case(6): field = this.path;
this.path.setEditable(false); break;
- case(7): field = this.priority;
this.priority.setEditable(false); break;
- case(8): field = this.identifier;
this.identifier.setEditable(false); break;
- case(9): field = this.globalQueue;
this.globalQueue.setEditable(false); break;
+ case(4): field = status;
status.setEditable(false); break;
+ case(5): field = key;
key.setEditable(false);break;
+ case(6): field = path; path.setEditable(false);
break;
+ case(7): field = priority;
priority.setEditable(false); break;
+ case(8): field = identifier;
identifier.setEditable(false); break;
+ case(9): field = globalQueue;
globalQueue.setEditable(false); break;
default: Logger.error(this, "Gouli goula ? ...
is going to crash :p"); break;
}
- this.subPanel.add(field);
+ subPanel.add(field);
}
} /* for (i < fieldNames.length) */
- this.subPanel.setPreferredSize(dim);
+ subPanel.setPreferredSize(DetailPanel.dim);
- this.panel.add(this.subPanel);
+ panel.add(subPanel);
}
public JPanel getPanel() {
- return this.panel;
+ return panel;
}
- public void setQuery(FCPTransferQuery query) {
+ public void setQuery(final FCPTransferQuery query) {
if(this.query != null)
((Observable)this.query).deleteObserver(this);
@@ -118,86 +115,86 @@
if(this.query != null)
((Observable)this.query).addObserver(this);
- this.refreshAll();
+ refreshAll();
}
- public void update(Observable o, Object arg) {
- this.refresh();
+ public void update(final Observable o, final Object arg) {
+ refresh();
}
public void refresh() {
- if(this.query != null) {
-
this.withTheNodeProgress.setValue(this.query.getTransferWithTheNodeProgression());
-
this.withTheNodeProgress.setString(Integer.toString(this.query.getTransferWithTheNodeProgression())
+ "%");
+ if(query != null) {
+
withTheNodeProgress.setValue(query.getTransferWithTheNodeProgression());
+
withTheNodeProgress.setString(Integer.toString(query.getTransferWithTheNodeProgression())
+ "%");
- this.progress.setValue(this.query.getProgression());
- if(!this.query.isFinished() ||
this.query.isSuccessful()) {
- String progression =
Integer.toString(this.query.getProgression()) + "%";
+ progress.setValue(query.getProgression());
+ if(!query.isFinished() || query.isSuccessful()) {
+ String progression =
Integer.toString(query.getProgression()) + "%";
- if(!this.query.isProgressionReliable())
+ if(!query.isProgressionReliable())
progression = progression + "
("+I18n.getMessage("thaw.common.estimation")+")";
- this.progress.setString(progression);
+ progress.setString(progression);
} else
-
this.progress.setString(I18n.getMessage("thaw.common.failed"));
+
progress.setString(I18n.getMessage("thaw.common.failed"));
- if(this.query.getFileKey() != null)
- this.key.setText(this.query.getFileKey());
+ if(query.getFileKey() != null)
+ key.setText(query.getFileKey());
else
-
this.key.setText(I18n.getMessage("thaw.common.unknown"));
+
key.setText(I18n.getMessage("thaw.common.unknown"));
- if(this.query.getFileSize() == 0)
-
this.size.setText(I18n.getMessage("thaw.common.unknown"));
+ if(query.getFileSize() == 0)
+
size.setText(I18n.getMessage("thaw.common.unknown"));
else
- this.size.setText((new
Long(this.query.getFileSize())).toString()+" B");
+ size.setText((new
Long(query.getFileSize())).toString()+" B");
- this.status.setText(this.query.getStatus());
- if(this.query.getIdentifier() != null)
-
this.identifier.setText(this.query.getIdentifier());
+ status.setText(query.getStatus());
+ if(query.getIdentifier() != null)
+ identifier.setText(query.getIdentifier());
else
- this.identifier.setText("N/A");
+ identifier.setText("N/A");
- if(this.query.getThawPriority() != -1)
-
this.priority.setText(I18n.getMessage("thaw.plugin.priority.p"+Integer.toString(this.query.getThawPriority())));
+ if(query.getThawPriority() != -1)
+
priority.setText(I18n.getMessage("thaw.plugin.priority.p"+Integer.toString(query.getThawPriority())));
else
-
this.priority.setText(I18n.getMessage("thaw.common.unknown"));
+
priority.setText(I18n.getMessage("thaw.common.unknown"));
} else {
- this.withTheNodeProgress.setValue(0);
- this.withTheNodeProgress.setString("");
- this.progress.setValue(0);
- this.progress.setString("");
- this.status.setText("");
- this.identifier.setText("");
- this.size.setText("");
- this.priority.setText("");
- this.key.setText("");
+ withTheNodeProgress.setValue(0);
+ withTheNodeProgress.setString("");
+ progress.setValue(0);
+ progress.setString("");
+ status.setText("");
+ identifier.setText("");
+ size.setText("");
+ priority.setText("");
+ key.setText("");
}
}
public void refreshAll() {
- this.refresh();
+ refresh();
- if(this.query != null) {
+ if(query != null) {
- this.file.setText(this.query.getFilename());
+ file.setText(query.getFilename());
- if(this.query.getPath() != null)
- this.path.setText(this.query.getPath());
+ if(query.getPath() != null)
+ path.setText(query.getPath());
else
-
this.path.setText(I18n.getMessage("thaw.common.unspecified"));
+
path.setText(I18n.getMessage("thaw.common.unspecified"));
- if(this.query.isGlobal())
-
this.globalQueue.setText(I18n.getMessage("thaw.common.yes"));
+ if(query.isGlobal())
+
globalQueue.setText(I18n.getMessage("thaw.common.yes"));
else
-
this.globalQueue.setText(I18n.getMessage("thaw.common.no"));
+
globalQueue.setText(I18n.getMessage("thaw.common.no"));
} else {
- this.file.setText("");
- this.key.setText("");
- this.path.setText("");
- this.globalQueue.setText("");
+ file.setText("");
+ key.setText("");
+ path.setText("");
+ globalQueue.setText("");
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DragAndDropManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DragAndDropManager.java
2006-12-06 18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DragAndDropManager.java
2006-12-06 18:21:00 UTC (rev 11273)
@@ -1,47 +1,43 @@
package thaw.plugins.queueWatcher;
-import java.awt.dnd.DragSource;
-import java.awt.dnd.DragGestureListener;
-import java.awt.dnd.DragGestureEvent;
-import java.awt.dnd.DnDConstants;
-import java.awt.datatransfer.Transferable;
+import java.awt.Component;
import java.awt.datatransfer.DataFlavor;
-import java.awt.dnd.DragSourceListener;
+import java.awt.datatransfer.Transferable;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DragSourceContext;
import java.awt.dnd.DragSourceDragEvent;
-import java.awt.dnd.DragSourceEvent;
import java.awt.dnd.DragSourceDropEvent;
-import java.awt.dnd.DragSourceContext;
-import javax.swing.TransferHandler;
+import java.awt.dnd.DragSourceEvent;
+import java.awt.dnd.DragSourceListener;
+import java.io.File;
+import java.util.Iterator;
+import java.util.Vector;
-import java.awt.Component;
import javax.swing.JComponent;
+import javax.swing.TransferHandler;
-import java.util.Vector;
-import java.util.Iterator;
-import java.io.File;
+import thaw.core.Core;
+import thaw.core.Logger;
+import thaw.fcp.FCPTransferQuery;
-import thaw.core.*;
-import thaw.fcp.*;
-
public class DragAndDropManager implements DragGestureListener,
DragSourceListener {
-
- private Core core;
private QueuePanel[] queuePanels;
private DragSource dragSource;
- private DragGestureListener dgListener;
- private String tmpDir = System.getProperty("java.io.tmpdir");
+ private final String tmpDir = System.getProperty("java.io.tmpdir");
- public DragAndDropManager(Core core, QueuePanel[] queuePanels) {
- this.core = core;
+ public DragAndDropManager(final Core core, final QueuePanel[]
queuePanels) {
this.queuePanels = queuePanels;
- this.dragSource = DragSource.getDefaultDragSource();
+ dragSource = DragSource.getDefaultDragSource();
for(int i = 0 ; i < queuePanels.length ; i++) {
-
this.dragSource.createDefaultDragGestureRecognizer(queuePanels[i].getTable(),
+
dragSource.createDefaultDragGestureRecognizer(queuePanels[i].getTable(),
DnDConstants.ACTION_COPY_OR_MOVE,
this);
@@ -52,19 +48,18 @@
}
}
-
private class FileTransferHandler extends TransferHandler {
private static final long serialVersionUID = 1L;
- protected Transferable createTransferable(JComponent c) {
- if(c ==
DragAndDropManager.this.queuePanels[0].getTable()) {
-
DragAndDropManager.this.queuePanels[0].reloadSelections();
- return new
DragableFinishedTransfers(DragAndDropManager.this.queuePanels[0].getSelectedQueries(),
false);
+ protected Transferable createTransferable(final JComponent c) {
+ if(c == queuePanels[0].getTable()) {
+ queuePanels[0].reloadSelections();
+ return new
DragableFinishedTransfers(queuePanels[0].getSelectedQueries(), false);
}
- if(c ==
DragAndDropManager.this.queuePanels[1].getTable()) {
-
DragAndDropManager.this.queuePanels[1].reloadSelections();
- return new
DragableFinishedTransfers(DragAndDropManager.this.queuePanels[1].getSelectedQueries(),
true);
+ if(c == queuePanels[1].getTable()) {
+ queuePanels[1].reloadSelections();
+ return new
DragableFinishedTransfers(queuePanels[1].getSelectedQueries(), true);
}
return null;
@@ -72,16 +67,16 @@
}
- public void dragGestureRecognized(DragGestureEvent dge) {
+ public void dragGestureRecognized(final DragGestureEvent dge) {
try {
Transferable transferable;
- transferable =
this.getTransferableFor(dge.getComponent());
+ transferable = getTransferableFor(dge.getComponent());
dge.startDrag(DragSource.DefaultCopyDrop, transferable);
- } catch(java.awt.dnd.InvalidDnDOperationException e) {
+ } catch(final java.awt.dnd.InvalidDnDOperationException e) {
Logger.warning(this, "InvalideDnDOperation !");
}
}
@@ -97,8 +92,8 @@
private Vector queries; /* FCPTransferQuery */
private boolean insert;
- public DragableFinishedTransfers(Vector queries, boolean
insert) {
- if(queries == null || queries.size() <= 0) {
+ public DragableFinishedTransfers(final Vector queries, final
boolean insert) {
+ if((queries == null) || (queries.size() <= 0)) {
Logger.warning(this, "Selection null ?!");
}
@@ -106,26 +101,21 @@
this.insert = insert;
}
-
- private Vector getQueries() {
- return this.queries;
- }
-
- public Object getTransferData(DataFlavor flavor) {
- if(flavor == DataFlavor.javaFileListFlavor
+ public Object getTransferData(final DataFlavor flavor) {
+ if((flavor == DataFlavor.javaFileListFlavor)
|| flavor.equals(DataFlavor.javaFileListFlavor) ) {
- Vector fileList = new Vector();
+ final Vector fileList = new Vector();
- for(Iterator queryIt = this.queries.iterator();
+ for(final Iterator queryIt = queries.iterator();
queryIt.hasNext();) {
- FCPTransferQuery query =
(FCPTransferQuery)queryIt.next();
+ final FCPTransferQuery query =
(FCPTransferQuery)queryIt.next();
if(!query.isFinished() ||
!query.isSuccessful())
continue;
if(query.getPath() == null) // We need
a path !
-
query.saveFileTo(DragAndDropManager.this.tmpDir);
+ query.saveFileTo(tmpDir);
fileList.add(new File(query.getPath()));
}
@@ -134,13 +124,13 @@
return fileList;
}
- if(flavor == DataFlavor.stringFlavor
+ if((flavor == DataFlavor.stringFlavor)
|| flavor.equals(DataFlavor.stringFlavor) ) {
String result = "";
- for(Iterator queryIt = this.queries.iterator();
+ for(final Iterator queryIt = queries.iterator();
queryIt.hasNext();) {
- FCPTransferQuery query =
(FCPTransferQuery)queryIt.next();
+ final FCPTransferQuery query =
(FCPTransferQuery)queryIt.next();
if(!query.isFinished() ||
!query.isSuccessful())
continue;
@@ -148,7 +138,7 @@
if(query.getPath() == null) // We need
a path !
continue;
- if(!this.insert)
+ if(!insert)
result = result
+query.getPath()+"\n";
else
result = result +
query.getFileKey() + "\n";
@@ -161,12 +151,12 @@
}
public DataFlavor[] getTransferDataFlavors() {
- return this.FLAVORS;
+ return FLAVORS;
}
- public boolean isDataFlavorSupported(DataFlavor flavor) {
- for(int i = 0 ; i < this.FLAVORS.length ; i++)
- if(this.FLAVORS[i] == flavor ||
this.FLAVORS[i].equals(flavor))
+ public boolean isDataFlavorSupported(final DataFlavor flavor) {
+ for(int i = 0 ; i < FLAVORS.length ; i++)
+ if((FLAVORS[i] == flavor) ||
FLAVORS[i].equals(flavor))
return true;
return false;
@@ -176,26 +166,26 @@
- private Transferable getTransferableFor(Component c) {
+ private Transferable getTransferableFor(final Component c) {
- if(c == this.queuePanels[0].getTable()) {
- this.queuePanels[0].reloadSelections();
- return new
DragableFinishedTransfers(this.queuePanels[0].getSelectedQueries(), false);
+ if(c == queuePanels[0].getTable()) {
+ queuePanels[0].reloadSelections();
+ return new
DragableFinishedTransfers(queuePanels[0].getSelectedQueries(), false);
}
- if(c == this.queuePanels[1].getTable()) {
- this.queuePanels[1].reloadSelections();
- return new
DragableFinishedTransfers(this.queuePanels[1].getSelectedQueries(), true);
+ if(c == queuePanels[1].getTable()) {
+ queuePanels[1].reloadSelections();
+ return new
DragableFinishedTransfers(queuePanels[1].getSelectedQueries(), true);
}
return null;
}
- public void dragEnter(DragSourceDragEvent e) {
+ public void dragEnter(final DragSourceDragEvent e) {
- DragSourceContext context = e.getDragSourceContext();
+ final DragSourceContext context = e.getDragSourceContext();
//intersection of the users selected action, and the source and
target actions
- int myaction = e.getDropAction();
+ final int myaction = e.getDropAction();
if( (myaction & DnDConstants.ACTION_COPY) != 0) {
context.setCursor(DragSource.DefaultCopyDrop);
@@ -206,12 +196,12 @@
}
- public void dragOver(DragSourceDragEvent e) { }
- public void dragExit(DragSourceEvent e) { }
+ public void dragOver(final DragSourceDragEvent e) { }
+ public void dragExit(final DragSourceEvent e) { }
- public void dragDropEnd(DragSourceDropEvent e) {
+ public void dragDropEnd(final DragSourceDropEvent e) {
}
- public void dropActionChanged (DragSourceDragEvent e) { }
+ public void dropActionChanged (final DragSourceDragEvent e) { }
}
Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
2006-12-06 18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
2006-12-06 18:21:00 UTC (rev 11273)
@@ -1,46 +1,45 @@
package thaw.plugins.queueWatcher;
-import javax.swing.JPanel;
-import javax.swing.JTable;
-import javax.swing.JLabel;
-import javax.swing.JButton;
-import javax.swing.JScrollPane;
-import javax.swing.JProgressBar;
-import javax.swing.JFileChooser;
-import javax.swing.SwingConstants;
-
-import java.awt.Dimension;
import java.awt.BorderLayout;
-import java.awt.Component;
-import java.util.Vector;
-import java.util.Iterator;
-
-import javax.swing.table.DefaultTableCellRenderer;
import java.awt.Color;
-import java.awt.event.MouseListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.KeyListener;
-import java.awt.event.KeyEvent;
-
-import javax.swing.JPopupMenu;
-import javax.swing.JMenuItem;
-import javax.swing.JMenu;
-import javax.swing.JRadioButtonMenuItem;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-import javax.swing.ButtonGroup;
-import javax.swing.table.JTableHeader;
-
+import java.awt.Component;
+import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.StringSelection;
-
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
import java.io.File;
+import java.util.Iterator;
+import java.util.Vector;
-import thaw.core.*;
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JProgressBar;
+import javax.swing.JRadioButtonMenuItem;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.SwingConstants;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.JTableHeader;
-import thaw.fcp.*;
+import thaw.core.Core;
+import thaw.core.FileChooser;
+import thaw.core.I18n;
+import thaw.core.IconBox;
+import thaw.core.Logger;
+import thaw.fcp.FCPTransferQuery;
public class QueuePanel implements MouseListener, ActionListener, KeyListener {
private Core core;
@@ -74,23 +73,23 @@
private boolean insertionQueue = false;
- public QueuePanel(Core core, DetailPanel detailPanel,
+ public QueuePanel(final Core core, final DetailPanel detailPanel,
boolean isForInsertionQueue) {
- this.insertionQueue = isForInsertionQueue;
+ insertionQueue = isForInsertionQueue;
this.core = core;
this.detailPanel = detailPanel;
- this.tableModel = new QueueTableModel(isForInsertionQueue,
core.getQueueManager());
+ tableModel = new QueueTableModel(isForInsertionQueue,
core.getQueueManager());
- this.table = new JTable(this.tableModel);
+ table = new JTable(tableModel);
- this.table.setShowGrid(true);
+ table.setShowGrid(true);
- JTableHeader header = this.table.getTableHeader();
+ final JTableHeader header = table.getTableHeader();
header.setUpdateTableInRealTime(true);
- header.addMouseListener(this.tableModel.new
ColumnListener(this.table));
+ header.addMouseListener(tableModel.new ColumnListener(table));
header.setReorderingAllowed(true);
if(isForInsertionQueue) {
@@ -105,87 +104,87 @@
button.setHorizontalAlignment(SwingConstants.LEFT);
button.setPreferredSize(new Dimension(190, 40));
- JPanel buttonPanel = new JPanel(new BorderLayout());
+ final JPanel buttonPanel = new JPanel(new BorderLayout());
buttonPanel.add(button, BorderLayout.EAST);
buttonPanel.add(new JLabel(""), BorderLayout.CENTER);
- this.panel = new JPanel();
- this.panel.setLayout(new BorderLayout());
+ panel = new JPanel();
+ panel.setLayout(new BorderLayout());
- this.panel.add(buttonPanel, BorderLayout.NORTH);
+ panel.add(buttonPanel, BorderLayout.NORTH);
- this.scrollPane = new JScrollPane(this.table);
- this.panel.add(this.scrollPane, BorderLayout.CENTER);
+ scrollPane = new JScrollPane(table);
+ panel.add(scrollPane, BorderLayout.CENTER);
- this.table.setDefaultRenderer( this.table.getColumnClass(0),
new ProgressRenderer(this.table, this.tableModel, isForInsertionQueue) );
+ table.setDefaultRenderer( table.getColumnClass(0), new
ProgressRenderer(table, tableModel, isForInsertionQueue) );
- this.tableModel.addTableModelListener(this.table);
+ tableModel.addTableModelListener(table);
- this.rightClickMenu = new JPopupMenu();
- this.clearFinishedItem = new
JMenuItem(I18n.getMessage("thaw.common.clearFinished"));
- this.removeItem = new
JMenuItem(I18n.getMessage("thaw.common.removeFromTheList"));
- this.cancelItem = new
JMenuItem(I18n.getMessage("thaw.common.cancel"));
- this.delayItem = new
JMenuItem(I18n.getMessage("thaw.common.delay"));
- this.downloadItem = new
JMenuItem(I18n.getMessage("thaw.common.downloadLocally"));
- this.forceRestartItem = new
JMenuItem(I18n.getMessage("thaw.common.forceRestart"));
- this.copyKeysItem = new
JMenuItem(I18n.getMessage("thaw.common.copyKeysToClipboard"));
- JMenu priorityMenu = new
JMenu(I18n.getMessage("thaw.common.priority"));
+ rightClickMenu = new JPopupMenu();
+ clearFinishedItem = new
JMenuItem(I18n.getMessage("thaw.common.clearFinished"));
+ removeItem = new
JMenuItem(I18n.getMessage("thaw.common.removeFromTheList"));
+ cancelItem = new
JMenuItem(I18n.getMessage("thaw.common.cancel"));
+ delayItem = new JMenuItem(I18n.getMessage("thaw.common.delay"));
+ downloadItem = new
JMenuItem(I18n.getMessage("thaw.common.downloadLocally"));
+ forceRestartItem = new
JMenuItem(I18n.getMessage("thaw.common.forceRestart"));
+ copyKeysItem = new
JMenuItem(I18n.getMessage("thaw.common.copyKeysToClipboard"));
+ final JMenu priorityMenu = new
JMenu(I18n.getMessage("thaw.common.priority"));
- this.priorityGroup = new ButtonGroup();
- this.priorityRadioButton = new
JRadioButtonMenuItem[this.MIN_PRIORITY+1];
- for(int i =0 ; i <= this.MIN_PRIORITY ; i++) {
- this.priorityRadioButton[i] = new
JRadioButtonMenuItem(I18n.getMessage("thaw.plugin.priority.p"+Integer.toString(i)));
- this.priorityRadioButton[i].addActionListener(this);
- priorityMenu.add(this.priorityRadioButton[i]);
- this.priorityGroup.add(this.priorityRadioButton[i]);
+ priorityGroup = new ButtonGroup();
+ priorityRadioButton = new JRadioButtonMenuItem[MIN_PRIORITY+1];
+ for(int i =0 ; i <= MIN_PRIORITY ; i++) {
+ priorityRadioButton[i] = new
JRadioButtonMenuItem(I18n.getMessage("thaw.plugin.priority.p"+Integer.toString(i)));
+ priorityRadioButton[i].addActionListener(this);
+ priorityMenu.add(priorityRadioButton[i]);
+ priorityGroup.add(priorityRadioButton[i]);
}
- this.unknowPriority = new JRadioButtonMenuItem("Coin");
- this.priorityGroup.add(this.unknowPriority);
+ unknowPriority = new JRadioButtonMenuItem("Coin");
+ priorityGroup.add(unknowPriority);
- this.rightClickMenu.add(this.clearFinishedItem);
- this.rightClickMenu.add(this.removeItem);
+ rightClickMenu.add(clearFinishedItem);
+ rightClickMenu.add(removeItem);
- if(
Integer.parseInt(core.getConfig().getValue("maxSimultaneousDownloads")) >= 0
- ||
Integer.parseInt(core.getConfig().getValue("maxSimultaneousInsertions")) >= 0)
- this.rightClickMenu.add(this.cancelItem);
+ if(
(Integer.parseInt(core.getConfig().getValue("maxSimultaneousDownloads")) >= 0)
+ ||
(Integer.parseInt(core.getConfig().getValue("maxSimultaneousInsertions")) >= 0))
+ rightClickMenu.add(cancelItem);
- if(
Integer.parseInt(core.getConfig().getValue("maxSimultaneousDownloads")) >= 0
- ||
Integer.parseInt(core.getConfig().getValue("maxSimultaneousInsertions")) >= 0)
- this.rightClickMenu.add(this.delayItem);
+ if(
(Integer.parseInt(core.getConfig().getValue("maxSimultaneousDownloads")) >= 0)
+ ||
(Integer.parseInt(core.getConfig().getValue("maxSimultaneousInsertions")) >= 0))
+ rightClickMenu.add(delayItem);
if(!isForInsertionQueue)
- this.rightClickMenu.add(this.downloadItem);
+ rightClickMenu.add(downloadItem);
- this.rightClickMenu.add(this.forceRestartItem);
- this.rightClickMenu.add(this.copyKeysItem);
+ rightClickMenu.add(forceRestartItem);
+ rightClickMenu.add(copyKeysItem);
if(
Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue() ==
true) {
- this.rightClickMenu.add(priorityMenu);
+ rightClickMenu.add(priorityMenu);
}
- this.clearFinishedItem.addActionListener(this);
- this.removeItem.addActionListener(this);
- this.cancelItem.addActionListener(this);
- this.copyKeysItem.addActionListener(this);
- this.forceRestartItem.addActionListener(this);
- this.delayItem.addActionListener(this);
- this.downloadItem.addActionListener(this);
+ clearFinishedItem.addActionListener(this);
+ removeItem.addActionListener(this);
+ cancelItem.addActionListener(this);
+ copyKeysItem.addActionListener(this);
+ forceRestartItem.addActionListener(this);
+ delayItem.addActionListener(this);
+ downloadItem.addActionListener(this);
- this.table.addMouseListener(this);
- this.table.addKeyListener(this);
+ table.addMouseListener(this);
+ table.addKeyListener(this);
/* If a queue is already existing, we need to add it */
if(core.getQueueManager() != null) {
this.addToTable(core.getQueueManager().getRunningQueue());
- Vector[] pendingQueues =
core.getQueueManager().getPendingQueues();
+ final Vector[] pendingQueues =
core.getQueueManager().getPendingQueues();
for(int i = 0 ; i < pendingQueues.length ; i++) {
this.addToTable(pendingQueues[i]);
}
}
}
- public void addMenuItem(JMenuItem item) {
+ public void addMenuItem(final JMenuItem item) {
rightClickMenu.insert(item, 0);
}
@@ -206,25 +205,25 @@
private JTable tabl = null;
private boolean insertionQueue;
- public ProgressRenderer(JTable table, QueueTableModel model,
boolean isForInsertion) {
+ public ProgressRenderer(final JTable table, final
QueueTableModel model, final boolean isForInsertion) {
this.model = model;
- this.tabl = table;
- this.insertionQueue = isForInsertion;
+ tabl = table;
+ insertionQueue = isForInsertion;
}
- public Component getTableCellRendererComponent(JTable table,
Object value,
- boolean
isSelected, boolean hasFocus,
- int row, int
column) {
+ public Component getTableCellRendererComponent(final JTable
table, final Object value,
+ boolean
isSelected, final boolean hasFocus,
+ final int row,
final int column) {
if(value == null)
return null;
- FCPTransferQuery query = this.model.getQuery(row);
+ final FCPTransferQuery query = model.getQuery(row);
if(value instanceof Integer) {
- Integer progress = (Integer)value;
- JProgressBar bar = new JProgressBar(0, 100);
+ final Integer progress = (Integer)value;
+ final JProgressBar bar = new JProgressBar(0,
100);
bar.setStringPainted(true);
bar.setBorderPainted(false);
@@ -248,7 +247,7 @@
}
- Component cell =
super.getTableCellRendererComponent(table, value,
+ final Component cell =
super.getTableCellRendererComponent(table, value,
isSelected, hasFocus,
row, column);
@@ -258,13 +257,13 @@
return null;
if(!query.isRunning() && !query.isFinished())
- cell.setBackground(this.PENDING);
+ cell.setBackground(PENDING);
if(query.isFinished() && query.isSuccessful())
- cell.setBackground(this.SUCCESS);
+ cell.setBackground(SUCCESS);
if(query.isFinished() && !query.isSuccessful())
- cell.setBackground(this.FAILURE);
+ cell.setBackground(FAILURE);
if(query.isRunning() && !query.isFinished())
- cell.setBackground(this.RUNNING);
+ cell.setBackground(RUNNING);
}
@@ -275,17 +274,17 @@
public void reloadSelections() {
- this.selectedRows = this.table.getSelectedRows();
+ selectedRows = table.getSelectedRows();
- if(this.selectedRows.length > 1 || this.selectedRows.length <
1) {
- this.resetPriorityRadioButtons();
+ if((selectedRows.length > 1) || (selectedRows.length < 1)) {
+ resetPriorityRadioButtons();
} else {
- FCPTransferQuery query =
this.tableModel.getQuery(this.selectedRows[0]);
+ final FCPTransferQuery query =
tableModel.getQuery(selectedRows[0]);
if (query == null)
return;
-
this.priorityRadioButton[query.getFCPPriority()].setSelected(true);
+
priorityRadioButton[query.getFCPPriority()].setSelected(true);
}
}
@@ -294,15 +293,15 @@
* Doesn't refresh the selection !
*/
public Vector getSelectedQueries() {
- Vector queries = new Vector();
- Vector initialQueries = this.tableModel.getQueries();
+ final Vector queries = new Vector();
+ final Vector initialQueries = tableModel.getQueries();
- if(this.selectedRows == null)
+ if(selectedRows == null)
return queries;
/* Create a separate vector to avoid collisions */
- for(int i = 0 ; i < this.selectedRows.length; i++) {
- queries.add(initialQueries.get(this.selectedRows[i]));
+ for(int i = 0 ; i < selectedRows.length; i++) {
+ queries.add(initialQueries.get(selectedRows[i]));
}
return queries;
@@ -310,57 +309,57 @@
public void resetTable() {
- this.tableModel.resetTable();
+ tableModel.resetTable();
}
- public void addToTable(FCPTransferQuery query) {
- if( (this.insertionQueue && query.getQueryType() == 2)
- || (!this.insertionQueue && query.getQueryType() == 1)) {
- this.tableModel.addQuery(query);
+ public void addToTable(final FCPTransferQuery query) {
+ if( (insertionQueue && (query.getQueryType() == 2))
+ || (!insertionQueue && (query.getQueryType() == 1))) {
+ tableModel.addQuery(query);
}
}
/**
* @param queries Vector of FCPTransferQuery only
*/
- public synchronized void addToTable(Vector queries) {
+ public synchronized void addToTable(final Vector queries) {
try {
- for(Iterator queryIt = queries.iterator();
+ for(final Iterator queryIt = queries.iterator();
queryIt.hasNext();) {
- FCPTransferQuery query =
(FCPTransferQuery)queryIt.next();
+ final FCPTransferQuery query =
(FCPTransferQuery)queryIt.next();
this.addToTable(query);
}
- } catch(java.util.ConcurrentModificationException e) {
+ } catch(final java.util.ConcurrentModificationException e) {
Logger.notice(this, "Collision.");
}
}
public void refreshDetailPanel() {
- int selected = this.table.getSelectedRow();
+ final int selected = table.getSelectedRow();
if(selected != -1) {
- FCPTransferQuery query =
this.tableModel.getQuery(selected);
- this.detailPanel.setQuery(query);
+ final FCPTransferQuery query =
tableModel.getQuery(selected);
+ detailPanel.setQuery(query);
}
}
private void resetPriorityRadioButtons() {
- this.unknowPriority.setSelected(true);
+ unknowPriority.setSelected(true);
}
public JPanel getPanel() {
- return this.panel;
+ return panel;
}
public JTable getTable() {
- return this.table;
+ return table;
}
@@ -368,23 +367,23 @@
ActionEvent e;
Vector queries;
- public ActionReplier(ActionEvent e, Vector queries) {
+ public ActionReplier(final ActionEvent e, final Vector queries)
{
this.e = e;
this.queries = queries;
}
public void run() {
- Toolkit tk = Toolkit.getDefaultToolkit();
+ final Toolkit tk = Toolkit.getDefaultToolkit();
String keys = "";
File dir = null;
- if(this.e.getSource() ==
QueuePanel.this.clearFinishedItem) {
- QueuePanel.this.removeAllFinishedTransfers();
+ if(e.getSource() == clearFinishedItem) {
+ removeAllFinishedTransfers();
return;
}
- if(this.e.getSource() == QueuePanel.this.downloadItem) {
- FileChooser fileChooser = new FileChooser();
+ if(e.getSource() == downloadItem) {
+ final FileChooser fileChooser = new
FileChooser();
fileChooser.setTitle(I18n.getMessage("thaw.common.downloadLocally"));
fileChooser.setDirectoryOnly(true);
fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
@@ -397,18 +396,18 @@
int prioritySelected = 0;
for(prioritySelected = 0;
- prioritySelected <= QueuePanel.this.MIN_PRIORITY;
+ prioritySelected <= MIN_PRIORITY;
prioritySelected++) {
-
if(QueuePanel.this.priorityRadioButton[prioritySelected] == this.e.getSource())
{
+ if(priorityRadioButton[prioritySelected] ==
e.getSource()) {
break;
}
}
- if(prioritySelected > QueuePanel.this.MIN_PRIORITY)
+ if(prioritySelected > MIN_PRIORITY)
prioritySelected = -1;
- for(Iterator queryIt = this.queries.iterator() ;
queryIt.hasNext() ;) {
- FCPTransferQuery query =
(FCPTransferQuery)queryIt.next();
+ for(final Iterator queryIt = queries.iterator() ;
queryIt.hasNext() ;) {
+ final FCPTransferQuery query =
(FCPTransferQuery)queryIt.next();
if(query == null)
continue;
@@ -420,45 +419,45 @@
}
}
- if(this.e.getSource() ==
QueuePanel.this.removeItem) {
+ if(e.getSource() == removeItem) {
-
if(query.stop(QueuePanel.this.core.getQueueManager())) {
-
QueuePanel.this.core.getQueueManager().remove(query);
+ if(query.stop(core.getQueueManager())) {
+
core.getQueueManager().remove(query);
}
}
- if(this.e.getSource() ==
QueuePanel.this.cancelItem) {
-
query.stop(QueuePanel.this.core.getQueueManager());
+ if(e.getSource() == cancelItem) {
+ query.stop(core.getQueueManager());
}
- if(this.e.getSource() ==
QueuePanel.this.delayItem) {
+ if(e.getSource() == delayItem) {
if(query.isRunning() &&
!query.isFinished()) {
-
query.pause(QueuePanel.this.core.getQueueManager());
-
QueuePanel.this.core.getQueueManager().moveFromRunningToPendingQueue(query);
+
query.pause(core.getQueueManager());
+
core.getQueueManager().moveFromRunningToPendingQueue(query);
}
}
- if(this.e.getSource() ==
QueuePanel.this.forceRestartItem) {
-
query.stop(QueuePanel.this.core.getQueueManager());
+ if(e.getSource() == forceRestartItem) {
+ query.stop(core.getQueueManager());
if(query.getMaxAttempt() >= 0)
query.setAttempt(0);
-
query.start(QueuePanel.this.core.getQueueManager());
+ query.start(core.getQueueManager());
}
- if(this.e.getSource() ==
QueuePanel.this.copyKeysItem) {
- if(query.getFileKey() != null
+ if(e.getSource() == copyKeysItem) {
+ if((query.getFileKey() != null)
&& !"".equals( query.getFileKey() ))
keys = keys +
query.getFileKey() + "\n";
}
- if(this.e.getSource() ==
QueuePanel.this.downloadItem
- && dir != null) {
+ if((e.getSource() == downloadItem)
+ && (dir != null)) {
if(query.isPersistent()) {
query.saveFileTo(dir.getPath());
-
if(query.getIdentifier().startsWith(QueuePanel.this.core.getConfig().getValue("thawId")))
+
if(query.getIdentifier().startsWith(core.getConfig().getValue("thawId")))
query.updatePersistentRequest(true);
}
}
@@ -466,29 +465,29 @@
} /* for i in selectedRows */
- if(this.e.getSource() == QueuePanel.this.copyKeysItem) {
- StringSelection st = new StringSelection(keys);
- Clipboard cp = tk.getSystemClipboard();
+ if(e.getSource() == copyKeysItem) {
+ final StringSelection st = new
StringSelection(keys);
+ final Clipboard cp = tk.getSystemClipboard();
cp.setContents(st, this);
}
}
- public void lostOwnership(Clipboard clipboard,
java.awt.datatransfer.Transferable contents) {
+ public void lostOwnership(final Clipboard clipboard, final
java.awt.datatransfer.Transferable contents) {
/* we dont care */
}
}
public void removeAllFinishedTransfers() {
- Vector queries = this.tableModel.getQueries();
+ final Vector queries = tableModel.getQueries();
- for(Iterator it = queries.iterator();
+ for(final Iterator it = queries.iterator();
it.hasNext(); ) {
- FCPTransferQuery query = (FCPTransferQuery)it.next();
+ final FCPTransferQuery query =
(FCPTransferQuery)it.next();
if(query.isFinished()) {
- if(query.stop(this.core.getQueueManager())) {
-
this.core.getQueueManager().remove(query);
+ if(query.stop(core.getQueueManager())) {
+ core.getQueueManager().remove(query);
}
}
}
@@ -497,36 +496,36 @@
/**
* Manage it on a different thread to avoid UI freeze.
*/
- public void actionPerformed(ActionEvent e) {
- Thread action = new Thread(new ActionReplier(e,
this.getSelectedQueries()));
+ public void actionPerformed(final ActionEvent e) {
+ final Thread action = new Thread(new ActionReplier(e,
getSelectedQueries()));
action.start();
}
- public void mouseClicked(MouseEvent e) {
+ public void mouseClicked(final MouseEvent e) {
if(e.getButton() == MouseEvent.BUTTON3) {
- this.reloadSelections();
- this.queries = this.tableModel.getQueries();
- this.rightClickMenu.show(e.getComponent(), e.getX(),
e.getY());
+ reloadSelections();
+ queries = tableModel.getQueries();
+ rightClickMenu.show(e.getComponent(), e.getX(),
e.getY());
}
if(e.getButton() == MouseEvent.BUTTON1) {
- this.refreshDetailPanel();
+ refreshDetailPanel();
}
}
- public void mouseEntered(MouseEvent e) { }
+ public void mouseEntered(final MouseEvent e) { }
- public void mouseExited(MouseEvent e) { }
+ public void mouseExited(final MouseEvent e) { }
- public void mousePressed(MouseEvent e) { }
+ public void mousePressed(final MouseEvent e) { }
- public void mouseReleased(MouseEvent e) { }
+ public void mouseReleased(final MouseEvent e) { }
- public void keyPressed(KeyEvent e) { }
+ public void keyPressed(final KeyEvent e) { }
- public void keyReleased(KeyEvent e) { this.refreshDetailPanel(); }
+ public void keyReleased(final KeyEvent e) { refreshDetailPanel(); }
- public void keyTyped(KeyEvent e) { }
+ public void keyTyped(final KeyEvent e) { }
}
Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java
2006-12-06 18:18:48 UTC (rev 11272)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java
2006-12-06 18:21:00 UTC (rev 11273)
@@ -1,28 +1,28 @@
package thaw.plugins.queueWatcher;
-import java.util.Vector;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.Iterator;
import java.util.Observable;
import java.util.Observer;
+import java.util.Vector;
-import javax.swing.event.TableModelEvent;
import javax.swing.JTable;
-import javax.swing.table.TableColumnModel;
+import javax.swing.event.TableModelEvent;
import javax.swing.table.TableColumn;
+import javax.swing.table.TableColumnModel;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
+import thaw.core.I18n;
+import thaw.core.Logger;
+import thaw.fcp.FCPQueueManager;
+import thaw.fcp.FCPTransferQuery;
-import java.util.Comparator;
-import java.util.Collections;
-
-import thaw.core.*;
-import thaw.fcp.*;
-
public class QueueTableModel extends javax.swing.table.AbstractTableModel
implements Observer {
private static final long serialVersionUID = 20060708;
- private Vector columnNames = new Vector();
+ private final Vector columnNames = new Vector();
private Vector queries = null;
@@ -35,25 +35,25 @@
private FCPQueueManager queueManager;
- public QueueTableModel(boolean isForInsertions, FCPQueueManager
queueManager) {
+ public QueueTableModel(boolean isForInsertions, final FCPQueueManager
queueManager) {
super();
this.queueManager = queueManager;
this.isForInsertions = isForInsertions;
- this.columnNames.add(I18n.getMessage("thaw.common.file"));
- this.columnNames.add(I18n.getMessage("thaw.common.size"));
+ columnNames.add(I18n.getMessage("thaw.common.file"));
+ columnNames.add(I18n.getMessage("thaw.common.size"));
if(!isForInsertions)
-
this.columnNames.add(I18n.getMessage("thaw.common.localPath"));
+
columnNames.add(I18n.getMessage("thaw.common.localPath"));
- this.columnNames.add(I18n.getMessage("thaw.common.status"));
- this.columnNames.add(I18n.getMessage("thaw.common.progress"));
+ columnNames.add(I18n.getMessage("thaw.common.status"));
+ columnNames.add(I18n.getMessage("thaw.common.progress"));
- this.resetTable();
+ resetTable();
if(queueManager != null) {
- this.reloadQueue();
+ reloadQueue();
queueManager.addObserver(this);
} else {
Logger.warning(this, "Unable to connect to
QueueManager. Is the connection established ?");
@@ -64,21 +64,21 @@
public int getRowCount() {
- if(this.queries != null)
- return this.queries.size();
+ if(queries != null)
+ return queries.size();
else
return 0;
}
public int getColumnCount() {
- return this.columnNames.size();
+ return columnNames.size();
}
- public String getColumnName(int col) {
- String result = (String)this.columnNames.get(col);
+ public String getColumnName(final int col) {
+ String result = (String)columnNames.get(col);
- if(col == this.sortedColumn) {
- if(this.isSortedAsc)
+ if(col == sortedColumn) {
+ if(isSortedAsc)
result = result + " >>";
else
result = result + " <<";
@@ -88,7 +88,7 @@
}
- public static String getPrintableSize(long size) {
+ public static String getPrintableSize(final long size) {
if(size == 0)
return I18n.getMessage("thaw.common.unknown");
@@ -96,48 +96,45 @@
return ((new Long(size)).toString() + " B");
if(size < 1048576) { /* < 1MB */
- long kb = size / 1024;
+ final long kb = size / 1024;
return ((new Long(kb)).toString() + " KB");
}
if(size < 1073741824) { /* < 1GB */
- long mb = size / 1048576;
+ final long mb = size / 1048576;
return ((new Long(mb)).toString() + " MB");
}
- long gb = size / 1073741824;
+ final long gb = size / 1073741824;
return ((new Long(gb)).toString() +" GB");
}
- public Object getValueAt(int row, int column) {
- if(row >= this.queries.size())
+ public Object getValueAt(final int row, final int column) {
+ if(row >= queries.size())
return null;
- FCPTransferQuery query =
(FCPTransferQuery)this.queries.get(row);
+ final FCPTransferQuery query =
(FCPTransferQuery)queries.get(row);
- if(column == 0) {
+ if(column == 0)
return query.getFilename();
- }
- if(column == 1) {
- return getPrintableSize(query.getFileSize());
- }
+ if(column == 1)
+ return
QueueTableModel.getPrintableSize(query.getFileSize());
- if(!this.isForInsertions && column == 2) {
+ if(!isForInsertions && (column == 2)) {
if(query.getPath() != null)
return query.getPath();
else
return
I18n.getMessage("thaw.common.unspecified");
}
- if( (this.isForInsertions && column == 2)
- || (!this.isForInsertions && column == 3) ) {
+ if( (isForInsertions && (column == 2))
+ || (!isForInsertions && (column == 3)) )
return query.getStatus();
- }
- if( (this.isForInsertions && column == 3
- || (!this.isForInsertions && column == 4) ) ) {
+ if( ((isForInsertions && (column == 3))
+ || (!isForInsertions && (column == 4)) ) ) {
if(!query.isFinished() || query.isSuccessful())
return new Integer(query.getProgression());
else
@@ -148,7 +145,7 @@
return null;
}
- public boolean isCellEditable(int row, int column) {
+ public boolean isCellEditable(final int row, final int column) {
return false;
}
@@ -157,74 +154,74 @@
*/
public synchronized void resetTable() {
- if(this.queries != null) {
- for(Iterator it = this.queries.iterator();
+ if(queries != null) {
+ for(final Iterator it = queries.iterator();
it.hasNext();) {
- Observable query = (Observable)it.next();
+ final Observable query = (Observable)it.next();
query.deleteObserver(this);
}
}
- this.queries = new Vector();
+ queries = new Vector();
}
public synchronized void reloadQueue() {
try {
- this.resetTable();
+ resetTable();
- this.addQueries(this.queueManager.getRunningQueue());
+ addQueries(queueManager.getRunningQueue());
- Vector[] pendings =
this.queueManager.getPendingQueues();
+ final Vector[] pendings =
queueManager.getPendingQueues();
for(int i = 0;i < pendings.length ; i++)
- this.addQueries(pendings[i]);
- } catch(java.util.ConcurrentModificationException e) {
+ addQueries(pendings[i]);
+ } catch(final java.util.ConcurrentModificationException e) {
Logger.warning(this, "reloadQueue: Collision !");
- this.reloadQueue();
+ reloadQueue();
}
}
- public synchronized void addQueries(Vector queries) {
- for(Iterator it = queries.iterator();
+ public synchronized void addQueries(final Vector queries) {
+ for(final Iterator it = queries.iterator();
it.hasNext();) {
- FCPTransferQuery query = (FCPTransferQuery)it.next();
+ final FCPTransferQuery query =
(FCPTransferQuery)it.next();
- if(query.getQueryType() == 1 && !this.isForInsertions)
- this.addQuery(query);
+ if((query.getQueryType() == 1) && !isForInsertions)
+ addQuery(query);
- if(query.getQueryType() == 2 && this.isForInsertions)
- this.addQuery(query);
+ if((query.getQueryType() == 2) && isForInsertions)
+ addQuery(query);
}
}
- public synchronized void addQuery(FCPTransferQuery query) {
- if(this.queries.contains(query)) {
+ public synchronized void addQuery(final FCPTransferQuery query) {
+ if(queries.contains(query)) {
Logger.debug(this, "addQuery() : Already known");
return;
}
((Observable)query).addObserver(this);
- this.queries.add(query);
+ queries.add(query);
- this.sortTable();
+ sortTable();
- int changedRow = this.queries.indexOf(query);
+ final int changedRow = queries.indexOf(query);
this.notifyObservers(new TableModelEvent(this, changedRow,
changedRow, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT));
}
- public synchronized void removeQuery(FCPTransferQuery query) {
+ public synchronized void removeQuery(final FCPTransferQuery query) {
((Observable)query).deleteObserver(this);
- this.sortTable();
+ sortTable();
- int changedRow = this.queries.indexOf(query);
+ final int changedRow = queries.indexOf(query);
- this.queries.remove(query);
+ queries.remove(query);
if(changedRow >= 0) {
this.notifyObservers(new TableModelEvent(this,
changedRow, changedRow, TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE));
@@ -233,10 +230,10 @@
}
- public synchronized FCPTransferQuery getQuery(int row) {
+ public synchronized FCPTransferQuery getQuery(final int row) {
try {
- return (FCPTransferQuery)this.queries.get(row);
- } catch(java.lang.ArrayIndexOutOfBoundsException e) {
+ return (FCPTransferQuery)queries.get(row);
+ } catch(final java.lang.ArrayIndexOutOfBoundsException e) {
Logger.notice(this, "Query not found, row: "+row);
return null;
}
@@ -246,9 +243,9 @@
* returns a *copy*
*/
public synchronized Vector getQueries() {
- Vector newVect = new Vector();
+ final Vector newVect = new Vector();
- for(Iterator queryIt = this.queries.iterator() ;
+ for(final Iterator queryIt = queries.iterator() ;
queryIt.hasNext();) {
newVect.add(queryIt.next());
}
@@ -257,19 +254,19 @@
}
public void notifyObservers() {
- TableModelEvent event = new TableModelEvent(this);
+ final TableModelEvent event = new TableModelEvent(this);
this.notifyObservers(event);
}
- public void notifyObservers(int changedRow) {
- TableModelEvent event = new TableModelEvent(this, changedRow);
+ public void notifyObservers(final int changedRow) {
+ final TableModelEvent event = new TableModelEvent(this,
changedRow);
this.notifyObservers(event);
}
- public void notifyObservers(TableModelEvent event) {
- this.fireTableChanged(event);
+ public void notifyObservers(final TableModelEvent event) {
+ fireTableChanged(event);
/*
TableModelListener[] listeners = getTableModelListeners();
@@ -280,43 +277,43 @@
*/
}
- public synchronized void update(Observable o, Object arg) {
+ public synchronized void update(final Observable o, final Object arg) {
int i;
- this.sortTable();
+ sortTable();
- if( (i = this.queries.indexOf(o)) >= 0) {
+ if( (i = queries.indexOf(o)) >= 0) {
this.notifyObservers(i);
return;
}
if(arg == null) {
- this.reloadQueue();
+ reloadQueue();
return;
}
- if(o == this.queueManager) {
- FCPTransferQuery query = (FCPTransferQuery)arg;
+ if(o == queueManager) {
+ final FCPTransferQuery query = (FCPTransferQuery)arg;
- if(query.getQueryType() == 1 && this.isForInsertions)
+ if((query.getQueryType() == 1) && isForInsertions)
return;
- if(query.getQueryType() == 2 && !this.isForInsertions)
+ if((query.getQueryType() == 2) && !isForInsertions)
return;
- if(this.queueManager.isInTheQueues(query)) { // then
it's an adding
- this.addQuery(query);
+ if(queueManager.isInTheQueues(query)) { // then it's an
adding
+ addQuery(query);
return;
}
- if(this.queries.contains(query)) {
- this.removeQuery(query);
+ if(queries.contains(query)) {
+ removeQuery(query);
return;
}
}
Logger.notice(this, "update(): unknow change");
- this.reloadQueue();
+ reloadQueue();
}
@@ -324,10 +321,10 @@
* @return false if nothing sorted
*/
public boolean sortTable() {
- if(this.sortedColumn < 0 || this.queries.size() <= 0)
+ if((sortedColumn < 0) || (queries.size() <= 0))
return false;
- Collections.sort(this.queries, new
QueryComparator(this.isSortedAsc, this.sortedColumn, this.isForInsertions));
+ Collections.sort(queries, new QueryComparator(isSortedAsc,
sortedColumn, isForInsertions));
return true;
}
@@ -336,36 +333,36 @@
public class ColumnListener extends MouseAdapter {
private JTable table;
- public ColumnListener(JTable t) {
- this.table = t;
+ public ColumnListener(final JTable t) {
+ table = t;
}
- public void mouseClicked(MouseEvent e) {
- TableColumnModel colModel = this.table.getColumnModel();
- int columnModelIndex =
colModel.getColumnIndexAtX(e.getX());
- int modelIndex =
colModel.getColumn(columnModelIndex).getModelIndex();
+ public void mouseClicked(final MouseEvent e) {
+ final TableColumnModel colModel =
table.getColumnModel();
+ final int columnModelIndex =
colModel.getColumnIndexAtX(e.getX());
+ final int modelIndex =
colModel.getColumn(columnModelIndex).getModelIndex();
- int columnsCount = this.table.getColumnCount();
+ final int columnsCount = table.getColumnCount();
if (modelIndex < 0)
return;
- if (QueueTableModel.this.sortedColumn == modelIndex)
- QueueTableModel.this.isSortedAsc =
!QueueTableModel.this.isSortedAsc;
+ if (sortedColumn == modelIndex)
+ isSortedAsc = !isSortedAsc;
else
- QueueTableModel.this.sortedColumn = modelIndex;
+ sortedColumn = modelIndex;
for (int i = 0; i < columnsCount; i++) {
- TableColumn column = colModel.getColumn(i);
-
column.setHeaderValue(QueueTableModel.this.getColumnName(column.getModelIndex()));
+ final TableColumn column =
colModel.getColumn(i);
+
column.setHeaderValue(getColumnName(column.getModelIndex()));
}
- this.table.getTableHeader().repaint();
+ table.getTableHeader().repaint();
- QueueTableModel.this.sortTable();
+ sortTable();
}
}
@@ -375,25 +372,25 @@
private int column;
private boolean isForInsertionTable;
- public QueryComparator(boolean sortedAsc, int column,
- boolean isForInsertionTable) {
- this.isSortedAsc = sortedAsc;
+ public QueryComparator(final boolean sortedAsc, final int
column,
+ final boolean isForInsertionTable) {
+ isSortedAsc = sortedAsc;
this.column = column;
this.isForInsertionTable = isForInsertionTable;
}
- public int compare(Object o1, Object o2) {
+ public int compare(final Object o1, final Object o2) {
int result = 0;
if(!(o1 instanceof FCPTransferQuery)
|| !(o2 instanceof FCPTransferQuery))
return 0;
- FCPTransferQuery q1 = (FCPTransferQuery)o1;
- FCPTransferQuery q2 = (FCPTransferQuery)o2;
+ final FCPTransferQuery q1 = (FCPTransferQuery)o1;
+ final FCPTransferQuery q2 = (FCPTransferQuery)o2;
- if(this.column == 0) { /* File name */
+ if(column == 0) { /* File name */
if(q1.getFilename() == null)
return -1;
@@ -403,11 +400,11 @@
result =
q1.getFilename().compareTo(q2.getFilename());
}
- if(this.column == 1) { /* Size */
+ if(column == 1) { /* Size */
result = (new
Long(q1.getFileSize())).compareTo(new Long(q2.getFileSize()));
}
- if( (this.column == 2 && !this.isForInsertionTable) ) {
/* localPath */
+ if( ((column == 2) && !isForInsertionTable) ) { /*
localPath */
if(q1.getPath() == null)
return -1;
@@ -417,8 +414,8 @@
result = q1.getPath().compareTo(q2.getPath());
}
- if( (this.column == 2 && this.isForInsertionTable)
- || (this.column == 3 && !this.isForInsertionTable)
) { /* status */
+ if( ((column == 2) && isForInsertionTable)
+ || ((column == 3) && !isForInsertionTable) ) { /*
status */
if(q1.getStatus() == null)
return -1;
@@ -429,10 +426,10 @@
result =
q1.getStatus().compareTo(q2.getStatus());
}
- if( (this.column == 3 && this.isForInsertionTable)
- || (this.column == 4 && !this.isForInsertionTable)
) { /* progress */
- if(q1.getProgression() <= 0
- && q2.getProgression() <= 0) {
+ if( ((column == 3) && isForInsertionTable)
+ || ((column == 4) && !isForInsertionTable) ) { /*
progress */
+ if((q1.getProgression() <= 0)
+ && (q2.getProgression() <= 0)) {
if(q1.isRunning() && !q2.isRunning())
return 1;
@@ -444,20 +441,20 @@
}
- if (!this.isSortedAsc)
+ if (!isSortedAsc)
result = -result;
return result;
}
public boolean isSortedAsc() {
- return this.isSortedAsc;
+ return isSortedAsc;
}
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (obj instanceof QueryComparator) {
- QueryComparator compObj = (QueryComparator) obj;
- return compObj.isSortedAsc() ==
this.isSortedAsc();
+ final QueryComparator compObj =
(QueryComparator) obj;
+ return compObj.isSortedAsc() == isSortedAsc();
}
return false;
}