private boolean needToChangePopup(MouseEvent e) { ContactInfoWindow contact = UIComponentRegistry.getContactInfoWindow(); int loc = getList().locationToIndex(e.getPoint()); ContactItem item = (ContactItem)getList().getModel().getElementAt(loc); return item == null || contact == null || contact.getContactItem() == null ? true : !contact.getContactItem().getJID().equals(item.getJID()); }
private ContactGroup getSubContactGroup(ContactGroup group, JList list) { for (ContactGroup g : group.getContactGroups()) { if (g.getList() == list) { return g; } // Search subs ContactGroup g1 = getSubContactGroup(g, list); if (g1 != null) { return g1; } } return null; }
public void showPopup(MouseEvent e, final Collection<ContactItem> items) { ContactGroup group = null; for (ContactItem item : items) { group = getContactGroup(item.getGroupName()); break; } final JPopupMenu popup = new JPopupMenu(); final JMenuItem sendMessagesMenu = new JMenuItem(Res.getString("menuitem.send.a.message"), SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_IMAGE)); fireContextMenuListenerPopup(popup, items); // See if we should disable all "Broadcast" menu items if (!Default.getBoolean("DISABLE_BROADCAST_MENU_ITEM") && Enterprise.containsFeature(Enterprise.BROADCAST_FEATURE)) popup.add(sendMessagesMenu); sendMessagesMenu.addActionListener( e1 -> sendMessages(items) ); try { popup.show(group.getList(), e.getX(), e.getY()); } catch (NullPointerException ee) { // Nothing we can do here } }
public void display(ContactGroup group, MouseEvent e) { int loc = group.getList().locationToIndex(e.getPoint()); ContactItem item = (ContactItem)group.getList().getModel().getElementAt(loc); if (item == null || item.getJID() == null) { return; } if (getContactItem() != null && getContactItem() == item) { return; } iconLabel.setIcon(item.getIcon()); Point point = group.getList().indexToLocation(loc); window.setFocusableWindowState(false); setContactItem(item); window.pack(); Point mainWindowLocation = SparkManager.getMainWindow().getLocationOnScreen(); Point listLocation = group.getList().getLocationOnScreen(); int x = (int)mainWindowLocation.getX() + SparkManager.getMainWindow().getWidth(); int y = (int) listLocation.getY() + (int) point.getY(); setWindowLocation(x, y); if (!window.isVisible()) { window.setVisible(true); } }
/** * Selects the first user found with specified jid * @param jid, the Users JID */ public void setSelectedUser(BareJid jid) { for (ContactGroup group : getContactGroups()) { if (group.getContactItemByJID(jid) != null) { ContactItem item = group.getContactItemByJID(jid); group.getList().setSelectedValue(item, false); return; } } }
private ContactGroup getContactGroup(JList list) { ContactList contactList = SparkManager.getWorkspace().getContactList(); for (ContactGroup group : contactList.getContactGroups()) { if (group.getList() == list) { return group; } ContactGroup subGroup = getSubContactGroup(group, list); if (subGroup != null) { return subGroup; } } return null; }
popup.show(group.getList(), e.getX(), e.getY()); } else { popup.show(component, e.getX(), e.getY());