Program: 188239
Project: 188239
Buggy source:
/** 
 * Create a representation information page
 */
public RepresentationInformationAssociations(){
  Facets facets=new Facets(new SimpleFacetParameter(RodaConstants.REPRESENTATION_INFORMATION_TAGS),new SimpleFacetParameter(RodaConstants.REPRESENTATION_INFORMATION_SUPPORT));
  representationInformationList=new RepresentationInformationList(filter,facets,messages.representationInformationTitle(),false);
  searchPanel=new SearchPanel(DEFAULT_FILTER,ALL_FILTER,true,messages.representationInformationRegisterSearchPlaceHolder(),false,false,true);
  searchPanel.setList(representationInformationList);
  initWidget(uiBinder.createAndBindUi(this));
  resultsPanel.setVisible(false);
  createPanel.setVisible(false);
  searchPanel.addValueChangeHandler(new ValueChangeHandler<String>(){
    @Override public void onValueChange(    ValueChangeEvent<String> valueChangeEvent){
      gettingFilterResults=false;
    }
  }
);
  representationInformationList.getSelectionModel().addSelectionChangeHandler(new SelectionChangeEvent.Handler(){
    @Override public void onSelectionChange(    SelectionChangeEvent event){
      RepresentationInformation selected=representationInformationList.getSelectionModel().getSelectedObject();
      if (selected != null) {
        LastSelectedItemsSingleton selectedItems=LastSelectedItemsSingleton.getInstance();
        selectedItems.setLastHistory(HistoryUtils.getCurrentHistoryPath());
        HistoryUtils.newHistory(ShowRepresentationInformation.RESOLVER,selected.getId());
      }
    }
  }
);
  representationInformationList.addValueChangeHandler(new ValueChangeHandler<IndexResult<RepresentationInformation>>(){
    @Override public void onValueChange(    ValueChangeEvent<IndexResult<RepresentationInformation>> event){
      boolean associating=gettingFilterResults && event.getValue().getTotalCount() == 0;
      resultsPanel.setVisible(!associating);
      createPanel.setVisible(associating);
    }
  }
);
  Label titleLabel=new Label(messages.representationInformationAssociationsTitle());
  titleLabel.addStyleName("String_Node_Str");
  title.add(titleLabel);
  InlineHTML badge=new InlineHTML("String_Node_Str");
  title.add(badge);
  buttonAddToExistingRI.addClickHandler(new ClickHandler(){
    @Override public void onClick(    ClickEvent event){
      RepresentationInformationDialogs.showPromptAddRepresentationInformationWithAssociation(addWithAssociationDialogTitle,messages.cancelButton(),messages.addToExistingRepresentationInformation(),messages.createNewRepresentationInformation(),new NoAsyncCallback<SelectedItemsList<RepresentationInformation>>(){
        @Override public void onSuccess(        final SelectedItemsList<RepresentationInformation> selectedItemsList){
          if (selectedItemsList != null) {
            String filtertoAdd=HistoryUtils.getCurrentHistoryPath().get(HistoryUtils.getCurrentHistoryPath().size() - 1);
            BrowserService.Util.getInstance().updateRepresentationInformationListWithFilter(selectedItemsList,filtertoAdd,new NoAsyncCallback<Void>(){
              @Override public void onSuccess(              Void result){
                if (selectedItemsList.getIds().size() == 1) {
                  HistoryUtils.newHistory(ShowRepresentationInformation.RESOLVER,selectedItemsList.getIds().get(0));
                }
 else {
                  gettingFilterResults=false;
                  representationInformationList.refresh();
                  createPanel.setVisible(false);
                  resultsPanel.setVisible(true);
                }
              }
            }
);
          }
 else {
            addToNewClickHandler();
          }
        }
      }
);
    }
  }
);
  buttonCreateNewRI.addClickHandler(new ClickHandler(){
    @Override public void onClick(    ClickEvent clickEvent){
      addToNewClickHandler();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Create a representation information page
 */
public RepresentationInformationAssociations(){
  representationInformationList=new RepresentationInformationList(Filter.NULL,Facets.NONE,messages.representationInformationTitle(),false);
  searchPanel=new SearchPanel(DEFAULT_FILTER,ALL_FILTER,true,messages.representationInformationRegisterSearchPlaceHolder(),false,false,true);
  searchPanel.setList(representationInformationList);
  initWidget(uiBinder.createAndBindUi(this));
  resultsPanel.setVisible(false);
  createPanel.setVisible(false);
  searchPanel.addValueChangeHandler(new ValueChangeHandler<String>(){
    @Override public void onValueChange(    ValueChangeEvent<String> valueChangeEvent){
      gettingFilterResults=false;
    }
  }
);
  representationInformationList.getSelectionModel().addSelectionChangeHandler(new SelectionChangeEvent.Handler(){
    @Override public void onSelectionChange(    SelectionChangeEvent event){
      RepresentationInformation selected=representationInformationList.getSelectionModel().getSelectedObject();
      if (selected != null) {
        LastSelectedItemsSingleton selectedItems=LastSelectedItemsSingleton.getInstance();
        selectedItems.setLastHistory(HistoryUtils.getCurrentHistoryPath());
        HistoryUtils.newHistory(ShowRepresentationInformation.RESOLVER,selected.getId());
      }
    }
  }
);
  representationInformationList.addValueChangeHandler(new ValueChangeHandler<IndexResult<RepresentationInformation>>(){
    @Override public void onValueChange(    ValueChangeEvent<IndexResult<RepresentationInformation>> event){
      boolean associating=gettingFilterResults && event.getValue().getTotalCount() == 0;
      resultsPanel.setVisible(!associating);
      createPanel.setVisible(associating);
    }
  }
);
  Label titleLabel=new Label(messages.representationInformationAssociationsTitle());
  titleLabel.addStyleName("String_Node_Str");
  title.add(titleLabel);
  InlineHTML badge=new InlineHTML("String_Node_Str");
  title.add(badge);
  buttonAddToExistingRI.addClickHandler(new ClickHandler(){
    @Override public void onClick(    ClickEvent event){
      RepresentationInformationDialogs.showPromptAddRepresentationInformationWithAssociation(addWithAssociationDialogTitle,messages.cancelButton(),messages.addToExistingRepresentationInformation(),messages.createNewRepresentationInformation(),new NoAsyncCallback<SelectedItemsList<RepresentationInformation>>(){
        @Override public void onSuccess(        final SelectedItemsList<RepresentationInformation> selectedItemsList){
          if (selectedItemsList != null) {
            String filtertoAdd=HistoryUtils.getCurrentHistoryPath().get(HistoryUtils.getCurrentHistoryPath().size() - 1);
            BrowserService.Util.getInstance().updateRepresentationInformationListWithFilter(selectedItemsList,filtertoAdd,new NoAsyncCallback<Void>(){
              @Override public void onSuccess(              Void result){
                if (selectedItemsList.getIds().size() == 1) {
                  HistoryUtils.newHistory(ShowRepresentationInformation.RESOLVER,selectedItemsList.getIds().get(0));
                }
 else {
                  gettingFilterResults=false;
                  representationInformationList.refresh();
                  createPanel.setVisible(false);
                  resultsPanel.setVisible(true);
                }
              }
            }
);
          }
 else {
            addToNewClickHandler();
          }
        }
      }
);
    }
  }
);
  buttonCreateNewRI.addClickHandler(new ClickHandler(){
    @Override public void onClick(    ClickEvent clickEvent){
      addToNewClickHandler();
    }
  }
);
}