diff options
-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(); } } |