mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
Thanks to Guus der Kinderen for this patch:
[SPARK-1025] Make rename global and not limited to just the contact list git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@10687 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
committed by
andrew.seymour
parent
bd984dc5a0
commit
ae0eacf8ff
@ -237,7 +237,7 @@ public class ChatManager implements MessageEventNotificationListener {
|
||||
ContactList contactList = SparkManager.getWorkspace().getContactList();
|
||||
ContactItem item = contactList.getContactItemByJID(jid);
|
||||
if (item != null) {
|
||||
String nickname = item.getNickname();
|
||||
String nickname = item.getDisplayName();
|
||||
chatRoom = new ChatRoomImpl(jid, nickname, nickname);
|
||||
}
|
||||
else {
|
||||
@ -896,4 +896,4 @@ public class ChatManager implements MessageEventNotificationListener {
|
||||
ConferenceUtils.joinConferenceOnSeperateThread(conference, conference, null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,7 +275,7 @@ public class UserManager {
|
||||
ContactList contactList = SparkManager.getWorkspace().getContactList();
|
||||
ContactItem item = contactList.getContactItemByJID(jid);
|
||||
if (item != null) {
|
||||
return item.getNickname();
|
||||
return item.getDisplayName();
|
||||
}
|
||||
|
||||
return unescapeJID(jid);
|
||||
@ -321,15 +321,15 @@ public class UserManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full jid w/ resource of a user by their nickname
|
||||
* Returns the full jid w/ resource of a user by their display name
|
||||
* in the ContactList.
|
||||
*
|
||||
* @param nickname the nickname of the user.
|
||||
* @param displayName the displayed name of the user.
|
||||
* @return the full jid w/ resource of the user.
|
||||
*/
|
||||
public String getJIDFromNickname(String nickname) {
|
||||
public String getJIDFromDisplayName(String displayName) {
|
||||
ContactList contactList = SparkManager.getWorkspace().getContactList();
|
||||
ContactItem item = contactList.getContactItemByNickname(nickname);
|
||||
ContactItem item = contactList.getContactItemByDisplayName(displayName);
|
||||
if (item != null) {
|
||||
return getFullJID(item.getJID());
|
||||
}
|
||||
@ -398,7 +398,7 @@ public class UserManager {
|
||||
parent.setGlassPane(glassPane);
|
||||
parent.getGlassPane().setVisible(false);
|
||||
contactField.dispose();
|
||||
SparkManager.getChatManager().activateChat(item.getJID(), item.getNickname());
|
||||
SparkManager.getChatManager().activateChat(item.getJID(), item.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -423,7 +423,7 @@ public class UserManager {
|
||||
parent.setGlassPane(glassPane);
|
||||
parent.getGlassPane().setVisible(false);
|
||||
contactField.dispose();
|
||||
SparkManager.getChatManager().activateChat(item.getJID(), item.getNickname());
|
||||
SparkManager.getChatManager().activateChat(item.getJID(), item.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -501,10 +501,11 @@ public class UserManager {
|
||||
*/
|
||||
final Comparator<ContactItem> itemComparator = new Comparator<ContactItem>() {
|
||||
public int compare(ContactItem item1, ContactItem item2) {
|
||||
return item1.getNickname().toLowerCase().compareTo(item2.getNickname().toLowerCase());
|
||||
return item1.getDisplayName().toLowerCase().compareTo(item2.getDisplayName().toLowerCase());
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -361,7 +361,7 @@ public class Workspace extends JPanel implements PacketListener {
|
||||
ContactItem contact = contactList.getContactItemByJID(bareJID);
|
||||
String nickname = StringUtils.parseName(bareJID);
|
||||
if (contact != null) {
|
||||
nickname = contact.getNickname();
|
||||
nickname = contact.getDisplayName();
|
||||
}
|
||||
|
||||
// Create the room if it does not exist.
|
||||
@ -386,7 +386,7 @@ public class Workspace extends JPanel implements PacketListener {
|
||||
ContactItem contact = contactList.getContactItemByJID(bareJID);
|
||||
String nickname = StringUtils.parseName(bareJID);
|
||||
if (contact != null) {
|
||||
nickname = contact.getNickname();
|
||||
nickname = contact.getDisplayName();
|
||||
}
|
||||
else {
|
||||
// Attempt to load VCard from users who we are not subscribed to.
|
||||
|
||||
@ -75,7 +75,7 @@ public class JContactItemField extends JPanel {
|
||||
int index = list.getSelectedIndex();
|
||||
if (index >= 0) {
|
||||
ContactItem selection = (ContactItem)list.getSelectedValue();
|
||||
textField.setText(selection.getNickname());
|
||||
textField.setText(selection.getDisplayName());
|
||||
popup.setVisible(false);
|
||||
}
|
||||
}
|
||||
@ -119,7 +119,7 @@ public class JContactItemField extends JPanel {
|
||||
int index = list.getSelectedIndex();
|
||||
if (index >= 0) {
|
||||
ContactItem selection = (ContactItem)list.getSelectedValue();
|
||||
textField.setText(selection.getNickname());
|
||||
textField.setText(selection.getDisplayName());
|
||||
popup.setVisible(false);
|
||||
}
|
||||
}
|
||||
@ -146,7 +146,7 @@ public class JContactItemField extends JPanel {
|
||||
|
||||
final List<ContactItem> validItems = new ArrayList<ContactItem>();
|
||||
for (ContactItem contactItem : items) {
|
||||
String nickname = contactItem.getNickname().toLowerCase();
|
||||
String nickname = contactItem.getDisplayName().toLowerCase();
|
||||
if (nickname.startsWith(typedItem.toLowerCase())) {
|
||||
validItems.add(contactItem);
|
||||
}
|
||||
@ -275,7 +275,7 @@ public class JContactItemField extends JPanel {
|
||||
|
||||
|
||||
ContactItem contactItem = (ContactItem)value;
|
||||
setText(contactItem.getNickname());
|
||||
setText(contactItem.getDisplayName());
|
||||
if (contactItem.getIcon() == null) {
|
||||
setIcon(SparkRes.getImageIcon(SparkRes.CLEAR_BALL_ICON));
|
||||
}
|
||||
|
||||
@ -254,7 +254,7 @@ public class SparkTransferManager {
|
||||
|
||||
ChatRoom chatRoom;
|
||||
if (contactItem != null) {
|
||||
chatRoom = SparkManager.getChatManager().createChatRoom(bareJID, contactItem.getNickname(), contactItem.getNickname());
|
||||
chatRoom = SparkManager.getChatManager().createChatRoom(bareJID, contactItem.getDisplayName(), contactItem.getDisplayName());
|
||||
}
|
||||
else {
|
||||
chatRoom = SparkManager.getChatManager().createChatRoom(bareJID, bareJID, bareJID);
|
||||
@ -291,7 +291,7 @@ public class SparkTransferManager {
|
||||
|
||||
chatRoom.scrollToBottom();
|
||||
|
||||
String fileTransMsg = contactItem.getNickname() + " " + Res.getString("message.file.transfer.short.message") + " " + fileName;
|
||||
String fileTransMsg = contactItem.getDisplayName() + " " + Res.getString("message.file.transfer.short.message") + " " + fileName;
|
||||
SparkManager.getChatManager().getChatContainer().fireNotifyOnMessage(chatRoom, true, fileTransMsg, Res.getString("message.file.transfer.notification"));
|
||||
}
|
||||
|
||||
@ -512,7 +512,7 @@ public class SparkTransferManager {
|
||||
ChatRoom chatRoom;
|
||||
ContactItem contactItem = contactList.getContactItemByJID(jid);
|
||||
if (contactItem != null) {
|
||||
chatRoom = SparkManager.getChatManager().createChatRoom(jid, contactItem.getNickname(), contactItem.getNickname());
|
||||
chatRoom = SparkManager.getChatManager().createChatRoom(jid, contactItem.getDisplayName(), contactItem.getDisplayName());
|
||||
}
|
||||
else {
|
||||
chatRoom = SparkManager.getChatManager().createChatRoom(jid, jid, jid);
|
||||
@ -530,7 +530,7 @@ public class SparkTransferManager {
|
||||
|
||||
ChatRoom chatRoom;
|
||||
if (contactItem != null) {
|
||||
chatRoom = SparkManager.getChatManager().createChatRoom(bareJID, contactItem.getNickname(), contactItem.getNickname());
|
||||
chatRoom = SparkManager.getChatManager().createChatRoom(bareJID, contactItem.getDisplayName(), contactItem.getDisplayName());
|
||||
}
|
||||
else {
|
||||
chatRoom = SparkManager.getChatManager().createChatRoom(bareJID, bareJID, bareJID);
|
||||
@ -578,7 +578,7 @@ public class SparkTransferManager {
|
||||
});
|
||||
|
||||
try {
|
||||
sendingUI.sendFile(transfer, transferManager, fullJID, contactItem.getNickname());
|
||||
sendingUI.sendFile(transfer, transferManager, fullJID, contactItem.getDisplayName());
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
Log.error(e);
|
||||
|
||||
@ -65,7 +65,7 @@ public class ContactGroup extends CollapsiblePane implements MouseListener {
|
||||
private JPanel listPanel;
|
||||
|
||||
// Used to display no contacts in list.
|
||||
private final ContactItem noContacts = new ContactItem(Res.getString("group.empty"), null);
|
||||
private final ContactItem noContacts = new ContactItem(Res.getString("group.empty"), null, null);
|
||||
|
||||
private final ListMotionListener motionListener = new ListMotionListener();
|
||||
|
||||
@ -153,13 +153,14 @@ public class ContactGroup extends CollapsiblePane implements MouseListener {
|
||||
/**
|
||||
* Adds a new offline contact.
|
||||
*
|
||||
* @param alias the alias of the offline contact.
|
||||
* @param nickname the nickname of the offline contact.
|
||||
* @param jid the jid of the offline contact.
|
||||
* @param status the current status of the offline contact.
|
||||
*/
|
||||
public void addOfflineContactItem(String nickname, String jid, String status) {
|
||||
public void addOfflineContactItem(String alias, String nickname, String jid, String status) {
|
||||
// Build new ContactItem
|
||||
final ContactItem offlineItem = new ContactItem(nickname, jid);
|
||||
final ContactItem offlineItem = new ContactItem(alias, nickname, jid);
|
||||
offlineItem.setGroupName(getGroupName());
|
||||
|
||||
final Presence offlinePresence = PresenceManager.getPresence(jid);
|
||||
@ -173,7 +174,7 @@ public class ContactGroup extends CollapsiblePane implements MouseListener {
|
||||
offlineItem.setStatusText(status);
|
||||
}
|
||||
|
||||
// Add to offlien contacts.
|
||||
// Add to offline contacts.
|
||||
offlineContacts.add(offlineItem);
|
||||
|
||||
insertOfflineContactItem(offlineItem);
|
||||
@ -390,14 +391,14 @@ public class ContactGroup extends CollapsiblePane implements MouseListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a <code>ContactItem</code> by the nickname the user has been assigned.
|
||||
* Returns a <code>ContactItem</code> by the displayed name the user has been assigned.
|
||||
*
|
||||
* @param nickname the nickname of the user.
|
||||
* @param displayName the displayed name of the user.
|
||||
* @return the ContactItem.
|
||||
*/
|
||||
public ContactItem getContactItemByNickname(String nickname) {
|
||||
public ContactItem getContactItemByDisplayName(String displayName) {
|
||||
for (ContactItem item : new ArrayList<ContactItem>(contactItems)) {
|
||||
if (item.getNickname().equals(nickname)) {
|
||||
if (item.getDisplayName().equals(displayName)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@ -673,7 +674,7 @@ public class ContactGroup extends CollapsiblePane implements MouseListener {
|
||||
*/
|
||||
final Comparator<ContactItem> itemComparator = new Comparator<ContactItem>() {
|
||||
public int compare(ContactItem item1, ContactItem item2) {
|
||||
return item1.getNickname().toLowerCase().compareTo(item2.getNickname().toLowerCase());
|
||||
return item1.getDisplayName().toLowerCase().compareTo(item2.getDisplayName().toLowerCase());
|
||||
}
|
||||
};
|
||||
|
||||
@ -871,3 +872,4 @@ public class ContactGroup extends CollapsiblePane implements MouseListener {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -92,7 +92,7 @@ public class ContactGroupTransferHandler extends TransferHandler {
|
||||
int size = model.getSize();
|
||||
for (int i = 0; i < size; i++) {
|
||||
ContactItem it = (ContactItem)model.getElementAt(i);
|
||||
if (it.getNickname().equals(item.getNickname())) {
|
||||
if (it.getDisplayName().equals(item.getDisplayName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -195,13 +195,13 @@ public class ContactGroupTransferHandler extends TransferHandler {
|
||||
}
|
||||
|
||||
private void addContactItem(final ContactGroup contactGroup, final ContactItem item) {
|
||||
ContactItem newContact = new ContactItem(item.getNickname(), item.getJID());
|
||||
ContactItem newContact = new ContactItem(item.getAlias(), item.getNickname(), item.getJID());
|
||||
newContact.setPresence(item.getPresence());
|
||||
newContact.setIcon(item.getIcon());
|
||||
newContact.getNicknameLabel().setFont(item.getNicknameLabel().getFont());
|
||||
|
||||
if (!PresenceManager.isOnline(item.getJID())) {
|
||||
contactGroup.addOfflineContactItem(item.getNickname(), item.getJID(), null);
|
||||
contactGroup.addOfflineContactItem(item.getAlias(), item.getNickname(), item.getJID(), null);
|
||||
}
|
||||
else {
|
||||
contactGroup.addContactItem(newContact);
|
||||
@ -298,3 +298,4 @@ public class ContactGroupTransferHandler extends TransferHandler {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -184,7 +184,7 @@ public class ContactInfoWindow extends JPanel {
|
||||
return;
|
||||
}
|
||||
|
||||
nicknameLabel.setText(contactItem.getNickname());
|
||||
nicknameLabel.setText(contactItem.getDisplayName());
|
||||
|
||||
String status = contactItem.getStatus();
|
||||
if (!ModelUtil.hasLength(status)) {
|
||||
|
||||
@ -41,9 +41,10 @@ import java.net.URL;
|
||||
*/
|
||||
public class ContactItem extends JPanel {
|
||||
private JLabel imageLabel;
|
||||
private JLabel nicknameLabel;
|
||||
private JLabel displayNameLabel;
|
||||
private JLabel descriptionLabel;
|
||||
private String nickname;
|
||||
private String alias;
|
||||
private String fullyQualifiedJID;
|
||||
private Icon icon;
|
||||
|
||||
@ -69,10 +70,11 @@ public class ContactItem extends JPanel {
|
||||
/**
|
||||
* Creates a new instance of a contact.
|
||||
*
|
||||
* @param alias the alias of the contact
|
||||
* @param nickname the nickname of the contact.
|
||||
* @param fullyQualifiedJID the fully-qualified jid of the contact (ex. derek@jivesoftware.com)
|
||||
*/
|
||||
public ContactItem(String nickname, String fullyQualifiedJID) {
|
||||
public ContactItem(String alias, String nickname, String fullyQualifiedJID) {
|
||||
setLayout(new GridBagLayout());
|
||||
|
||||
// Set Default Font
|
||||
@ -86,7 +88,7 @@ public class ContactItem extends JPanel {
|
||||
|
||||
contactsDir = new File(SparkManager.getUserDirectory(), "contacts");
|
||||
|
||||
nicknameLabel = new JLabel();
|
||||
displayNameLabel = new JLabel();
|
||||
descriptionLabel = new JLabel();
|
||||
imageLabel = new JLabel();
|
||||
sideIcon = new JLabel();
|
||||
@ -96,9 +98,9 @@ public class ContactItem extends JPanel {
|
||||
sideIcon.setPreferredSize(new Dimension(iconSize, iconSize));
|
||||
}
|
||||
|
||||
nicknameLabel.setHorizontalTextPosition(JLabel.LEFT);
|
||||
nicknameLabel.setHorizontalAlignment(JLabel.LEFT);
|
||||
nicknameLabel.setText(nickname);
|
||||
displayNameLabel.setHorizontalTextPosition(JLabel.LEFT);
|
||||
displayNameLabel.setHorizontalAlignment(JLabel.LEFT);
|
||||
//displayNameLabel.setText(nickname);
|
||||
|
||||
|
||||
descriptionLabel.setFont(new Font("Dialog", Font.PLAIN, fontSize));
|
||||
@ -110,24 +112,52 @@ public class ContactItem extends JPanel {
|
||||
this.setOpaque(true);
|
||||
|
||||
add(imageLabel, new GridBagConstraints(0, 0, 1, 2, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 15, 0, 0), 0, 0));
|
||||
add(nicknameLabel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0));
|
||||
add(displayNameLabel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0));
|
||||
add(descriptionLabel, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 2, 0), 0, 0));
|
||||
add(sideIcon, new GridBagConstraints(3, 0, 1, 2, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0));
|
||||
|
||||
setNickname(nickname);
|
||||
|
||||
this.alias = alias;
|
||||
this.nickname = nickname;
|
||||
this.fullyQualifiedJID = fullyQualifiedJID;
|
||||
|
||||
setDisplayName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name that should be displayed to represent the the contact.
|
||||
* If an alias has been set, this alias will be returned. If no alias has
|
||||
* been set, the nickname will be returned. If that hasn't been set either,
|
||||
* the JID will be returned.
|
||||
*
|
||||
* @return a name suitable to be displayed
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
final String displayName;
|
||||
if (alias != null) {
|
||||
displayName = alias;
|
||||
} else if (nickname != null) {
|
||||
displayName = nickname;
|
||||
} else {
|
||||
displayName = getJID();
|
||||
}
|
||||
|
||||
if (displayName != null) {
|
||||
return displayName;
|
||||
} else {
|
||||
return ""; // weird, but happens.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the nickname of the contact.
|
||||
*
|
||||
* @return the nickname.
|
||||
*/
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
* Returns the nickname of the contact. Note that for typical user-interface
|
||||
* related tasks, you probably should use {@link #getDisplayName()} instead.
|
||||
*
|
||||
* @return the contact nickname.
|
||||
*/
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the nickname of the contact.
|
||||
*
|
||||
@ -135,18 +165,51 @@ public class ContactItem extends JPanel {
|
||||
*/
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
int nickLength = nickname.length();
|
||||
if (alias == null) {
|
||||
setDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the alias of the contact. Note that for typical user-interface
|
||||
* related tasks, you probably should use {@link #getDisplayName()} instead.
|
||||
*
|
||||
* @return the contact alias.
|
||||
*/
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the alias of the contact.
|
||||
*
|
||||
* @param alias the contact alias.
|
||||
*/
|
||||
public void setAlias(String alias) {
|
||||
this.alias = alias;
|
||||
setDisplayName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the displayed name for the contact. This method tries to use an
|
||||
* alias first. If that's not set, the nickname will be used instead. If
|
||||
* that's not set either, the JID of the user will be used.
|
||||
*/
|
||||
private void setDisplayName() {
|
||||
final String displayName = getDisplayName();
|
||||
|
||||
int nickLength = displayName.length();
|
||||
|
||||
LayoutSettings settings = LayoutSettingsManager.getLayoutSettings();
|
||||
int windowWidth = (int)Math.round((settings.getMainWindowHeight() / 15.2));
|
||||
|
||||
if (nickLength > windowWidth) {
|
||||
nicknameLabel.setText(StringUtils.unescapeNode(nickname).substring(0, windowWidth) + "...");
|
||||
displayNameLabel.setText(StringUtils.unescapeNode(displayName).substring(0, windowWidth) + "...");
|
||||
} else {
|
||||
nicknameLabel.setText(StringUtils.unescapeNode(nickname));
|
||||
}
|
||||
displayNameLabel.setText(StringUtils.unescapeNode(displayName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the fully qualified JID of the contact. (If available). Otherwise will
|
||||
* return the bare jid.
|
||||
@ -226,7 +289,7 @@ public class ContactItem extends JPanel {
|
||||
* @return the nickname label.
|
||||
*/
|
||||
public JLabel getNicknameLabel() {
|
||||
return nicknameLabel;
|
||||
return displayNameLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -316,7 +379,7 @@ public class ContactItem extends JPanel {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return nicknameLabel.getText();
|
||||
return displayNameLabel.getText();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -39,6 +39,8 @@ import org.jivesoftware.sparkimpl.profile.VCardManager;
|
||||
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
|
||||
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
|
||||
|
||||
import sun.util.logging.resources.logging;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
@ -359,14 +361,9 @@ public final class ContactList extends JPanel implements ActionListener, Contact
|
||||
}
|
||||
|
||||
if (contactGroup != null) {
|
||||
String name = entry.getName();
|
||||
if (name == null) {
|
||||
name = entry.getUser();
|
||||
}
|
||||
|
||||
ContactItem contactItem = null;
|
||||
ContactItem contactItem = null;
|
||||
if (contactGroup.getContactItemByJID(entry.getUser()) == null) {
|
||||
contactItem = new ContactItem(name, entry.getUser());
|
||||
contactItem = new ContactItem(entry.getName(), null, entry.getUser());
|
||||
contactGroup.addContactItem(contactItem);
|
||||
}
|
||||
else if (contactGroup.getContactItemByJID(entry.getUser()) != null) {
|
||||
@ -403,11 +400,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
|
||||
}
|
||||
|
||||
if (!isFiled) {
|
||||
String name = entry.getName();
|
||||
if (name == null) {
|
||||
name = entry.getUser();
|
||||
}
|
||||
ContactItem contactItem = new ContactItem(name, entry.getUser());
|
||||
ContactItem contactItem = new ContactItem(entry.getName(), null, entry.getUser());
|
||||
if (unfiledGroup == null) {
|
||||
unfiledGroup = new ContactGroup(Res.getString("unfiled"));
|
||||
addContactGroup(unfiledGroup);
|
||||
@ -441,12 +434,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
|
||||
ContactGroup contactGroup = getContactGroup(group.getName());
|
||||
|
||||
for (RosterEntry entry : group.getEntries()) {
|
||||
String name = entry.getName();
|
||||
if (!ModelUtil.hasLength(name)) {
|
||||
name = entry.getUser();
|
||||
}
|
||||
|
||||
ContactItem contactItem = new ContactItem(name, entry.getUser());
|
||||
ContactItem contactItem = new ContactItem(entry.getName(), null, entry.getUser());
|
||||
contactItem.setPresence(new Presence(Presence.Type.unavailable));
|
||||
if ((entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from)
|
||||
&& RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == entry.getStatus()) {
|
||||
@ -468,12 +456,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
|
||||
unfiledGroup = new ContactGroup(Res.getString("unfiled"));
|
||||
addContactGroup(unfiledGroup);
|
||||
}
|
||||
String name = entry.getName();
|
||||
if (!ModelUtil.hasLength(name)) {
|
||||
name = entry.getUser();
|
||||
}
|
||||
|
||||
ContactItem contactItem = new ContactItem(name, entry.getUser());
|
||||
ContactItem contactItem = new ContactItem(entry.getName(), null, entry.getUser());
|
||||
moveToOffline(contactItem);
|
||||
}
|
||||
}
|
||||
@ -503,12 +486,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
|
||||
* @param entry the <code>RosterEntry</code> of the the user.
|
||||
*/
|
||||
private void addUser(RosterEntry entry) {
|
||||
String nickname = entry.getName();
|
||||
if (!ModelUtil.hasLength(nickname)) {
|
||||
nickname = entry.getUser();
|
||||
}
|
||||
|
||||
ContactItem newContactItem = new ContactItem(nickname, entry.getUser());
|
||||
ContactItem newContactItem = new ContactItem(entry.getName(), null, entry.getUser());
|
||||
|
||||
if (entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from) {
|
||||
// Ignore, since the new user is pending to be added.
|
||||
@ -594,12 +572,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
|
||||
ContactGroup contactGroup = addContactGroup(group.getName());
|
||||
contactGroup.setVisible(false);
|
||||
contactGroup = getContactGroup(group.getName());
|
||||
String name = rosterEntry.getName();
|
||||
if (name == null) {
|
||||
name = rosterEntry.getUser();
|
||||
}
|
||||
|
||||
ContactItem contactItem = new ContactItem(name, rosterEntry.getUser());
|
||||
ContactItem contactItem = new ContactItem(rosterEntry.getName(), null, rosterEntry.getUser());
|
||||
contactGroup.addContactItem(contactItem);
|
||||
Presence presence = PresenceManager.getPresence(jid);
|
||||
contactItem.setPresence(presence);
|
||||
@ -615,11 +588,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
|
||||
}
|
||||
// Check to see if this entry is new to a pre-existing group.
|
||||
if (item == null) {
|
||||
String name = rosterEntry.getName();
|
||||
if (name == null) {
|
||||
name = rosterEntry.getUser();
|
||||
}
|
||||
item = new ContactItem(name, rosterEntry.getUser());
|
||||
item = new ContactItem(rosterEntry.getName(), null, rosterEntry.getUser());
|
||||
Presence presence = PresenceManager.getPresence(jid);
|
||||
item.setPresence(presence);
|
||||
if (presence.isAvailable()) {
|
||||
@ -778,14 +747,14 @@ public final class ContactList extends JPanel implements ActionListener, Contact
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the ContactItem by their nickname.
|
||||
* Retrieve the ContactItem by their displayed name (either alias, nickname or username).
|
||||
*
|
||||
* @param nickname the users nickname in the contact list.
|
||||
* @param displayName the users nickname in the contact list.
|
||||
* @return the "first" contact item found.
|
||||
*/
|
||||
public ContactItem getContactItemByNickname(String nickname) {
|
||||
public ContactItem getContactItemByDisplayName(String displayName) {
|
||||
for (ContactGroup contactGroup : getContactGroups()) {
|
||||
ContactItem item = contactGroup.getContactItemByNickname(nickname);
|
||||
ContactItem item = contactGroup.getContactItemByDisplayName(displayName);
|
||||
if (item != null) {
|
||||
return item;
|
||||
}
|
||||
@ -1066,7 +1035,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
|
||||
}
|
||||
else if (e.getSource() == chatMenu) {
|
||||
if (activeItem != null) {
|
||||
SparkManager.getChatManager().activateChat(activeItem.getJID(), activeItem.getNickname());
|
||||
SparkManager.getChatManager().activateChat(activeItem.getJID(), activeItem.getDisplayName());
|
||||
}
|
||||
}
|
||||
else if (e.getSource() == addContactMenu) {
|
||||
@ -1086,29 +1055,35 @@ public final class ContactList extends JPanel implements ActionListener, Contact
|
||||
return;
|
||||
}
|
||||
|
||||
String oldNickname = activeItem.getNickname();
|
||||
String newNickname = JOptionPane.showInputDialog(this, Res.getString("label.rename.to") + ":", oldNickname);
|
||||
if (ModelUtil.hasLength(newNickname)) {
|
||||
String address = activeItem.getJID();
|
||||
ContactGroup contactGroup = getContactGroup(activeItem.getGroupName());
|
||||
ContactItem contactItem = contactGroup.getContactItemByNickname(activeItem.getNickname());
|
||||
contactItem.setNickname(newNickname);
|
||||
|
||||
final Roster roster = SparkManager.getConnection().getRoster();
|
||||
RosterEntry entry = roster.getEntry(address);
|
||||
entry.setName(newNickname);
|
||||
|
||||
|
||||
final Iterator contactGroups = groupList.iterator();
|
||||
String user = StringUtils.parseBareAddress(address);
|
||||
while (contactGroups.hasNext()) {
|
||||
ContactGroup cg = (ContactGroup)contactGroups.next();
|
||||
ContactItem ci = cg.getContactItemByJID(user);
|
||||
if (ci != null) {
|
||||
ci.setNickname(newNickname);
|
||||
}
|
||||
}
|
||||
|
||||
String oldAlias = activeItem.getAlias();
|
||||
String newAlias = JOptionPane.showInputDialog(this, Res.getString("label.rename.to") + ":", oldAlias);
|
||||
|
||||
// if user pressed 'cancel', output will be null.
|
||||
// if user removed alias, output will be an empty String.
|
||||
if (newAlias != null) {
|
||||
if (!ModelUtil.hasLength(newAlias)) {
|
||||
newAlias = null; // allows you to remove an alias.
|
||||
}
|
||||
|
||||
String address = activeItem.getJID();
|
||||
ContactGroup contactGroup = getContactGroup(activeItem.getGroupName());
|
||||
ContactItem contactItem = contactGroup.getContactItemByDisplayName(activeItem.getDisplayName());
|
||||
contactItem.setAlias(newAlias);
|
||||
|
||||
final Roster roster = SparkManager.getConnection().getRoster();
|
||||
RosterEntry entry = roster.getEntry(address);
|
||||
entry.setName(newAlias);
|
||||
|
||||
|
||||
final Iterator contactGroups = groupList.iterator();
|
||||
String user = StringUtils.parseBareAddress(address);
|
||||
while (contactGroups.hasNext()) {
|
||||
ContactGroup cg = (ContactGroup)contactGroups.next();
|
||||
ContactItem ci = cg.getContactItemByJID(user);
|
||||
if (ci != null) {
|
||||
ci.setAlias(newAlias);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1185,7 +1160,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
|
||||
boolean handled = chatManager.fireContactItemDoubleClicked(item);
|
||||
|
||||
if (!handled) {
|
||||
chatManager.activateChat(item.getJID(), item.getNickname());
|
||||
chatManager.activateChat(item.getJID(), item.getDisplayName());
|
||||
}
|
||||
|
||||
clearSelectionList(item);
|
||||
@ -1473,7 +1448,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
|
||||
message.setProperty("broadcast", true);
|
||||
message.setBody(messageText);
|
||||
if (!broadcastMessages.containsKey(item.getJID())) {
|
||||
buf.append(item.getNickname()).append("\n");
|
||||
buf.append(item.getDisplayName()).append("\n");
|
||||
broadcastMessages.put(item.getJID(), message);
|
||||
}
|
||||
}
|
||||
@ -1582,11 +1557,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
|
||||
final Roster roster = SparkManager.getConnection().getRoster();
|
||||
RosterEntry entry = roster.getEntry(jid);
|
||||
if (entry != null) {
|
||||
String nickname = entry.getName();
|
||||
if (nickname == null) {
|
||||
nickname = entry.getUser();
|
||||
}
|
||||
item = new ContactItem(nickname, jid);
|
||||
item = new ContactItem(entry.getName(), null, jid);
|
||||
moveToOffline(item);
|
||||
offlineGroup.fireContactGroupUpdated();
|
||||
}
|
||||
@ -2061,11 +2032,11 @@ public final class ContactList extends JPanel implements ActionListener, Contact
|
||||
ContactGroup contactGroup = getContactGroup(group.getName());
|
||||
if (contactGroup != null) {
|
||||
isFiled = true;
|
||||
contactGroup.addOfflineContactItem(contactItem.getNickname(), contactItem.getJID(), contactItem.getStatus());
|
||||
contactGroup.addOfflineContactItem(contactItem.getAlias(), contactItem.getNickname(), contactItem.getJID(), contactItem.getStatus());
|
||||
}
|
||||
}
|
||||
if (!isFiled) {
|
||||
unfiledGroup.addOfflineContactItem(contactItem.getNickname(), contactItem.getJID(), contactItem.getStatus());
|
||||
unfiledGroup.addOfflineContactItem(contactItem.getAlias(), contactItem.getNickname(), contactItem.getJID(), contactItem.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
@ -2074,7 +2045,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
|
||||
*/
|
||||
public final static Comparator<ContactItem> ContactItemComparator = new Comparator<ContactItem>() {
|
||||
public int compare(ContactItem item1, ContactItem item2) {
|
||||
return item1.getNickname().toLowerCase().compareTo(item2.getNickname().toLowerCase());
|
||||
return item1.getDisplayName().toLowerCase().compareTo(item2.getDisplayName().toLowerCase());
|
||||
}
|
||||
};
|
||||
|
||||
@ -2082,3 +2053,4 @@ public final class ContactList extends JPanel implements ActionListener, Contact
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ public class RosterPickList extends JPanel {
|
||||
for (RosterEntry entry : roster.getEntries()) {
|
||||
Presence presence = PresenceManager.getPresence(entry.getUser());
|
||||
if (presence.isAvailable()) {
|
||||
ContactItem item = new ContactItem(entry.getName(), entry.getUser());
|
||||
ContactItem item = new ContactItem(entry.getName(), null, entry.getUser());
|
||||
item.setPresence(presence);
|
||||
userList.add(item);
|
||||
}
|
||||
@ -152,8 +152,8 @@ public class RosterPickList extends JPanel {
|
||||
*/
|
||||
final Comparator<ContactItem> itemComparator = new Comparator<ContactItem>() {
|
||||
public int compare(ContactItem item1, ContactItem item2) {
|
||||
String nickname1 = item1.getNickname();
|
||||
String nickname2 = item2.getNickname();
|
||||
String nickname1 = item1.getDisplayName();
|
||||
String nickname2 = item2.getDisplayName();
|
||||
if (nickname1 == null || nickname2 == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -75,7 +75,7 @@ public class BroadcastDialog extends JPanel {
|
||||
|
||||
// Now add contact items from contact group.
|
||||
for (ContactItem item : group.getContactItems()) {
|
||||
CheckNode itemNode = new CheckNode(item.getNickname(), false, item.getIcon());
|
||||
CheckNode itemNode = new CheckNode(item.getDisplayName(), false, item.getIcon());
|
||||
itemNode.setAssociatedObject(item.getJID());
|
||||
groupNode.add(itemNode);
|
||||
nodes.add(itemNode);
|
||||
@ -85,7 +85,7 @@ public class BroadcastDialog extends JPanel {
|
||||
Collections.sort(offlineContacts, ContactList.ContactItemComparator);
|
||||
|
||||
for (ContactItem item : offlineContacts) {
|
||||
CheckNode itemNode = new CheckNode(item.getNickname(), false, item.getIcon());
|
||||
CheckNode itemNode = new CheckNode(item.getDisplayName(), false, item.getIcon());
|
||||
itemNode.setAssociatedObject(item.getJID());
|
||||
groupNode.add(itemNode);
|
||||
nodes.add(itemNode);
|
||||
|
||||
@ -104,7 +104,7 @@ public class BuzzPlugin implements Plugin {
|
||||
ContactItem contact = SparkManager.getWorkspace().getContactList().getContactItemByJID(bareJID);
|
||||
String nickname = StringUtils.parseName(bareJID);
|
||||
if (contact != null) {
|
||||
nickname = contact.getNickname();
|
||||
nickname = contact.getDisplayName();
|
||||
}
|
||||
|
||||
ChatRoom room;
|
||||
|
||||
@ -206,7 +206,7 @@ public class ContactListAssistantPlugin implements Plugin {
|
||||
* @param move true if the ContactItem should be moved, otherwise false.
|
||||
*/
|
||||
private void addContactItem(final ContactGroup contactGroup, final ContactItem item, final boolean move) {
|
||||
ContactItem newContact = new ContactItem(item.getNickname(), item.getJID());
|
||||
ContactItem newContact = new ContactItem(item.getAlias(), item.getNickname(), item.getJID());
|
||||
newContact.setPresence(item.getPresence());
|
||||
newContact.setIcon(item.getIcon());
|
||||
newContact.getNicknameLabel().setFont(item.getNicknameLabel().getFont());
|
||||
@ -217,7 +217,7 @@ public class ContactListAssistantPlugin implements Plugin {
|
||||
}
|
||||
|
||||
if (!PresenceManager.isOnline(item.getJID())) {
|
||||
contactGroup.addOfflineContactItem(item.getNickname(), item.getJID(), null);
|
||||
contactGroup.addOfflineContactItem(item.getAlias(), item.getNickname(), item.getJID(), null);
|
||||
}
|
||||
else {
|
||||
contactGroup.addContactItem(newContact);
|
||||
|
||||
@ -142,7 +142,7 @@ public class ReceiveMessage extends JPanel {
|
||||
ContactList contactList = SparkManager.getWorkspace().getContactList();
|
||||
ContactItem contactItem = contactList.getContactItemByJID(bareJID);
|
||||
|
||||
titleLabel.setText(Res.getString("message.user.is.sending.you.a.file", contactItem.getNickname()));
|
||||
titleLabel.setText(Res.getString("message.user.is.sending.you.a.file", contactItem.getDisplayName()));
|
||||
|
||||
File tempFile = new File(Spark.getSparkUserHome(), "/tmp");
|
||||
try {
|
||||
@ -261,7 +261,7 @@ public class ReceiveMessage extends JPanel {
|
||||
titleLabel.setText(Res.getString("message.negotiate.stream"));
|
||||
}
|
||||
else if (status == FileTransfer.Status.in_progress) {
|
||||
titleLabel.setText(Res.getString("message.receiving.file", contactItem.getNickname()));
|
||||
titleLabel.setText(Res.getString("message.receiving.file", contactItem.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -375,7 +375,7 @@ public class ReceiveMessage extends JPanel {
|
||||
ContactList contactList = SparkManager.getWorkspace().getContactList();
|
||||
ContactItem contactItem = contactList.getContactItemByJID(bareJID);
|
||||
|
||||
titleLabel.setText(Res.getString("message.received.file", contactItem.getNickname()));
|
||||
titleLabel.setText(Res.getString("message.received.file", contactItem.getDisplayName()));
|
||||
fileLabel.setText(request.getFileName());
|
||||
|
||||
remove(acceptLabel);
|
||||
|
||||
@ -134,7 +134,7 @@ public class SendMessage extends JPanel {
|
||||
ContactList contactList = SparkManager.getWorkspace().getContactList();
|
||||
ContactItem contactItem = contactList.getContactItemByJID(jid);
|
||||
|
||||
titleLabel.setText(Res.getString("message.transfer.waiting.on.user", contactItem.getNickname()));
|
||||
titleLabel.setText(Res.getString("message.transfer.waiting.on.user", contactItem.getDisplayName()));
|
||||
|
||||
if (isImage(fileName)) {
|
||||
try {
|
||||
|
||||
@ -205,7 +205,7 @@ public class ConversationHistoryPlugin implements Plugin {
|
||||
}
|
||||
|
||||
JLabel label = new JLabel();
|
||||
label.setText(contactItem.getNickname());
|
||||
label.setText(contactItem.getDisplayName());
|
||||
label.setIcon(icon);
|
||||
|
||||
model.addElement(label);
|
||||
|
||||
@ -161,7 +161,7 @@ public class FrequentContactsPlugin implements Plugin {
|
||||
}
|
||||
|
||||
JLabel label = new JLabel();
|
||||
label.setText(contactItem.getNickname());
|
||||
label.setText(contactItem.getDisplayName());
|
||||
label.setIcon(icon);
|
||||
|
||||
model.addElement(label);
|
||||
|
||||
@ -416,6 +416,13 @@ public class VCardManager {
|
||||
// Otherwise retrieve vCard from server and persist back out.
|
||||
vcard.load(SparkManager.getConnection(), jid);
|
||||
vcard.setJabberId(jid);
|
||||
if (vcard.getNickName() != null && vcard.getNickName().length() > 0)
|
||||
{
|
||||
// update nickname.
|
||||
ContactItem item = SparkManager.getWorkspace().getContactList().getContactItemByJID(jid);
|
||||
item.setNickname(vcard.getNickName());
|
||||
// TODO: this doesn't work if someone removes his nickname. If we remove it in that case, it will cause problems with people using another way to manage their nicknames.
|
||||
}
|
||||
vcards.put(jid, vcard);
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
@ -443,6 +450,13 @@ public class VCardManager {
|
||||
try {
|
||||
vcard.load(SparkManager.getConnection(), jid);
|
||||
vcard.setJabberId(jid);
|
||||
if (vcard.getNickName() != null && vcard.getNickName().length() > 0)
|
||||
{
|
||||
// update nickname.
|
||||
ContactItem item = SparkManager.getWorkspace().getContactList().getContactItemByJID(jid);
|
||||
item.setNickname(vcard.getNickName());
|
||||
// TODO: this doesn't work if someone removes his nickname. If we remove it in that case, it will cause problems with people using another way to manage their nicknames.
|
||||
}
|
||||
vcards.put(jid, vcard);
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
|
||||
Reference in New Issue
Block a user