Author: jflesch
Date: 2007-01-25 07:05:44 +0000 (Thu, 25 Jan 2007)
New Revision: 11614
Modified:
trunk/apps/Thaw/src/thaw/core/ConfigWindow.java
trunk/apps/Thaw/src/thaw/core/PluginManager.java
trunk/apps/Thaw/src/thaw/core/SplashScreen.java
Log:
Improve reconnection process when a change is done in the configuration
Modified: trunk/apps/Thaw/src/thaw/core/ConfigWindow.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 2007-01-25 07:03:17 UTC
(rev 11613)
+++ trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 2007-01-25 07:05:44 UTC
(rev 11614)
@@ -182,22 +182,45 @@
/* should reinit the whole connection correctly */
core.getPluginManager().stopPlugins();
- if (needConnectionReset && !core.initNodeConnection()) {
+ Reloader reloader = new Reloader(needConnectionReset);
+ Thread reload = new Thread(reloader);
+ reload.start();
+
+ needConnectionReset = false;
+ }
+ }
+
+
+ /**
+ * We reload the change in another thread to avoid UI freeze
+ */
+ public class Reloader implements Runnable {
+ private boolean resetConnection;
+
+ public Reloader(boolean resetConnection) {
+ this.resetConnection = resetConnection;
+ }
+
+ public void run() {
+
+/* should reinit the whole connection correctly */
+ core.getPluginManager().stopPlugins();
+
+ if (resetConnection && !core.initNodeConnection()) {
new WarningWindow(core,
I18n.getMessage("thaw.warning.unableToConnectTo")+ "
"+core.getConfig().getValue("nodeAddress")+":"+
core.getConfig().getValue("nodePort"));
}
needConnectionReset = false;
+ /* put back the config tab */
+ addTabs();
+
core.getPluginManager().loadPlugins();
core.getPluginManager().runPlugins();
-
- /* reinit config win */
- addTabs();
}
}
-
public void windowActivated(final WindowEvent e) {
}
Modified: trunk/apps/Thaw/src/thaw/core/PluginManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/PluginManager.java 2007-01-25 07:03:17 UTC
(rev 11613)
+++ trunk/apps/Thaw/src/thaw/core/PluginManager.java 2007-01-25 07:05:44 UTC
(rev 11614)
@@ -160,6 +160,8 @@
final Plugin plugin = (Plugin)pluginIt.next();
try {
+ Logger.info(this, "Stopping plugin
'"+plugin.getClass().getName()+"'");
+
if (plugin != null)
plugin.stop();
else
@@ -190,6 +192,8 @@
return null;
}
+ Logger.info(this, "Loading plugin '"+className+"'");
+
plugin = (Plugin)Class.forName(className).newInstance();
plugins.put(className, plugin);
Modified: trunk/apps/Thaw/src/thaw/core/SplashScreen.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/SplashScreen.java 2007-01-25 07:03:17 UTC
(rev 11613)
+++ trunk/apps/Thaw/src/thaw/core/SplashScreen.java 2007-01-25 07:05:44 UTC
(rev 11614)
@@ -26,6 +26,7 @@
public int nmbIcon = 0;
public Vector emptyLabels;
+ public Vector iconLabels;
public SplashScreen() {
@@ -46,6 +47,7 @@
iconPanel.setLayout(new GridLayout(1, NMB_ICONS));
emptyLabels = new Vector();
+ iconLabels = new Vector();
/* it's a dirty method to keep the NMB_ICONS parts of the panel
at the same size */
for (int i = 0 ; i < NMB_ICONS ; i++) {
@@ -123,6 +125,10 @@
lb.repaint();
}
+
+ /* TODO : removeIcon() */
+
+
public int getProgression() {
if(progressBar != null)
return progressBar.getValue();