Program: 120644
Project: 120644
Buggy source:
@Override public void drop(DropTargetEvent event){
  super.drop(event);
  retrieveInsertionIndicator().setVisible(false);
  UIManager uiManager=getUiManager();
  DraggedData draggedData=TableEntriesTransfer.getInstance().getDraggedData();
  DropContextAnalyzer analyzer=analyzeDropTarget(event,draggedData);
  Point cursorPosition=new Point(event.x,event.y);
  int startInsertAtThisIndex=TableUtils.getItemIndexWhereInsertFromPosition(draggableTargetControl,cursorPosition);
  ILanguage currentLanguage=LanguageProvider.getCurrentLanguage();
  DataMapTableView dataMapTableViewTarget=getMapperManager().retrieveDataMapTableView(draggableTargetControl);
  Zone zoneTarget=dataMapTableViewTarget.getZone();
  uiManager.selectDataMapTableView(dataMapTableViewTarget,true,false);
  MetadataTableEditorView metadataEditorView=getUiManager().getMetadataEditorView(dataMapTableViewTarget.getZone());
  List<TransferableEntry> transferableEntryList=draggedData.getTransferableEntryList();
  int currentIndex=startInsertAtThisIndex;
  uiManager.clearLastCreatedInOutColumnEntries();
  draggableTargetControl.deselectAll();
  ITableEntry currentEntryTarget=getEntryFromPosition(cursorPosition);
  ArrayList<String> columnsBeingAdded=new ArrayList<String>();
  ArrayList<Integer> columnIndicesToSelect=new ArrayList<Integer>();
  ArrayList<ITableEntry> sourceEntriesOfEntriesBeingAdded=new ArrayList<ITableEntry>();
  ArrayList<IMetadataColumn> metadataColumnsBeingAdded=new ArrayList<IMetadataColumn>();
  boolean targetTableIsFiltersTable=analyzer.targetTableIsFiltersTable();
  boolean targetTableIsGlobalMapTable=analyzer.targetTableIsGlobalMapTable();
  boolean atLeastOneEntryInserted=false;
  boolean insertionEntryMode=analyzer.isInsertionEntryMode();
  boolean mapEachSourceToNextTargets=analyzer.isMapOneToOneMode();
  TableViewerCreator tableViewerCreatorTarget=null;
  if (!analyzer.targetIsExpressionFilterText()) {
    if (targetTableIsFiltersTable) {
      tableViewerCreatorTarget=dataMapTableViewTarget.getTableViewerCreatorForFilters();
    }
 else     if (targetTableIsGlobalMapTable) {
      tableViewerCreatorTarget=dataMapTableViewTarget.getTableViewerCreatorForGlobalMap();
    }
 else {
      tableViewerCreatorTarget=dataMapTableViewTarget.getTableViewerCreatorForColumns();
    }
  }
  uiManager.applyActivatedCellEditors(tableViewerCreatorTarget);
  ITableEntry lastEntryTarget=null;
  for (  TransferableEntry transferableEntry : transferableEntryList) {
    ITableEntry tableEntrySource=transferableEntry.getTableEntrySource();
    IMetadataColumn metadataColumnDragged=transferableEntry.getMetadataColumn();
    Zone zoneSourceEntry=(Zone)transferableEntry.getZoneSourceEntry();
    TableEntryLocation tableEntryLocationTarget=new TableEntryLocation(dataMapTableViewTarget.getDataMapTable().getName(),tableEntrySource.getName());
    if (zoneSourceEntry == Zone.INPUTS && zoneTarget == Zone.INPUTS && tableEntrySource.getParentName().equals(tableEntryLocationTarget.tableName)) {
      continue;
    }
 else     if (currentEntryTarget != null && !insertionEntryMode) {
      if (currentEntryTarget instanceof InputColumnTableEntry) {
        ((InputColumnTableEntry)currentEntryTarget).setOperator(Operator.EQUALS.getLiteral());
      }
      boolean overwrite=(lastEntryTarget != currentEntryTarget && analyzer.isOverwriteExpression());
      modifyExistingExpression(currentLanguage,currentEntryTarget,tableEntrySource,overwrite,zoneSourceEntry);
      uiManager.parseExpression(currentEntryTarget.getExpression(),currentEntryTarget,false,true,true);
      int indexOfEntry=tableViewerCreatorTarget.getInputList().indexOf(currentEntryTarget);
      columnIndicesToSelect.add(indexOfEntry);
    }
 else {
      String columnName=transferableEntry.getTableEntrySource().getName();
      tableEntryLocationTarget=getMapperManager().findUniqueLocation(tableEntryLocationTarget,columnsBeingAdded.toArray(new String[0]));
      columnName=tableEntryLocationTarget.columnName;
      if (currentEntryTarget == null && analyzer.isMapOneToOneMode()) {
        currentIndex=tableViewerCreatorTarget.getInputList().size();
        columnIndicesToSelect.add(currentIndex);
      }
      if (zoneSourceEntry == Zone.INPUTS && zoneTarget == Zone.VARS || zoneSourceEntry == Zone.VARS && zoneTarget == Zone.VARS) {
        columnIndicesToSelect.add(currentIndex);
        currentIndex=insertNewVarEntry(currentLanguage,dataMapTableViewTarget,currentIndex,tableEntrySource,columnName);
        atLeastOneEntryInserted=true;
      }
 else       if (zoneSourceEntry == Zone.VARS && zoneTarget == Zone.OUTPUTS) {
        insertNewOutputEntryFromVarEntry(sourceEntriesOfEntriesBeingAdded,metadataColumnsBeingAdded,tableEntrySource,columnName);
        atLeastOneEntryInserted=true;
      }
 else       if (zoneSourceEntry == Zone.INPUTS && targetTableIsGlobalMapTable) {
        insertNewGlobalMapEntryFromInputEntry(currentLanguage,dataMapTableViewTarget,currentIndex,tableEntrySource);
        atLeastOneEntryInserted=true;
      }
 else       if (zoneSourceEntry == Zone.INPUTS && zoneTarget != Zone.VARS) {
        insertNewInOutEntryFromInputEntry(sourceEntriesOfEntriesBeingAdded,metadataColumnsBeingAdded,tableEntrySource,metadataColumnDragged,columnName);
        atLeastOneEntryInserted=true;
      }
 else       if (zoneSourceEntry == Zone.OUTPUTS && zoneTarget == Zone.VARS) {
      }
 else       if (zoneSourceEntry == Zone.OUTPUTS && zoneTarget == Zone.OUTPUTS) {
        insertOutpuEntryCopyToOtherOutput(sourceEntriesOfEntriesBeingAdded,metadataColumnsBeingAdded,tableEntrySource,metadataColumnDragged,columnName);
        atLeastOneEntryInserted=true;
      }
 else {
      }
      columnsBeingAdded.add(columnName);
    }
    lastEntryTarget=currentEntryTarget;
    if (mapEachSourceToNextTargets && currentEntryTarget != null) {
      currentEntryTarget=getNextEntryTarget(currentEntryTarget,tableViewerCreatorTarget);
    }
  }
  if (!atLeastOneEntryInserted) {
    tableViewerCreatorTarget.getTableViewer().refresh();
  }
 else {
    updateExpressionsOfInsertedEntries(currentLanguage,metadataEditorView,currentIndex,sourceEntriesOfEntriesBeingAdded,targetTableIsFiltersTable,tableViewerCreatorTarget,metadataColumnsBeingAdded);
    for (int i=currentIndex; i < currentIndex + sourceEntriesOfEntriesBeingAdded.size(); i++) {
      columnIndicesToSelect.add(i);
    }
  }
  if (zoneTarget == Zone.VARS) {
    dataMapTableViewTarget.resizeAtExpandedSize();
  }
  if (targetTableIsGlobalMapTable) {
    dataMapTableViewTarget.updateGridDataHeightForTableGlobalMap();
    dataMapTableViewTarget.resizeAtExpandedSize();
  }
  uiManager.unselectAllEntriesOfAllTables();
  uiManager.refreshBackground(true,false);
  if (metadataEditorView != null && !targetTableIsFiltersTable) {
    metadataEditorView.getTableViewerCreator().getTableViewer().refresh();
  }
  int[] selection=ArrayUtils.toPrimitive(columnIndicesToSelect.toArray(new Integer[0]));
  tableViewerCreatorTarget.getSelectionHelper().setSelection(selection);
  ISelection iselection=tableViewerCreatorTarget.getTableViewer().getSelection();
  List<ITableEntry> selectedEntries=uiManager.extractSelectedTableEntries(iselection);
  tableViewerCreatorTarget.getTable().deselectAll();
  uiManager.unselectAllOutputMetaDataEntries();
  uiManager.unselectAllInputMetaDataEntries();
  uiManager.parseAllExpressionsForAllTables();
  getMapperManager().getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
  getMapperManager().getProblemsManager().checkLookupExpressionProblem();
  uiManager.selectLinks(dataMapTableViewTarget,selectedEntries,true,false);
  dataMapTableViewTarget.checkChangementsAfterEntryModifiedOrAdded(false);
  tableViewerCreatorTarget.getTable().setFocus();
  uiManager.setDragging(false);
}

Fixed version (ground truth):
@Override public void drop(DropTargetEvent event){
  super.drop(event);
  retrieveInsertionIndicator().setVisible(false);
  UIManager uiManager=getUiManager();
  DraggedData draggedData=TableEntriesTransfer.getInstance().getDraggedData();
  DropContextAnalyzer analyzer=analyzeDropTarget(event,draggedData);
  Point cursorPosition=new Point(event.x,event.y);
  int startInsertAtThisIndex=TableUtils.getItemIndexWhereInsertFromPosition(draggableTargetControl,cursorPosition);
  ILanguage currentLanguage=LanguageProvider.getCurrentLanguage();
  DataMapTableView dataMapTableViewTarget=getMapperManager().retrieveDataMapTableView(draggableTargetControl);
  Zone zoneTarget=dataMapTableViewTarget.getZone();
  uiManager.selectDataMapTableView(dataMapTableViewTarget,true,false);
  MetadataTableEditorView metadataEditorView=getUiManager().getMetadataEditorView(dataMapTableViewTarget.getZone());
  List<TransferableEntry> transferableEntryList=draggedData.getTransferableEntryList();
  int currentIndex=startInsertAtThisIndex;
  uiManager.clearLastCreatedInOutColumnEntries();
  draggableTargetControl.deselectAll();
  ITableEntry currentEntryTarget=getEntryFromPosition(cursorPosition);
  ArrayList<String> columnsBeingAdded=new ArrayList<String>();
  ArrayList<Integer> columnIndicesToSelect=new ArrayList<Integer>();
  ArrayList<ITableEntry> sourceEntriesOfEntriesBeingAdded=new ArrayList<ITableEntry>();
  ArrayList<IMetadataColumn> metadataColumnsBeingAdded=new ArrayList<IMetadataColumn>();
  boolean targetTableIsFiltersTable=analyzer.targetTableIsFiltersTable();
  boolean targetTableIsGlobalMapTable=analyzer.targetTableIsGlobalMapTable();
  boolean atLeastOneEntryInserted=false;
  boolean insertionEntryMode=analyzer.isInsertionEntryMode();
  boolean mapEachSourceToNextTargets=analyzer.isMapOneToOneMode();
  TableViewerCreator tableViewerCreatorTarget=null;
  if (!analyzer.targetIsExpressionFilterText()) {
    if (targetTableIsFiltersTable) {
      tableViewerCreatorTarget=dataMapTableViewTarget.getTableViewerCreatorForFilters();
    }
 else     if (targetTableIsGlobalMapTable) {
      tableViewerCreatorTarget=dataMapTableViewTarget.getTableViewerCreatorForGlobalMap();
    }
 else {
      tableViewerCreatorTarget=dataMapTableViewTarget.getTableViewerCreatorForColumns();
    }
  }
  uiManager.applyActivatedCellEditors(tableViewerCreatorTarget);
  ITableEntry lastEntryTarget=null;
  for (  TransferableEntry transferableEntry : transferableEntryList) {
    ITableEntry tableEntrySource=transferableEntry.getTableEntrySource();
    IMetadataColumn metadataColumnDragged=transferableEntry.getMetadataColumn();
    Zone zoneSourceEntry=(Zone)transferableEntry.getZoneSourceEntry();
    TableEntryLocation tableEntryLocationTarget=new TableEntryLocation(dataMapTableViewTarget.getDataMapTable().getName(),tableEntrySource.getName());
    if (zoneSourceEntry == Zone.INPUTS && zoneTarget == Zone.INPUTS && tableEntrySource.getParentName().equals(tableEntryLocationTarget.tableName)) {
      continue;
    }
 else     if (currentEntryTarget != null && !insertionEntryMode) {
      if (currentEntryTarget instanceof InputColumnTableEntry) {
        ((InputColumnTableEntry)currentEntryTarget).setOperator(Operator.EQUALS.getLiteral());
      }
      boolean overwrite=(lastEntryTarget != currentEntryTarget && analyzer.isOverwriteExpression());
      modifyExistingExpression(currentLanguage,currentEntryTarget,tableEntrySource,overwrite,zoneSourceEntry);
      uiManager.parseExpression(currentEntryTarget.getExpression(),currentEntryTarget,false,true,true);
      int indexOfEntry=tableViewerCreatorTarget.getInputList().indexOf(currentEntryTarget);
      columnIndicesToSelect.add(indexOfEntry);
    }
 else {
      String columnName=transferableEntry.getTableEntrySource().getName();
      tableEntryLocationTarget=getMapperManager().findUniqueLocation(tableEntryLocationTarget);
      columnName=tableEntryLocationTarget.columnName;
      if (currentEntryTarget == null && analyzer.isMapOneToOneMode()) {
        currentIndex=tableViewerCreatorTarget.getInputList().size();
        columnIndicesToSelect.add(currentIndex);
      }
      if (zoneSourceEntry == Zone.INPUTS && zoneTarget == Zone.VARS || zoneSourceEntry == Zone.VARS && zoneTarget == Zone.VARS) {
        columnIndicesToSelect.add(currentIndex);
        currentIndex=insertNewVarEntry(currentLanguage,dataMapTableViewTarget,currentIndex,tableEntrySource,columnName);
        atLeastOneEntryInserted=true;
      }
 else       if (zoneSourceEntry == Zone.VARS && zoneTarget == Zone.OUTPUTS) {
        insertNewOutputEntryFromVarEntry(sourceEntriesOfEntriesBeingAdded,metadataColumnsBeingAdded,tableEntrySource,columnName);
        atLeastOneEntryInserted=true;
      }
 else       if (zoneSourceEntry == Zone.INPUTS && targetTableIsGlobalMapTable) {
        insertNewGlobalMapEntryFromInputEntry(currentLanguage,dataMapTableViewTarget,currentIndex,tableEntrySource);
        atLeastOneEntryInserted=true;
      }
 else       if (zoneSourceEntry == Zone.INPUTS && zoneTarget != Zone.VARS) {
        insertNewInOutEntryFromInputEntry(sourceEntriesOfEntriesBeingAdded,metadataColumnsBeingAdded,tableEntrySource,metadataColumnDragged,columnName);
        atLeastOneEntryInserted=true;
      }
 else       if (zoneSourceEntry == Zone.OUTPUTS && zoneTarget == Zone.VARS) {
      }
 else       if (zoneSourceEntry == Zone.OUTPUTS && zoneTarget == Zone.OUTPUTS) {
        insertOutpuEntryCopyToOtherOutput(sourceEntriesOfEntriesBeingAdded,metadataColumnsBeingAdded,tableEntrySource,metadataColumnDragged,columnName);
        atLeastOneEntryInserted=true;
      }
 else {
      }
      columnsBeingAdded.add(columnName);
    }
    lastEntryTarget=currentEntryTarget;
    if (mapEachSourceToNextTargets && currentEntryTarget != null) {
      currentEntryTarget=getNextEntryTarget(currentEntryTarget,tableViewerCreatorTarget);
    }
  }
  if (!atLeastOneEntryInserted) {
    tableViewerCreatorTarget.getTableViewer().refresh();
  }
 else {
    updateExpressionsOfInsertedEntries(currentLanguage,metadataEditorView,currentIndex,sourceEntriesOfEntriesBeingAdded,targetTableIsFiltersTable,tableViewerCreatorTarget,metadataColumnsBeingAdded);
    for (int i=currentIndex; i < currentIndex + sourceEntriesOfEntriesBeingAdded.size(); i++) {
      columnIndicesToSelect.add(i);
    }
  }
  if (zoneTarget == Zone.VARS) {
    dataMapTableViewTarget.resizeAtExpandedSize();
  }
  if (targetTableIsGlobalMapTable) {
    dataMapTableViewTarget.updateGridDataHeightForTableGlobalMap();
    dataMapTableViewTarget.resizeAtExpandedSize();
  }
  uiManager.unselectAllEntriesOfAllTables();
  uiManager.refreshBackground(true,false);
  if (metadataEditorView != null && !targetTableIsFiltersTable) {
    metadataEditorView.getTableViewerCreator().getTableViewer().refresh();
  }
  int[] selection=ArrayUtils.toPrimitive(columnIndicesToSelect.toArray(new Integer[0]));
  tableViewerCreatorTarget.getSelectionHelper().setSelection(selection);
  ISelection iselection=tableViewerCreatorTarget.getTableViewer().getSelection();
  List<ITableEntry> selectedEntries=uiManager.extractSelectedTableEntries(iselection);
  tableViewerCreatorTarget.getTable().deselectAll();
  uiManager.unselectAllOutputMetaDataEntries();
  uiManager.unselectAllInputMetaDataEntries();
  uiManager.parseAllExpressionsForAllTables();
  getMapperManager().getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
  getMapperManager().getProblemsManager().checkLookupExpressionProblem();
  uiManager.selectLinks(dataMapTableViewTarget,selectedEntries,true,false);
  dataMapTableViewTarget.checkChangementsAfterEntryModifiedOrAdded(false);
  tableViewerCreatorTarget.getTable().setFocus();
  uiManager.setDragging(false);
}