Program: 188246
Project: 188246
Buggy source:
public static void showPromptDialogRepresentationInformationRelations(String title,final String cancelButtonText,final String confirmButtonText,final RepresentationInformation ri,final AsyncCallback<RepresentationInformationRelation> callback){
  final List<HandlerRegistration> clickHandlers=new ArrayList<>();
  final DialogBox dialogBox=new DialogBox(true,true);
  dialogBox.addStyleName("String_Node_Str");
  dialogBox.setText(title);
  final FlowPanel layout=new FlowPanel();
  dialogBox.addStyleName("String_Node_Str");
  layout.addStyleName("String_Node_Str");
  BrowserService.Util.getInstance().retrieveRelationTypeTranslations(LocaleInfo.getCurrentLocale().getLocaleName(),new AsyncCallback<RelationTypeTranslationsBundle>(){
    @Override public void onFailure(    Throwable caught){
      AsyncCallbackUtils.defaultFailureTreatment(caught);
    }
    @Override public void onSuccess(    final RelationTypeTranslationsBundle relationTypes){
      final FlowPanel content=new FlowPanel();
      content.addStyleName("String_Node_Str");
      final FlowPanel leftSide=new FlowPanel();
      leftSide.addStyleName("String_Node_Str");
      final FlowPanel rightSide=new FlowPanel();
      rightSide.addStyleName("String_Node_Str");
      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");
      rightSide.add(description);
      final Label aipLabel=new Label();
      aipLabel.setText(messages.representationInformationRelationObjectType(RelationObjectType.AIP.toString()));
      aipLabel.setTitle(messages.representationInformationRelationObjectType(RelationObjectType.AIP.toString()));
      aipLabel.addStyleName("String_Node_Str");
      leftSide.add(aipLabel);
      final Label riLabel=new Label();
      riLabel.setText(messages.representationInformationRelationObjectType(RelationObjectType.REPRESENTATION_INFORMATION.toString()));
      riLabel.setTitle(messages.representationInformationRelationObjectType(RelationObjectType.REPRESENTATION_INFORMATION.toString()));
      riLabel.addStyleName("String_Node_Str");
      leftSide.add(riLabel);
      final Label webLabel=new Label();
      webLabel.setText(messages.representationInformationRelationObjectType(RelationObjectType.WEB.toString()));
      webLabel.setTitle(messages.representationInformationRelationObjectType(RelationObjectType.WEB.toString()));
      webLabel.addStyleName("String_Node_Str");
      leftSide.add(webLabel);
      final Label txtLabel=new Label();
      txtLabel.setText(messages.representationInformationRelationObjectType(RelationObjectType.TEXT.toString()));
      txtLabel.setTitle(messages.representationInformationRelationObjectType(RelationObjectType.TEXT.toString()));
      txtLabel.addStyleName("String_Node_Str");
      leftSide.add(txtLabel);
      final Label helpLabel=new Label();
      helpLabel.setText(messages.title("String_Node_Str"));
      helpLabel.setTitle(messages.title("String_Node_Str"));
      helpLabel.addStyleName("String_Node_Str");
      leftSide.add(helpLabel);
      content.add(leftSide);
      content.add(rightSide);
      layout.add(content);
      final FlowPanel buttonPanel=new FlowPanel();
      final Button cancelButton=new Button(cancelButtonText);
      final Button confirmButton=new Button(confirmButtonText);
      confirmButton.setEnabled(false);
      buttonPanel.add(cancelButton);
      buttonPanel.add(confirmButton);
      layout.add(buttonPanel);
      dialogBox.setWidget(layout);
      dialogBox.setGlassEnabled(true);
      dialogBox.setAnimationEnabled(false);
      cancelButton.addClickHandler(new ClickHandler(){
        @Override public void onClick(        ClickEvent event){
          dialogBox.hide();
          callback.onFailure(null);
        }
      }
);
      cancelButton.addStyleName("String_Node_Str");
      confirmButton.addStyleName("String_Node_Str");
      dialogBox.center();
      dialogBox.show();
      helpLabel.addClickHandler(new ClickHandler(){
        @Override public void onClick(        ClickEvent event){
          aipLabel.removeStyleName("String_Node_Str");
          riLabel.removeStyleName("String_Node_Str");
          txtLabel.removeStyleName("String_Node_Str");
          webLabel.removeStyleName("String_Node_Str");
          helpLabel.addStyleName("String_Node_Str");
          rightSide.clear();
          HTMLWidgetWrapper description=new HTMLWidgetWrapper("String_Node_Str");
          description.addStyleName("String_Node_Str");
          rightSide.add(description);
          confirmButton.setEnabled(false);
        }
      }
);
      aipLabel.addClickHandler(new ClickHandler(){
        @Override public void onClick(        ClickEvent event){
          aipLabel.addStyleName("String_Node_Str");
          riLabel.removeStyleName("String_Node_Str");
          txtLabel.removeStyleName("String_Node_Str");
          webLabel.removeStyleName("String_Node_Str");
          helpLabel.removeStyleName("String_Node_Str");
          rightSide.clear();
          HTMLWidgetWrapper description=new HTMLWidgetWrapper("String_Node_Str");
          description.addStyleName("String_Node_Str");
          rightSide.add(description);
          Label selectLabel=new Label(messages.representationInformationRelationType());
          selectLabel.addStyleName("String_Node_Str");
          rightSide.add(selectLabel);
          final ListBox select=new ListBox();
          select.addStyleName("String_Node_Str");
          for (          Entry<String,String> type : relationTypes.getTranslations().get(RelationObjectType.AIP).entrySet()) {
            select.addItem(type.getValue(),type.getKey());
          }
          rightSide.add(select);
          Label linkLabel=new Label(messages.representationInformationRelationLink());
          linkLabel.addStyleName("String_Node_Str");
          rightSide.add(linkLabel);
          final Button button=new Button(messages.selectButton());
          button.addStyleName("String_Node_Str");
          rightSide.add(button);
          final ValuedLabel linkText=new ValuedLabel();
          linkText.setStyleName("String_Node_Str");
          linkText.setVisible(false);
          rightSide.add(linkText);
          Label titleLabel=new Label(messages.representationInformationRelationTitle());
          titleLabel.addStyleName("String_Node_Str");
          rightSide.add(titleLabel);
          final TextBox titleBox=new TextBox();
          titleBox.addStyleName("String_Node_Str");
          rightSide.add(titleBox);
          button.addClickHandler(new ClickHandler(){
            @Override public void onClick(            ClickEvent event){
              List<String> aipsAlreadyLinked=new ArrayList<>();
              if (ri != null) {
                for (                RepresentationInformationRelation r : ri.getRelations()) {
                  if (r.getObjectType().equals(RelationObjectType.AIP)) {
                    aipsAlreadyLinked.add(r.getLink());
                  }
                }
              }
              Filter filter=new Filter(new OneOfManyFilterParameter(RodaConstants.INDEX_UUID,aipsAlreadyLinked));
              SelectAipDialog selectAipDialog=new SelectAipDialog(messages.moveItemTitle(),filter,false,false);
              selectAipDialog.setSingleSelectionMode();
              selectAipDialog.showAndCenter();
              selectAipDialog.addValueChangeHandler(new ValueChangeHandler<IndexedAIP>(){
                @Override public void onValueChange(                ValueChangeEvent<IndexedAIP> event){
                  final IndexedAIP aip=event.getValue();
                  button.setVisible(false);
                  linkText.setVisible(true);
                  linkText.setText(aip.getTitle());
                  linkText.setValue(aip.getId());
                  if (titleBox.getText().isEmpty()) {
                    titleBox.setText(aip.getTitle());
                  }
                  confirmButton.setEnabled(true);
                }
              }
);
            }
          }
);
          for (          HandlerRegistration handler : clickHandlers) {
            handler.removeHandler();
          }
          clickHandlers.add(confirmButton.addClickHandler(new ClickHandler(){
            @Override public void onClick(            ClickEvent event){
              if (!titleBox.getText().isEmpty() && !linkText.getValue().isEmpty()) {
                dialogBox.hide();
                callback.onSuccess(new RepresentationInformationRelation(select.getSelectedValue(),RelationObjectType.AIP,linkText.getValue(),titleBox.getValue()));
              }
 else {
                Toast.showError(messages.representationInformationMissingFieldsTitle(),messages.representationInformationMissingFields());
              }
            }
          }
));
        }
      }
);
      riLabel.addClickHandler(new ClickHandler(){
        @Override public void onClick(        ClickEvent event){
          riLabel.addStyleName("String_Node_Str");
          aipLabel.removeStyleName("String_Node_Str");
          txtLabel.removeStyleName("String_Node_Str");
          webLabel.removeStyleName("String_Node_Str");
          helpLabel.removeStyleName("String_Node_Str");
          rightSide.clear();
          HTMLWidgetWrapper description=new HTMLWidgetWrapper("String_Node_Str");
          description.addStyleName("String_Node_Str");
          rightSide.add(description);
          Label selectLabel=new Label(messages.representationInformationRelationType());
          selectLabel.addStyleName("String_Node_Str");
          rightSide.add(selectLabel);
          final ListBox select=new ListBox();
          select.addStyleName("String_Node_Str");
          for (          Entry<String,String> type : relationTypes.getTranslations().get(RelationObjectType.REPRESENTATION_INFORMATION).entrySet()) {
            select.addItem(type.getValue(),type.getKey());
          }
          rightSide.add(select);
          Label linkLabel=new Label(messages.representationInformationRelationLink());
          linkLabel.addStyleName("String_Node_Str");
          rightSide.add(linkLabel);
          final Button button=new Button(messages.selectButton());
          button.addStyleName("String_Node_Str");
          rightSide.add(button);
          final ValuedLabel linkText=new ValuedLabel();
          linkText.setStyleName("String_Node_Str");
          linkText.setVisible(false);
          rightSide.add(linkText);
          Label titleLabel=new Label(messages.representationInformationRelationTitle());
          titleLabel.addStyleName("String_Node_Str");
          rightSide.add(titleLabel);
          final TextBox titleBox=new TextBox();
          titleBox.addStyleName("String_Node_Str");
          rightSide.add(titleBox);
          button.addClickHandler(new ClickHandler(){
            @Override public void onClick(            ClickEvent event){
              List<String> riAlreadyLinked=new ArrayList<>();
              if (ri != null) {
                for (                RepresentationInformationRelation r : ri.getRelations()) {
                  if (r.getObjectType().equals(RelationObjectType.REPRESENTATION_INFORMATION)) {
                    riAlreadyLinked.add(r.getLink());
                  }
                }
              }
              Filter filter=new Filter(new OneOfManyFilterParameter(RodaConstants.INDEX_UUID,riAlreadyLinked));
              SelectRepresentationInformationDialog selectDialog=new SelectRepresentationInformationDialog(messages.moveItemTitle(),filter,false);
              selectDialog.setSingleSelectionMode();
              selectDialog.showAndCenter();
              selectDialog.addValueChangeHandler(new ValueChangeHandler<RepresentationInformation>(){
                @Override public void onValueChange(                ValueChangeEvent<RepresentationInformation> event){
                  final RepresentationInformation ri=event.getValue();
                  button.setVisible(false);
                  linkText.setVisible(true);
                  linkText.setText(ri.getName());
                  linkText.setValue(ri.getId());
                  if (titleBox.getText().isEmpty()) {
                    titleBox.setText(ri.getName());
                  }
                  confirmButton.setEnabled(true);
                }
              }
);
            }
          }
);
          for (          HandlerRegistration handler : clickHandlers) {
            handler.removeHandler();
          }
          clickHandlers.add(confirmButton.addClickHandler(new ClickHandler(){
            @Override public void onClick(            ClickEvent event){
              if (!titleBox.getText().isEmpty() && !linkText.getValue().isEmpty()) {
                dialogBox.hide();
                callback.onSuccess(new RepresentationInformationRelation(select.getSelectedValue(),RelationObjectType.REPRESENTATION_INFORMATION,linkText.getValue(),titleBox.getValue()));
              }
 else {
                Toast.showError(messages.representationInformationMissingFieldsTitle(),messages.representationInformationMissingFields());
              }
            }
          }
));
        }
      }
);
      txtLabel.addClickHandler(new ClickHandler(){
        @Override public void onClick(        ClickEvent event){
          txtLabel.addStyleName("String_Node_Str");
          aipLabel.removeStyleName("String_Node_Str");
          riLabel.removeStyleName("String_Node_Str");
          webLabel.removeStyleName("String_Node_Str");
          helpLabel.removeStyleName("String_Node_Str");
          rightSide.clear();
          HTMLWidgetWrapper description=new HTMLWidgetWrapper("String_Node_Str");
          description.addStyleName("String_Node_Str");
          rightSide.add(description);
          Label selectLabel=new Label(messages.representationInformationRelationType());
          selectLabel.addStyleName("String_Node_Str");
          rightSide.add(selectLabel);
          final ListBox select=new ListBox();
          select.addStyleName("String_Node_Str");
          for (          Entry<String,String> type : relationTypes.getTranslations().get(RelationObjectType.TEXT).entrySet()) {
            select.addItem(type.getValue(),type.getKey());
          }
          rightSide.add(select);
          Label titleLabel=new Label(messages.representationInformationRelationTitle());
          titleLabel.addStyleName("String_Node_Str");
          rightSide.add(titleLabel);
          final TextBox titleBox=new TextBox();
          titleBox.setStyleName("String_Node_Str");
          rightSide.add(titleBox);
          confirmButton.setEnabled(true);
          for (          HandlerRegistration handler : clickHandlers) {
            handler.removeHandler();
          }
          clickHandlers.add(confirmButton.addClickHandler(new ClickHandler(){
            @Override public void onClick(            ClickEvent event){
              if (!titleBox.getText().isEmpty()) {
                dialogBox.hide();
                callback.onSuccess(new RepresentationInformationRelation(select.getSelectedValue(),RelationObjectType.TEXT,titleBox.getValue(),titleBox.getValue()));
              }
 else {
                Toast.showError(messages.representationInformationMissingFieldsTitle(),messages.representationInformationMissingFields());
              }
            }
          }
));
        }
      }
);
      webLabel.addClickHandler(new ClickHandler(){
        @Override public void onClick(        ClickEvent event){
          webLabel.addStyleName("String_Node_Str");
          aipLabel.removeStyleName("String_Node_Str");
          riLabel.removeStyleName("String_Node_Str");
          txtLabel.removeStyleName("String_Node_Str");
          helpLabel.removeStyleName("String_Node_Str");
          rightSide.clear();
          HTMLWidgetWrapper description=new HTMLWidgetWrapper("String_Node_Str");
          description.addStyleName("String_Node_Str");
          rightSide.add(description);
          Label selectLabel=new Label(messages.representationInformationRelationType());
          selectLabel.addStyleName("String_Node_Str");
          rightSide.add(selectLabel);
          final ListBox select=new ListBox();
          select.addStyleName("String_Node_Str");
          for (          Entry<String,String> type : relationTypes.getTranslations().get(RelationObjectType.WEB).entrySet()) {
            select.addItem(type.getValue(),type.getKey());
          }
          rightSide.add(select);
          Label linkLabel=new Label(messages.representationInformationRelationLink());
          linkLabel.addStyleName("String_Node_Str");
          rightSide.add(linkLabel);
          final TextBox linkText=new TextBox();
          linkText.setStyleName("String_Node_Str");
          rightSide.add(linkText);
          Label titleLabel=new Label(messages.representationInformationRelationTitle());
          titleLabel.addStyleName("String_Node_Str");
          rightSide.add(titleLabel);
          final TextBox titleBox=new TextBox();
          titleBox.addStyleName("String_Node_Str");
          rightSide.add(titleBox);
          confirmButton.setEnabled(true);
          for (          HandlerRegistration handler : clickHandlers) {
            handler.removeHandler();
          }
          clickHandlers.add(confirmButton.addClickHandler(new ClickHandler(){
            @Override public void onClick(            ClickEvent event){
              if (!titleBox.getText().isEmpty() && !linkText.getText().isEmpty()) {
                dialogBox.hide();
                callback.onSuccess(new RepresentationInformationRelation(select.getSelectedValue(),RelationObjectType.WEB,linkText.getValue(),titleBox.getValue()));
              }
 else {
                Toast.showError(messages.representationInformationMissingFieldsTitle(),messages.representationInformationMissingFields());
              }
            }
          }
));
        }
      }
);
    }
  }
);
}

Fixed version (ground truth):
public static void showPromptDialogRepresentationInformationRelations(String title,final String cancelButtonText,final String confirmButtonText,final RepresentationInformation ri,final AsyncCallback<RepresentationInformationRelation> callback){
  final List<HandlerRegistration> clickHandlers=new ArrayList<>();
  final DialogBox dialogBox=new DialogBox(true,true);
  dialogBox.addStyleName("String_Node_Str");
  dialogBox.setText(title);
  final FlowPanel layout=new FlowPanel();
  dialogBox.addStyleName("String_Node_Str");
  layout.addStyleName("String_Node_Str");
  BrowserService.Util.getInstance().retrieveRelationTypeTranslations(LocaleInfo.getCurrentLocale().getLocaleName(),new AsyncCallback<RelationTypeTranslationsBundle>(){
    @Override public void onFailure(    Throwable caught){
      AsyncCallbackUtils.defaultFailureTreatment(caught);
    }
    @Override public void onSuccess(    final RelationTypeTranslationsBundle relationTypes){
      final FlowPanel content=new FlowPanel();
      content.addStyleName("String_Node_Str");
      final FlowPanel leftSide=new FlowPanel();
      leftSide.addStyleName("String_Node_Str");
      final FlowPanel rightSide=new FlowPanel();
      rightSide.addStyleName("String_Node_Str");
      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");
      rightSide.add(description);
      final Label aipLabel=new Label();
      aipLabel.setText(messages.representationInformationRelationObjectType(RelationObjectType.AIP.toString()));
      aipLabel.setTitle(messages.representationInformationRelationObjectType(RelationObjectType.AIP.toString()));
      aipLabel.addStyleName("String_Node_Str");
      leftSide.add(aipLabel);
      final Label riLabel=new Label();
      riLabel.setText(messages.representationInformationRelationObjectType(RelationObjectType.REPRESENTATION_INFORMATION.toString()));
      riLabel.setTitle(messages.representationInformationRelationObjectType(RelationObjectType.REPRESENTATION_INFORMATION.toString()));
      riLabel.addStyleName("String_Node_Str");
      leftSide.add(riLabel);
      final Label webLabel=new Label();
      webLabel.setText(messages.representationInformationRelationObjectType(RelationObjectType.WEB.toString()));
      webLabel.setTitle(messages.representationInformationRelationObjectType(RelationObjectType.WEB.toString()));
      webLabel.addStyleName("String_Node_Str");
      leftSide.add(webLabel);
      final Label txtLabel=new Label();
      txtLabel.setText(messages.representationInformationRelationObjectType(RelationObjectType.TEXT.toString()));
      txtLabel.setTitle(messages.representationInformationRelationObjectType(RelationObjectType.TEXT.toString()));
      txtLabel.addStyleName("String_Node_Str");
      leftSide.add(txtLabel);
      final Label helpLabel=new Label();
      helpLabel.setText(messages.title("String_Node_Str"));
      helpLabel.setTitle(messages.title("String_Node_Str"));
      helpLabel.addStyleName("String_Node_Str");
      leftSide.add(helpLabel);
      content.add(leftSide);
      content.add(rightSide);
      layout.add(content);
      final FlowPanel buttonPanel=new FlowPanel();
      final Button cancelButton=new Button(cancelButtonText);
      final Button confirmButton=new Button(confirmButtonText);
      confirmButton.setEnabled(false);
      buttonPanel.add(cancelButton);
      buttonPanel.add(confirmButton);
      layout.add(buttonPanel);
      dialogBox.setWidget(layout);
      dialogBox.setGlassEnabled(true);
      dialogBox.setAnimationEnabled(false);
      cancelButton.addClickHandler(new ClickHandler(){
        @Override public void onClick(        ClickEvent event){
          dialogBox.hide();
          callback.onFailure(null);
        }
      }
);
      cancelButton.addStyleName("String_Node_Str");
      confirmButton.addStyleName("String_Node_Str");
      dialogBox.center();
      dialogBox.show();
      helpLabel.addClickHandler(new ClickHandler(){
        @Override public void onClick(        ClickEvent event){
          aipLabel.removeStyleName("String_Node_Str");
          riLabel.removeStyleName("String_Node_Str");
          txtLabel.removeStyleName("String_Node_Str");
          webLabel.removeStyleName("String_Node_Str");
          helpLabel.addStyleName("String_Node_Str");
          rightSide.clear();
          HTMLWidgetWrapper description=new HTMLWidgetWrapper("String_Node_Str");
          description.addStyleName("String_Node_Str");
          rightSide.add(description);
          confirmButton.setEnabled(false);
        }
      }
);
      aipLabel.addClickHandler(new ClickHandler(){
        @Override public void onClick(        ClickEvent event){
          aipLabel.addStyleName("String_Node_Str");
          riLabel.removeStyleName("String_Node_Str");
          txtLabel.removeStyleName("String_Node_Str");
          webLabel.removeStyleName("String_Node_Str");
          helpLabel.removeStyleName("String_Node_Str");
          rightSide.clear();
          HTMLWidgetWrapper description=new HTMLWidgetWrapper("String_Node_Str");
          description.addStyleName("String_Node_Str");
          rightSide.add(description);
          Label selectLabel=new Label(messages.representationInformationRelationType());
          selectLabel.addStyleName("String_Node_Str");
          rightSide.add(selectLabel);
          final ListBox select=new ListBox();
          select.addStyleName("String_Node_Str");
          for (          Entry<String,String> type : relationTypes.getTranslations().get(RelationObjectType.AIP).entrySet()) {
            select.addItem(type.getValue(),type.getKey());
          }
          rightSide.add(select);
          Label linkLabel=new Label(messages.representationInformationRelationLink());
          linkLabel.addStyleName("String_Node_Str");
          rightSide.add(linkLabel);
          final Button button=new Button(messages.selectButton());
          button.addStyleName("String_Node_Str");
          rightSide.add(button);
          final ValuedLabel linkText=new ValuedLabel();
          linkText.setStyleName("String_Node_Str");
          linkText.setVisible(false);
          rightSide.add(linkText);
          Label titleLabel=new Label(messages.representationInformationRelationTitle());
          titleLabel.addStyleName("String_Node_Str");
          rightSide.add(titleLabel);
          final TextBox titleBox=new TextBox();
          titleBox.addStyleName("String_Node_Str");
          rightSide.add(titleBox);
          button.addClickHandler(new ClickHandler(){
            @Override public void onClick(            ClickEvent event){
              List<String> aipsAlreadyLinked=new ArrayList<>();
              if (ri != null) {
                for (                RepresentationInformationRelation r : ri.getRelations()) {
                  if (r.getObjectType().equals(RelationObjectType.AIP)) {
                    aipsAlreadyLinked.add(r.getLink());
                  }
                }
              }
              Filter filter=new Filter(new OneOfManyFilterParameter(RodaConstants.INDEX_UUID,aipsAlreadyLinked));
              SelectAipDialog selectAipDialog=new SelectAipDialog(messages.moveItemTitle(),filter,false,false);
              selectAipDialog.setSingleSelectionMode();
              selectAipDialog.showAndCenter();
              selectAipDialog.addValueChangeHandler(new ValueChangeHandler<IndexedAIP>(){
                @Override public void onValueChange(                ValueChangeEvent<IndexedAIP> event){
                  final IndexedAIP aip=event.getValue();
                  button.setVisible(false);
                  linkText.setVisible(true);
                  linkText.setValue(aip.getId());
                  if (StringUtils.isNotBlank(aip.getTitle())) {
                    linkText.setText(aip.getTitle());
                  }
 else {
                    linkText.setText(messages.noTitleMessage());
                  }
                  if (titleBox.getText().isEmpty()) {
                    titleBox.setText(aip.getTitle());
                  }
                  confirmButton.setEnabled(true);
                }
              }
);
            }
          }
);
          for (          HandlerRegistration handler : clickHandlers) {
            handler.removeHandler();
          }
          clickHandlers.add(confirmButton.addClickHandler(new ClickHandler(){
            @Override public void onClick(            ClickEvent event){
              if (!titleBox.getText().isEmpty() && !linkText.getValue().isEmpty()) {
                dialogBox.hide();
                callback.onSuccess(new RepresentationInformationRelation(select.getSelectedValue(),RelationObjectType.AIP,linkText.getValue(),titleBox.getValue()));
              }
 else {
                Toast.showError(messages.representationInformationMissingFieldsTitle(),messages.representationInformationMissingFields());
              }
            }
          }
));
        }
      }
);
      riLabel.addClickHandler(new ClickHandler(){
        @Override public void onClick(        ClickEvent event){
          riLabel.addStyleName("String_Node_Str");
          aipLabel.removeStyleName("String_Node_Str");
          txtLabel.removeStyleName("String_Node_Str");
          webLabel.removeStyleName("String_Node_Str");
          helpLabel.removeStyleName("String_Node_Str");
          rightSide.clear();
          HTMLWidgetWrapper description=new HTMLWidgetWrapper("String_Node_Str");
          description.addStyleName("String_Node_Str");
          rightSide.add(description);
          Label selectLabel=new Label(messages.representationInformationRelationType());
          selectLabel.addStyleName("String_Node_Str");
          rightSide.add(selectLabel);
          final ListBox select=new ListBox();
          select.addStyleName("String_Node_Str");
          for (          Entry<String,String> type : relationTypes.getTranslations().get(RelationObjectType.REPRESENTATION_INFORMATION).entrySet()) {
            select.addItem(type.getValue(),type.getKey());
          }
          rightSide.add(select);
          Label linkLabel=new Label(messages.representationInformationRelationLink());
          linkLabel.addStyleName("String_Node_Str");
          rightSide.add(linkLabel);
          final Button button=new Button(messages.selectButton());
          button.addStyleName("String_Node_Str");
          rightSide.add(button);
          final ValuedLabel linkText=new ValuedLabel();
          linkText.setStyleName("String_Node_Str");
          linkText.setVisible(false);
          rightSide.add(linkText);
          Label titleLabel=new Label(messages.representationInformationRelationTitle());
          titleLabel.addStyleName("String_Node_Str");
          rightSide.add(titleLabel);
          final TextBox titleBox=new TextBox();
          titleBox.addStyleName("String_Node_Str");
          rightSide.add(titleBox);
          button.addClickHandler(new ClickHandler(){
            @Override public void onClick(            ClickEvent event){
              List<String> riAlreadyLinked=new ArrayList<>();
              if (ri != null) {
                for (                RepresentationInformationRelation r : ri.getRelations()) {
                  if (r.getObjectType().equals(RelationObjectType.REPRESENTATION_INFORMATION)) {
                    riAlreadyLinked.add(r.getLink());
                  }
                }
              }
              Filter filter=new Filter(new OneOfManyFilterParameter(RodaConstants.INDEX_UUID,riAlreadyLinked));
              SelectRepresentationInformationDialog selectDialog=new SelectRepresentationInformationDialog(messages.moveItemTitle(),filter,false);
              selectDialog.setSingleSelectionMode();
              selectDialog.showAndCenter();
              selectDialog.addValueChangeHandler(new ValueChangeHandler<RepresentationInformation>(){
                @Override public void onValueChange(                ValueChangeEvent<RepresentationInformation> event){
                  final RepresentationInformation ri=event.getValue();
                  button.setVisible(false);
                  linkText.setVisible(true);
                  linkText.setText(ri.getName());
                  linkText.setValue(ri.getId());
                  if (titleBox.getText().isEmpty()) {
                    titleBox.setText(ri.getName());
                  }
                  confirmButton.setEnabled(true);
                }
              }
);
            }
          }
);
          for (          HandlerRegistration handler : clickHandlers) {
            handler.removeHandler();
          }
          clickHandlers.add(confirmButton.addClickHandler(new ClickHandler(){
            @Override public void onClick(            ClickEvent event){
              if (!titleBox.getText().isEmpty() && !linkText.getValue().isEmpty()) {
                dialogBox.hide();
                callback.onSuccess(new RepresentationInformationRelation(select.getSelectedValue(),RelationObjectType.REPRESENTATION_INFORMATION,linkText.getValue(),titleBox.getValue()));
              }
 else {
                Toast.showError(messages.representationInformationMissingFieldsTitle(),messages.representationInformationMissingFields());
              }
            }
          }
));
        }
      }
);
      txtLabel.addClickHandler(new ClickHandler(){
        @Override public void onClick(        ClickEvent event){
          txtLabel.addStyleName("String_Node_Str");
          aipLabel.removeStyleName("String_Node_Str");
          riLabel.removeStyleName("String_Node_Str");
          webLabel.removeStyleName("String_Node_Str");
          helpLabel.removeStyleName("String_Node_Str");
          rightSide.clear();
          HTMLWidgetWrapper description=new HTMLWidgetWrapper("String_Node_Str");
          description.addStyleName("String_Node_Str");
          rightSide.add(description);
          Label selectLabel=new Label(messages.representationInformationRelationType());
          selectLabel.addStyleName("String_Node_Str");
          rightSide.add(selectLabel);
          final ListBox select=new ListBox();
          select.addStyleName("String_Node_Str");
          for (          Entry<String,String> type : relationTypes.getTranslations().get(RelationObjectType.TEXT).entrySet()) {
            select.addItem(type.getValue(),type.getKey());
          }
          rightSide.add(select);
          Label titleLabel=new Label(messages.representationInformationRelationTitle());
          titleLabel.addStyleName("String_Node_Str");
          rightSide.add(titleLabel);
          final TextBox titleBox=new TextBox();
          titleBox.setStyleName("String_Node_Str");
          rightSide.add(titleBox);
          confirmButton.setEnabled(true);
          for (          HandlerRegistration handler : clickHandlers) {
            handler.removeHandler();
          }
          clickHandlers.add(confirmButton.addClickHandler(new ClickHandler(){
            @Override public void onClick(            ClickEvent event){
              if (!titleBox.getText().isEmpty()) {
                dialogBox.hide();
                callback.onSuccess(new RepresentationInformationRelation(select.getSelectedValue(),RelationObjectType.TEXT,titleBox.getValue(),titleBox.getValue()));
              }
 else {
                Toast.showError(messages.representationInformationMissingFieldsTitle(),messages.representationInformationMissingFields());
              }
            }
          }
));
        }
      }
);
      webLabel.addClickHandler(new ClickHandler(){
        @Override public void onClick(        ClickEvent event){
          webLabel.addStyleName("String_Node_Str");
          aipLabel.removeStyleName("String_Node_Str");
          riLabel.removeStyleName("String_Node_Str");
          txtLabel.removeStyleName("String_Node_Str");
          helpLabel.removeStyleName("String_Node_Str");
          rightSide.clear();
          HTMLWidgetWrapper description=new HTMLWidgetWrapper("String_Node_Str");
          description.addStyleName("String_Node_Str");
          rightSide.add(description);
          Label selectLabel=new Label(messages.representationInformationRelationType());
          selectLabel.addStyleName("String_Node_Str");
          rightSide.add(selectLabel);
          final ListBox select=new ListBox();
          select.addStyleName("String_Node_Str");
          for (          Entry<String,String> type : relationTypes.getTranslations().get(RelationObjectType.WEB).entrySet()) {
            select.addItem(type.getValue(),type.getKey());
          }
          rightSide.add(select);
          Label linkLabel=new Label(messages.representationInformationRelationLink());
          linkLabel.addStyleName("String_Node_Str");
          rightSide.add(linkLabel);
          final TextBox linkText=new TextBox();
          linkText.setStyleName("String_Node_Str");
          rightSide.add(linkText);
          Label titleLabel=new Label(messages.representationInformationRelationTitle());
          titleLabel.addStyleName("String_Node_Str");
          rightSide.add(titleLabel);
          final TextBox titleBox=new TextBox();
          titleBox.addStyleName("String_Node_Str");
          rightSide.add(titleBox);
          confirmButton.setEnabled(true);
          for (          HandlerRegistration handler : clickHandlers) {
            handler.removeHandler();
          }
          clickHandlers.add(confirmButton.addClickHandler(new ClickHandler(){
            @Override public void onClick(            ClickEvent event){
              if (!titleBox.getText().isEmpty() && !linkText.getText().isEmpty()) {
                dialogBox.hide();
                callback.onSuccess(new RepresentationInformationRelation(select.getSelectedValue(),RelationObjectType.WEB,linkText.getValue(),titleBox.getValue()));
              }
 else {
                Toast.showError(messages.representationInformationMissingFieldsTitle(),messages.representationInformationMissingFields());
              }
            }
          }
));
        }
      }
);
    }
  }
);
}