Program: 188478
Project: 188478
Buggy source:
/** 
 * Create a new panel to view a representation
 * @param viewers
 * @param index
 * @param sorter
 * @param aipId
 * @param itemBundle
 * @param representationUUID
 * @param fileUUID
 * @param file
 */
public BrowseFile(Viewers viewers,final BrowseFileBundle bundle,Sorter sorter,Integer index){
  this.bundle=bundle;
  this.sorter=sorter;
  this.index=index;
  filePreview=new IndexedFilePreview(viewers,bundle.getFile(),new Command(){
    @Override public void execute(){
      Scheduler.get().scheduleDeferred(new Command(){
        @Override public void execute(){
          Filter filter=new Filter(new SimpleFilterParameter(RodaConstants.DIP_FILE_UUIDS,bundle.getFile().getUUID()));
          BrowserService.Util.getInstance().count(IndexedDIP.class.getName(),filter,new AsyncCallback<Long>(){
            @Override public void onFailure(            Throwable caught){
              AsyncCallbackUtils.defaultFailureTreatment(caught);
            }
            @Override public void onSuccess(            Long dipCount){
              if (dipCount > 0) {
                toggleDisseminationsPanel();
              }
            }
          }
);
        }
      }
);
    }
  }
);
  initWidget(uiBinder.createAndBindUi(this));
  breadcrumb.updatePath(getBreadcrumbs());
  breadcrumb.setVisible(true);
  infoFileButton.setTitle(messages.viewRepresentationInfoFileButton());
  optionDownload.setEnabled(!bundle.getFile().isDirectory());
  infoFileButton.setVisible(!bundle.getFile().isDirectory());
  downloadDocumentationButton.setVisible(bundle.getRepresentation().getNumberOfDocumentationFiles() > 0);
  downloadSchemasButton.setVisible(bundle.getRepresentation().getNumberOfSchemaFiles() > 0);
  keyboardFocus.setFocus(true);
  keyboardFocus.addKeyDownHandler(new KeyDownHandler(){
    @Override public void onKeyDown(    KeyDownEvent event){
      if (!bundle.getFile().isDirectory()) {
        NativeEvent ne=event.getNativeEvent();
        if (ne.getKeyCode() == KeyCodes.KEY_RIGHT) {
          ne.preventDefault();
          next();
        }
 else         if (ne.getKeyCode() == KeyCodes.KEY_LEFT) {
          ne.preventDefault();
          previous();
        }
      }
    }
  }
);
  if (index < 0) {
    HtmlSnippetUtils.setCssClassDisabled(previousButton,true);
    HtmlSnippetUtils.setCssClassDisabled(nextButton,bundle.getTotalSiblingCount() < 2);
  }
 else {
    HtmlSnippetUtils.setCssClassDisabled(previousButton,index == 0);
    HtmlSnippetUtils.setCssClassDisabled(nextButton,index >= bundle.getTotalSiblingCount() - 1);
  }
}

Fixed version (ground truth):
/** 
 * Create a new panel to view a representation
 * @param viewers
 * @param index
 * @param sorter
 * @param aipId
 * @param itemBundle
 * @param representationUUID
 * @param fileUUID
 * @param file
 */
public BrowseFile(Viewers viewers,final BrowseFileBundle bundle,Sorter sorter,Integer index){
  this.bundle=bundle;
  this.sorter=sorter;
  this.index=index;
  filePreview=new IndexedFilePreview(viewers,bundle.getFile(),new Command(){
    @Override public void execute(){
      Scheduler.get().scheduleDeferred(new Command(){
        @Override public void execute(){
          Filter filter=new Filter(new SimpleFilterParameter(RodaConstants.DIP_FILE_UUIDS,bundle.getFile().getUUID()));
          BrowserService.Util.getInstance().count(IndexedDIP.class.getName(),filter,new AsyncCallback<Long>(){
            @Override public void onFailure(            Throwable caught){
              AsyncCallbackUtils.defaultFailureTreatment(caught);
            }
            @Override public void onSuccess(            Long dipCount){
              if (dipCount > 0) {
                toggleDisseminationsPanel();
              }
            }
          }
);
        }
      }
);
    }
  }
);
  initWidget(uiBinder.createAndBindUi(this));
  breadcrumb.updatePath(getBreadcrumbs());
  breadcrumb.setVisible(true);
  infoFileButton.setTitle(messages.viewRepresentationInfoFileButton());
  optionDownload.setEnabled(!bundle.getFile().isDirectory());
  infoFileButton.setVisible(!bundle.getFile().isDirectory());
  downloadDocumentationButton.setVisible(bundle.getRepresentation().getNumberOfDocumentationFiles() > 0);
  downloadSchemasButton.setVisible(bundle.getRepresentation().getNumberOfSchemaFiles() > 0);
  keyboardFocus.setFocus(true);
  keyboardFocus.addKeyDownHandler(new KeyDownHandler(){
    @Override public void onKeyDown(    KeyDownEvent event){
      if (event.isControlKeyDown()) {
        NativeEvent ne=event.getNativeEvent();
        if (ne.getKeyCode() == KeyCodes.KEY_RIGHT) {
          ne.preventDefault();
          next();
        }
 else         if (ne.getKeyCode() == KeyCodes.KEY_LEFT) {
          ne.preventDefault();
          previous();
        }
      }
    }
  }
);
  if (index < 0) {
    HtmlSnippetUtils.setCssClassDisabled(previousButton,true);
    HtmlSnippetUtils.setCssClassDisabled(nextButton,bundle.getTotalSiblingCount() < 2);
  }
 else {
    HtmlSnippetUtils.setCssClassDisabled(previousButton,index == 0);
    HtmlSnippetUtils.setCssClassDisabled(nextButton,index >= bundle.getTotalSiblingCount() - 1);
  }
  boolean directory=bundle.getFile().isDirectory();
  optionDownload.setVisible(!directory);
  optionRename.setVisible(directory);
  optionMove.setVisible(true);
  optionUploadFiles.setVisible(directory);
  optionCreateFolder.setVisible(directory);
  optionRemove.setVisible(true);
  optionNewProcess.setVisible(true);
  optionIdentify.setVisible(true);
  optionEvents.setVisible(true);
  optionRisk.setVisible(true);
}