From 22d87b73c3ef9a8d62815e7054927dc7790d7d2b Mon Sep 17 00:00:00 2001 From: Yana Stamcheva Date: Mon, 6 Nov 2006 15:30:03 +0000 Subject: [PATCH] invoke remove group in a new thread --- .../contactlist/GroupRightButtonMenu.java | 81 ++++++++++--------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java index 9576c5de8..f66956ad0 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java @@ -103,47 +103,12 @@ public void actionPerformed(ActionEvent e) { String itemName = item.getName(); if(itemName.equals("removeGroup")) { - if(group != null) { - if(Constants.REMOVE_CONTACT_ASK) { - String message = "Are you sure you want to remove " - + this.group.getGroupName() - + "
from your contact list?"; - - MessageDialog dialog = new MessageDialog(this.mainFrame, - message, Messages.getString("remove")); - - int returnCode = dialog.showDialog(); - - if (returnCode == MessageDialog.OK_RETURN_CODE) { - new Thread() { - public void run() { - mainFrame.getContactList() - .removeMetaContactGroup(group); - } - }.start(); - } - else if (returnCode == MessageDialog.OK_DONT_ASK_CODE) { - new Thread() { - public void run() { - mainFrame.getContactList() - .removeMetaContactGroup(group); - } - }.start(); - - Constants.REMOVE_CONTACT_ASK = false; - } - } - else { - new Thread() { - public void run() { - mainFrame.getContactList() - .removeMetaContactGroup(group); - } - }.start(); - } - } + + if(group != null) + new RemoveGroupThread(group).start(); } else if(itemName.equals("renameGroup")) { + RenameGroupDialog dialog = new RenameGroupDialog( mainFrame.getContactList(), group); @@ -175,4 +140,42 @@ else if(mainFrame.getProtocolProviderForAccount(itemText) != null) { dialog.setVisible(true); } } + + /** + * Removes a group from the contact list in a separate thread. + */ + private class RemoveGroupThread extends Thread + { + private MetaContactGroup group; + + public RemoveGroupThread(MetaContactGroup group) { + this.group = group; + } + public void run() { + if(Constants.REMOVE_CONTACT_ASK) { + String message = "Are you sure you want to remove " + + this.group.getGroupName() + + "
from your contact list?"; + + MessageDialog dialog = new MessageDialog(mainFrame, + message, Messages.getString("remove")); + + int returnCode = dialog.showDialog(); + + if (returnCode == MessageDialog.OK_RETURN_CODE) { + mainFrame.getContactList() + .removeMetaContactGroup(group); + } + else if (returnCode == MessageDialog.OK_DONT_ASK_CODE) { + mainFrame.getContactList() + .removeMetaContactGroup(group); + + Constants.REMOVE_CONTACT_ASK = false; + } + } + else { + mainFrame.getContactList().removeMetaContactGroup(group); + } + } + } }