diff options
author | Yana Stamcheva <yana@jitsi.org> | 2009-10-30 11:37:19 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2009-10-30 11:37:19 +0000 |
commit | cf8a7b04a68737b626c5bd86818a45d2ae0ae30a (patch) | |
tree | 36a3a6e3c36d4c9acefdd91905554b806eb3a42c /src/net/java/sip/communicator/impl/gui/main/contactlist/DefaultContactList.java | |
parent | 86901fcffa1438058738f4ba14d56b217d7eb0c1 (diff) | |
download | jitsi-cf8a7b04a68737b626c5bd86818a45d2ae0ae30a.zip jitsi-cf8a7b04a68737b626c5bd86818a45d2ae0ae30a.tar.gz jitsi-cf8a7b04a68737b626c5bd86818a45d2ae0ae30a.tar.bz2 |
Drag'n'Drop related implementations including:
- dropping MetaContact-s or simple String addresses in the Call dialog would initiate an invite and hence the creation of a conference call or if such already exist just the adding of the new callee to the conference.
- added the possibility to drag the number entered in the call field on the bottom of the contact list.
- replaced previous implementation of Drag'n'Drop in the contact list with the default drag'n'drop mechanism used in java, thus allowing the dropping of contacts outside the contact list (like in an existing call, chat or simply as a string in any other desktop application)
- extended and override the default TransferHandler to provide visual representation of the dragged object (special handling of MetaContacts is provided in the ContactListCellRenderer) and add support of MetaContact flavor.
Diffstat (limited to 'src/net/java/sip/communicator/impl/gui/main/contactlist/DefaultContactList.java')
-rw-r--r-- | src/net/java/sip/communicator/impl/gui/main/contactlist/DefaultContactList.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/DefaultContactList.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/DefaultContactList.java index fb7ea7a..c5ac9a3 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/DefaultContactList.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/DefaultContactList.java @@ -31,6 +31,11 @@ public class DefaultContactList private static final long serialVersionUID = 0L; /** + * The cached mouse event. + */ + private MouseEvent cachedMouseEvent; + + /** * Creates an instance of <tt>DefaultContactList</tt>. */ public DefaultContactList() @@ -40,6 +45,7 @@ public class DefaultContactList this.getSelectionModel().setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + this.setDragEnabled(true); this.setTransferHandler(new ContactListTransferHandler(this)); this.setCellRenderer(new ContactListCellRenderer()); } @@ -277,4 +283,56 @@ public class DefaultContactList } while (index != startIndex); return -1; } + + /** + * Processes the <tt>MouseEvent</tt> we have previously cached before + * invoking the parent <tt>fireSelectionValueChanged</tt> which would + * notify the <tt>JList</tt> <tt>ListSelectionListener</tt>s that the + * selection model has changed. + * <p> + * Workaround provided by simon@tardell.se on 29-DEC-2002 for bug 4521075 + * http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=a13e98ab2364524506eb91505565?bug_id=4521075 + * "Drag gesture in JAVA different from Windows". The bug is also noticed + * on Mac Leopard. + * + * @param firstIndex the first selected index + * @param lastIndex the last selected index + * @param isAdjusting true if multiple changes are being made + */ + protected void fireSelectionValueChanged(int firstIndex, int lastIndex, + boolean isAdjusting) + { + if (cachedMouseEvent != null) + { + super.processMouseEvent(new MouseEvent( + (Component) cachedMouseEvent.getSource(), + cachedMouseEvent.getID(), + cachedMouseEvent.getWhen(), + cachedMouseEvent.getModifiers(), + cachedMouseEvent.getX(), + cachedMouseEvent.getY(), + cachedMouseEvent.getClickCount(), + cachedMouseEvent.isPopupTrigger())); + + cachedMouseEvent = null; + } + super.fireSelectionValueChanged(firstIndex, lastIndex, isAdjusting); + } + + /** + * Caches the incoming mouse <tt>event</tt> before passing it to the parent + * implementation of <tt>processMouseEvent</tt>. + * <p> + * Workaround provided by simon@tardell.se on 29-DEC-2002 for bug 4521075 + * http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=a13e98ab2364524506eb91505565?bug_id=4521075 + * "Drag gesture in JAVA different from Windows". The bug is also noticed + * on Mac Leopard. + * @param event the <tt>MouseEvent</tt> to process + */ + protected void processMouseEvent(MouseEvent event) + { + if ((event.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) + cachedMouseEvent= event; + super.processMouseEvent(event); + } } |