Program: 125469
Project: 125469
Buggy source:
@Override public void drop(DropTargetEvent event){
  DropTarget dropTarget=(DropTarget)event.getSource();
  Control control=dropTarget.getControl();
  XmlToSchemaDraggedData draggedData=XPathTransfer.getInstance().getDraggedData();
  List<TransferableXPathEntry> transferableEntryList=draggedData.getTransferableEntryList();
  ExtractionLoopWithXPathEditorView loopTableEditorView=linker.getLoopTableEditorView();
  if (loopTableEditorView.isReadOnly()) {
    return;
  }
  ExtendedTableModel<XmlXPathLoopDescriptor> extendedTableModel=loopTableEditorView.getExtendedTableModel();
  XmlXPathLoopDescriptor pathLoopDescriptor=extendedTableModel.getBeansList().get(0);
  if (linker.isLoopTable((Table)control)) {
    if (transferableEntryList.size() > 0) {
      String absoluteXPath=transferableEntryList.get(0).getAbsoluteXPath();
      TableViewerCreatorColumn xpathColumn=linker.getLoopTableEditorView().getXPathColumn();
      Display display=linker.getTree().getDisplay();
      Cursor cursor=new Cursor(display,SWT.CURSOR_WAIT);
      linker.getTree().getShell().setCursor(cursor);
      loopTableEditorView.getTableViewerCreator().setBeanValue(xpathColumn,pathLoopDescriptor,absoluteXPath,true);
      linker.getTree().getShell().setCursor(null);
    }
  }
 else {
    ExtractionFieldsWithXPathEditorView tableEditorView=linker.getFieldsTableEditorView();
    Integer startInsertAtThisIndex=TableUtils.getItemIndexWhereInsertFromPosition(fieldsTable,new Point(event.x,event.y));
    List<SchemaTarget> fullSchemaTargetList=new ArrayList<SchemaTarget>(tableEditorView.getModel().getBeansList());
    List<SchemaTarget> list=new ArrayList<SchemaTarget>(transferableEntryList.size());
    for (    TransferableXPathEntry entry : transferableEntryList) {
      ArrayList<String> loopXpathNodes=linker.getLoopXpathNodes();
      if (loopXpathNodes.size() > 0) {
        String loopPath=loopXpathNodes.get(0);
        String relativeXPath=XPathPopulationUtil.populateColumnPath(loopPath,entry.getAbsoluteXPath());
        if (relativeXPath.startsWith("String_Node_Str")) {
          relativeXPath=relativeXPath.substring(1);
        }
        if (relativeXPath.endsWith("String_Node_Str")) {
          relativeXPath=relativeXPath.substring(0,relativeXPath.length() - 1);
        }
        if (relativeXPath.trim().equals("String_Node_Str")) {
          relativeXPath="String_Node_Str";
        }
        SchemaTarget newTargetEntry=linker.getNewSchemaTargetEntry(relativeXPath);
        String name=extractColumnName(extractTagName(relativeXPath),fullSchemaTargetList);
        newTargetEntry.setTagName(name);
        list.add(newTargetEntry);
        fullSchemaTargetList.add(newTargetEntry);
      }
    }
    tableEditorView.getTableViewerCreator().getTableViewer().refresh();
    loopTable.deselectAll();
    fieldsTable.deselectAll();
    linker.getTree().deselectAll();
    if (list.size() > 0) {
      ExtendedTableAddCommand addCommand=new ExtendedTableAddCommand(tableEditorView.getModel(),list,startInsertAtThisIndex);
      tableEditorView.getExtendedTableViewer().executeCommand(addCommand);
    }
  }
  linker.updateLinksStyleAndControlsSelection(control,true);
}

Fixed version (ground truth):
@Override public void drop(DropTargetEvent event){
  DropTarget dropTarget=(DropTarget)event.getSource();
  Control control=dropTarget.getControl();
  XmlToSchemaDraggedData draggedData=XPathTransfer.getInstance().getDraggedData();
  List<TransferableXPathEntry> transferableEntryList=draggedData.getTransferableEntryList();
  ExtractionLoopWithXPathEditorView loopTableEditorView=linker.getLoopTableEditorView();
  ExtendedTableModel<XmlXPathLoopDescriptor> extendedTableModel=loopTableEditorView.getExtendedTableModel();
  XmlXPathLoopDescriptor pathLoopDescriptor=extendedTableModel.getBeansList().get(0);
  ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(pathLoopDescriptor.getConnection(),pathLoopDescriptor.getConnection().getContextName());
  String originalValue=pathLoopDescriptor.getAbsoluteXPathQuery();
  if (contextType != null) {
    originalValue=ConnectionContextHelper.getOriginalValue(contextType,pathLoopDescriptor.getAbsoluteXPathQuery());
    originalValue=TalendQuoteUtils.removeQuotes(originalValue);
  }
  if (linker.isLoopTable((Table)control)) {
    if (transferableEntryList.size() > 0) {
      String absoluteXPath=transferableEntryList.get(0).getAbsoluteXPath();
      TableViewerCreatorColumn xpathColumn=linker.getLoopTableEditorView().getXPathColumn();
      Display display=linker.getTree().getDisplay();
      Cursor cursor=new Cursor(display,SWT.CURSOR_WAIT);
      linker.getTree().getShell().setCursor(cursor);
      loopTableEditorView.getTableViewerCreator().setBeanValue(xpathColumn,pathLoopDescriptor,absoluteXPath,true);
      linker.getTree().getShell().setCursor(null);
    }
  }
 else {
    ExtractionFieldsWithXPathEditorView tableEditorView=linker.getFieldsTableEditorView();
    Integer startInsertAtThisIndex=TableUtils.getItemIndexWhereInsertFromPosition(fieldsTable,new Point(event.x,event.y));
    List<SchemaTarget> fullSchemaTargetList=new ArrayList<SchemaTarget>(tableEditorView.getModel().getBeansList());
    List<SchemaTarget> list=new ArrayList<SchemaTarget>(transferableEntryList.size());
    for (    TransferableXPathEntry entry : transferableEntryList) {
      ArrayList<String> loopXpathNodes=linker.getLoopXpathNodes();
      if (loopXpathNodes.size() > 0 || (loopTableEditorView.isReadOnly() && originalValue != null)) {
        String loopPath=originalValue;
        if (loopXpathNodes.size() > 0) {
          loopPath=loopXpathNodes.get(0);
        }
        String relativeXPath=XPathPopulationUtil.populateColumnPath(loopPath,entry.getAbsoluteXPath());
        if (relativeXPath.startsWith("String_Node_Str")) {
          relativeXPath=relativeXPath.substring(1);
        }
        if (relativeXPath.endsWith("String_Node_Str")) {
          relativeXPath=relativeXPath.substring(0,relativeXPath.length() - 1);
        }
        if (relativeXPath.trim().equals("String_Node_Str")) {
          relativeXPath="String_Node_Str";
        }
        SchemaTarget newTargetEntry=linker.getNewSchemaTargetEntry(relativeXPath);
        String name=extractColumnName(extractTagName(relativeXPath),fullSchemaTargetList);
        newTargetEntry.setTagName(name);
        list.add(newTargetEntry);
        fullSchemaTargetList.add(newTargetEntry);
      }
    }
    tableEditorView.getTableViewerCreator().getTableViewer().refresh();
    loopTable.deselectAll();
    fieldsTable.deselectAll();
    linker.getTree().deselectAll();
    if (list.size() > 0) {
      ExtendedTableAddCommand addCommand=new ExtendedTableAddCommand(tableEditorView.getModel(),list,startInsertAtThisIndex);
      tableEditorView.getExtendedTableViewer().executeCommand(addCommand);
    }
  }
  linker.updateLinksStyleAndControlsSelection(control,true);
}