contact list disapearing problem - fixed

cusax-fix
Yana Stamcheva 20 years ago
parent f3146e613e
commit ad445d7c84

@ -518,7 +518,8 @@ public void contactPresenceStatusChanged(
if (metaContact != null) {
ContactListPanel clistPanel = tabbedPane.getContactListPanel();
clistPanel.getContactList().repaint();
clistPanel.getContactList().refresh();
if(!evt.getOldStatus().equals(evt.getNewStatus()))
clistPanel.updateChatContactStatus(
metaContact, sourceContact);

@ -50,7 +50,7 @@ public class ContactList extends JList
/**
* Creates an instance of the <tt>ContactList</tt>.
*
* @param contactList The related meta contactlist.
* @param mainFrame The main application window.
*/
public ContactList(MainFrame mainFrame) {
@ -90,7 +90,7 @@ public void valueChanged(ListSelectionEvent e) {
* Refreshes the list model.
*/
public void metaContactAdded(MetaContactEvent evt) {
this.repaint();
this.refresh();
}
/**
@ -98,7 +98,7 @@ public void metaContactAdded(MetaContactEvent evt) {
* Refreshes the list when a meta contact is renamed.
*/
public void metaContactRenamed(MetaContactRenamedEvent evt) {
this.repaint();
this.refresh();
}
/**
@ -108,7 +108,7 @@ public void metaContactRenamed(MetaContactRenamedEvent evt) {
public void protoContactAdded(ProtoContactEvent evt) {
int index = this.listModel.indexOf(evt.getNewParent());
this.listModel.contentChanged(index, index);
this.listModel.contentChanged(index, index);
}
/**
@ -116,7 +116,7 @@ public void protoContactAdded(ProtoContactEvent evt) {
* Refreshes the list when a protocol contact has been removed.
*/
public void protoContactRemoved(ProtoContactEvent evt) {
this.repaint();
this.refresh();
}
/**
@ -124,7 +124,7 @@ public void protoContactRemoved(ProtoContactEvent evt) {
* Refreshes the list when a protocol contact has been moved.
*/
public void protoContactMoved(ProtoContactEvent evt) {
this.repaint();
this.refresh();
}
/**
@ -132,7 +132,7 @@ public void protoContactMoved(ProtoContactEvent evt) {
* Refreshes the list when a meta contact has been removed.
*/
public void metaContactRemoved(MetaContactEvent evt) {
this.repaint();
this.refresh();
}
/**
@ -140,15 +140,15 @@ public void metaContactRemoved(MetaContactEvent evt) {
* Refreshes the list when a meta contact has been moved.
*/
public void metaContactMoved(MetaContactMovedEvent evt) {
this.repaint();
this.refresh();
}
/**
* Handles the <tt>MetaContactGroupEvent</tt>.
* Refreshes the list model when a new meta contact group has been added.
*/
public void metaContactGroupAdded(MetaContactGroupEvent evt) {
this.repaint();
public void metaContactGroupAdded(MetaContactGroupEvent evt) {
this.refresh();
//this.ensureIndexIsVisible(0);
}
@ -157,7 +157,7 @@ public void metaContactGroupAdded(MetaContactGroupEvent evt) {
* Refreshes the list when a meta contact group has been modified.
*/
public void metaContactGroupModified(MetaContactGroupEvent evt) {
this.repaint();
this.refresh();
}
/**
@ -165,7 +165,7 @@ public void metaContactGroupModified(MetaContactGroupEvent evt) {
* Refreshes the list when a meta contact group has been removed.
*/
public void metaContactGroupRemoved(MetaContactGroupEvent evt) {
this.repaint();
this.refresh();
}
/**
@ -176,7 +176,7 @@ public void metaContactGroupRemoved(MetaContactGroupEvent evt) {
* depends on the contact and not on the index.
*/
public void childContactsReordered(MetaContactGroupEvent evt) {
this.repaint();
this.refresh();
if (currentlySelectedContact != null)
this.setSelectedValue(currentlySelectedContact, false);
}
@ -571,61 +571,7 @@ public void mouseDragged(MouseEvent e)
{}
public void mouseMoved(MouseEvent e)
{
/* SET A TOOLTIP - NEED TO BE FIXED
int index = this.locationToIndex(e.getPoint());
Object value = this.listModel.getElementAt(index);
ContactListCellRenderer renderer
= (ContactListCellRenderer)
this.getCellRenderer().getListCellRendererComponent(
this, value, index, true,
true);
Point selectedCellPoint = this.indexToLocation(index);
int translatedX = e.getX() - selectedCellPoint.x;
int translatedY = e.getY() - selectedCellPoint.y;
if (value instanceof MetaContact) {
//get the component under the mouse
Component component = this.getInnerComponent(renderer, translatedX);
if (component instanceof JPanel) {
if(component.getName() != null
&& component.getName().equals("buttonsPanel")){
JPanel panel = (JPanel) component;
int internalX = translatedX
- (renderer.getWidth() - panel.getWidth() - 2);
int internalY = translatedY
- (renderer.getHeight() - panel.getHeight());
Component c = this.getInnerComponent(panel, internalX);
if (c instanceof ContactProtocolButton) {
ContactProtocolButton button
= (ContactProtocolButton)c;
Point p = e.getPoint();
SwingUtilities
.convertPointToScreen(p, this);
if(button.isToolTipShown())
button.hideToolTip();
else
button.showToolTip(p.x, p.y);
}
}
}
}
*/
}
{}
/**
* Returns the component positioned at the given x in the given container.
@ -682,4 +628,14 @@ public void run() {
}
}
/**
* Refreshes the contact list. Should be invoked after any change in the
* contact list.
*/
public void refresh()
{
this.revalidate();
this.repaint();
}
}

@ -106,8 +106,7 @@ public int getSize() {
* @return The object at the given index.
*/
public Object getElementAt(int index) {
Object element = this.getElementAt(this.rootGroup, -1, index);
return element;
return this.getElementAt(this.rootGroup, -1, index);
}
/**
@ -140,7 +139,7 @@ private int getContactListSize(MetaContactGroup group) {
while (subgroups.hasNext()) {
size += getContactListSize((MetaContactGroup) subgroups.next());
}
}
}
return size;
}
@ -307,24 +306,31 @@ public int countDirectChildContacts(MetaContactGroup parentGroup) {
}
/**
* Recursively searches all groups for the element at the given index.
* Recursively searches the given group in depth for the element at the
* given index.
*
* @param group The group in which we search.
* @param searchedIndex The index to search for.
* @return The element at the given index, if it finds it, otherwise null.
* @param group the group in which we search
* @param currentIndex the index, where we currently are
* @param searchedIndex the index to search for
* @return The element at the given index, if we find it, otherwise null.
*/
private Object getElementAt(MetaContactGroup group,
int currentIndex, int searchedIndex) {
Object element = null;
if(currentIndex == searchedIndex) {
//the current index is the index of the group so if this is the
//searched index we return the group
element = group;
}
else {
//if the group is closed don't count its children
if(!isGroupClosed(group)) {
int childCount = countChildContacts(group);
if(searchedIndex <= (currentIndex + childCount)) {
//if the searched index is lower than or equal to
//the greater child index in this group then our element is
//here
MetaContact contact = group.getMetaContact(
searchedIndex - currentIndex - 1);
@ -332,6 +338,7 @@ private Object getElementAt(MetaContactGroup group,
element = contact;
}
else {
//if we haven't found the contact we search the subgroups
currentIndex += childCount;
Iterator subgroups = group.getSubgroups();
@ -344,6 +351,8 @@ private Object getElementAt(MetaContactGroup group,
if(element != null)
break;
else {
//if we haven't found the element on this iteration
//we update the current index and we continue
if(!isGroupClosed(subgroup))
currentIndex
+= countChildContacts(subgroup) + 1;
@ -353,7 +362,7 @@ private Object getElementAt(MetaContactGroup group,
}
}
}
}
}
return element;
}
@ -436,9 +445,9 @@ public boolean isContactOnline(MetaContact contact)
}
/**
*
* @param group
* @return
* Counts group child contacts depending on the showOffline option.
* @param group the parent group to count for
* @return child contacts count for the given group
*/
public int countChildContacts(MetaContactGroup group)
{

Loading…
Cancel
Save