diff options
author | Sebastien Vincent <seb@jitsi.org> | 2011-03-10 12:45:31 +0000 |
---|---|---|
committer | Sebastien Vincent <seb@jitsi.org> | 2011-03-10 12:45:31 +0000 |
commit | a6c2e54ae93a26064dc7d1b1a1d44e885f44a6bf (patch) | |
tree | 817175acda04bf1fc508fe39d51590ef2ef7f971 /src/net/java/sip/communicator/plugin/ldap | |
parent | f40aba30474b2b1cd78316efe039758a3173dd53 (diff) | |
download | jitsi-a6c2e54ae93a26064dc7d1b1a1d44e885f44a6bf.zip jitsi-a6c2e54ae93a26064dc7d1b1a1d44e885f44a6bf.tar.gz jitsi-a6c2e54ae93a26064dc7d1b1a1d44e885f44a6bf.tar.bz2 |
Add/remove LDAP contact source service in a separate thread to avoid take too much time in Event Dispatch Thread.
Diffstat (limited to 'src/net/java/sip/communicator/plugin/ldap')
-rw-r--r-- | src/net/java/sip/communicator/plugin/ldap/configform/LdapConfigForm.java | 59 | ||||
-rw-r--r-- | src/net/java/sip/communicator/plugin/ldap/configform/LdapTableModel.java | 6 |
2 files changed, 55 insertions, 10 deletions
diff --git a/src/net/java/sip/communicator/plugin/ldap/configform/LdapConfigForm.java b/src/net/java/sip/communicator/plugin/ldap/configform/LdapConfigForm.java index 2f36ef2..8a0c3ae 100644 --- a/src/net/java/sip/communicator/plugin/ldap/configform/LdapConfigForm.java +++ b/src/net/java/sip/communicator/plugin/ldap/configform/LdapConfigForm.java @@ -150,14 +150,14 @@ public class LdapConfigForm if(ret == 1) { - LdapActivator.disableContactSource(oldServer); LdapDirectory newServer = factory.createServer( settingsForm.getSettings()); serverSet.removeServerWithName( oldServer.getSettings(). getName()); + new RefreshContactSourceThread(oldServer, + newServer).start(); serverSet.addServer(newServer); - LdapActivator.enableContactSource(newServer); refresh(); } } @@ -267,9 +267,8 @@ public class LdapConfigForm { LdapDirectory server = factory.createServer( settingsForm.getSettings()); - + new RefreshContactSourceThread(null, server).start(); serverSet.addServer(server); - LdapActivator.enableContactSource(server); refresh(); } } @@ -285,21 +284,20 @@ public class LdapConfigForm if(ret == 1) { - LdapActivator.disableContactSource(oldServer); LdapDirectory newServer = factory.createServer( settingsForm.getSettings()); + new RefreshContactSourceThread(oldServer, newServer).start(); serverSet.removeServerWithName(oldServer.getSettings(). getName()); serverSet.addServer(newServer); - LdapActivator.enableContactSource(newServer); refresh(); } } if (e.getActionCommand().equals("remove") && row != -1) { - LdapActivator.disableContactSource(this.tableModel.getServerAt( - row)); + new RefreshContactSourceThread(this.tableModel.getServerAt(row), + null).start(); serverSet.removeServerWithName(this.tableModel.getServerAt(row). getSettings().getName()); refresh(); @@ -343,5 +341,50 @@ public class LdapConfigForm { return true; } + + /** + * Thread that will perform refresh of contact sources. + */ + public static class RefreshContactSourceThread + extends Thread + { + /** + * LDAP directory to remove. + */ + private LdapDirectory oldLdap = null; + + /** + * LDAP directory to add. + */ + private LdapDirectory newLdap = null; + + /** + * Constructor. + * + * @param oldLdap LDAP directory to remove + * @param newLdap LDAP directory to add. + */ + RefreshContactSourceThread(LdapDirectory oldLdap, LdapDirectory newLdap) + { + this.oldLdap = oldLdap; + this.newLdap = newLdap; + } + + /** + * Thread entry point. + */ + public void run() + { + if(oldLdap != null) + { + LdapActivator.disableContactSource(oldLdap); + } + + if(newLdap != null) + { + LdapActivator.enableContactSource(newLdap); + } + } + } } diff --git a/src/net/java/sip/communicator/plugin/ldap/configform/LdapTableModel.java b/src/net/java/sip/communicator/plugin/ldap/configform/LdapTableModel.java index 576b49c..725ab20 100644 --- a/src/net/java/sip/communicator/plugin/ldap/configform/LdapTableModel.java +++ b/src/net/java/sip/communicator/plugin/ldap/configform/LdapTableModel.java @@ -161,19 +161,21 @@ public class LdapTableModel if(columnIndex != 0) throw new IllegalArgumentException("non editable column!"); LdapDirectory server = this.getServerAt(rowIndex); + LdapConfigForm.RefreshContactSourceThread th = null; /* toggle enabled marker and save */ server.setEnabled(!server.isEnabled()); if(!server.isEnabled()) { - LdapActivator.disableContactSource(server); + th = new LdapConfigForm.RefreshContactSourceThread(server, null); } else { - LdapActivator.enableContactSource(server); + th = new LdapConfigForm.RefreshContactSourceThread(null, server); } + th.start(); server.getSettings().persistentSave(); } } |