nus-yam/ex-repair huggingface dataset:
Program: 104518
Project: 104518
Buggy source:
/** 
 * Handles the <tt>MetaContactRenamedEvent</tt>. Refreshes the list when a meta contact is renamed.
 */
public void metaContactRenamed(MetaContactRenamedEvent evt){
  this.refresh();
}

Fixed version (ground truth):
/** 
 * Handles the <tt>MetaContactRenamedEvent</tt>. Refreshes the list when a meta contact is renamed.
 */
public void metaContactRenamed(MetaContactRenamedEvent evt){
  this.refreshAll();
}
Program: 104519
Project: 104519
Buggy source:
/** 
 * Handles the <tt>MetaContactGroupEvent</tt>. Refreshes the list when a meta contact group has been modified.
 */
public void metaContactGroupModified(MetaContactGroupEvent evt){
  this.refresh();
}

Fixed version (ground truth):
/** 
 * Handles the <tt>MetaContactGroupEvent</tt>. Refreshes the list when a meta contact group has been modified.
 */
public void metaContactGroupModified(MetaContactGroupEvent evt){
  this.refreshAll();
}
Program: 104520
Project: 104520
Buggy source:
/** 
 * Handles the <tt>MetaContactGroupEvent</tt>. Refreshes the list when a meta contact group has been removed.
 */
public void metaContactGroupRemoved(MetaContactGroupEvent evt){
  this.refresh();
}

Fixed version (ground truth):
/** 
 * Handles the <tt>MetaContactGroupEvent</tt>. Refreshes the list when a meta contact group has been removed.
 */
public void metaContactGroupRemoved(MetaContactGroupEvent evt){
  this.refreshAll();
}
Program: 104521
Project: 104521
Buggy source:
public void valueChanged(ListSelectionEvent e){
  if (getSelectedValue() instanceof MetaContact) {
    currentlySelectedContact=(MetaContact)getSelectedValue();
  }
}

Fixed version (ground truth):
public void valueChanged(ListSelectionEvent e){
  currentlySelectedObject=getSelectedValue();
}
Program: 104522
Project: 104522
Buggy source:
/** 
 * Creates an instance of the <tt>ContactList</tt>.
 * @param mainFrame The main application window.
 */
public ContactList(MainFrame mainFrame){
  this.mainFrame=mainFrame;
  this.contactList=mainFrame.getContactList();
  this.listModel=new ContactListModel(contactList);
  this.setModel(listModel);
  this.setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
  this.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  this.setCellRenderer(new ContactListCellRenderer(mainFrame));
  this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  this.contactList.addMetaContactListListener(this);
  this.addMouseListener(this);
  this.addMouseMotionListener(this);
  this.addListSelectionListener(new ListSelectionListener(){
    public void valueChanged(    ListSelectionEvent e){
      if (getSelectedValue() instanceof MetaContact) {
        currentlySelectedContact=(MetaContact)getSelectedValue();
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Creates an instance of the <tt>ContactList</tt>.
 * @param mainFrame The main application window.
 */
public ContactList(MainFrame mainFrame){
  this.mainFrame=mainFrame;
  this.contactList=mainFrame.getContactList();
  this.listModel=new ContactListModel(contactList);
  this.setModel(listModel);
  this.setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
  this.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  this.setCellRenderer(new ContactListCellRenderer(mainFrame));
  this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  this.contactList.addMetaContactListListener(this);
  this.addMouseListener(this);
  this.addMouseMotionListener(this);
  this.addListSelectionListener(new ListSelectionListener(){
    public void valueChanged(    ListSelectionEvent e){
      currentlySelectedObject=getSelectedValue();
    }
  }
);
  new ContactListRefresh().start();
}
Program: 104523
Project: 104523
Buggy source:
/** 
 * Handles the <tt>MetaContactEvent</tt>. Refreshes the list model.
 */
public void metaContactAdded(MetaContactEvent evt){
  this.refresh();
}

Fixed version (ground truth):
/** 
 * Handles the <tt>MetaContactEvent</tt>. Refreshes the list model.
 */
public void metaContactAdded(MetaContactEvent evt){
  this.refreshAll();
}
Program: 104524
Project: 104524
Buggy source:
/** 
 * Handles the <tt>ProtoContactEvent</tt>. Refreshes the list when a protocol contact has been removed.
 */
public void protoContactRemoved(ProtoContactEvent evt){
  this.refresh();
}

Fixed version (ground truth):
/** 
 * Handles the <tt>ProtoContactEvent</tt>. Refreshes the list when a protocol contact has been removed.
 */
public void protoContactRemoved(ProtoContactEvent evt){
  this.refreshAll();
}
Program: 104525
Project: 104525
Buggy source:
public void contactPresenceStatusChanged(ContactPresenceStatusChangeEvent evt){
  Contact sourceContact=evt.getSourceContact();
  MetaContact metaContact=contactList.findMetaContactByContact(sourceContact);
  if (metaContact != null) {
    ContactListPanel clistPanel=tabbedPane.getContactListPanel();
    clistPanel.getContactList().refresh();
    if (!evt.getOldStatus().equals(evt.getNewStatus()))     clistPanel.updateChatContactStatus(metaContact,sourceContact);
  }
}

Fixed version (ground truth):
public void contactPresenceStatusChanged(ContactPresenceStatusChangeEvent evt){
  ContactListPanel clistPanel=tabbedPane.getContactListPanel();
  clistPanel.getContactList().refresh();
  Contact sourceContact=evt.getSourceContact();
  MetaContact metaContact=contactList.findMetaContactByContact(sourceContact);
  if (metaContact != null) {
    if (!evt.getOldStatus().equals(evt.getNewStatus()))     clistPanel.updateChatContactStatus(metaContact,sourceContact);
  }
}
Program: 104526
Project: 104526
Buggy source:
public void contactPresenceStatusChanged(ContactPresenceStatusChangeEvent evt){
  Contact sourceContact=evt.getSourceContact();
  MetaContact metaContact=contactList.findMetaContactByContact(sourceContact);
  if (metaContact != null) {
    ContactListPanel clistPanel=tabbedPane.getContactListPanel();
    clistPanel.getContactList().repaint();
    if (!evt.getOldStatus().equals(evt.getNewStatus()))     clistPanel.updateChatContactStatus(metaContact,sourceContact);
  }
}

Fixed version (ground truth):
public void contactPresenceStatusChanged(ContactPresenceStatusChangeEvent evt){
  Contact sourceContact=evt.getSourceContact();
  MetaContact metaContact=contactList.findMetaContactByContact(sourceContact);
  if (metaContact != null) {
    ContactListPanel clistPanel=tabbedPane.getContactListPanel();
    clistPanel.getContactList().refresh();
    if (!evt.getOldStatus().equals(evt.getNewStatus()))     clistPanel.updateChatContactStatus(metaContact,sourceContact);
  }
}
Program: 104527
Project: 104527
Buggy source:
/** 
 * 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();
}

Fixed version (ground truth):
/** 
 * Handles the <tt>MetaContactGroupEvent</tt>. Refreshes the list model when a new meta contact group has been added.
 */
public void metaContactGroupAdded(MetaContactGroupEvent evt){
  this.refresh();
}
Program: 104528
Project: 104528
Buggy source:
/** 
 * Handles the <tt>MetaContactEvent</tt>. Refreshes the list when a meta contact has been removed.
 */
public void metaContactRemoved(MetaContactEvent evt){
  this.repaint();
}

Fixed version (ground truth):
/** 
 * Handles the <tt>MetaContactEvent</tt>. Refreshes the list when a meta contact has been removed.
 */
public void metaContactRemoved(MetaContactEvent evt){
  this.refresh();
}
Program: 104529
Project: 104529
Buggy source:
/** 
 * Handles the <tt>MetaContactMovedEvent</tt>. Refreshes the list when a meta contact has been moved.
 */
public void metaContactMoved(MetaContactMovedEvent evt){
  this.repaint();
}

Fixed version (ground truth):
/** 
 * Handles the <tt>MetaContactMovedEvent</tt>. Refreshes the list when a meta contact has been moved.
 */
public void metaContactMoved(MetaContactMovedEvent evt){
  this.refresh();
}
Program: 104530
Project: 104530
Buggy source:
/** 
 * Handles the <tt>MetaContactGroupEvent</tt>. Refreshes the list model when the contact list groups has been reordered. Moves the selection index to the index of the contact that was selected before the reordered event. This way the selection depends on the contact and not on the index.
 */
public void childContactsReordered(MetaContactGroupEvent evt){
  this.repaint();
  if (currentlySelectedContact != null)   this.setSelectedValue(currentlySelectedContact,false);
}

Fixed version (ground truth):
/** 
 * Handles the <tt>MetaContactGroupEvent</tt>. Refreshes the list model when the contact list groups has been reordered. Moves the selection index to the index of the contact that was selected before the reordered event. This way the selection depends on the contact and not on the index.
 */
public void childContactsReordered(MetaContactGroupEvent evt){
  this.refresh();
  if (currentlySelectedContact != null)   this.setSelectedValue(currentlySelectedContact,false);
}
Program: 104531
Project: 104531
Buggy source:
/** 
 * Handles the <tt>ProtoContactEvent</tt>. Refreshes the list when a protocol contact has been moved.
 */
public void protoContactMoved(ProtoContactEvent evt){
  this.repaint();
}

Fixed version (ground truth):
/** 
 * Handles the <tt>ProtoContactEvent</tt>. Refreshes the list when a protocol contact has been moved.
 */
public void protoContactMoved(ProtoContactEvent evt){
  this.refresh();
}
Program: 104532
Project: 104532
Buggy source:
/** 
 * Handles the <tt>MetaContactRenamedEvent</tt>. Refreshes the list when a meta contact is renamed.
 */
public void metaContactRenamed(MetaContactRenamedEvent evt){
  this.repaint();
}

Fixed version (ground truth):
/** 
 * Handles the <tt>MetaContactRenamedEvent</tt>. Refreshes the list when a meta contact is renamed.
 */
public void metaContactRenamed(MetaContactRenamedEvent evt){
  this.refresh();
}
Program: 104533
Project: 104533
Buggy source:
/** 
 * Handles the <tt>MetaContactGroupEvent</tt>. Refreshes the list when a meta contact group has been modified.
 */
public void metaContactGroupModified(MetaContactGroupEvent evt){
  this.repaint();
}

Fixed version (ground truth):
/** 
 * Handles the <tt>MetaContactGroupEvent</tt>. Refreshes the list when a meta contact group has been modified.
 */
public void metaContactGroupModified(MetaContactGroupEvent evt){
  this.refresh();
}
Program: 104534
Project: 104534
Buggy source:
/** 
 * Handles the <tt>MetaContactGroupEvent</tt>. Refreshes the list when a meta contact group has been removed.
 */
public void metaContactGroupRemoved(MetaContactGroupEvent evt){
  this.repaint();
}

Fixed version (ground truth):
/** 
 * Handles the <tt>MetaContactGroupEvent</tt>. Refreshes the list when a meta contact group has been removed.
 */
public void metaContactGroupRemoved(MetaContactGroupEvent evt){
  this.refresh();
}
Program: 104535
Project: 104535
Buggy source:
/** 
 * Creates an instance of the <tt>ContactList</tt>.
 * @param contactList The related meta contactlist.
 */
public ContactList(MainFrame mainFrame){
  this.mainFrame=mainFrame;
  this.contactList=mainFrame.getContactList();
  this.listModel=new ContactListModel(contactList);
  this.setModel(listModel);
  this.setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
  this.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  this.setCellRenderer(new ContactListCellRenderer(mainFrame));
  this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  this.contactList.addMetaContactListListener(this);
  this.addMouseListener(this);
  this.addMouseMotionListener(this);
  this.addListSelectionListener(new ListSelectionListener(){
    public void valueChanged(    ListSelectionEvent e){
      if (getSelectedValue() instanceof MetaContact) {
        currentlySelectedContact=(MetaContact)getSelectedValue();
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Creates an instance of the <tt>ContactList</tt>.
 * @param mainFrame The main application window.
 */
public ContactList(MainFrame mainFrame){
  this.mainFrame=mainFrame;
  this.contactList=mainFrame.getContactList();
  this.listModel=new ContactListModel(contactList);
  this.setModel(listModel);
  this.setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
  this.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  this.setCellRenderer(new ContactListCellRenderer(mainFrame));
  this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  this.contactList.addMetaContactListListener(this);
  this.addMouseListener(this);
  this.addMouseMotionListener(this);
  this.addListSelectionListener(new ListSelectionListener(){
    public void valueChanged(    ListSelectionEvent e){
      if (getSelectedValue() instanceof MetaContact) {
        currentlySelectedContact=(MetaContact)getSelectedValue();
      }
    }
  }
);
}
Program: 104536
Project: 104536
Buggy source:
/** 
 * Handles the <tt>MetaContactEvent</tt>. Refreshes the list model.
 */
public void metaContactAdded(MetaContactEvent evt){
  this.repaint();
}

Fixed version (ground truth):
/** 
 * Handles the <tt>MetaContactEvent</tt>. Refreshes the list model.
 */
public void metaContactAdded(MetaContactEvent evt){
  this.refresh();
}
Program: 104537
Project: 104537
Buggy source:
/** 
 * Handles the <tt>ProtoContactEvent</tt>. Refreshes the list when a protocol contact has been removed.
 */
public void protoContactRemoved(ProtoContactEvent evt){
  this.repaint();
}

Fixed version (ground truth):
/** 
 * Handles the <tt>ProtoContactEvent</tt>. Refreshes the list when a protocol contact has been removed.
 */
public void protoContactRemoved(ProtoContactEvent evt){
  this.refresh();
}
Program: 104538
Project: 104538
Buggy source:
/** 
 * @param group
 * @return
 */
public int countChildContacts(MetaContactGroup group){
  if (showOffline)   return group.countChildContacts();
 else {
    int count=0;
    Iterator i=group.getChildContacts();
    while (i.hasNext()) {
      MetaContact metaContact=(MetaContact)i.next();
      if (isContactOnline(metaContact)) {
        count++;
      }
 else {
        break;
      }
    }
    return count;
  }
}

Fixed version (ground truth):
/** 
 * 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){
  if (showOffline)   return group.countChildContacts();
 else {
    int count=0;
    Iterator i=group.getChildContacts();
    while (i.hasNext()) {
      MetaContact metaContact=(MetaContact)i.next();
      if (isContactOnline(metaContact)) {
        count++;
      }
 else {
        break;
      }
    }
    return count;
  }
}
Program: 104539
Project: 104539
Buggy source:
/** 
 * Recursively searches all groups 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.
 */
private Object getElementAt(MetaContactGroup group,int currentIndex,int searchedIndex){
  Object element=null;
  if (currentIndex == searchedIndex) {
    element=group;
  }
 else {
    if (!isGroupClosed(group)) {
      int childCount=countChildContacts(group);
      if (searchedIndex <= (currentIndex + childCount)) {
        MetaContact contact=group.getMetaContact(searchedIndex - currentIndex - 1);
        if (showOffline || isContactOnline(contact))         element=contact;
      }
 else {
        currentIndex+=childCount;
        Iterator subgroups=group.getSubgroups();
        while (subgroups.hasNext()) {
          MetaContactGroup subgroup=(MetaContactGroup)subgroups.next();
          element=getElementAt(subgroup,currentIndex + 1,searchedIndex);
          if (element != null)           break;
 else {
            if (!isGroupClosed(subgroup))             currentIndex+=countChildContacts(subgroup) + 1;
 else             currentIndex++;
          }
        }
      }
    }
  }
  return element;
}

Fixed version (ground truth):
/** 
 * Recursively searches the given group in depth for the element at the given index. 
 * @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) {
    element=group;
  }
 else {
    if (!isGroupClosed(group)) {
      int childCount=countChildContacts(group);
      if (searchedIndex <= (currentIndex + childCount)) {
        MetaContact contact=group.getMetaContact(searchedIndex - currentIndex - 1);
        if (showOffline || isContactOnline(contact))         element=contact;
      }
 else {
        currentIndex+=childCount;
        Iterator subgroups=group.getSubgroups();
        while (subgroups.hasNext()) {
          MetaContactGroup subgroup=(MetaContactGroup)subgroups.next();
          element=getElementAt(subgroup,currentIndex + 1,searchedIndex);
          if (element != null)           break;
 else {
            if (!isGroupClosed(subgroup))             currentIndex+=countChildContacts(subgroup) + 1;
 else             currentIndex++;
          }
        }
      }
    }
  }
  return element;
}
Program: 104540
Project: 104540
Buggy source:
public void run(){
  while (refreshEnabled) {
synchronized (refreshLock) {
      if (isModified) {
        try {
          refreshLock.wait(5000);
        }
 catch (        InterruptedException e) {
          logger.error("String_Node_Str",e);
        }
      }
    }
    if (isModified) {
      if (groupsToModify.size() > 0) {
        for (int i=0; i < groupsToModify.size(); i++) {
          MetaContactGroup group=(MetaContactGroup)groupsToModify.get(i);
          this.refreshGroup(group);
        }
        groupsToModify.removeAllElements();
      }
 else {
        this.refreshAll();
      }
      isModified=false;
    }
  }
}

Fixed version (ground truth):
public void run(){
  while (refreshEnabled) {
synchronized (refreshLock) {
      if (!isModified) {
        try {
          refreshLock.wait(5000);
        }
 catch (        InterruptedException e) {
          logger.error("String_Node_Str",e);
        }
      }
    }
    if (isModified) {
      if (groupsToModify.size() > 0) {
        for (int i=0; i < groupsToModify.size(); i++) {
          MetaContactGroup group=(MetaContactGroup)groupsToModify.get(i);
          this.refreshGroup(group);
        }
        groupsToModify.removeAllElements();
      }
 else {
        this.refreshAll();
      }
      isModified=false;
    }
  }
}
Program: 104541
Project: 104541
Buggy source:
/** 
 * Adds all UI components (status selector box, etc) related to the given protocol provider.
 * @param protocolProvider the <tt>ProtocolProviderService</tt>
 */
private void handleProviderAdded(ProtocolProviderService protocolProvider){
  protocolProvider.addRegistrationStateChangeListener(this);
  this.mainFrame.addProtocolProvider(protocolProvider);
  this.login(protocolProvider);
}

Fixed version (ground truth):
/** 
 * Adds all UI components (status selector box, etc) related to the given protocol provider.
 * @param protocolProvider the <tt>ProtocolProviderService</tt>
 */
private void handleProviderAdded(ProtocolProviderService protocolProvider){
  protocolProvider.addRegistrationStateChangeListener(this);
  this.mainFrame.addProtocolProvider(protocolProvider);
  PresenceStatus status=this.mainFrame.getStatusPanel().getProtocolProviderLastStatus(protocolProvider);
  if (status == null || status.getStatus() > PresenceStatus.ONLINE_THRESHOLD) {
    this.login(protocolProvider);
  }
}
Program: 104542
Project: 104542
Buggy source:
/** 
 * Shows login window for each registered account.
 * @param parent The parent MainFrame window.
 */
public void runLogin(MainFrame parent){
  Set set=GuiActivator.getProtocolProviderFactories().entrySet();
  Iterator iter=set.iterator();
  boolean hasRegisteredAccounts=false;
  while (iter.hasNext()) {
    Map.Entry entry=(Map.Entry)iter.next();
    ProtocolProviderFactory providerFactory=(ProtocolProviderFactory)entry.getValue();
    ArrayList accountsList=providerFactory.getRegisteredAccounts();
    AccountID accountID;
    ServiceReference serRef;
    ProtocolProviderService protocolProvider;
    for (int i=0; i < accountsList.size(); i++) {
      hasRegisteredAccounts=true;
      accountID=(AccountID)accountsList.get(i);
      serRef=providerFactory.getProviderForAccount(accountID);
      protocolProvider=(ProtocolProviderService)GuiActivator.bundleContext.getService(serRef);
      protocolProvider.addRegistrationStateChangeListener(this);
      this.mainFrame.addProtocolProvider(protocolProvider);
      this.login(protocolProvider);
    }
  }
  if (!hasRegisteredAccounts) {
    this.showAccountRegistrationWizard();
  }
}

Fixed version (ground truth):
/** 
 * Shows login window for each registered account.
 * @param parent The parent MainFrame window.
 */
public void runLogin(MainFrame parent){
  Set set=GuiActivator.getProtocolProviderFactories().entrySet();
  Iterator iter=set.iterator();
  boolean hasRegisteredAccounts=false;
  while (iter.hasNext()) {
    Map.Entry entry=(Map.Entry)iter.next();
    ProtocolProviderFactory providerFactory=(ProtocolProviderFactory)entry.getValue();
    ArrayList accountsList=providerFactory.getRegisteredAccounts();
    AccountID accountID;
    ServiceReference serRef;
    ProtocolProviderService protocolProvider;
    for (int i=0; i < accountsList.size(); i++) {
      hasRegisteredAccounts=true;
      accountID=(AccountID)accountsList.get(i);
      serRef=providerFactory.getProviderForAccount(accountID);
      protocolProvider=(ProtocolProviderService)GuiActivator.bundleContext.getService(serRef);
      protocolProvider.addRegistrationStateChangeListener(this);
      this.mainFrame.addProtocolProvider(protocolProvider);
      PresenceStatus status=this.mainFrame.getStatusPanel().getProtocolProviderLastStatus(protocolProvider);
      if (status == null || status.getStatus() > PresenceStatus.ONLINE_THRESHOLD) {
        this.login(protocolProvider);
      }
    }
  }
  if (!hasRegisteredAccounts) {
    this.showAccountRegistrationWizard();
  }
}
Program: 104543
Project: 104543
Buggy source:
/** 
 * Registers the given protocol provider.
 * @param protocolProvider the ProtocolProviderService to register.
 */
public void login(ProtocolProviderService protocolProvider){
  SecurityAuthorityImpl secAuth=new SecurityAuthorityImpl(mainFrame,protocolProvider);
  PresenceStatus status=this.mainFrame.getStatusPanel().getProtocolProviderLastStatus(protocolProvider);
  if (status == null || status.getStatus() > PresenceStatus.ONLINE_THRESHOLD) {
    this.mainFrame.activateAccount(protocolProvider);
    new RegisterProvider(protocolProvider,secAuth).start();
  }
}

Fixed version (ground truth):
/** 
 * Registers the given protocol provider.
 * @param protocolProvider the ProtocolProviderService to register.
 */
public void login(ProtocolProviderService protocolProvider){
  SecurityAuthorityImpl secAuth=new SecurityAuthorityImpl(mainFrame,protocolProvider);
  this.mainFrame.activateAccount(protocolProvider);
  new RegisterProvider(protocolProvider,secAuth).start();
}
Program: 104544
Project: 104544
Buggy source:
/** 
 * Recursively searches all groups 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.
 */
private Object getElementAt(MetaContactGroup group,int searchedIndex){
  Object element=null;
  if (!this.isGroupClosed(group)) {
    Iterator contacts=group.getChildContacts();
    while (contacts.hasNext()) {
      MetaContact contact=(MetaContact)contacts.next();
      if (!offlineContacts.contains(contact) && this.indexOf(contact) == searchedIndex) {
        element=contact;
        break;
      }
    }
    if (element == null) {
      Iterator subgroups=group.getSubgroups();
      while (subgroups.hasNext()) {
        MetaContactGroup subgroup=(MetaContactGroup)subgroups.next();
        if (this.indexOf(subgroup) != searchedIndex) {
          element=getElementAt(subgroup,searchedIndex);
          if (element != null)           break;
        }
 else {
          element=subgroup;
          break;
        }
      }
    }
  }
  return element;
}

Fixed version (ground truth):
/** 
 * Recursively searches all groups 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.
 */
private Object getElementAt(MetaContactGroup group,int searchedIndex){
  Object element=null;
  if (!this.isGroupClosed(group)) {
    Iterator contacts=group.getChildContacts();
    while (contacts.hasNext()) {
      MetaContact contact=(MetaContact)contacts.next();
      if (!offlineContacts.contains(contact) && this.indexOf(contact) == searchedIndex) {
        element=contact;
        break;
      }
    }
    if (element == null) {
      Iterator subgroups=group.getSubgroups();
      while (subgroups.hasNext()) {
        MetaContactGroup subgroup=(MetaContactGroup)subgroups.next();
        if (this.indexOf(subgroup) != searchedIndex) {
          element=getElementAt(subgroup,searchedIndex);
          if (element != null) {
            break;
          }
        }
 else {
          element=subgroup;
          break;
        }
      }
    }
  }
  return element;
}
Program: 104545
Project: 104545
Buggy source:
/** 
 * Returns the index of the given MetaContactGroup.
 * @param group The given MetaContactGroup to search for.
 * @return The index of the given MetaContactGroup.
 */
public int indexOf(MetaContactGroup group){
  int index=-1;
  int currentIndex=0;
  MetaContactGroup parentGroup=this.contactList.findParentMetaContactGroup(group);
  if (parentGroup != null && !this.isGroupClosed(parentGroup)) {
    currentIndex+=this.indexOf(parentGroup);
    currentIndex+=parentGroup.indexOf(group) + 1;
    for (int i=0; i < parentGroup.indexOf(group); i++) {
      MetaContactGroup subGroup=parentGroup.getMetaContactSubgroup(i);
      currentIndex+=countSubgroupContacts(subGroup);
    }
    index=currentIndex;
  }
  return index;
}

Fixed version (ground truth):
/** 
 * Returns the index of the given MetaContactGroup.
 * @param group The given MetaContactGroup to search for.
 * @return The index of the given MetaContactGroup.
 */
public int indexOf(MetaContactGroup group){
  int index=-1;
  int currentIndex=0;
  MetaContactGroup parentGroup=this.contactList.findParentMetaContactGroup(group);
  if (parentGroup != null && !this.isGroupClosed(parentGroup)) {
    currentIndex+=this.indexOf(parentGroup);
    currentIndex+=countChildContacts(parentGroup);
    currentIndex+=parentGroup.indexOf(group) + 1;
    for (int i=0; i < parentGroup.indexOf(group); i++) {
      MetaContactGroup subGroup=parentGroup.getMetaContactSubgroup(i);
      currentIndex+=countSubgroupContacts(subGroup);
    }
    index=currentIndex;
  }
  return index;
}
Program: 104547
Project: 104547
Buggy source:
/** 
 * Opens a link in the default browser when clicked and shows link url in a popup on mouseover.
 * @param e The HyperlinkEvent.
 */
public void hyperlinkUpdate(HyperlinkEvent e){
  if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
    URL url=e.getURL();
    CrossPlatformBrowserLauncher.openURL(url.toString());
  }
 else   if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) {
    String href=e.getDescription();
    this.chatContainer.setStatusMessage(href);
    this.currentHref=href;
  }
 else   if (e.getEventType() == HyperlinkEvent.EventType.EXITED) {
    this.chatContainer.setStatusMessage("String_Node_Str");
    this.currentHref="String_Node_Str";
  }
}

Fixed version (ground truth):
/** 
 * Opens a link in the default browser when clicked and shows link url in a popup on mouseover.
 * @param e The HyperlinkEvent.
 */
public void hyperlinkUpdate(HyperlinkEvent e){
  if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) {
    String href=e.getDescription();
    this.chatContainer.setStatusMessage(href);
    this.currentHref=href;
  }
 else   if (e.getEventType() == HyperlinkEvent.EventType.EXITED) {
    this.chatContainer.setStatusMessage("String_Node_Str");
    this.currentHref="String_Node_Str";
  }
}
Program: 104548
Project: 104548
Buggy source:
/** 
 * Opens this panel context menu at the given point.
 * @param p the point where to position the left-top cornet of thecontext menu
 */
private void openContextMenu(Point p){
  if (currentHref != null) {
    if (currentHref != "String_Node_Str") {
      rightButtonMenu.insert(openLinkItem,0);
      rightButtonMenu.insert(copyLinkItem,1);
      rightButtonMenu.insert(copyLinkSeparator,2);
    }
 else {
      rightButtonMenu.remove(openLinkItem);
      rightButtonMenu.remove(copyLinkItem);
      rightButtonMenu.remove(copyLinkSeparator);
    }
  }
  if (chatEditorPane.getSelectedText() != null) {
    rightButtonMenu.enableCopy();
  }
 else {
    rightButtonMenu.disableCopy();
  }
  rightButtonMenu.setInvoker(chatEditorPane);
  rightButtonMenu.setLocation(p.x,p.y);
  rightButtonMenu.setVisible(true);
}

Fixed version (ground truth):
/** 
 * Opens this panel context menu at the given point.
 * @param p the point where to position the left-top cornet of thecontext menu
 */
private void openContextMenu(Point p){
  if (currentHref != null && currentHref != "String_Node_Str") {
    rightButtonMenu.insert(openLinkItem,0);
    rightButtonMenu.insert(copyLinkItem,1);
    rightButtonMenu.insert(copyLinkSeparator,2);
  }
 else {
    rightButtonMenu.remove(openLinkItem);
    rightButtonMenu.remove(copyLinkItem);
    rightButtonMenu.remove(copyLinkSeparator);
  }
  if (chatEditorPane.getSelectedText() != null) {
    rightButtonMenu.enableCopy();
  }
 else {
    rightButtonMenu.disableCopy();
  }
  rightButtonMenu.setInvoker(chatEditorPane);
  rightButtonMenu.setLocation(p.x,p.y);
  rightButtonMenu.setVisible(true);
}
Program: 104549
Project: 104549
Buggy source:
/** 
 * When a right button click is performed in the editor pane, a popup menu is opened.
 * @param e The MouseEvent.
 */
public void mouseClicked(MouseEvent e){
  Point p=e.getPoint();
  SwingUtilities.convertPointToScreen(p,e.getComponent());
  if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || (e.isControlDown() && !e.isMetaDown())) {
    openContextMenu(p);
  }
}

Fixed version (ground truth):
/** 
 * When a right button click is performed in the editor pane, a popup menu is opened.
 * @param e The MouseEvent.
 */
public void mouseClicked(MouseEvent e){
  Point p=e.getPoint();
  SwingUtilities.convertPointToScreen(p,e.getComponent());
  if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || (e.isControlDown() && !e.isMetaDown())) {
    openContextMenu(p);
  }
 else   if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {
    CrossPlatformBrowserLauncher.openURL(currentHref);
  }
}
Program: 104550
Project: 104550
Buggy source:
private void fireProgressStateChanged(Date startDate,Date endDate,String[] keywords,int progress){
  ProgressEvent event=new ProgressEvent(this,startDate,endDate,keywords,progress);
  Iterator iter=progressListeners.iterator();
  while (iter.hasNext()) {
    HistorySearchProgressListener item=(HistorySearchProgressListener)iter.next();
    item.progressChanged(event);
  }
}

Fixed version (ground truth):
private void fireProgressStateChanged(Date startDate,Date endDate,String[] keywords,int progress){
  ProgressEvent event=new ProgressEvent(this,startDate,endDate,keywords,progress);
synchronized (progressListeners) {
    Iterator iter=progressListeners.iterator();
    while (iter.hasNext()) {
      HistorySearchProgressListener item=(HistorySearchProgressListener)iter.next();
      item.progressChanged(event);
    }
  }
}
Program: 104551
Project: 104551
Buggy source:
/** 
 * Removing progress listener
 * @param listener HistorySearchProgressListener
 */
public void removeSearchProgressListener(HistorySearchProgressListener listener){
  progressListeners.remove(listener);
}

Fixed version (ground truth):
/** 
 * Removing progress listener
 * @param listener HistorySearchProgressListener
 */
public void removeSearchProgressListener(HistorySearchProgressListener listener){
synchronized (progressListeners) {
    progressListeners.remove(listener);
  }
}
Program: 104552
Project: 104552
Buggy source:
/** 
 * Adding progress listener for monitoring progress of search process
 * @param listener HistorySearchProgressListener
 */
public void addSearchProgressListener(HistorySearchProgressListener listener){
  progressListeners.add(listener);
}

Fixed version (ground truth):
/** 
 * Adding progress listener for monitoring progress of search process
 * @param listener HistorySearchProgressListener
 */
public void addSearchProgressListener(HistorySearchProgressListener listener){
synchronized (progressListeners) {
    progressListeners.add(listener);
  }
}
Program: 104553
Project: 104553
Buggy source:
/** 
 * Add the registered MessageHistorySearchProgressListeners to the given HistoryReader
 * @param reader HistoryReader
 */
private void addHistorySearchProgressListeners(HistoryReader reader){
  Iterator iter=progressListeners.values().iterator();
  while (iter.hasNext()) {
    HistorySearchProgressListener l=(HistorySearchProgressListener)iter.next();
    reader.addSearchProgressListener(l);
  }
}

Fixed version (ground truth):
/** 
 * Add the registered MessageHistorySearchProgressListeners to the given HistoryReader
 * @param reader HistoryReader
 */
private void addHistorySearchProgressListeners(HistoryReader reader){
synchronized (progressListeners) {
    Iterator iter=progressListeners.values().iterator();
    while (iter.hasNext()) {
      HistorySearchProgressListener l=(HistorySearchProgressListener)iter.next();
      reader.addSearchProgressListener(l);
    }
  }
}
Program: 104554
Project: 104554
Buggy source:
/** 
 * Removing progress listener
 * @param listener HistorySearchProgressListener
 */
public void removeSearchProgressListener(MessageHistorySearchProgressListener listener){
  progressListeners.remove(listener);
}

Fixed version (ground truth):
/** 
 * Removing progress listener
 * @param listener HistorySearchProgressListener
 */
public void removeSearchProgressListener(MessageHistorySearchProgressListener listener){
synchronized (progressListeners) {
    progressListeners.remove(listener);
  }
}
Program: 104555
Project: 104555
Buggy source:
/** 
 * Removes the registered MessageHistorySearchProgressListeners from the given HistoryReader
 * @param reader HistoryReader
 */
private void removeHistorySearchProgressListeners(HistoryReader reader){
  Iterator iter=progressListeners.values().iterator();
  while (iter.hasNext()) {
    HistorySearchProgressListener l=(HistorySearchProgressListener)iter.next();
    reader.removeSearchProgressListener(l);
  }
}

Fixed version (ground truth):
/** 
 * Removes the registered MessageHistorySearchProgressListeners from the given HistoryReader
 * @param reader HistoryReader
 */
private void removeHistorySearchProgressListeners(HistoryReader reader){
synchronized (progressListeners) {
    Iterator iter=progressListeners.values().iterator();
    while (iter.hasNext()) {
      HistorySearchProgressListener l=(HistorySearchProgressListener)iter.next();
      reader.removeSearchProgressListener(l);
    }
  }
}
Program: 104556
Project: 104556
Buggy source:
/** 
 * Adding progress listener for monitoring progress of search process
 * @param listener HistorySearchProgressListener
 */
public void addSearchProgressListener(MessageHistorySearchProgressListener listener){
  HistorySearchProgressListener wrapperListener=new SearchProgressWrapper(listener);
  progressListeners.put(listener,wrapperListener);
}

Fixed version (ground truth):
/** 
 * Adding progress listener for monitoring progress of search process
 * @param listener HistorySearchProgressListener
 */
public void addSearchProgressListener(MessageHistorySearchProgressListener listener){
synchronized (progressListeners) {
    HistorySearchProgressListener wrapperListener=new SearchProgressWrapper(listener);
    progressListeners.put(listener,wrapperListener);
  }
}
Program: 104557
Project: 104557
Buggy source:
public void run(){
  try {
    while (true) {
synchronized (contactsForUpdate) {
        if (contactsForUpdate.isEmpty())         contactsForUpdate.wait();
        Iterator iter=contactsForUpdate.iterator();
        while (iter.hasNext()) {
          ContactIcqImpl contact=(ContactIcqImpl)iter.next();
          String oldNickname=contact.getDisplayName();
          String nickName=getParentProvider().getInfoRetreiver().getNickName(contact.getUIN());
          if (nickName != null) {
            contact.setNickname(nickName);
            parentOperationSet.fireContactPropertyChangeEvent(ContactPropertyChangeEvent.PROPERTY_DISPLAY_NAME,contact,oldNickname,nickName);
          }
        }
        contactsForUpdate.clear();
      }
    }
  }
 catch (  InterruptedException ex) {
    logger.error("String_Node_Str",ex);
  }
}

Fixed version (ground truth):
public void run(){
  try {
    Collection copyContactsForUpdate=null;
    while (true) {
synchronized (contactsForUpdate) {
        if (contactsForUpdate.isEmpty())         contactsForUpdate.wait();
        copyContactsForUpdate=new Vector(contactsForUpdate);
        contactsForUpdate.clear();
      }
      Iterator iter=copyContactsForUpdate.iterator();
      while (iter.hasNext()) {
        ContactIcqImpl contact=(ContactIcqImpl)iter.next();
        String oldNickname=contact.getDisplayName();
        String nickName=getParentProvider().getInfoRetreiver().getNickName(contact.getUIN());
        if (nickName != null) {
          contact.setNickname(nickName);
          parentOperationSet.fireContactPropertyChangeEvent(ContactPropertyChangeEvent.PROPERTY_DISPLAY_NAME,contact,oldNickname,nickName);
        }
      }
    }
  }
 catch (  InterruptedException ex) {
    logger.error("String_Node_Str",ex);
  }
}
Program: 104558
Project: 104558
Buggy source:
private void fireProgressStateChanged(ProgressEvent event,int progress){
  event.setProgress(progress);
  Iterator iter=progressListeners.iterator();
  while (iter.hasNext()) {
    HistorySearchProgressListener item=(HistorySearchProgressListener)iter.next();
    item.progressChanged(event);
  }
}

Fixed version (ground truth):
private void fireProgressStateChanged(Date startDate,Date endDate,String[] keywords,int progress){
  ProgressEvent event=new ProgressEvent(this,startDate,endDate,keywords,progress);
  Iterator iter=progressListeners.iterator();
  while (iter.hasNext()) {
    HistorySearchProgressListener item=(HistorySearchProgressListener)iter.next();
    item.progressChanged(event);
  }
}
Program: 104560
Project: 104560
Buggy source:
/** 
 * Used to convert HistoryRecord in MessageDeliveredEvent or MessageReceivedEvent which are returned by the finder methods
 * @param hr HistoryRecord
 * @param contact Contact
 * @return Object
 */
private Object convertHistoryRecordToMessageEvent(HistoryRecord hr,Contact contact){
  MessageImpl msg=new MessageImpl(hr);
  Date timestamp=null;
  if (msg.getMessageReceivedDate() != null)   timestamp=msg.getMessageReceivedDate();
 else   timestamp=hr.getTimestamp();
  if (msg.isOutgoing) {
    return new MessageDeliveredEvent(msg,contact,timestamp);
  }
 else   return new MessageReceivedEvent(msg,contact,timestamp);
}

Fixed version (ground truth):
/** 
 * Used to convert HistoryRecord in MessageDeliveredEvent or MessageReceivedEvent which are returned by the finder methods
 * @param hr HistoryRecord
 * @param contact Contact
 * @return Object
 */
private Object convertHistoryRecordToMessageEvent(HistoryRecord hr,Contact contact){
  MessageImpl msg=new MessageImpl(hr);
  Date timestamp=null;
  if (msg.getMessageReceivedDate() != null) {
    if (msg.getMessageReceivedDate().after(hr.getTimestamp()) && (msg.getMessageReceivedDate().getTime() - hr.getTimestamp().getTime()) > 86400000)     timestamp=hr.getTimestamp();
 else     timestamp=msg.getMessageReceivedDate();
  }
 else   timestamp=hr.getTimestamp();
  if (msg.isOutgoing) {
    return new MessageDeliveredEvent(msg,contact,timestamp);
  }
 else   return new MessageReceivedEvent(msg,contact,timestamp);
}
Program: 104561
Project: 104561
Buggy source:
/** 
 * Constructs a new <tt>ProgressEvent</tt>.
 * @param source Object The source firing this event
 * @param startDate Date The start date in the search condition.
 * @param endDate Date The end date in the search condition.
 */
public ProgressEvent(Object source,Date startDate,Date endDate){
  this(source,startDate,endDate,null,-1,0);
}

Fixed version (ground truth):
/** 
 * Constructs a new <tt>ProgressEvent</tt>.
 * @param source Object The source firing this event
 * @param startDate Date The start date in the search condition.
 * @param endDate Date The end date in the search condition.
 */
public ProgressEvent(Object source,Date startDate,Date endDate){
  this(source,startDate,endDate,null,0);
}
Program: 104563
Project: 104563
Buggy source:
/** 
 * Returns the screenname of this contact
 * @return this contact's screen name.
 */
public String getAlias(){
  return screenname.getFormatted();
}

Fixed version (ground truth):
/** 
 * Returns the screenname of this contact
 * @return this contact's screen name.
 */
public String getAlias(){
  return null;
}
Program: 104564
Project: 104564
Buggy source:
/** 
 * Called whnever an indication is received that a new server stored group is created.
 * @param evt a ServerStoredGroupEvent containing a reference to thenewly created group.
 */
public void groupCreated(ServerStoredGroupEvent evt){
synchronized (this) {
    Contact contact=evt.getSourceGroup().getContact(subscriptionAddress);
    if (sourceContact != null) {
      this.evt=evt;
      this.sourceContact=contact;
      this.notifyAll();
    }
  }
}

Fixed version (ground truth):
/** 
 * Called whnever an indication is received that a new server stored group is created.
 * @param evt a ServerStoredGroupEvent containing a reference to thenewly created group.
 */
public void groupCreated(ServerStoredGroupEvent evt){
synchronized (this) {
    Contact contact=evt.getSourceGroup().getContact(subscriptionAddress);
    if (contact != null) {
      this.evt=evt;
      this.sourceContact=contact;
      this.notifyAll();
    }
  }
}
Program: 104566
Project: 104566
Buggy source:
/** 
 * Starts the registration process. Connection details such as registration server, user name/number are provided through the configuration service through implementation specific properties.
 * @param authority the security authority that will be used for resolvingany security challenges that may be returned during the registration or at any moment while wer're registered.
 */
public void register(SecurityAuthority authority){
  aimConnection.connect();
}

Fixed version (ground truth):
/** 
 * Starts the registration process. Connection details such as registration server, user name/number are provided through the configuration service through implementation specific properties.
 * @param authority the security authority that will be used for resolvingany security challenges that may be returned during the registration or at any moment while wer're registered.
 */
public void register(SecurityAuthority authority){
synchronized (initializationLock) {
    String accountPrefix=IcqActivator.getProtocolProviderFactory().findAccountPrefix(getAccountID());
    String password=IcqActivator.getConfigurationService().getString(accountPrefix + "String_Node_Str" + ProtocolProviderFactory.PASSWORD);
    if (password != null) {
      password=new String(Base64.decode(password));
    }
 else {
    }
    session=new DefaultAppSession();
    aimSession=session.openAimSession(new Screenname(getAccountID().getUserID()));
    aimConnection=aimSession.openConnection(new AimConnectionProperties(new Screenname(getAccountID().getUserID()),password));
    aimConnStateListener=new AimConnStateListener();
    aimConnection.addStateListener(aimConnStateListener);
    aimConnection.connect();
  }
}
Program: 104567
Project: 104567
Buggy source:
public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected,boolean hasFocus,int row,int column){
  if (value instanceof JLabel) {
    JLabel labelValue=(JLabel)value;
    label.setText(labelValue.getText());
    label.setIcon(labelValue.getIcon());
  }
 else   if (value instanceof ProtocolProviderService) {
    ProtocolProviderService pps=(ProtocolProviderService)value;
    label.setText(pps.getAccountID().getAccountUserID());
  }
 else   if (value instanceof MetaContactGroup) {
    MetaContactGroup group=(MetaContactGroup)value;
    label.setText(group.getGroupName());
  }
 else {
    label.setText(value.toString());
  }
  if (isSelected)   this.setBackground(Constants.SELECTED_END_COLOR);
  return this;
}

Fixed version (ground truth):
public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected,boolean hasFocus,int row,int column){
  if (value instanceof JLabel) {
    JLabel labelValue=(JLabel)value;
    label.setText(labelValue.getText());
    label.setIcon(labelValue.getIcon());
  }
 else   if (value instanceof ProtocolProviderService) {
    ProtocolProviderService pps=(ProtocolProviderService)value;
    label.setText(pps.getAccountID().getAccountUserID());
  }
 else   if (value instanceof MetaContactGroup) {
    MetaContactGroup group=(MetaContactGroup)value;
    label.setText(group.getGroupName());
  }
 else {
    label.setText(value.toString());
  }
  if (isSelected)   this.setBackground(Constants.SELECTED_END_COLOR);
 else   this.setBackground(UIManager.getColor("String_Node_Str"));
  return this;
}
Program: 104568
Project: 104568
Buggy source:
public void actionPerformed(ActionEvent e){
  JButton button=(JButton)e.getSource();
  String name=button.getName();
  if (name.equals("String_Node_Str")) {
    if (metaContact != null) {
      this.clist.renameMetaContact(metaContact,renameContactPanel.getName());
    }
    this.dispose();
  }
 else {
    this.dispose();
  }
}

Fixed version (ground truth):
public void actionPerformed(ActionEvent e){
  JButton button=(JButton)e.getSource();
  String name=button.getName();
  if (name.equals("String_Node_Str")) {
    if (metaContact != null) {
      this.clist.renameMetaContact(metaContact,renameContactPanel.getNewName());
    }
    this.dispose();
  }
 else {
    this.dispose();
  }
}
Program: 104569
Project: 104569
Buggy source:
public static void loadAdiumStyle(){
  try {
    File is=new File(Constants.class.getClassLoader().getResource(DEFAULT_STYLE_PATH + "String_Node_Str").toURI());
    System.out.println("String_Node_Str" + is);
  }
 catch (  URISyntaxException e) {
    logger.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public static void loadAdiumStyle(){
  File is=new File(Constants.class.getClassLoader().getResource(DEFAULT_STYLE_PATH + "String_Node_Str").toString());
  System.out.println("String_Node_Str" + is);
}