move subcontact to group

cusax-fix
Yana Stamcheva 19 years ago
parent ce1bcb9069
commit b8f547fa5c

@ -355,9 +355,9 @@ public void removeExcContactListListener(ContactListListener listener)
* @param sourceContact the contact that this event is about.
* @param eventID the id indicating the exact type of the event to fire.
*/
public void fireContactListEvent(MetaContact sourceContact, int eventID)
public void fireContactListEvent(Object source, int eventID)
{
ContactListEvent evt = new ContactListEvent(sourceContact, eventID);
ContactListEvent evt = new ContactListEvent(source, eventID);
if (excContactListListeners.size() > 0) {
synchronized (excContactListListeners) {
@ -374,6 +374,9 @@ public void fireContactListEvent(MetaContact sourceContact, int eventID)
case ContactListEvent.PROTOCOL_CONTACT_SELECTED:
listener.protocolContactSelected(evt);
break;
case ContactListEvent.GROUP_SELECTED:
listener.groupSelected(evt);
break;
default:
logger.error("Unknown event type " + evt.getEventID());
}
@ -394,6 +397,9 @@ public void fireContactListEvent(MetaContact sourceContact, int eventID)
case ContactListEvent.PROTOCOL_CONTACT_SELECTED:
listener.protocolContactSelected(evt);
break;
case ContactListEvent.GROUP_SELECTED:
listener.groupSelected(evt);
break;
default:
logger.error("Unknown event type " + evt.getEventID());
}
@ -529,6 +535,9 @@ public void mousePressed(MouseEvent e)
groupRightButtonMenu.setVisible(true);
}
else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0){
fireContactListEvent(group, ContactListEvent.GROUP_SELECTED);
}
}
// Open message window, right button menu or contact info when

@ -27,8 +27,12 @@ public class ContactListEvent
* selecting a protocol contact in the contact list.
*/
public static final int PROTOCOL_CONTACT_SELECTED = 2;
private MetaContact sourceContact;
/**
* Indicates that the ContactListEvent instance was triggered by selecting
* a group in the contact list.
*/
public static final int GROUP_SELECTED = 3;
private Contact sourceProtoContact;
@ -38,11 +42,11 @@ public class ContactListEvent
* @param eventID one of the XXX_SELECTED static fields indicating the
* nature of the event.
*/
public ContactListEvent(MetaContact source, int eventID)
public ContactListEvent(Object source, int eventID)
{
super(source);
this.eventID = eventID;
this.sourceContact = source;
}
/**
@ -52,12 +56,11 @@ public ContactListEvent(MetaContact source, int eventID)
* @param eventID one of the XXX_SELECTED static fields indicating the
* nature of the event.
*/
public ContactListEvent(MetaContact source,
public ContactListEvent(Object source,
Contact protocolContact, int eventID)
{
super(source);
this.eventID = eventID;
this.sourceContact = source;
this.sourceProtoContact = protocolContact;
}
@ -77,7 +80,18 @@ public int getEventID()
*/
public MetaContact getSourceContact()
{
return sourceContact;
if(getSource() instanceof MetaContact)
return (MetaContact)getSource();
return null;
}
public MetaContactGroup getSourceGroup()
{
if(getSource() instanceof MetaContactGroup)
return (MetaContactGroup)getSource();
return null;
}
/**

@ -11,6 +11,8 @@
public interface ContactListListener extends EventListener
{
public void groupSelected(ContactListEvent evt);
public void contactSelected(ContactListEvent evt);
public void protocolContactSelected(ContactListEvent evt);

@ -7,14 +7,13 @@
package net.java.sip.communicator.impl.gui.main.contactlist;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.Timer;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.message.*;
@ -126,6 +125,12 @@ public void contactSelected(ContactListEvent evt)
SwingUtilities
.invokeLater(new RunMessageWindow(evt.getSourceContact()));
}
/**
* Implements the ContactListListener.groupSelected method.
*/
public void groupSelected(ContactListEvent evt)
{}
/**
* Implements the ContactListListener.protocolContactSelected method.

@ -87,7 +87,7 @@ public class ContactRightButtonMenu
private ContactList guiContactList;
/**
* Creates an instance of ContactRightButtonMenu.
* @param mainFrame The parent MainFrame window.
* @param contactList The contact list over which this menu is shown.
* @param contactItem The MetaContact for which the menu is opened.
*/
public ContactRightButtonMenu(ContactList contactList,
@ -186,9 +186,6 @@ private void init() {
JMenuItem allItem = new JMenuItem(Messages.getString("allContacts"));
JMenuItem allItem1 = new JMenuItem(Messages.getString("allContacts"));
allItem.setFont(Constants.FONT.deriveFont(Font.BOLD));
allItem1.setFont(Constants.FONT.deriveFont(Font.BOLD));
allItem.addActionListener(this);
allItem1.addActionListener(this);
@ -529,6 +526,26 @@ else if (returnCode == MessageDialog.OK_DONT_ASK_CODE) {
}
}
}
public void groupSelected(ContactListEvent evt)
{
this.moveDialog.dispose();
MetaContactGroup sourceGroup = evt.getSourceGroup();
guiContactList.removeExcContactListListener(this);
guiContactList.setCursor(
Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
if(moveAllContacts) {
mainFrame.getContactList()
.moveMetaContact(contactItem, sourceGroup);
}
else if(contactToMove != null) {
new MoveSubcontactThread(sourceGroup).start();
}
}
/**
* Implements ContactListListener.contactSelected method in order
@ -580,21 +597,35 @@ else if(contactToMove != null) {
}
/**
*
* Moves the previously choosen contact in the given meta group or meta
* contact.
*/
private class MoveSubcontactThread extends Thread
{
private MetaContact metaContact;
private MetaContactGroup metaGroup;
public MoveSubcontactThread(MetaContact metaContact)
{
this.metaContact = metaContact;
}
public MoveSubcontactThread(MetaContactGroup metaGroup)
{
this.metaGroup = metaGroup;
}
public void run()
{
mainFrame.getContactList()
.moveContact(contactToMove, metaContact);
if(metaContact != null) {
mainFrame.getContactList()
.moveContact(contactToMove, metaContact);
}
else {
mainFrame.getContactList()
.moveContact(contactToMove, metaGroup);
}
}
}
@ -620,5 +651,5 @@ public void run()
.moveContact(contact, metaContact);
}
}
}
}
}

Loading…
Cancel
Save