Program: 188236
Project: 188236
Buggy source:
public static void showPromptDialogRepresentationInformation(String title,String cancelButtonText,String confirmButtonText,String listButtonText,final RepresentationInformation ri,final AsyncCallback<RepresentationInformation> callback){
  final DialogBox dialogBox=new DialogBox(true,true);
  dialogBox.addStyleName("String_Node_Str");
  dialogBox.setText(title);
  final FlowPanel layout=new FlowPanel();
  HTMLWidgetWrapper description=new HTMLWidgetWrapper("String_Node_Str",new AsyncCallback<Void>(){
    @Override public void onFailure(    Throwable caught){
      AsyncCallbackUtils.defaultFailureTreatment(caught);
    }
    @Override public void onSuccess(    Void result){
      dialogBox.center();
    }
  }
);
  description.addStyleName("String_Node_Str");
  layout.add(description);
  final FlowPanel relationFormPanel=new FlowPanel();
  relationFormPanel.addStyleName("String_Node_Str");
  layout.add(relationFormPanel);
  final FlowPanel listPanel=new FlowPanel();
  layout.add(listPanel);
  final Label section=new Label(messages.currentRelationResults());
  section.addStyleName("String_Node_Str");
  final FlowPanel buttonPanel=new FlowPanel();
  final Button cancelButton=new Button(cancelButtonText);
  final Button confirmButton=new Button(confirmButtonText);
  final Button listButton=new Button(listButtonText);
  buttonPanel.add(cancelButton);
  buttonPanel.add(confirmButton);
  buttonPanel.add(listButton);
  layout.add(buttonPanel);
  dialogBox.setWidget(layout);
  dialogBox.setGlassEnabled(true);
  dialogBox.setAnimationEnabled(false);
  final Dropdown dropDown=new Dropdown();
  dropDown.setStyleName("String_Node_Str");
  dropDown.addPopupStyleName("String_Node_Str");
  dropDown.setVisible(true);
  dropDown.setLabel(messages.searchListBoxItems());
  dropDown.addItem(messages.searchListBoxItems(),RodaConstants.SEARCH_ITEMS);
  dropDown.addItem(messages.searchListBoxRepresentations(),RodaConstants.SEARCH_REPRESENTATIONS);
  dropDown.addItem(messages.searchListBoxFiles(),RodaConstants.SEARCH_FILES);
  final FlowPanel fieldsPanel=new FlowPanel();
  fieldsPanel.setStyleName("String_Node_Str");
  BrowserService.Util.getInstance().retrieveObjectClassFields(LocaleInfo.getCurrentLocale().getLocaleName(),new AsyncCallback<RepresentationInformationFilterBundle>(){
    @Override public void onFailure(    Throwable caught){
      AsyncCallbackUtils.defaultFailureTreatment(caught);
    }
    @Override public void onSuccess(    final RepresentationInformationFilterBundle result){
      relationFormPanel.add(dropDown);
      relationFormPanel.add(fieldsPanel);
      final List<String> appropriateFields=new ArrayList<>();
      final Map<String,List<String>> values=new HashMap<>();
      dropDown.addValueChangeHandler(new ValueChangeHandler<String>(){
        @Override public void onValueChange(        ValueChangeEvent<String> event){
          updateAssociationFields(fieldsPanel,dropDown,appropriateFields,result,ri,values);
          dialogBox.center();
        }
      }
);
      if (!ri.getFilters().isEmpty()) {
        if (ri.getFilters().get(0).startsWith(Representation.class.getSimpleName())) {
          appropriateFields.addAll(result.getObjectClassFields().get(Representation.class.getSimpleName()));
          dropDown.setSelectedValue(RodaConstants.SEARCH_REPRESENTATIONS,true);
        }
 else         if (ri.getFilters().get(0).startsWith(File.class.getSimpleName())) {
          appropriateFields.addAll(result.getObjectClassFields().get(File.class.getSimpleName()));
          dropDown.setSelectedValue(RodaConstants.SEARCH_FILES,true);
        }
 else         if (ri.getFilters().get(0).startsWith(AIP.class.getSimpleName())) {
          appropriateFields.addAll(result.getObjectClassFields().get(AIP.class.getSimpleName()));
          dropDown.setSelectedValue(RodaConstants.SEARCH_ITEMS,true);
        }
      }
 else {
        appropriateFields.addAll(result.getObjectClassFields().get(AIP.class.getSimpleName()));
        dropDown.setSelectedValue(RodaConstants.SEARCH_ITEMS,true);
      }
      dialogBox.center();
      confirmButton.addClickHandler(new ClickHandler(){
        @Override public void onClick(        ClickEvent event){
          dialogBox.hide();
          ri.setFilters(new ArrayList<String>());
          String className;
switch (dropDown.getSelectedValue()) {
case RodaConstants.SEARCH_ITEMS:
            className=AIP.class.getSimpleName();
          break;
case RodaConstants.SEARCH_REPRESENTATIONS:
        className=Representation.class.getSimpleName();
      break;
case RodaConstants.SEARCH_FILES:
    className=File.class.getSimpleName();
  break;
default :
return;
}
for (String field : values.keySet()) {
for (String value : values.get(field)) {
if (StringUtils.isNotBlank(value)) {
  ri.addFilter(RepresentationInformationUtils.createRepresentationInformationFilter(className,field,value));
}
}
}
callback.onSuccess(ri);
}
}
);
listButton.addClickHandler(new ClickHandler(){
@Override public void onClick(ClickEvent event){
Filter tableFilter=new Filter();
for (String field : values.keySet()) {
for (String value : values.get(field)) {
if (StringUtils.isNotBlank(value)) {
  tableFilter.add(new SimpleFilterParameter(field,value));
}
}
}
listPanel.clear();
if (!tableFilter.getParameters().isEmpty()) {
BasicAsyncTableCell<?> table=null;
switch (dropDown.getSelectedValue()) {
case RodaConstants.SEARCH_ITEMS:
table=new AIPList(tableFilter,true,Facets.NONE,"String_Node_Str",false,5,5);
break;
case RodaConstants.SEARCH_REPRESENTATIONS:
table=new RepresentationList(tableFilter,true,Facets.NONE,"String_Node_Str",false,5,5);
break;
case RodaConstants.SEARCH_FILES:
table=new SimpleFileList(tableFilter,true,Facets.NONE,"String_Node_Str",false,5,5);
break;
default :
break;
}
if (table != null) {
table.addRedrawHandler(new AbstractHasData.RedrawEvent.Handler(){
@Override public void onRedraw(){
dialogBox.center();
}
}
);
listPanel.add(section);
listPanel.add(table);
}
}
}
}
);
}
}
);
cancelButton.addClickHandler(new ClickHandler(){
@Override public void onClick(ClickEvent event){
dialogBox.hide();
callback.onFailure(null);
}
}
);
dialogBox.addStyleName("String_Node_Str");
layout.addStyleName("String_Node_Str");
cancelButton.addStyleName("String_Node_Str");
confirmButton.addStyleName("String_Node_Str");
listButton.addStyleName("String_Node_Str");
dialogBox.center();
dialogBox.show();
}

Fixed version (ground truth):
public static void showPromptDialogRepresentationInformation(String title,String cancelButtonText,String confirmButtonText,String listButtonText,final RepresentationInformation ri,final AsyncCallback<RepresentationInformation> callback){
  final DialogBox dialogBox=new DialogBox(true,true);
  dialogBox.addStyleName("String_Node_Str");
  dialogBox.setText(title);
  final FlowPanel layout=new FlowPanel();
  HTMLWidgetWrapper description=new HTMLWidgetWrapper("String_Node_Str",new AsyncCallback<Void>(){
    @Override public void onFailure(    Throwable caught){
      AsyncCallbackUtils.defaultFailureTreatment(caught);
    }
    @Override public void onSuccess(    Void result){
      dialogBox.center();
    }
  }
);
  description.addStyleName("String_Node_Str");
  layout.add(description);
  final FlowPanel relationFormPanel=new FlowPanel();
  relationFormPanel.addStyleName("String_Node_Str");
  layout.add(relationFormPanel);
  final FlowPanel listPanel=new FlowPanel();
  layout.add(listPanel);
  final Label section=new Label(messages.currentRelationResults());
  section.addStyleName("String_Node_Str");
  final FlowPanel buttonPanel=new FlowPanel();
  final Button cancelButton=new Button(cancelButtonText);
  final Button confirmButton=new Button(confirmButtonText);
  final Button listButton=new Button(listButtonText);
  buttonPanel.add(cancelButton);
  buttonPanel.add(confirmButton);
  buttonPanel.add(listButton);
  layout.add(buttonPanel);
  dialogBox.setWidget(layout);
  dialogBox.setGlassEnabled(true);
  dialogBox.setAnimationEnabled(false);
  final Dropdown dropDown=new Dropdown();
  dropDown.setStyleName("String_Node_Str");
  dropDown.addPopupStyleName("String_Node_Str");
  dropDown.setVisible(true);
  dropDown.setLabel(messages.searchListBoxItems());
  dropDown.addItem(messages.searchListBoxItems(),RodaConstants.SEARCH_ITEMS);
  dropDown.addItem(messages.searchListBoxRepresentations(),RodaConstants.SEARCH_REPRESENTATIONS);
  dropDown.addItem(messages.searchListBoxFiles(),RodaConstants.SEARCH_FILES);
  final FlowPanel fieldsPanel=new FlowPanel();
  fieldsPanel.setStyleName("String_Node_Str");
  BrowserService.Util.getInstance().retrieveObjectClassFields(LocaleInfo.getCurrentLocale().getLocaleName(),new AsyncCallback<RepresentationInformationFilterBundle>(){
    @Override public void onFailure(    Throwable caught){
      AsyncCallbackUtils.defaultFailureTreatment(caught);
    }
    @Override public void onSuccess(    final RepresentationInformationFilterBundle result){
      relationFormPanel.add(dropDown);
      relationFormPanel.add(fieldsPanel);
      final List<String> appropriateFields=new ArrayList<>();
      final Map<String,List<String>> values=new HashMap<>();
      dropDown.addValueChangeHandler(new ValueChangeHandler<String>(){
        @Override public void onValueChange(        ValueChangeEvent<String> event){
          updateAssociationFields(fieldsPanel,dropDown,appropriateFields,result,ri,values);
          dialogBox.center();
        }
      }
);
      if (!ri.getFilters().isEmpty()) {
        if (ri.getFilters().get(0).startsWith(Representation.class.getSimpleName())) {
          appropriateFields.addAll(result.getObjectClassFields().get(Representation.class.getSimpleName()));
          dropDown.setSelectedValue(RodaConstants.SEARCH_REPRESENTATIONS,true);
        }
 else         if (ri.getFilters().get(0).startsWith(File.class.getSimpleName())) {
          appropriateFields.addAll(result.getObjectClassFields().get(File.class.getSimpleName()));
          dropDown.setSelectedValue(RodaConstants.SEARCH_FILES,true);
        }
 else         if (ri.getFilters().get(0).startsWith(AIP.class.getSimpleName())) {
          appropriateFields.addAll(result.getObjectClassFields().get(AIP.class.getSimpleName()));
          dropDown.setSelectedValue(RodaConstants.SEARCH_ITEMS,true);
        }
      }
 else {
        appropriateFields.addAll(result.getObjectClassFields().get(AIP.class.getSimpleName()));
        dropDown.setSelectedValue(RodaConstants.SEARCH_ITEMS,true);
      }
      dialogBox.center();
      confirmButton.addClickHandler(new ClickHandler(){
        @Override public void onClick(        ClickEvent event){
          dialogBox.hide();
          ri.setFilters(new ArrayList<String>());
          String className;
switch (dropDown.getSelectedValue()) {
case RodaConstants.SEARCH_ITEMS:
            className=AIP.class.getSimpleName();
          break;
case RodaConstants.SEARCH_REPRESENTATIONS:
        className=Representation.class.getSimpleName();
      break;
case RodaConstants.SEARCH_FILES:
    className=File.class.getSimpleName();
  break;
default :
return;
}
for (String field : values.keySet()) {
for (String value : values.get(field)) {
if (StringUtils.isNotBlank(value)) {
  ri.addFilter(RepresentationInformationUtils.createRepresentationInformationFilter(className,field,value));
}
}
}
callback.onSuccess(ri);
}
}
);
listButton.addClickHandler(new ClickHandler(){
@Override public void onClick(ClickEvent event){
List<FilterParameter> filterList=new ArrayList<>();
for (String field : values.keySet()) {
for (String value : values.get(field)) {
if (StringUtils.isNotBlank(value)) {
  filterList.add(new SimpleFilterParameter(field,value));
}
}
}
listPanel.clear();
if (!filterList.isEmpty()) {
BasicAsyncTableCell<?> table=null;
Filter tableFilter=new Filter(new OrFiltersParameters(filterList));
switch (dropDown.getSelectedValue()) {
case RodaConstants.SEARCH_ITEMS:
table=new AIPList(tableFilter,true,Facets.NONE,"String_Node_Str",false,5,5);
break;
case RodaConstants.SEARCH_REPRESENTATIONS:
table=new RepresentationList(tableFilter,true,Facets.NONE,"String_Node_Str",false,5,5);
break;
case RodaConstants.SEARCH_FILES:
table=new SimpleFileList(tableFilter,true,Facets.NONE,"String_Node_Str",false,5,5);
break;
default :
break;
}
if (table != null) {
table.addRedrawHandler(new AbstractHasData.RedrawEvent.Handler(){
@Override public void onRedraw(){
dialogBox.center();
}
}
);
listPanel.add(section);
listPanel.add(table);
}
}
}
}
);
}
}
);
cancelButton.addClickHandler(new ClickHandler(){
@Override public void onClick(ClickEvent event){
dialogBox.hide();
callback.onFailure(null);
}
}
);
dialogBox.addStyleName("String_Node_Str");
layout.addStyleName("String_Node_Str");
cancelButton.addStyleName("String_Node_Str");
confirmButton.addStyleName("String_Node_Str");
listButton.addStyleName("String_Node_Str");
dialogBox.center();
dialogBox.show();
}