Author: jflesch
Date: 2006-12-16 15:52:21 +0000 (Sat, 16 Dec 2006)
New Revision: 11438
Modified:
trunk/apps/Thaw/src/thaw/core/Core.java
trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java
Log:
Put unwanted disconnection management process into a thread to avoid UI freezes
=> Fix bug #676
Modified: trunk/apps/Thaw/src/thaw/core/Core.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Core.java 2006-12-16 15:08:11 UTC (rev
11437)
+++ trunk/apps/Thaw/src/thaw/core/Core.java 2006-12-16 15:52:21 UTC (rev
11438)
@@ -28,7 +28,7 @@
* A "core" contains references to all the main parts of Thaw.
* The Core has all the functions needed to initialize Thaw / stop Thaw.
*/
-public class Core implements Observer, ActionListener {
+public class Core implements Observer {
private SplashScreen splashScreen = null;
private MainWindow mainWindow = null;
@@ -44,8 +44,6 @@
private static String lookAndFeel = null;
- private JDialog warningDialog = null;
-
public final static int MAX_CONNECT_TRIES = 3;
public final static int TIME_BETWEEN_EACH_TRY = 5000;
@@ -410,10 +408,11 @@
return true;
}
- public void update(final Observable o, final Object target) {
- Logger.debug(this, "Move on the connection (?)");
- if((o == connection) && !connection.isConnected()) {
+ protected class UnwantedDisconnectionManager implements Runnable,
ActionListener {
+ private JDialog warningDialog = null;
+
+ public void run() {
disconnect();
int nmbReconnect = 0;
@@ -481,16 +480,25 @@
getPluginManager().loadPlugins();
getPluginManager().runPlugins();
}
+
+ public void actionPerformed(ActionEvent e) {
+ if (warningDialog == null)
+ return;
+ // we assume that the action comes from the button in
the reconnection dialog
+ warningDialog.setVisible(false);
+ warningDialog.dispose();
+ warningDialog = null;
+ }
}
- public void actionPerformed(ActionEvent e) {
- if (warningDialog == null)
- return;
- // we assume that the action comes from the button in the
reconnection dialog
- warningDialog.setVisible(false);
- warningDialog.dispose();
- warningDialog = null;
+ public void update(final Observable o, final Object target) {
+ Logger.debug(this, "Move on the connection (?)");
+
+ if((o == connection) && !connection.isConnected()) {
+ Thread th = new Thread(new
UnwantedDisconnectionManager());
+ th.run();
+ }
}
}
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2006-12-16 15:08:11 UTC
(rev 11437)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2006-12-16 15:52:21 UTC
(rev 11438)
@@ -495,7 +495,7 @@
}
} catch(final java.io.IOException e) {
/* we will suppose its ok ... */
- Logger.notice(this, "available() die (hu ?)");
+ Logger.notice(this, "available() IOException (hu ?)");
}
return true;
Modified: trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java 2006-12-16
15:08:11 UTC (rev 11437)
+++ trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java 2006-12-16
15:52:21 UTC (rev 11438)
@@ -6,7 +6,8 @@
import thaw.plugins.Hsqldb;
/**
- * Create all the tables used to save the indexes.
+ * Creates all the tables used to save the indexes,
+ * manages structure changes if needed, etc.
* <br/>
* "Comprenne qui pourra" :P
*
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java 2006-12-16
15:08:11 UTC (rev 11437)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java 2006-12-16
15:52:21 UTC (rev 11438)
@@ -220,7 +220,7 @@
final PreparedStatement st = c.prepareStatement("UPDATE
indexCategories SET name = ?, positionInTree = ?, parent = ? WHERE id = ?");
st.setString(1, name);
- st.setInt(2, getParent().getIndex(this));
+ st.setInt(2, getParent().getIndex(this)); /* Index =
position here */
if( ((IndexTreeNode)getParent()).getId() < 0)
st.setNull(3, Types.INTEGER);