nus-yam/ex-repair huggingface dataset:
Program: 2579
Project: 2579
Buggy source:
@Override public void onChatChanged(ChatChangedEvent event){
  if (event.isCreated()) {
    createChat(event.getChat(),Visibility.notFocused);
  }
  if (event.isOpened()) {
    final PairChatPage page=chatPages.get(event.getChat());
    if (page != null) {
      page.requestVisibility(Visibility.focused);
    }
 else {
      createChat(event.getChat(),Visibility.notFocused);
    }
  }
  if (event.isClosed()) {
    final PairChatPage page=chatPages.get(event.getChat().getURI());
    page.requestVisibility(Visibility.hidden);
  }
}

Fixed version (ground truth):
@Override public void onChatChanged(ChatChangedEvent event){
  if (event.isCreated()) {
    createChat(event.getChat(),Visibility.notFocused);
  }
  if (event.isOpened()) {
    final PairChatPage page=chatPages.get(event.getChat());
    if (page != null) {
      page.requestVisibility(Visibility.focused);
    }
 else {
      createChat(event.getChat(),Visibility.notFocused);
    }
  }
  if (event.isClosed()) {
    final PairChatPage page=chatPages.get(event.getChat());
    page.requestVisibility(Visibility.hidden);
  }
}
Program: 2582
Project: 2582
Buggy source:
@Override public void onEvent(final XmppURI uri,final String reason){
  final Roster roster=Suco.get(Roster.class);
  final RosterItem item=roster.getItemByJID(uri);
  final String name=item != null ? item.getName() : uri.getNode();
  final String body=isEmpty(reason) ? i18n().invitationSent(name) : i18n().invitationSentWithReason(name,reason);
  show(body);
}

Fixed version (ground truth):
@Override public void onEvent(final XmppURI uri,final String reason){
  final Roster roster=Suco.get(Roster.class);
  final RosterItem item=roster.getItemByJID(uri);
  final String name=((item != null) && (item.getName() != null)) ? item.getName() : uri.getNode();
  final String body=isEmpty(reason) ? i18n().invitationSent(name) : i18n().invitationSentWithReason(name,reason);
  show(body);
}
Program: 2583
Project: 2583
Buggy source:
private void receiveMessage(final Message message){
  final String messageBody=message.getBody();
  if (Empty.not(messageBody)) {
    final Delay delay=DelayHelper.getDelay(message);
    final String color=ColorHelper.getColor(message.getFrom().getJID());
    final ChatMessage chatMessage=new ChatMessage(null,color,userName,messageBody,ChatMessage.MessageType.incoming);
    if (delay != null) {
      chatMessage.setDate(delay.getStamp());
    }
    addMessage(chatMessage);
    fireUserMessage(messageBody);
    if (getVisibility() == Visibility.hidden) {
      requestVisibility(Visibility.notFocused);
    }
  }
}

Fixed version (ground truth):
private void receiveMessage(final Message message){
  final String messageBody=message.getBody();
  if ((Type.error != message.getType()) && Empty.not(messageBody)) {
    final Delay delay=DelayHelper.getDelay(message);
    final String color=ColorHelper.getColor(message.getFrom().getJID());
    final ChatMessage chatMessage=new ChatMessage(null,color,userName,messageBody,ChatMessage.MessageType.incoming);
    if (delay != null) {
      chatMessage.setDate(delay.getStamp());
    }
    addMessage(chatMessage);
    fireUserMessage(messageBody);
    if (getVisibility() == Visibility.hidden) {
      requestVisibility(Visibility.notFocused);
    }
  }
}
Program: 2584
Project: 2584
Buggy source:
public PairChatPresenter(final XmppRoster roster,final HablarEventBus eventBus,final Chat chat,final ChatDisplay display){
  super(TYPE,Idify.uriId(chat.getURI().toString()),eventBus,chat,display);
  this.roster=roster;
  this.chat=chat;
  display.setId(getId());
  final XmppURI fromURI=chat.getURI();
  userName=roster.getJidName(fromURI);
  model.init(Icons.BUDDY_OFF,userName,userName + "String_Node_Str" + fromURI.toString());
  setVisibility(Visibility.notFocused);
  model.setCloseable(true);
  chat.addMessageReceivedHandler(new MessageHandler(){
    @Override public void onMessage(    final MessageEvent event){
      receiveMessage(event.getMessage());
    }
  }
);
  display.getAction().addClickHandler(new ClickHandler(){
    @Override public void onClick(    final ClickEvent event){
      sendMessage(chat,display);
    }
  }
);
  display.getTextBox().addKeyDownHandler(new KeyDownHandler(){
    @Override public void onKeyDown(    final KeyDownEvent event){
      if (event.getNativeKeyCode() == 13) {
        event.stopPropagation();
        event.preventDefault();
        sendMessage(chat,display);
      }
    }
  }
);
}

Fixed version (ground truth):
public PairChatPresenter(final XmppRoster roster,final HablarEventBus eventBus,final Chat chat,final ChatDisplay display){
  super(TYPE,Idify.uriId(chat.getURI().toString()),eventBus,chat,display);
  this.chat=chat;
  display.setId(getId());
  final XmppURI fromURI=chat.getURI();
  userName=roster.getJidName(fromURI);
  model.init(Icons.BUDDY_OFF,userName,userName + "String_Node_Str" + fromURI.toString());
  setVisibility(Visibility.notFocused);
  model.setCloseable(true);
  chat.addMessageReceivedHandler(new MessageHandler(){
    @Override public void onMessage(    final MessageEvent event){
      receiveMessage(event.getMessage());
    }
  }
);
  display.getAction().addClickHandler(new ClickHandler(){
    @Override public void onClick(    final ClickEvent event){
      sendMessage(chat,display);
    }
  }
);
  display.getTextBox().addKeyDownHandler(new KeyDownHandler(){
    @Override public void onKeyDown(    final KeyDownEvent event){
      if (event.getNativeKeyCode() == 13) {
        event.stopPropagation();
        event.preventDefault();
        sendMessage(chat,display);
      }
    }
  }
);
}
Program: 2585
Project: 2585
Buggy source:
public void setItem(final RosterItem item){
  this.item=item;
  String name=item.getName();
  if (name == null) {
    name=item.getJID().getShortName();
  }
  display.getName().setText(name);
  final String jidString=item.getJID().toString();
  display.getJid().setText(jidString);
  final String status=item.getStatus();
  final boolean hasStatus=(status != null) && (status.trim().length() > 0);
  if (hasStatus) {
    display.getStatus().setText(status);
  }
  display.setStatusVisible(hasStatus);
  display.setIcon(PresenceIcon.get(item.isAvailable(),item.getShow()));
  final String title=clickActionDescription + name + "String_Node_Str"+ jidString+ "String_Node_Str";
  display.setWidgetTitle(title);
  display.setColor(ColorHelper.getColor(item.getJID()));
}

Fixed version (ground truth):
public void setItem(final RosterItem item){
  this.item=item;
  String name=item.getName();
  if (name == null) {
    name=item.getJID().getShortName();
  }
  display.getName().setText(name);
  final String jidString=item.getJID().toString();
  display.getJid().setText(jidString);
  final String status=item.getStatus();
  final boolean hasStatus=(status != null) && (status.trim().length() > 0);
  if (hasStatus) {
    display.getStatus().setText(status);
  }
  display.setStatusVisible(hasStatus);
  display.setIcon(PresenceIcon.get(item.isAvailable(),item.getShow()));
  final String title=clickActionDescription + name + "String_Node_Str"+ jidString+ "String_Node_Str";
  display.setWidgetTitle(title);
}
Program: 2586
Project: 2586
Buggy source:
protected void unfocus(final Page<?> page){
  if (focusedPage != null && focusedPage == page) {
    page.setVisibility(Visibility.notFocused);
    focusedPage=null;
  }
 else   if (page.getVisibility() == Visibility.hidden) {
    final PageAndHead widgets=getWidgets(page);
    display.add(widgets.pageWidget,widgets.headWidget);
    if (focusedPage != null) {
      focus(focusedPage);
      page.setVisibility(Visibility.notFocused);
    }
 else {
      focus(page);
    }
  }
}

Fixed version (ground truth):
protected void unfocus(final Page<?> page){
}
Program: 2587
Project: 2587
Buggy source:
protected boolean hide(final Page<?> page){
  if (focusedPage == page && lastFocused != null) {
    focus(lastFocused);
    lastFocused=focusedPage;
  }
  final PageAndHead widgets=getWidgets(page);
  if (widgets != null) {
    display.remove(widgets.pageWidget);
    page.setVisibility(Visibility.hidden);
    if (page == focusedPage) {
      focusedPage=null;
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
protected boolean hide(final Page<?> page){
  if ((focusedPage == page) && (lastFocused != null)) {
    focus(lastFocused);
    lastFocused=focusedPage;
  }
  final PageAndHead widgets=getWidgets(page);
  if (widgets != null) {
    display.remove(widgets.pageWidget);
    page.setVisibility(Visibility.hidden);
    if (page == focusedPage) {
      focusedPage=null;
    }
    return true;
  }
  return false;
}
Program: 2588
Project: 2588
Buggy source:
public MainContainer(final HablarEventBus eventBus,final MainLayout layout){
  this.eventBus=eventBus;
  display=layout;
  pages=new HashMap<Page<?>,PageAndHead>();
  eventBus.addHandler(VisibilityChangeRequestEvent.TYPE,new VisibilityChangeRequestHandler(){
    @Override public void onVisibilityChangeRequest(    final VisibilityChangeRequestEvent event){
      final Page<?> page=event.getPage();
      if (pages.containsKey(page)) {
        changeVisibility(page,event.getNewVisibility());
      }
    }
  }
);
  focusedPage=null;
}

Fixed version (ground truth):
public MainContainer(final HablarEventBus eventBus,final MainLayout layout){
  this.eventBus=eventBus;
  display=layout;
  pages=new HashMap<Page<?>,PageAndHead>();
  VisibilityChangeRequestEvent.bind(eventBus,new VisibilityChangeRequestHandler(){
    @Override public void onVisibilityChangeRequest(    final VisibilityChangeRequestEvent event){
      final Page<?> page=event.getPage();
      if (pages.containsKey(page)) {
        changeVisibility(page,event.getNewVisibility());
      }
    }
  }
);
  focusedPage=null;
}
Program: 2589
Project: 2589
Buggy source:
public OverlayContainer(final HablarEventBus eventBus,final OverlayPanel panel){
  this.panel=panel;
  pages=new ArrayList<Page<?>>();
  panel.setVisible(false);
  eventBus.addHandler(VisibilityChangeRequestEvent.TYPE,new VisibilityChangeRequestHandler(){
    @Override public void onVisibilityChangeRequest(    final VisibilityChangeRequestEvent event){
      changeVisibility(event.getNewVisibility(),event.getPage());
    }
  }
);
}

Fixed version (ground truth):
public OverlayContainer(final HablarEventBus eventBus,final OverlayPanel panel){
  this.panel=panel;
  pages=new ArrayList<Page<?>>();
  panel.setVisible(false);
  VisibilityChangeRequestEvent.bind(eventBus,new VisibilityChangeRequestHandler(){
    @Override public void onVisibilityChangeRequest(    final VisibilityChangeRequestEvent event){
      changeVisibility(event.getNewVisibility(),event.getPage());
    }
  }
);
}
Program: 2590
Project: 2590
Buggy source:
@Override public String toDebugString(){
  return super.toDebugString() + pageState + "String_Node_Str"+ page+ "String_Node_Str";
}

Fixed version (ground truth):
@Override public String toDebugString(){
  return super.toDebugString() + "String_Node_Str" + page+ "String_Node_Str";
}
Program: 2591
Project: 2591
Buggy source:
@Override protected void dispatch(VisibilityChangeRequestHandler handler){
  handler.onVisibilityChangeRequest(this);
}

Fixed version (ground truth):
@Override protected void dispatch(final VisibilityChangeRequestHandler handler){
  handler.onVisibilityChangeRequest(this);
}
Program: 2592
Project: 2592
Buggy source:
public VisibilityChangeRequestEvent(Page<?> page,Visibility newVisibility){
  this.page=page;
  this.newVisibility=newVisibility;
}

Fixed version (ground truth):
public VisibilityChangeRequestEvent(final Page<?> page,final Visibility newVisibility){
  this.page=page;
  this.newVisibility=newVisibility;
}
Program: 2593
Project: 2593
Buggy source:
@Override public String toDebugString(){
  return super.toDebugString() + newVisibility + "String_Node_Str"+ page.getId()+ "String_Node_Str";
}

Fixed version (ground truth):
@Override public String toDebugString(){
  return super.toDebugString() + newVisibility + "String_Node_Str"+ page.getId()+ "String_Node_Str"+ page.getVisibility();
}
Program: 2594
Project: 2594
Buggy source:
public VariableDockContainer(final HablarEventBus eventBus,final DockConfig config,final PagesContainer main,final HablarDisplay display){
  this.eventBus=eventBus;
  this.display=display;
  this.helper=new VariableDockHelper();
  this.headerSize=config.headerSize;
  final Widget mainWidget=main.getWidget();
  mainWidget.removeFromParent();
  this.split=new SplitLayoutPanel();
  display.add(split);
  display.setWidgetLeftRight(split,0,Unit.PX,0,Unit.PX);
  display.setWidgetTopBottom(split,headerSize,Unit.PX,3,Unit.PX);
  this.rosterPanel=new LayoutPanel();
  if ("String_Node_Str".equals(config.rosterDock)) {
    split.addWest(rosterPanel,config.rosterWidth);
  }
 else {
    split.addEast(rosterPanel,config.rosterWidth);
  }
  split.add(mainWidget);
  this.userPanel=new LayoutPanel();
  this.userPanel.addStyleName("String_Node_Str");
  display.add(userPanel);
  display.setWidgetLeftRight(userPanel,0,Unit.PX,0,Unit.PX);
  display.setWidgetTopHeight(userPanel,0,Unit.PX,24,Unit.PX);
  eventBus.addHandler(VisibilityChangeRequestEvent.TYPE,new VisibilityChangeRequestHandler(){
    @Override public void onVisibilityChangeRequest(    final VisibilityChangeRequestEvent event){
      final Page<?> page=event.getPage();
      if (page.getType().equals(UserPage.TYPE)) {
        changeVisibility(page,event.getNewVisibility());
      }
    }
  }
);
}

Fixed version (ground truth):
public VariableDockContainer(final HablarEventBus eventBus,final DockConfig config,final PagesContainer main,final HablarDisplay display){
  this.eventBus=eventBus;
  this.display=display;
  this.helper=new VariableDockHelper();
  this.headerSize=config.headerSize;
  final Widget mainWidget=main.getWidget();
  mainWidget.removeFromParent();
  this.split=new SplitLayoutPanel();
  display.add(split);
  display.setWidgetLeftRight(split,0,Unit.PX,0,Unit.PX);
  display.setWidgetTopBottom(split,headerSize,Unit.PX,3,Unit.PX);
  this.rosterPanel=new LayoutPanel();
  if ("String_Node_Str".equals(config.rosterDock)) {
    split.addWest(rosterPanel,config.rosterWidth);
  }
 else {
    split.addEast(rosterPanel,config.rosterWidth);
  }
  split.add(mainWidget);
  this.userPanel=new LayoutPanel();
  this.userPanel.addStyleName("String_Node_Str");
  display.add(userPanel);
  display.setWidgetLeftRight(userPanel,0,Unit.PX,0,Unit.PX);
  display.setWidgetTopHeight(userPanel,0,Unit.PX,24,Unit.PX);
  VisibilityChangeRequestEvent.bind(eventBus,new VisibilityChangeRequestHandler(){
    @Override public void onVisibilityChangeRequest(    final VisibilityChangeRequestEvent event){
      final Page<?> page=event.getPage();
      if (page.getType().equals(UserPage.TYPE)) {
        changeVisibility(page,event.getNewVisibility());
      }
    }
  }
);
}
Program: 2596
Project: 2596
Buggy source:
@Override public void onOccupantChanged(final OccupantChangedEvent event){
  if (event.isAdded()) {
    final String body=i18n().occupantHasJoined(event.getOccupant().getNick());
    show(body);
  }
 else   if (event.isRemoved()) {
    if (!me.equals(event.getOccupant().getUserUri().getNode())) {
      final String body=i18n().occupantHasLeft(event.getOccupant().getNick());
      show(body);
    }
  }
}

Fixed version (ground truth):
@Override public void onOccupantChanged(final OccupantChangedEvent event){
  if (event.isAdded()) {
    final String body=i18n().occupantHasJoined(event.getOccupant().getNick());
    show(body);
  }
 else   if (event.isRemoved()) {
    final XmppURI occupantUserUri=event.getOccupant().getUserUri();
    final String node=occupantUserUri != null ? occupantUserUri.getNode() : null;
    if (!me.equals(node)) {
      final String body=i18n().occupantHasLeft(event.getOccupant().getNick());
      show(body);
    }
  }
}
Program: 2597
Project: 2597
Buggy source:
private void onChatVisibilityChanged(final Page<?> page,Visibility visibility){
  if ((visibility == Visibility.focused || visibility == Visibility.hidden) && unattendedChatPages.remove(page)) {
    eventBus.fireEvent(new UnattendedChatsChangedEvent(ChangeType.removed,page));
  }
}

Fixed version (ground truth):
private void onChatVisibilityChanged(final Page<?> page,final Visibility visibility){
  if (((visibility == Visibility.focused) || (visibility == Visibility.hidden)) && unattendedChatPages.remove(page)) {
    eventBus.fireEvent(new UnattendedChatsChangedEvent(ChangeType.removed,page));
  }
}
Program: 2598
Project: 2598
Buggy source:
public UnattendedPagesManager(final HablarEventBus hablarEventBus,BrowserFocusHandler focusManager){
  eventBus=hablarEventBus;
  this.focusManager=focusManager;
  unattendedChatPages=new HashSet<Page<?>>();
  bind();
}

Fixed version (ground truth):
public UnattendedPagesManager(final HablarEventBus hablarEventBus,final BrowserFocusHandler focusManager){
  eventBus=hablarEventBus;
  this.focusManager=focusManager;
  unattendedChatPages=new HashSet<Page<?>>();
  bind();
}
Program: 2599
Project: 2599
Buggy source:
private void bind(){
  eventBus.addHandler(UserMessageEvent.TYPE,new UserMessageHandler(){
    @Override public void onUserMessage(    final UserMessageEvent event){
      final String messageType=event.getMessageType();
      if (isChatMessage(messageType)) {
        final Page<?> page=event.getPage();
        final Visibility visibility=page.getVisibility();
        if ((visibility != Visibility.focused || !focusManager.hasFocus()) && unattendedChatPages.add(page)) {
          eventBus.fireEvent(new UnattendedChatsChangedEvent(ChangeType.added,page));
        }
      }
    }
  }
);
  eventBus.addHandler(VisibilityChangedEvent.TYPE,new VisibilityChangedHandler(){
    @Override public void onVisibilityChanged(    final VisibilityChangedEvent event){
      final Page<?> page=event.getPage();
      if (isChatPage(page.getType())) {
        onChatVisibilityChanged(page,event.getVisibility());
      }
    }
  }
);
}

Fixed version (ground truth):
private void bind(){
  eventBus.addHandler(UserMessageEvent.TYPE,new UserMessageHandler(){
    @Override public void onUserMessage(    final UserMessageEvent event){
      final String messageType=event.getMessageType();
      if (isChatMessage(messageType)) {
        final Page<?> page=event.getPage();
        final Visibility visibility=page.getVisibility();
        GWT.log("String_Node_Str" + visibility);
        if (((visibility != Visibility.focused) || !focusManager.hasFocus()) && unattendedChatPages.add(page)) {
          eventBus.fireEvent(new UnattendedChatsChangedEvent(ChangeType.added,page));
        }
      }
    }
  }
);
  eventBus.addHandler(VisibilityChangedEvent.TYPE,new VisibilityChangedHandler(){
    @Override public void onVisibilityChanged(    final VisibilityChangedEvent event){
      final Page<?> page=event.getPage();
      if (isChatPage(page.getType())) {
        onChatVisibilityChanged(page,event.getVisibility());
      }
    }
  }
);
}
Program: 2600
Project: 2600
Buggy source:
@Override public void onUserMessage(final UserMessageEvent event){
  final String messageType=event.getMessageType();
  if (isChatMessage(messageType)) {
    final Page<?> page=event.getPage();
    final Visibility visibility=page.getVisibility();
    if ((visibility != Visibility.focused || !focusManager.hasFocus()) && unattendedChatPages.add(page)) {
      eventBus.fireEvent(new UnattendedChatsChangedEvent(ChangeType.added,page));
    }
  }
}

Fixed version (ground truth):
@Override public void onUserMessage(final UserMessageEvent event){
  final String messageType=event.getMessageType();
  if (isChatMessage(messageType)) {
    final Page<?> page=event.getPage();
    final Visibility visibility=page.getVisibility();
    GWT.log("String_Node_Str" + visibility);
    if (((visibility != Visibility.focused) || !focusManager.hasFocus()) && unattendedChatPages.add(page)) {
      eventBus.fireEvent(new UnattendedChatsChangedEvent(ChangeType.added,page));
    }
  }
}
Program: 2601
Project: 2601
Buggy source:
/** 
 * Sets current browser focus status
 * @param hasFocus
 */
public void setFocus(boolean hasFocus){
  GWT.log("String_Node_Str" + hasFocus);
  this.hasFocus=hasFocus;
  focusListener.onBrowserFocusChanged(hasFocus);
}

Fixed version (ground truth):
/** 
 * Sets current browser focus status
 * @param hasFocus
 */
public void setFocus(boolean hasFocus){
  if (this.hasFocus == hasFocus) {
    return;
  }
  GWT.log("String_Node_Str" + hasFocus);
  this.hasFocus=hasFocus;
  focusListener.onBrowserFocusChanged(hasFocus);
}
Program: 2602
Project: 2602
Buggy source:
@Override public void onBrowserFocusChanged(boolean hasFocus){
  if (currentFocused != null) {
    if (hasFocus == false) {
      currentFocused.getDisplay().setTextBoxFocus(false);
    }
 else     if (!unattendedManager.contains(currentFocused)) {
      currentFocused.getDisplay().setTextBoxFocus(true);
    }
  }
}

Fixed version (ground truth):
@Override public void onBrowserFocusChanged(boolean hasFocus){
  if (currentFocused != null) {
    if (hasFocus == false) {
      currentFocused.getDisplay().setTextBoxFocus(false);
    }
  }
}
Program: 2603
Project: 2603
Buggy source:
public BrowserFocusManager(HablarEventBus eventBus,final UnattendedPagesManager unattendedManager,BrowserFocusHandler handler){
  eventBus.addHandler(VisibilityChangedEvent.TYPE,new VisibilityChangedHandler(){
    @Override public void onVisibilityChanged(    VisibilityChangedEvent event){
      if (event.getVisibility() == Visibility.focused) {
        Page<?> page=event.getPage();
        if (PairChatPresenter.TYPE.equals(page.getType()) || RoomPresenter.TYPE.equals(page.getType())) {
          currentFocused=(ChatPresenter)page;
        }
      }
    }
  }
);
  handler.setFocusListener(new BrowserFocusListener(){
    @Override public void onBrowserFocusChanged(    boolean hasFocus){
      if (currentFocused != null) {
        if (hasFocus == false) {
          currentFocused.getDisplay().setTextBoxFocus(false);
        }
 else         if (!unattendedManager.contains(currentFocused)) {
          currentFocused.getDisplay().setTextBoxFocus(true);
        }
      }
    }
  }
);
}

Fixed version (ground truth):
public BrowserFocusManager(HablarEventBus eventBus,final UnattendedPagesManager unattendedManager,BrowserFocusHandler handler){
  eventBus.addHandler(VisibilityChangedEvent.TYPE,new VisibilityChangedHandler(){
    @Override public void onVisibilityChanged(    VisibilityChangedEvent event){
      if (event.getVisibility() == Visibility.focused) {
        Page<?> page=event.getPage();
        if (PairChatPresenter.TYPE.equals(page.getType()) || RoomPresenter.TYPE.equals(page.getType())) {
          currentFocused=(ChatPresenter)page;
        }
      }
    }
  }
);
  handler.setFocusListener(new BrowserFocusListener(){
    @Override public void onBrowserFocusChanged(    boolean hasFocus){
      if (currentFocused != null) {
        if (hasFocus == false) {
          currentFocused.getDisplay().setTextBoxFocus(false);
        }
      }
    }
  }
);
}
Program: 2604
Project: 2604
Buggy source:
/** 
 * Adds the focus events to the browser
 */
@Override protected native void addFocusListenerEvents();

Fixed version (ground truth):
/** 
 * Adds the focus events to the browser Thanks to http://www.sitepen.com/blog/2008/10/13/the-cross-browser-window- focus-blues/
 */
@Override protected native void addFocusListenerEvents();
Program: 2605
Project: 2605
Buggy source:
@Override public void onModuleLoad(){
  CoreMessages messages=GWT.create(CoreMessages.class);
  ConfirmWidget.setMessages(messages);
}

Fixed version (ground truth):
@Override public void onModuleLoad(){
  BrowserFocusHandler.getInstance();
  CoreMessages messages=GWT.create(CoreMessages.class);
  ConfirmWidget.setMessages(messages);
}
Program: 2606
Project: 2606
Buggy source:
/** 
 * Expose the method to javascript (do not use this function, use getInstance().setFocus() instead)
 * @param hasFocus
 */
public static void changeFocus(boolean hasFocus){
  getInstance().setFocus(hasFocus);
}

Fixed version (ground truth):
/** 
 * Expose the method to javascript (do not use this function, use getInstance().setFocus() instead)
 * @param hasFocus
 */
public static void changeFocus(final boolean hasFocus){
  getInstance().setFocus(hasFocus);
}
Program: 2607
Project: 2607
Buggy source:
public static RosterPage installModule(final Hablar hablar,RosterConfig rosterConfig){
  final SubscriptionHandler subscriptionHandler=Suco.get(SubscriptionHandler.class);
  subscriptionHandler.setBehaviour(Behaviour.acceptAll);
  if (rosterConfig.rosterItemclickAction == null && rosterConfig.oneClickChat) {
    rosterConfig.rosterItemclickAction=new SimpleAction<RosterItem>(i18n().clickToOpenChat(),"String_Node_Str"){
      @Override public void execute(      RosterItem item){
        final ChatManager manager=Suco.get(ChatManager.class);
        manager.open(item.getJID());
      }
    }
;
  }
  final RosterPage roster=new RosterPresenter(hablar.getEventBus(),new RosterWidget(),rosterConfig);
  roster.setVisibility(Visibility.notFocused);
  hablar.addPage(roster);
  final Session session=Suco.get(Session.class);
  session.onStateChanged(new Listener<Session>(){
    @Override public void onEvent(    final Session session){
      setState(roster,session.getState());
    }
  }
);
  setState(roster,session.getState());
  roster.addHighPriorityActions();
  return roster;
}

Fixed version (ground truth):
public static RosterPage installModule(final Hablar hablar,RosterConfig rosterConfig){
  final SubscriptionHandler subscriptionHandler=Suco.get(SubscriptionHandler.class);
  subscriptionHandler.setBehaviour(Behaviour.acceptAll);
  if (rosterConfig.rosterItemClickAction == null && rosterConfig.oneClickChat) {
    rosterConfig.rosterItemClickAction=new SimpleAction<RosterItem>(i18n().clickToOpenChat(),"String_Node_Str"){
      @Override public void execute(      RosterItem item){
        final ChatManager manager=Suco.get(ChatManager.class);
        manager.open(item.getJID());
      }
    }
;
  }
  final RosterPage roster=new RosterPresenter(hablar.getEventBus(),new RosterWidget(),rosterConfig);
  roster.setVisibility(Visibility.notFocused);
  hablar.addPage(roster);
  final Session session=Suco.get(Session.class);
  session.onStateChanged(new Listener<Session>(){
    @Override public void onEvent(    final Session session){
      setState(roster,session.getState());
    }
  }
);
  setState(roster,session.getState());
  roster.addHighPriorityActions();
  return roster;
}
Program: 2608
Project: 2608
Buggy source:
public RosterItemPresenter(final String groupName,final Menu<RosterItemPresenter> itemMenu,final RosterItemDisplay display,final RosterConfig rosterConfig){
  this.groupName=groupName;
  this.display=display;
  if (rosterConfig.rosterItemclickAction != null) {
    display.setWidgetTitle(rosterConfig.rosterItemclickAction.getDescription());
    display.getAction().addClickHandler(new ClickHandler(){
      @Override public void onClick(      final ClickEvent event){
        rosterConfig.rosterItemclickAction.execute(item);
      }
    }
);
    display.addStyleName("String_Node_Str");
  }
  display.getMenuAction().addClickHandler(new ClickHandler(){
    @Override public void onClick(    final ClickEvent event){
      event.stopPropagation();
      event.preventDefault();
      final Element element=event.getRelativeElement();
      itemMenu.setTarget(RosterItemPresenter.this);
      itemMenu.show(element.getAbsoluteLeft(),element.getAbsoluteTop());
    }
  }
);
}

Fixed version (ground truth):
public RosterItemPresenter(final String groupName,final Menu<RosterItemPresenter> itemMenu,final RosterItemDisplay display,final RosterConfig rosterConfig){
  this.groupName=groupName;
  this.display=display;
  if (rosterConfig.rosterItemClickAction != null) {
    display.setWidgetTitle(rosterConfig.rosterItemClickAction.getDescription());
    display.getAction().addClickHandler(new ClickHandler(){
      @Override public void onClick(      final ClickEvent event){
        rosterConfig.rosterItemClickAction.execute(item);
      }
    }
);
    display.addStyleName("String_Node_Str");
  }
  display.getMenuAction().addClickHandler(new ClickHandler(){
    @Override public void onClick(    final ClickEvent event){
      event.stopPropagation();
      event.preventDefault();
      final Element element=event.getRelativeElement();
      itemMenu.setTarget(RosterItemPresenter.this);
      itemMenu.show(element.getAbsoluteLeft(),element.getAbsoluteTop());
    }
  }
);
}
Program: 2609
Project: 2609
Buggy source:
public RosterGroupPresenter(final RosterGroup group,final Menu<RosterItemPresenter> itemMenu,final RosterGroupDisplay display,final RosterConfig rosterConfig){
  this.group=group;
  this.itemMenu=itemMenu;
  this.display=display;
  this.rosterConfig=rosterConfig;
  itemPresenters=new HashMap<XmppURI,RosterItemPresenter>();
  display.setVisible(group.isAllContacts());
  final Listener<RosterItem> updateListener=new Listener<RosterItem>(){
    @Override public void onEvent(    final RosterItem item){
      updateRosterItemGroups();
    }
  }
;
  group.onItemAdded(updateListener);
  group.onItemChanged(updateListener);
  group.onItemRemoved(updateListener);
  group.addMainRosterItemChangedHandler(new RosterItemChangedHandler(){
    @Override public void onRosterItemChanged(    RosterItemChangedEvent event){
      updateRosterItemGroups();
    }
  }
);
  updateRosterItemGroups();
}

Fixed version (ground truth):
public RosterGroupPresenter(final RosterGroup group,final Menu<RosterItemPresenter> itemMenu,final RosterGroupDisplay display,final RosterConfig rosterConfig){
  this.group=group;
  this.itemMenu=itemMenu;
  this.display=display;
  this.rosterConfig=rosterConfig;
  itemPresenters=new HashMap<XmppURI,RosterItemPresenter>();
  display.setVisible(group.isAllContacts());
  group.addRosterItemChangedHandler(new RosterItemChangedHandler(){
    @Override public void onRosterItemChanged(    RosterItemChangedEvent event){
      updateRosterItemGroups();
    }
  }
);
  updateRosterItemGroups();
}
Program: 2610
Project: 2610
Buggy source:
public RosterBasicActions(){
  roster=Suco.get(Roster.class);
}

Fixed version (ground truth):
public RosterBasicActions(HablarEventBus eventBus){
  this.eventBus=eventBus;
  roster=Suco.get(Roster.class);
}
Program: 2611
Project: 2611
Buggy source:
@Override public void execute(final RosterGroupPresenter target){
  final String groupName=target.getGroupName();
  final Collection<RosterItem> items=roster.getItemsByGroup(groupName);
  final String message=i18n().confirmDeleteGroup(groupName,"String_Node_Str" + items.size());
  if (Window.confirm(message)) {
    deleteGroup(groupName,items);
  }
}

Fixed version (ground truth):
@Override public void execute(final RosterGroupPresenter target){
  final String groupName=target.getGroupName();
  final Collection<RosterItem> items=roster.getItemsByGroup(groupName);
  final String title=i18n().confirmDeleteGroupTitle(groupName);
  final String message=i18n().confirmDeleteGroup(groupName,"String_Node_Str" + items.size());
  ConfirmPage.show(eventBus,title,message,new UserConfirmationHandler(){
    @Override public void cancel(){
    }
    @Override public void accept(){
      deleteGroup(groupName,items);
    }
  }
);
}
Program: 2612
Project: 2612
Buggy source:
public RosterPresenter(final HablarEventBus eventBus,final RosterDisplay display,final RosterConfig rosterConfig){
  super(TYPE,"String_Node_Str" + ++index,eventBus,display);
  roster=Suco.get(Roster.class);
  basicActions=new RosterBasicActions();
  this.rosterConfig=rosterConfig;
  groupPresenters=new HashMap<String,RosterGroupPresenter>();
  active=true;
  itemMenu=new Menu<RosterItemPresenter>(display.newRosterItemMenuDisplay("String_Node_Str"));
  groupMenu=new Menu<RosterGroupPresenter>(display.newRosterGroupMenuDisplay("String_Node_Str"));
  addRosterListeners();
  addSessionListeners();
  final String title=i18n().contacts();
  getState().init(Icons.ROSTER,title,title);
}

Fixed version (ground truth):
public RosterPresenter(final HablarEventBus eventBus,final RosterDisplay display,final RosterConfig rosterConfig){
  super(TYPE,"String_Node_Str" + ++index,eventBus,display);
  roster=Suco.get(Roster.class);
  basicActions=new RosterBasicActions(eventBus);
  this.rosterConfig=rosterConfig;
  groupPresenters=new HashMap<String,RosterGroupPresenter>();
  active=true;
  itemMenu=new Menu<RosterItemPresenter>(display.newRosterItemMenuDisplay("String_Node_Str"));
  groupMenu=new Menu<RosterGroupPresenter>(display.newRosterGroupMenuDisplay("String_Node_Str"));
  addRosterListeners();
  addSessionListeners();
  final String title=i18n().contacts();
  getState().init(Icons.ROSTER,title,title);
}
Program: 2613
Project: 2613
Buggy source:
public static VCardConfig getFromMeta(){
  VCardConfig config=new VCardConfig();
  config.vCardReadOnly=PageAssist.isMetaFalse("String_Node_Str");
  return config;
}

Fixed version (ground truth):
public static VCardConfig getFromMeta(){
  VCardConfig config=new VCardConfig();
  config.vCardReadOnly=PageAssist.isMetaTrue("String_Node_Str",false);
  return config;
}
Program: 2614
Project: 2614
Buggy source:
@Before public void setup(){
  HablarTester tester=new HablarTester();
  page=mock(Page.class);
  eventBus=tester.eventBus;
  state=new PageState(eventBus,page);
  when(page.getState()).thenReturn(state);
  display=tester.newDisplay(HeaderDisplay.class);
  presenter=new HeaderPresenter(eventBus,page,display);
}

Fixed version (ground truth):
@Before public void setup(){
  HablarTester tester=new HablarTester();
  page=mock(Page.class);
  eventBus=tester.eventBus;
  state=new PageState(eventBus,page);
  when(page.getState()).thenReturn(state);
  display=tester.newDisplay(HeaderDisplay.class);
  new HeaderPresenter(eventBus,page,display);
}
Program: 2615
Project: 2615
Buggy source:
@Test public void shouldRemoveChatIfClosed(){
  final Page<?> page=createChatPage(Visibility.notFocused);
  tester.fire(new UserMessageEvent(page,"String_Node_Str",PairChatPresenter.CHAT_MESSAGE));
  assertTrue(pages.contains(page));
  tester.fire(new VisibilityChangedEvent(page,Visibility.hidden));
  assertFalse(pages.contains(page));
}

Fixed version (ground truth):
/** 
 * Issue 287: An unattended chat tab can be closed without the unattended flag being reset
 */
@Test public void shouldRemoveChatIfClosed(){
  final Page<?> page=createChatPage(Visibility.notFocused);
  tester.fire(new UserMessageEvent(page,"String_Node_Str",PairChatPresenter.CHAT_MESSAGE));
  assertTrue(pages.contains(page));
  tester.fire(new VisibilityChangedEvent(page,Visibility.hidden));
  assertFalse(pages.contains(page));
}
Program: 2616
Project: 2616
Buggy source:
/** 
 * Retrieve Hablar configuration from meta tags in html
 */
public static HablarConfig getFromMeta(){
  final HablarConfig config=new HablarConfig();
  config.hasRoster=PageAssist.isMetaTrue("String_Node_Str");
  config.hasSearch=PageAssist.isMetaTrue("String_Node_Str");
  config.hasSignals=PageAssist.isMetaTrue("String_Node_Str");
  config.hasChat=PageAssist.isMetaTrue("String_Node_Str");
  config.hasVCard=PageAssist.isMetaTrue("String_Node_Str");
  config.hasCopyToClipboard=PageAssist.isMetaTrue("String_Node_Str");
  config.hasSound=PageAssist.isMetaTrue("String_Node_Str");
  config.dockRoster=PageAssist.getMeta("String_Node_Str");
  final String layout=PageAssist.getMeta("String_Node_Str");
  if ("String_Node_Str".equals(layout)) {
    config.layout=HablarDisplay.Layout.tabs;
  }
 else {
    config.layout=HablarDisplay.Layout.accordion;
  }
  if (config.layout == HablarDisplay.Layout.tabs) {
    createTabHeaderSize(config);
  }
  config.roomsConfig=HablarRoomsConfig.getFromMeta();
  config.rosterConfig=RosterConfig.getFromMeta();
  config.searchConfig=SearchConfig.getFromMeta();
  config.soundConfig=SoundSignalsConfig.getFromMeta();
  return config;
}

Fixed version (ground truth):
/** 
 * Retrieve Hablar configuration from meta tags in html
 */
public static HablarConfig getFromMeta(){
  final HablarConfig config=new HablarConfig();
  config.hasRoster=PageAssist.isMetaTrue("String_Node_Str");
  config.hasSearch=PageAssist.isMetaTrue("String_Node_Str");
  config.hasSignals=PageAssist.isMetaTrue("String_Node_Str");
  config.hasChat=PageAssist.isMetaTrue("String_Node_Str");
  config.hasVCard=PageAssist.isMetaTrue("String_Node_Str");
  config.hasCopyToClipboard=PageAssist.isMetaTrue("String_Node_Str");
  config.hasSound=PageAssist.isMetaTrue("String_Node_Str");
  config.dockRoster=PageAssist.getMeta("String_Node_Str");
  final String layout=PageAssist.getMeta("String_Node_Str");
  if ("String_Node_Str".equals(layout)) {
    config.layout=HablarDisplay.Layout.tabs;
  }
 else {
    config.layout=HablarDisplay.Layout.accordion;
  }
  if (config.layout == HablarDisplay.Layout.tabs) {
    createTabHeaderSize(config);
  }
  config.roomsConfig=HablarRoomsConfig.getFromMeta();
  config.rosterConfig=RosterConfig.getFromMeta();
  config.searchConfig=SearchConfig.getFromMeta();
  config.soundConfig=SoundSignalsConfig.getFromMeta();
  config.vcardConfig=VCardConfig.getFromMeta();
  return config;
}
Program: 2617
Project: 2617
Buggy source:
public static void install(final Hablar hablar){
  final OwnVCardPresenter ownVCardPage=new OwnVCardPresenter(hablar.getEventBus(),new VCardWidget(false,"String_Node_Str"));
  hablar.addPage(ownVCardPage,UserContainer.ROL);
  final OthersVCardPresenter othersVCardPage=new OthersVCardPresenter(hablar.getEventBus(),new OtherVCardWidget(true));
  hablar.addPage(othersVCardPage,OverlayContainer.ROL);
  hablar.addPageAddedHandler(new PageAddedHandler(){
    @Override public void onPageAdded(    final PageAddedEvent event){
      final RosterPage rosterPage=RosterPresenter.asRoster(event.getPage());
      if (rosterPage != null) {
        rosterPage.getItemMenu().addAction(createViewVCardAction(othersVCardPage));
      }
    }
  }
,true);
  prepareDefaultNicknameListener();
}

Fixed version (ground truth):
public static void install(final Hablar hablar,VCardConfig vCardConfig){
  VCardWidget vCardWidget=new VCardWidget(vCardConfig.vCardReadOnly,"String_Node_Str");
  final OwnVCardPresenter ownVCardPage=new OwnVCardPresenter(hablar.getEventBus(),vCardWidget);
  hablar.addPage(ownVCardPage,UserContainer.ROL);
  final OthersVCardPresenter othersVCardPage=new OthersVCardPresenter(hablar.getEventBus(),new OtherVCardWidget(true));
  hablar.addPage(othersVCardPage,OverlayContainer.ROL);
  hablar.addPageAddedHandler(new PageAddedHandler(){
    @Override public void onPageAdded(    final PageAddedEvent event){
      final RosterPage rosterPage=RosterPresenter.asRoster(event.getPage());
      if (rosterPage != null) {
        rosterPage.getItemMenu().addAction(createViewVCardAction(othersVCardPage));
      }
    }
  }
,true);
  prepareDefaultNicknameListener();
}
Program: 2618
Project: 2618
Buggy source:
@Override protected void onPageOpen(){
  display.setPageTitle(i18n().invitePeopleToGroupChat());
  display.setAcceptText(i18n().acceptAction());
  final Roster roster=Suco.get(Roster.class);
  final String roomName=RoomName.decode(room.getURI().toString());
  display.getRoomName().setValue(roomName);
  display.setRoomNameEnabled(false);
  Set<String> occupantUris=new HashSet<String>();
  for (  Occupant occupant : room.getOccupants()) {
    occupantUris.add(occupant.getURI().getResource());
  }
  for (  RosterItem item : roster.getItems()) {
    if (!occupantUris.contains(item.getJID().getNode())) {
      createItem(item,false);
    }
  }
}

Fixed version (ground truth):
@Override protected void onPageOpen(){
  display.setPageTitle(i18n().invitePeopleToGroupChat());
  display.setAcceptText(i18n().acceptAction());
  final Roster roster=Suco.get(Roster.class);
  final String roomName=RoomName.decode(room.getURI().getNode());
  display.getRoomName().setValue(roomName);
  display.setRoomNameEnabled(false);
  final Set<String> occupantUris=new HashSet<String>();
  for (  final Occupant occupant : room.getOccupants()) {
    occupantUris.add(occupant.getURI().getResource());
  }
  for (  final RosterItem item : roster.getItems()) {
    if (!occupantUris.contains(item.getJID().getNode())) {
      createItem(item,false);
    }
  }
}
Program: 2619
Project: 2619
Buggy source:
@Override public void onKeyDown(KeyDownEvent event){
  DeferredCommand.addCommand(roomNameValidator.getDeferredCommand());
}

Fixed version (ground truth):
@Override public void onKeyDown(final KeyDownEvent event){
  DeferredCommand.addCommand(roomNameValidator.getDeferredCommand());
}
Program: 2620
Project: 2620
Buggy source:
@Override public void onValueChange(ValueChangeEvent<List<Selectable>> event){
  DeferredCommand.addCommand(roomNameValidator.getDeferredCommand());
}

Fixed version (ground truth):
@Override public void onValueChange(final ValueChangeEvent<List<Selectable>> event){
  DeferredCommand.addCommand(roomNameValidator.getDeferredCommand());
}
Program: 2621
Project: 2621
Buggy source:
public EditRoomPresenter(final String pageType,final HablarEventBus eventBus,final EditRoomDisplay display){
  super(pageType,eventBus,display);
  display.getCancel().addClickHandler(new ClickHandler(){
    @Override public void onClick(    final ClickEvent event){
      requestVisibility(Visibility.hidden);
    }
  }
);
  display.getInvite().addClickHandler(new ClickHandler(){
    @Override public void onClick(    final ClickEvent event){
      onAccept();
      requestVisibility(Visibility.notFocused);
    }
  }
);
  roomNameValidator=new CompositeValidatorChecker(display.getRoomNameError(),display.getAcceptEnabled());
  roomNameValidator.add(display.getRoomName(),Validators.notEmpty(i18n().emptyGroupChatName()));
  roomNameValidator.add(display.getRoomName(),Validators.isValidRoomName(i18n().notValidGroupChatName()));
  roomNameValidator.add(display.getSelectionList(),new ListNotEmptyValidator<Selectable>(i18n().selectionEmptyErrorMessage()));
  display.getRoomNameKeys().addKeyDownHandler(new KeyDownHandler(){
    @Override public void onKeyDown(    KeyDownEvent event){
      DeferredCommand.addCommand(roomNameValidator.getDeferredCommand());
    }
  }
);
  display.getSelectionList().addValueChangeHandler(new ValueChangeHandler<List<Selectable>>(){
    @Override public void onValueChange(    ValueChangeEvent<List<Selectable>> event){
      DeferredCommand.addCommand(roomNameValidator.getDeferredCommand());
    }
  }
);
}

Fixed version (ground truth):
public EditRoomPresenter(final String pageType,final HablarEventBus eventBus,final EditRoomDisplay display){
  super(pageType,eventBus,display);
  display.getCancel().addClickHandler(new ClickHandler(){
    @Override public void onClick(    final ClickEvent event){
      requestVisibility(Visibility.hidden);
    }
  }
);
  display.getInvite().addClickHandler(new ClickHandler(){
    @Override public void onClick(    final ClickEvent event){
      onAccept();
      requestVisibility(Visibility.notFocused);
    }
  }
);
  roomNameValidator=new CompositeValidatorChecker(display.getRoomNameError(),display.getAcceptEnabled());
  roomNameValidator.add(display.getRoomName(),Validators.notEmpty(i18n().emptyGroupChatName()));
  roomNameValidator.add(display.getRoomName(),Validators.isValidRoomName(i18n().notValidGroupChatName()));
  roomNameValidator.add(display.getSelectionList(),new ListNotEmptyValidator<Selectable>(i18n().selectionEmptyErrorMessage()));
  display.getRoomNameKeys().addKeyDownHandler(new KeyDownHandler(){
    @Override public void onKeyDown(    final KeyDownEvent event){
      DeferredCommand.addCommand(roomNameValidator.getDeferredCommand());
    }
  }
);
  display.getSelectionList().addValueChangeHandler(new ValueChangeHandler<List<Selectable>>(){
    @Override public void onValueChange(    final ValueChangeEvent<List<Selectable>> event){
      DeferredCommand.addCommand(roomNameValidator.getDeferredCommand());
    }
  }
);
}
Program: 2622
Project: 2622
Buggy source:
@Override public Widget getWidget(){
  return widget;
}

Fixed version (ground truth):
@Override public Widget getWidget(){
  return rosterItemDisplay.asWidget();
}
Program: 2623
Project: 2623
Buggy source:
public RosterItemSelectable(RosterItem rosterItem,RosterItemWidget widget){
  this.rosterItem=rosterItem;
  this.widget=widget;
}

Fixed version (ground truth):
public RosterItemSelectable(RosterItem rosterItem,RosterItemDisplay rosterItemDisplay){
  this.rosterItem=rosterItem;
  this.rosterItemDisplay=rosterItemDisplay;
}
Program: 2624
Project: 2624
Buggy source:
@Override public HasClickHandlers getAction(){
  return widget.getAction();
}

Fixed version (ground truth):
@Override public HasClickHandlers getAction(){
  return rosterItemDisplay.getAction();
}
Program: 2625
Project: 2625
Buggy source:
@Override public int compareTo(Selectable o){
  RosterItemSelectable riSelectable=(RosterItemSelectable)o;
  RosterItem otherRosterItem=riSelectable.rosterItem;
  int retValue=statusValue(rosterItem) - statusValue(otherRosterItem);
  if (retValue == 0) {
    retValue=rosterItem.getName().compareTo(otherRosterItem.getName());
  }
  return retValue;
}

Fixed version (ground truth):
@Override public int compareTo(Selectable o){
}
Program: 2626
Project: 2626
Buggy source:
public ChatPresenter(final HablarEventBus eventBus,final Chat chat,final ChatDisplay display){
  super(TYPE,Idify.uriId(chat.getURI().toString()),eventBus,display);
  this.chat=chat;
  display.setId(getId());
  final XmppURI fromURI=chat.getURI();
  userName=getName(fromURI);
  model.init(HablarIcons.get(IconType.buddyOff),userName);
  model.setPageTitleTooltip(userName);
  setVisibility(Visibility.notFocused);
  model.setCloseable(true);
  chat.onMessageReceived(new Listener<Message>(){
    @Override public void onEvent(    final Message message){
      final String body=ChatMessageFormatter.format(message.getBody());
      if (body != null) {
        display.addMessage(userName,body,ChatDisplay.MessageType.incoming);
        fireUserMessage(body);
        if (getVisibility() == Visibility.hidden) {
          requestVisibility(Visibility.notFocused);
        }
      }
    }
  }
);
  chat.onStateChanged(new Listener<State>(){
    @Override public void onEvent(    final State state){
      setState(state);
    }
  }
);
  setState(chat.getState());
  display.getAction().addClickHandler(new ClickHandler(){
    @Override public void onClick(    final ClickEvent event){
      sendMessage(chat,display);
    }
  }
);
  display.getTextBox().addKeyDownHandler(new KeyDownHandler(){
    @Override public void onKeyDown(    final KeyDownEvent event){
      if (event.getNativeKeyCode() == 13) {
        event.stopPropagation();
        event.preventDefault();
        sendMessage(chat,display);
      }
    }
  }
);
}

Fixed version (ground truth):
public ChatPresenter(final HablarEventBus eventBus,final Chat chat,final ChatDisplay display){
  super(TYPE,Idify.uriId(chat.getURI().toString()),eventBus,display);
  this.chat=chat;
  display.setId(getId());
  final XmppURI fromURI=chat.getURI();
  userName=getName(fromURI);
  model.init(HablarIcons.get(IconType.buddyOff),userName,fromURI.toString());
  setVisibility(Visibility.notFocused);
  model.setCloseable(true);
  chat.onMessageReceived(new Listener<Message>(){
    @Override public void onEvent(    final Message message){
      final String body=ChatMessageFormatter.format(message.getBody());
      if (body != null) {
        display.addMessage(userName,body,ChatDisplay.MessageType.incoming);
        fireUserMessage(body);
        if (getVisibility() == Visibility.hidden) {
          requestVisibility(Visibility.notFocused);
        }
      }
    }
  }
);
  chat.onStateChanged(new Listener<State>(){
    @Override public void onEvent(    final State state){
      setState(state);
    }
  }
);
  setState(chat.getState());
  display.getAction().addClickHandler(new ClickHandler(){
    @Override public void onClick(    final ClickEvent event){
      sendMessage(chat,display);
    }
  }
);
  display.getTextBox().addKeyDownHandler(new KeyDownHandler(){
    @Override public void onKeyDown(    final KeyDownEvent event){
      if (event.getNativeKeyCode() == 13) {
        event.stopPropagation();
        event.preventDefault();
        sendMessage(chat,display);
      }
    }
  }
);
}
Program: 2628
Project: 2628
Buggy source:
public void init(final String style,final String title){
  pageIcon=style;
  pageTitle=title;
  pageTitleTooltip=title;
  fireChanged();
}

Fixed version (ground truth):
public void init(final String style,final String title,final String tooltip){
  pageIcon=style;
  pageTitle=title;
  pageTitleTooltip=tooltip;
  fireChanged();
}