public void poppingUp(Object object, JPopupMenu popup) { if (object instanceof ContactItem) { ContactItem item = (ContactItem)object; String bareAddress = XmppStringUtils.parseBareJid(item.getJID()); if (!item.getPresence().isAvailable() || item.getPresence().isAway()) { if (sparkContacts.contains(bareAddress)) { popup.add(removeAction); } else { popup.add(listenAction); } } } }
@Override public void doRun() { staticItem.updatePresenceIcon(staticItem.getPresence()); staticGroup.fireContactGroupUpdated(); } }, timeToRun);
public void poppingUp(final Object component, JPopupMenu popup) { if (!(component instanceof ContactItem)) { return; } ContactItem contactItem = (ContactItem)component; if(contactItem.getPresence() == null){ return; } Action versionRequest = new AbstractAction() { private static final long serialVersionUID = -5619737417315441711L; public void actionPerformed(ActionEvent e) { viewClient(); } }; versionRequest.putValue(Action.NAME, Res.getString("menuitem.view.client.version")); popup.add(versionRequest); }
/** * Returns true if the ContactGroup contains available users. * * @return true if the ContactGroup contains available users. */ public boolean hasAvailableContacts() { for (ContactGroup group : contactGroups) { if (group.hasAvailableContacts()) { return true; } } for (ContactItem item : getContactItems()) { if (item.getPresence() != null) { return true; } } return false; }
private void viewClient() { final ContactList contactList = SparkManager.getWorkspace().getContactList(); Collection<ContactItem> selectedUsers = contactList.getSelectedUsers(); if (selectedUsers.size() == 1) { ContactItem item = (ContactItem)selectedUsers.toArray()[0]; Presence presence = item.getPresence(); final String jid = presence.getFrom().toString(); SwingWorker worker = new SwingWorker() { public Object construct() { try { Thread.sleep(10); } catch (InterruptedException e1) { // Nothing to do } return jid; } public void finished() { VersionViewer.viewVersion(jid); } }; worker.start(); } }
/** * Sets the default settings for a ContactItem. * * @param jid the users jid. */ public void useDefaults(Jid jid) { for (ContactGroup group : getContactGroups()) { ContactItem item = group.getContactItemByJID(jid.asBareJid()); if (item != null) { item.updatePresenceIcon(item.getPresence()); group.fireContactGroupUpdated(); } } }
public void actionPerformed(ActionEvent actionEvent) { try { String client = ""; if (item.getPresence().getType() != Presence.Type.unavailable) { client = item.getPresence().getFrom().toString(); if ((client != null) && (client.lastIndexOf("/") != -1)) { client = client.substring(client.lastIndexOf("/")); } else client = "/"; } Jid jid = JidCreate.from(item.getJid().toString() + client); LastActivity activity = LastActivityManager.getInstanceFor( SparkManager.getConnection() ).getLastActivity(jid); long idleTime = (activity.getIdleTime() * 1000); String time = ModelUtil.getTimeFromLong(idleTime); UIManager.put("OptionPane.okButtonText", Res.getString("ok")); JOptionPane.showMessageDialog(getGUI(), Res.getString("message.idle.for", time), Res.getString("title.last.activity"), JOptionPane.INFORMATION_MESSAGE); } catch (Exception e1) { UIManager.put("OptionPane.okButtonText", Res.getString("ok")); JOptionPane.showMessageDialog(getGUI(), Res.getString("message.unable.to.retrieve.last.activity", item.getJID()), Res.getString("title.error"), JOptionPane.ERROR_MESSAGE); } } };
for (CheckNode node : nodes) { if (contactList.getContactItemByDisplayName(node.toString()) .getPresence().getType() == Presence.Type.unavailable) { if (node.getParent() != null) { TreeNode parent = node.getParent();
if (contactItem.getPresence() == null || contactItem.getPresence().getType() == Presence.Type.unavailable) { status = Res.getString("offline"); if (status.equals(Res.getString("offline")) || contactItem.getPresence().isAway()) { if (!status.equals(Res.getString("offline"))) { client = contactItem.getPresence().getFrom(); } else { client = contactItem.getJid(); } else if (contactItem.getPresence().isAway()) { status += "\n"; String time = ModelUtil.getTimeFromLong(idleTime);
if (item.getPresence().isAvailable()) { item.showUserGoingOfflineOnline(); item.setIcon(SparkRes.getImageIcon(SparkRes.CLEAR_BALL_ICON));
private void registerListener() { preferences = SettingsManager.getLocalPreferences(); // Iterate through all online users and add them to the list. ContactList contactList = SparkManager.getWorkspace().getContactList(); for (ContactGroup contactGroup : contactList.getContactGroups()) { for (ContactItem item : contactGroup.getContactItems()) { if (item != null && item.getJid() != null && item.getPresence().isAvailable()) { BareJid bareJID = item.getJid().asBareJid(); onlineUsers.add(bareJID); } } } // Add Presence Listener SparkManager.getConnection().addAsyncStanzaListener(this, new StanzaTypeFilter(Presence.class)); }
sendAction.putValue(Action.SMALL_ICON, SparkRes.getImageIcon(SparkRes.DOCUMENT_16x16)); sendAction.putValue(Action.NAME, Res.getString("menuitem.send.a.file")); if (item.getPresence() != null) popup.add(sendAction); lastActivityAction.putValue(Action.SMALL_ICON, SparkRes.getImageIcon(SparkRes.SMALL_USER1_STOPWATCH)); if (contactGroup == offlineGroup || item.getPresence().isAway() || (item.getPresence().getType() == Presence.Type.unavailable) || (item.getPresence().getType() == null)) { popup.add(lastActivityAction);
private void addContactItem(final ContactGroup contactGroup, final ContactItem item) { ContactItem newContact = UIComponentRegistry.createContactItem(Res.getString("group.empty"), null, null); newContact.setPresence(item.getPresence()); newContact.setIcon(item.getIcon()); newContact.getNicknameLabel().setFont(item.getNicknameLabel().getFont());
newContact.setPresence(item.getPresence()); newContact.setIcon(item.getIcon()); newContact.getNicknameLabel().setFont(item.getNicknameLabel().getFont());
changeContact.showUserComingOnline(); changeContact.setSpecialIcon(offlineItem.getSpecialImageLabel().getIcon()); changeContact.updatePresenceIcon(changeContact.getPresence()); toggleGroupVisibility(staticContactGroup.getGroupName(), true); staticContactGroup.fireContactGroupUpdated(); contactItem.setAvailable(true); unfiledGrp.addContactItem(contactItem); contactItem.updatePresenceIcon(contactItem.getPresence()); unfiledGrp.fireContactGroupUpdated();
for (ContactGroup contactGroup : contactList.getContactGroups()) { for (ContactItem contactItem : contactGroup.getContactItems()) { Presence presence = contactItem.getPresence(); if (presence.isAvailable()) { Domainpart domain = presence.getFrom().getDomain();